1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd.. All rights reserved. 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 #ifndef SKIA_SURFACE_H 17 #define SKIA_SURFACE_H 18 19 #include "include/core/SkSurface.h" 20 21 #include "impl_interface/surface_impl.h" 22 23 namespace OHOS { 24 namespace Rosen { 25 namespace Drawing { 26 class SkiaSurface : public SurfaceImpl { 27 public: 28 static inline constexpr AdapterType TYPE = AdapterType::SKIA_ADAPTER; 29 SkiaSurface(); 30 ~SkiaSurface() override = default; 31 32 bool Bind(const Bitmap& bitmap) override; 33 #ifdef ACE_ENABLE_GPU 34 bool Bind(const Image& image) override; 35 bool Bind(const FrameBuffer& frameBuffer) override; 36 #endif 37 38 std::shared_ptr<Canvas> GetCanvas() const override; 39 std::shared_ptr<Image> GetImageSnapshot() const override; 40 std::shared_ptr<Image> GetImageSnapshot(const RectI& bounds) const override; 41 42 private: 43 sk_sp<SkSurface> skSurface_ = nullptr; 44 sk_sp<SkImage> skImage_ = nullptr; 45 }; 46 } // namespace Drawing 47 } // namespace Rosen 48 } // namespace OHOS 49 #endif // SKIA_SURFACE_H 50