1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "ui/rs_effect_node.h"
17
18 #include "command/rs_effect_node_command.h"
19 #include "command/rs_node_command.h"
20 #include "platform/common/rs_log.h"
21 #include "pipeline/rs_node_map.h"
22 #include "transaction/rs_transaction_proxy.h"
23
24 namespace OHOS {
25 namespace Rosen {
Create(bool isRenderServiceNode,bool isTextureExportNode)26 RSEffectNode::SharedPtr RSEffectNode::Create(bool isRenderServiceNode, bool isTextureExportNode)
27 {
28 SharedPtr node(new RSEffectNode(isRenderServiceNode, isTextureExportNode));
29 RSNodeMap::MutableInstance().RegisterNode(node);
30
31 auto transactionProxy = RSTransactionProxy::GetInstance();
32 if (transactionProxy == nullptr) {
33 return node;
34 }
35 std::unique_ptr<RSCommand> command = std::make_unique<RSEffectNodeCreate>(node->GetId(), isTextureExportNode);
36 transactionProxy->AddCommand(command, node->IsRenderServiceNode());
37 return node;
38 }
39
SetFreeze(bool isFreeze)40 void RSEffectNode::SetFreeze(bool isFreeze)
41 {
42 if (!IsUniRenderEnabled()) {
43 ROSEN_LOGE("SetFreeze is not supported in separate render");
44 return;
45 }
46 std::unique_ptr<RSCommand> command = std::make_unique<RSSetFreeze>(GetId(), isFreeze);
47 auto transactionProxy = RSTransactionProxy::GetInstance();
48 if (transactionProxy != nullptr) {
49 transactionProxy->AddCommand(command, true);
50 }
51 }
52
RSEffectNode(bool isRenderServiceNode,bool isTextureExportNode)53 RSEffectNode::RSEffectNode(bool isRenderServiceNode, bool isTextureExportNode)
54 : RSNode(isRenderServiceNode, isTextureExportNode) {}
55
56 } // namespace Rosen
57 } // namespace OHOS
58