1 /* 2 * Copyright (c) 2021-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 IMAGEIMPL_H 17 #define IMAGEIMPL_H 18 19 #include "base_impl.h" 20 21 #include "draw/brush.h" 22 #include "effect/color_space.h" 23 #include "image/bitmap.h" 24 #include "image/picture.h" 25 #include "utils/matrix.h" 26 #include "utils/size.h" 27 28 namespace OHOS { 29 namespace Rosen { 30 namespace Drawing { 31 class Data; 32 #ifdef ACE_ENABLE_GPU 33 class GPUContext; 34 class TextureInfo; 35 enum class TextureOrigin; 36 enum class CompressedType; 37 #endif 38 enum class BitDepth; 39 class ImageImpl : public BaseImpl { 40 public: 41 static inline constexpr AdapterType TYPE = AdapterType::BASE_INTERFACE; ImageImpl()42 ImageImpl() noexcept {} ~ImageImpl()43 ~ImageImpl() override {} GetType()44 AdapterType GetType() const override 45 { 46 return AdapterType::BASE_INTERFACE; 47 } 48 virtual void* BuildFromBitmap(const Bitmap& bitmap) = 0; 49 virtual void* BuildFromPicture(const Picture& picture, const SizeI& dimensions, const Matrix& matrix, 50 const Brush& brush, BitDepth bitDepth, std::shared_ptr<ColorSpace> colorSpace) = 0; 51 #ifdef ACE_ENABLE_GPU 52 virtual bool BuildFromBitmap(GPUContext& gpuContext, const Bitmap& bitmap) = 0; 53 virtual bool BuildFromCompressed(GPUContext& gpuContext, const std::shared_ptr<Data>& data, int width, int height, 54 CompressedType type) = 0; 55 virtual bool BuildFromTexture(GPUContext& gpuContext, const TextureInfo& info, TextureOrigin origin, 56 BitmapFormat bitmapFormat, const std::shared_ptr<ColorSpace>& colorSpace) = 0; 57 #endif 58 virtual int GetWidth() const = 0; 59 virtual int GetHeight() const = 0; 60 virtual ColorType GetColorType() const = 0; 61 virtual AlphaType GetAlphaType() const = 0; 62 virtual uint32_t GetUniqueID() const = 0; 63 virtual bool ReadPixels(Bitmap& bitmap, int x, int y) = 0; 64 virtual bool IsTextureBacked() const = 0; 65 66 // using for recording, should to remove after using shared memory 67 virtual std::shared_ptr<Data> Serialize() const = 0; 68 virtual bool Deserialize(std::shared_ptr<Data> data) = 0; 69 }; 70 } // namespace Drawing 71 } // namespace Rosen 72 } // namespace OHOS 73 #endif 74