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 "draw/surface.h" 17 18 #include "impl_factory.h" 19 20 namespace OHOS { 21 namespace Rosen { 22 namespace Drawing { Surface()23Surface::Surface() : impl_(ImplFactory::CreateSurfaceImpl()), cachedCanvas_(nullptr) {} 24 Bind(const Bitmap & bitmap)25bool Surface::Bind(const Bitmap& bitmap) 26 { 27 return impl_->Bind(bitmap); 28 } 29 30 #ifdef ACE_ENABLE_GPU Bind(const Image & image)31bool Surface::Bind(const Image& image) 32 { 33 return impl_->Bind(image); 34 } 35 Bind(const FrameBuffer & frameBuffer)36bool Surface::Bind(const FrameBuffer& frameBuffer) 37 { 38 return impl_->Bind(frameBuffer); 39 } 40 #endif 41 GetCanvas()42std::shared_ptr<Canvas> Surface::GetCanvas() 43 { 44 if (cachedCanvas_ == nullptr) { 45 cachedCanvas_ = impl_->GetCanvas(); 46 } 47 return cachedCanvas_; 48 } 49 GetImageSnapshot() const50std::shared_ptr<Image> Surface::GetImageSnapshot() const 51 { 52 return impl_->GetImageSnapshot(); 53 } 54 GetImageSnapshot(const RectI & bounds) const55std::shared_ptr<Image> Surface::GetImageSnapshot(const RectI& bounds) const 56 { 57 return impl_->GetImageSnapshot(bounds); 58 } 59 60 } // namespace Drawing 61 } // namespace Rosen 62 } // namespace OHOS 63