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 RENDER_SERVICE_CORE_PIPELINE_PARALLEL_RENDER_RS_PARALLEL_HARDWARE_COMPOSER_H 17 #define RENDER_SERVICE_CORE_PIPELINE_PARALLEL_RENDER_RS_PARALLEL_HARDWARE_COMPOSER_H 18 #include <cstdint> 19 #include <map> 20 #include <memory> 21 #include <vector> 22 23 #ifndef USE_ROSEN_DRAWING 24 #include "include/core/SkRRect.h" 25 #include "include/core/SkRect.h" 26 #else 27 #include "utils/round_rect.h" 28 #endif 29 30 #include "common/rs_vector4.h" 31 #include "pipeline/rs_paint_filter_canvas.h" 32 #include "property/rs_properties_painter.h" 33 34 namespace OHOS { 35 namespace Rosen { 36 class RSParallelSelfDrawingSurfaceShape { 37 public: 38 RSParallelSelfDrawingSurfaceShape(bool isRRect, RectF rect, Vector4f cornerRadius); 39 ~RSParallelSelfDrawingSurfaceShape() = default; IsRRect()40 bool IsRRect() const 41 { 42 return isRRect_; 43 } 44 #ifndef USE_ROSEN_DRAWING GetRect()45 SkRect GetRect() 46 { 47 return SkRect::MakeXYWH(rect_.GetLeft(), rect_.GetTop(), rect_.GetWidth(), rect_.GetHeight()); 48 } GetRRect()49 SkRRect GetRRect() 50 { 51 if (isRRect_) { 52 RRect absClipRRect = RRect(rect_, cornerRadius_); 53 return RSPropertiesPainter::RRect2SkRRect(absClipRRect); 54 } 55 Vector4f radius = {0.f, 0.f, 0.f, 0.f}; 56 RRect absClipRect = RRect(rect_, radius); 57 return RSPropertiesPainter::RRect2SkRRect(absClipRect); 58 } 59 #else GetRect()60 Drawing::Rect GetRect() 61 { 62 return Drawing::Rect(rect_.GetLeft(), rect_.GetTop(), 63 rect_.GetWidth() + rect_.GetLeft(), rect_.GetHeight() + rect_.GetTop()); 64 } GetRRect()65 Drawing::RoundRect GetRRect() 66 { 67 if (isRRect_) { 68 RRect absClipRRect = RRect(rect_, cornerRadius_); 69 return RSPropertiesPainter::RRect2DrawingRRect(absClipRRect); 70 } 71 Vector4f radius = {0.f, 0.f, 0.f, 0.f}; 72 RRect absClipRect = RRect(rect_, radius); 73 return RSPropertiesPainter::RRect2DrawingRRect(absClipRect); 74 } 75 #endif 76 private: 77 bool isRRect_; 78 RectF rect_; 79 Vector4f cornerRadius_; 80 }; 81 82 class RSParallelHardwareComposer { 83 public: 84 RSParallelHardwareComposer() = default; 85 ~RSParallelHardwareComposer() = default; 86 void Init(uint32_t threadNum); 87 void ClearTransparentColor(RSPaintFilterCanvas& canvas, unsigned int surfaceIndex); 88 void AddTransparentColorArea(unsigned int surfaceIndex, 89 std::unique_ptr<RSParallelSelfDrawingSurfaceShape> &&shape); 90 private: 91 using Holes = std::vector<std::unique_ptr<RSParallelSelfDrawingSurfaceShape>>; 92 std::map<unsigned int, Holes> surfaceAndHolesMap_; 93 }; 94 95 } // namespace Rosen 96 } // namespace OHOS 97 #endif // RENDER_SERVICE_CORE_PIPELINE_PARALLEL_RENDER_RS_PARALLEL_HARDWARE_COMPOSER_H