Flutter Engine
flutter::PictureLayer Class Reference

#include <picture_layer.h>

Inheritance diagram for flutter::PictureLayer:
flutter::Layer

Public Member Functions

 PictureLayer (const SkPoint &offset, SkiaGPUObject< SkPicture > picture, bool is_complex, bool will_change)
 
SkPicture * picture () const
 
void Preroll (PrerollContext *frame, const SkMatrix &matrix) override
 
void Paint (PaintContext &context) const override
 
- Public Member Functions inherited from flutter::Layer
 Layer ()
 
virtual ~Layer ()
 
bool needs_system_composite () const
 
void set_needs_system_composite (bool value)
 
const SkRect & paint_bounds () const
 
void set_paint_bounds (const SkRect &paint_bounds)
 
bool needs_painting () const
 
uint64_t unique_id () const
 

Detailed Description

Definition at line 16 of file picture_layer.h.

Constructor & Destructor Documentation

◆ PictureLayer()

flutter::PictureLayer::PictureLayer ( const SkPoint &  offset,
SkiaGPUObject< SkPicture >  picture,
bool  is_complex,
bool  will_change 
)

Definition at line 11 of file picture_layer.cc.

15  : offset_(offset),
16  picture_(std::move(picture)),
17  is_complex_(is_complex),
18  will_change_(will_change) {}

Member Function Documentation

◆ Paint()

void flutter::PictureLayer::Paint ( PaintContext context) const
overridevirtual

Implements flutter::Layer.

Definition at line 45 of file picture_layer.cc.

References flutter::RasterCache::Draw(), FML_DCHECK, flutter::SkiaGPUObject< T >::get(), flutter::RasterCache::GetIntegralTransCTM(), flutter::Layer::PaintContext::leaf_nodes_canvas, flutter::Layer::needs_painting(), picture(), flutter::Layer::PaintContext::raster_cache, TRACE_EVENT0, and TRACE_EVENT_INSTANT0.

Referenced by picture().

45  {
46  TRACE_EVENT0("flutter", "PictureLayer::Paint");
47  FML_DCHECK(picture_.get());
49 
50  SkAutoCanvasRestore save(context.leaf_nodes_canvas, true);
51  context.leaf_nodes_canvas->translate(offset_.x(), offset_.y());
52 #ifndef SUPPORT_FRACTIONAL_TRANSLATION
53  context.leaf_nodes_canvas->setMatrix(RasterCache::GetIntegralTransCTM(
54  context.leaf_nodes_canvas->getTotalMatrix()));
55 #endif
56 
57  if (context.raster_cache &&
58  context.raster_cache->Draw(*picture(), *context.leaf_nodes_canvas)) {
59  TRACE_EVENT_INSTANT0("flutter", "raster cache hit");
60  return;
61  }
62  picture()->playback(context.leaf_nodes_canvas);
63 }
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:75
#define FML_DCHECK(condition)
Definition: logging.h:86
#define TRACE_EVENT_INSTANT0(category_group, name)
Definition: trace_event.h:104
sk_sp< SkiaObjectType > get() const
bool needs_painting() const
Definition: layer.h:174
static SkMatrix GetIntegralTransCTM(const SkMatrix &ctm)
Snap the translation components of the matrix to integers.
Definition: raster_cache.h:115
SkPicture * picture() const
Definition: picture_layer.h:23

◆ picture()

SkPicture* flutter::PictureLayer::picture ( ) const
inline

Definition at line 23 of file picture_layer.h.

References flutter::SkiaGPUObject< T >::get(), Paint(), and Preroll().

Referenced by Paint(), and Preroll().

23 { return picture_.get().get(); }
sk_sp< SkiaObjectType > get() const

◆ Preroll()

void flutter::PictureLayer::Preroll ( PrerollContext frame,
const SkMatrix &  matrix 
)
overridevirtual

Reimplemented from flutter::Layer.

Definition at line 20 of file picture_layer.cc.

References flutter::PrerollContext::dst_color_space, flutter::RasterCache::GetIntegralTransCTM(), flutter::PrerollContext::gr_context, picture(), flutter::PrerollContext::raster_cache, flutter::Layer::set_paint_bounds(), and TRACE_EVENT0.

Referenced by picture().

20  {
21  TRACE_EVENT0("flutter", "PictureLayer::Preroll");
22 
23 #if defined(LEGACY_FUCHSIA_EMBEDDER)
24  CheckForChildLayerBelow(context);
25 #endif
26 
27  SkPicture* sk_picture = picture();
28 
29  if (auto* cache = context->raster_cache) {
30  TRACE_EVENT0("flutter", "PictureLayer::RasterCache (Preroll)");
31 
32  SkMatrix ctm = matrix;
33  ctm.postTranslate(offset_.x(), offset_.y());
34 #ifndef SUPPORT_FRACTIONAL_TRANSLATION
36 #endif
37  cache->Prepare(context->gr_context, sk_picture, ctm,
38  context->dst_color_space, is_complex_, will_change_);
39  }
40 
41  SkRect bounds = sk_picture->cullRect().makeOffset(offset_.x(), offset_.y());
42  set_paint_bounds(bounds);
43 }
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:75
void set_paint_bounds(const SkRect &paint_bounds)
Definition: layer.h:170
static SkMatrix GetIntegralTransCTM(const SkMatrix &ctm)
Snap the translation components of the matrix to integers.
Definition: raster_cache.h:115
SkPicture * picture() const
Definition: picture_layer.h:23

The documentation for this class was generated from the following files: