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 #ifndef DRAWING_SURFACE_IMPL_H 17 #define DRAWING_SURFACE_IMPL_H 18 19 #include "base_impl.h" 20 #include "utils/rect.h" 21 #ifdef RS_ENABLE_VK 22 #include "vulkan/vulkan.h" 23 #endif 24 namespace OHOS { 25 namespace Rosen { 26 namespace Drawing { 27 class BackendTexture; 28 class Bitmap; 29 class Canvas; 30 class Image; 31 class Surface; 32 struct FlushInfo; 33 #ifdef ACE_ENABLE_GPU 34 struct FrameBuffer; 35 class ImageInfo; 36 class GPUContext; 37 #endif 38 enum class BackendAccess; 39 40 class SurfaceImpl : public BaseImpl { 41 public: SurfaceImpl()42 SurfaceImpl() {}; ~SurfaceImpl()43 ~SurfaceImpl() override {}; 44 45 virtual bool Bind(const Bitmap& bitmap) = 0; 46 #ifdef ACE_ENABLE_GPU 47 virtual bool Bind(const Image& image) = 0; 48 virtual bool Bind(const FrameBuffer& frameBuffer) = 0; 49 #endif 50 virtual std::shared_ptr<Canvas> GetCanvas() const = 0; 51 virtual std::shared_ptr<Image> GetImageSnapshot() const = 0; 52 virtual std::shared_ptr<Image> GetImageSnapshot(const RectI& bounds) const = 0; 53 virtual std::shared_ptr<Surface> MakeSurface(int width, int height) const = 0; 54 virtual BackendTexture GetBackendTexture(BackendAccess access) const = 0; 55 virtual void FlushAndSubmit(bool syncCpu) = 0; 56 virtual void Flush(FlushInfo *drawingflushInfo = nullptr) = 0; 57 #ifdef RS_ENABLE_VK 58 virtual void Wait(int32_t time, const VkSemaphore& semaphore) = 0; 59 virtual void SetDrawingArea(const std::vector<RectI>& rects) = 0; 60 virtual void ClearDrawingArea() = 0; 61 #endif 62 virtual int Width() const = 0; 63 virtual int Height() const = 0; 64 }; 65 } // namespace Drawing 66 } // namespace Rosen 67 } // namespace OHOS 68 #endif // DRAWING_SURFACE_IMPL_H 69