• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "core/pipeline/layers/picture_layer.h"
17 
18 #include "base/log/dump_log.h"
19 #include "base/log/log.h"
20 
21 namespace OHOS::Ace::Flutter {
22 
AddToScene(SceneBuilder & builder,double x,double y)23 void PictureLayer::AddToScene(SceneBuilder& builder, double x, double y)
24 {
25     offset_.SetX(x);
26     offset_.SetY(y);
27     if (needAddToScene_) {
28         builder.AddPicture(x, y, picture_, hints_);
29     }
30 }
31 
SetPicture(fml::RefPtr<flutter::Picture> picture)32 void PictureLayer::SetPicture(fml::RefPtr<flutter::Picture> picture)
33 {
34     if (!picture) {
35         LOGE("PictureLayer::SetPicture, origin picture null");
36         return;
37     }
38     if (!picture->picture()) {
39         LOGE("PictureLayer::SetPicture, picture null");
40         return;
41     }
42     needAddToScene_ = true;
43     picture_ = picture;
44 }
45 
Dump()46 void PictureLayer::Dump()
47 {
48     if (DumpLog::GetInstance().GetDumpFile()) {
49         DumpLog::GetInstance().AddDesc(
50             "UniqueID:", (picture_ && picture_->picture()) ? picture_->picture()->uniqueID() : 0);
51     }
52 }
53 
54 } // namespace OHOS::Ace::Flutter
55