Flutter Engine
shader_mask_layer.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "flutter/flow/layers/shader_mask_layer.h"
6 
7 namespace flutter {
8 
9 ShaderMaskLayer::ShaderMaskLayer(sk_sp<SkShader> shader,
10  const SkRect& mask_rect,
11  SkBlendMode blend_mode)
12  : shader_(shader), mask_rect_(mask_rect), blend_mode_(blend_mode) {}
13 
14 void ShaderMaskLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
15 #if defined(LEGACY_FUCHSIA_EMBEDDER)
16  CheckForChildLayerBelow(context);
17 #endif
18 
21  ContainerLayer::Preroll(context, matrix);
22 }
23 
24 void ShaderMaskLayer::Paint(PaintContext& context) const {
25  TRACE_EVENT0("flutter", "ShaderMaskLayer::Paint");
27 
29  Layer::AutoSaveLayer::Create(context, paint_bounds(), nullptr);
30  PaintChildren(context);
31 
32  SkPaint paint;
33  paint.setBlendMode(blend_mode_);
34  paint.setShader(shader_);
35  context.leaf_nodes_canvas->translate(mask_rect_.left(), mask_rect_.top());
36  context.leaf_nodes_canvas->drawRect(
37  SkRect::MakeWH(mask_rect_.width(), mask_rect_.height()), paint);
38 }
39 
40 } // namespace flutter
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:75
#define FML_DCHECK(condition)
Definition: logging.h:86
static AutoSaveLayer Create(const PaintContext &paint_context, const SkRect &bounds, const SkPaint *paint)
Definition: layer.cc:96
ShaderMaskLayer(sk_sp< SkShader > shader, const SkRect &mask_rect, SkBlendMode blend_mode)
bool needs_painting() const
Definition: layer.h:174
static AutoPrerollSaveLayerState Create(PrerollContext *preroll_context, bool save_layer_is_active=true, bool layer_itself_performs_readback=false)
Definition: layer.cc:43
const SkRect & paint_bounds() const
Definition: layer.h:166
void Preroll(PrerollContext *context, const SkMatrix &matrix) override
SkCanvas * leaf_nodes_canvas
Definition: layer.h:116
void Paint(PaintContext &context) const override
void Preroll(PrerollContext *context, const SkMatrix &matrix) override
void PaintChildren(PaintContext &context) const