1 /* 2 * Copyright (c) 2022 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_TEST_MOCK_ROSEN_TESTING_BITMAP_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_TEST_MOCK_ROSEN_TESTING_BITMAP_H 18 19 #include <cstddef> 20 #include <cstdint> 21 22 #include "testing_rect.h" 23 24 namespace OHOS::Ace::Testing { 25 class TestingImageInfo; 26 typedef uint32_t ColorQuad; 27 28 enum ColorType { 29 COLORTYPE_UNKNOWN = 0, 30 COLORTYPE_ALPHA_8, 31 COLORTYPE_RGB_565, 32 COLORTYPE_ARGB_4444, 33 COLORTYPE_RGBA_8888, 34 COLORTYPE_BGRA_8888, 35 }; 36 37 enum AlphaType { 38 ALPHATYPE_UNKNOWN = 0, 39 ALPHATYPE_OPAQUE, 40 ALPHATYPE_PREMUL, 41 ALPHATYPE_UNPREMUL, 42 }; 43 44 struct BitmapFormat { 45 ColorType colorType; 46 AlphaType alphaType; 47 }; 48 49 class TestingBitmap { 50 public: 51 TestingBitmap() = default; 52 ~TestingBitmap() = default; 53 GetPixels()54 virtual void* GetPixels() 55 { 56 return nullptr; 57 } 58 SetPixels(void * pixel)59 void SetPixels(void* pixel) {} 60 ClearWithColor(const ColorQuad & color)61 void ClearWithColor(const ColorQuad& color) const {} ComputeByteSize()62 size_t ComputeByteSize() const 63 { 64 return 0; 65 } 66 ExtractSubset(TestingBitmap & dst,const TestingRect & subset)67 bool ExtractSubset(TestingBitmap& dst, const TestingRect& subset) const 68 { 69 return false; 70 } 71 ReadPixels(const TestingImageInfo & dstInfo,void * dstPixels,size_t dstRowBytes,int32_t srcX,int32_t srcY)72 bool ReadPixels( 73 const TestingImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes, int32_t srcX, int32_t srcY) const 74 { 75 return false; 76 } 77 Free()78 void Free() {} 79 Build(const int width,const int height,const BitmapFormat & format)80 bool Build(const int width, const int height, const BitmapFormat& format) 81 { 82 return false; 83 } 84 }; 85 } // namespace OHOS::Ace::Testing 86 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_BITMAP_H 87