Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix comments
  • Loading branch information
JsouLiang committed Aug 30, 2022
commit 38312caf8841ab558fe3160ad4503dafeb573f5b
16 changes: 8 additions & 8 deletions flow/layers/shader_mask_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

namespace flutter {

ShaderMaskLayer::ShaderMaskLayer(std::shared_ptr<DlColorSource> shader,
ShaderMaskLayer::ShaderMaskLayer(std::shared_ptr<DlColorSource> color_source,
const SkRect& mask_rect,
DlBlendMode blend_mode)
: CacheableContainerLayer(
RasterCacheUtil::kMinimumRendersBeforeCachingFilterLayer),
shader_(std::move(shader)),
color_source_(std::move(color_source)),
mask_rect_(mask_rect),
blend_mode_(blend_mode) {}

Expand All @@ -21,8 +21,8 @@ void ShaderMaskLayer::Diff(DiffContext* context, const Layer* old_layer) {
auto* prev = static_cast<const ShaderMaskLayer*>(old_layer);
if (!context->IsSubtreeDirty()) {
FML_DCHECK(prev);
if (shader_ != prev->shader_ || mask_rect_ != prev->mask_rect_ ||
blend_mode_ != prev->blend_mode_) {
if (color_source_ != prev->color_source_ ||
mask_rect_ != prev->mask_rect_ || blend_mode_ != prev->blend_mode_) {
context->MarkSubtreeDirty(context->GetOldLayerPaintRegion(old_layer));
}
}
Expand Down Expand Up @@ -63,8 +63,8 @@ void ShaderMaskLayer::Paint(PaintContext& context) const {

DlPaint dl_paint;
dl_paint.setBlendMode(blend_mode_);
if (shader_) {
dl_paint.setColorSource(shader_.get());
if (color_source_) {
dl_paint.setColorSource(color_source_.get());
}
context.leaf_nodes_builder->translate(mask_rect_.left(), mask_rect_.top());
context.leaf_nodes_builder->drawRect(shader_rect, dl_paint);
Expand All @@ -75,8 +75,8 @@ void ShaderMaskLayer::Paint(PaintContext& context) const {
PaintChildren(context);
SkPaint paint;
paint.setBlendMode(ToSk(blend_mode_));
if (shader_) {
paint.setShader(shader_->skia_object());
if (color_source_) {
paint.setShader(color_source_->skia_object());
}
context.leaf_nodes_canvas->translate(mask_rect_.left(), mask_rect_.top());
context.leaf_nodes_canvas->drawRect(shader_rect, paint);
Expand Down
4 changes: 2 additions & 2 deletions flow/layers/shader_mask_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace flutter {

class ShaderMaskLayer : public CacheableContainerLayer {
public:
ShaderMaskLayer(std::shared_ptr<DlColorSource> shader,
ShaderMaskLayer(std::shared_ptr<DlColorSource> color_source,
const SkRect& mask_rect,
DlBlendMode blend_mode);

Expand All @@ -23,7 +23,7 @@ class ShaderMaskLayer : public CacheableContainerLayer {
void Paint(PaintContext& context) const override;

private:
std::shared_ptr<DlColorSource> shader_;
std::shared_ptr<DlColorSource> color_source_;
SkRect mask_rect_;
DlBlendMode blend_mode_;

Expand Down
3 changes: 1 addition & 2 deletions flow/layers/shader_mask_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,7 @@ TEST_F(ShaderMaskLayerTest, OpacityInheritance) {
expected_builder.saveLayer(&child_path.getBounds(), &sl_paint);
{
/* child layer paint */ {
expected_builder.drawPath(child_path,
DlPaint().setColor(0xFF000000));
expected_builder.drawPath(child_path, DlPaint());
}
expected_builder.translate(mask_rect.fLeft, mask_rect.fTop);
expected_builder.drawRect(
Expand Down