!2302 flutter适配布局边界

Merge pull request !2302 from xiexiyun/master
This commit is contained in:
openharmony_ci
2022-04-25 02:32:48 +00:00
committed by Gitee
5 changed files with 33 additions and 23 deletions
@@ -40,6 +40,7 @@
#include "core/pipeline/base/scoped_canvas_state.h"
#include "core/pipeline/layers/flutter_scene_builder.h"
#include "core/pipeline/layers/picture_layer.h"
#include "core/components/common/painter/debug_boundary_painter.h"
namespace OHOS::Ace {
namespace {
@@ -356,6 +357,16 @@ void FlutterRenderBox::Paint(RenderContext& context, const Offset& offset)
outerRRect, canvas->canvas(), frontDecoration_->GetColorBlend(), bgColor);
}
}
if (RenderBox::needPaintDebugBoundary_) {
flutter::Canvas* canvas = renderContext->GetCanvas();
if (canvas == nullptr) {
LOGE("Paint canvas is null.");
return;
}
DebugBoundaryPainter::PaintDebugBoundary(canvas->canvas(), offset, GetLayoutSize());
DebugBoundaryPainter::PaintDebugCorner(canvas->canvas(), offset, GetLayoutSize());
DebugBoundaryPainter::PaintDebugMargin(canvas->canvas(), offset, GetLayoutSize(), margin_);
}
if (isAccessibilityFocus_) {
PaintAccessibilityFocus(focusRect, context);
}
@@ -33,7 +33,7 @@
#include "core/components/image/image_component.h"
#include "core/components/image/rosen_render_image.h"
#include "core/pipeline/base/rosen_render_context.h"
#include "core/components/common/painter/rosen_debug_boundary_painter.h"
#include "core/components/common/painter/debug_boundary_painter.h"
namespace OHOS::Ace {
namespace {
@@ -309,16 +309,6 @@ void RosenRenderBox::Paint(RenderContext& context, const Offset& offset)
}
}
RenderNode::Paint(context, offset);
if (RenderBox::needPaintDebugBoundary_) {
auto canvas = static_cast<RosenRenderContext*>(&context)->GetCanvas();
if (canvas == nullptr) {
LOGE("Paint canvas is null.");
return;
}
RosenDebugBoundaryPainter::PaintDebugBoundary(canvas, offset, GetLayoutSize());
RosenDebugBoundaryPainter::PaintDebugCorner(canvas, offset, GetLayoutSize());
RosenDebugBoundaryPainter::PaintDebugMargin(canvas, offset, GetLayoutSize(), RenderBoxBase::margin_);
}
if (frontDecoration_) {
auto canvas = static_cast<RosenRenderContext*>(&context)->GetCanvas();
if (canvas == nullptr) {
@@ -337,7 +327,16 @@ void RosenRenderBox::Paint(RenderContext& context, const Offset& offset)
RosenDecorationPainter::PaintColorBlend(outerRRect, canvas, frontDecoration_->GetColorBlend(), bgColor);
}
}
if (RenderBox::needPaintDebugBoundary_) {
auto canvas = static_cast<RosenRenderContext*>(&context)->GetCanvas();
if (canvas == nullptr) {
LOGE("Paint canvas is null.");
return;
}
DebugBoundaryPainter::PaintDebugBoundary(canvas, offset, GetLayoutSize());
DebugBoundaryPainter::PaintDebugCorner(canvas, offset, GetLayoutSize());
DebugBoundaryPainter::PaintDebugMargin(canvas, offset, GetLayoutSize(), RenderBoxBase::margin_);
}
if (isAccessibilityFocus_) {
PaintAccessibilityFocus(focusRect, context);
}
+1 -1
View File
@@ -17,6 +17,7 @@ import("//foundation/ace/ace_engine/frameworks/core/components/components.gni")
build_component("common") {
sources = [
# painter
"painter/debug_boundary_painter.cpp",
"painter/flutter_checkable_painter.cpp",
"painter/flutter_decoration_painter.cpp",
"painter/flutter_scroll_bar_painter.cpp",
@@ -50,7 +51,6 @@ build_component("common") {
]
rosen_sources = [
"painter/rosen_checkable_painter.cpp",
"painter/rosen_debug_boundary_painter.cpp",
"painter/rosen_decoration_painter.cpp",
"painter/rosen_scroll_bar_painter.cpp",
"painter/rosen_scroll_fade_painter.cpp",
@@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "core/components/common/painter/rosen_debug_boundary_painter.h"
#include "core/components/common/painter/debug_boundary_painter.h"
#include <cmath>
#include <functional>
@@ -21,10 +21,8 @@
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorFilter.h"
#include "render_service_client/core/ui/rs_node.h"
#include "core/components/common/properties/color.h"
#include "core/pipeline/base/render_node.h"
#include "core/pipeline/base/rosen_render_context.h"
#include "core/pipeline/pipeline_context.h"
namespace OHOS::Ace {
@@ -36,7 +34,7 @@ constexpr uint32_t BOUNDARY_CORNER_COLOR = 0xFF637FFF;
constexpr uint32_t BOUNDARY_MARGIN_COLOR = 0xB3FFC0CB;
}
void RosenDebugBoundaryPainter::PaintDebugBoundary(SkCanvas* canvas, const Offset& offset, const Size& layoutSize)
void DebugBoundaryPainter::PaintDebugBoundary(SkCanvas* canvas, const Offset& offset, const Size& layoutSize)
{
SkPaint skpaint;
auto layoutRect = SkRect::MakeXYWH(offset.GetX(), offset.GetY(), layoutSize.Width(), layoutSize.Height());
@@ -46,7 +44,7 @@ void RosenDebugBoundaryPainter::PaintDebugBoundary(SkCanvas* canvas, const Offse
canvas->drawRect(layoutRect, skpaint);
}
void RosenDebugBoundaryPainter::PaintDebugMargin(SkCanvas* canvas, const Offset& offset,
void DebugBoundaryPainter::PaintDebugMargin(SkCanvas* canvas, const Offset& offset,
const Size& layoutSize, const EdgePx& margin)
{
SkPaint skpaint;
@@ -73,7 +71,7 @@ void RosenDebugBoundaryPainter::PaintDebugMargin(SkCanvas* canvas, const Offset&
canvas->drawRect(layoutRect, skpaint);
}
void RosenDebugBoundaryPainter::PaintDebugCorner(SkCanvas* canvas, const Offset& offset, const Size& layoutSize)
void DebugBoundaryPainter::PaintDebugCorner(SkCanvas* canvas, const Offset& offset, const Size& layoutSize)
{
SkPaint skpaint;
auto startPointX = offset.GetX();
@@ -16,18 +16,20 @@
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_PAINTER_ROSEN_DEBUG_BOUNDARY_PAINTER_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_PAINTER_ROSEN_DEBUG_BOUNDARY_PAINTER_H
#include <math.h>
#include <cmath>
#include "include/core/SkCanvas.h"
#include "include/core/SkPaint.h"
#include "base/memory/ace_type.h"
#include "base/utils/utils.h"
#include "core/components/common/layout/constants.h"
#include "core/components/common/properties/decoration.h"
#include "core/components/common/properties/edge.h"
#include "core/pipeline/base/rosen_render_context.h"
namespace OHOS::Ace {
class RosenDebugBoundaryPainter : public virtual AceType {
DECLARE_ACE_TYPE(RosenDebugBoundaryPainter, AceType);
class DebugBoundaryPainter : public virtual AceType {
DECLARE_ACE_TYPE(DebugBoundaryPainter, AceType);
public:
static void PaintDebugBoundary(SkCanvas* canvas, const Offset& offset, const Size& layoutSize);
static void PaintDebugMargin(SkCanvas* canvas, const Offset& offset, const Size& layoutSize, const EdgePx& margin);