Flutter Engine
flutter::CompositorContext::ScopedFrame Class Reference

#include <compositor_context.h>

Inheritance diagram for flutter::CompositorContext::ScopedFrame:
flutter_runner::ScopedFrame

Public Member Functions

 ScopedFrame (CompositorContext &context, GrDirectContext *gr_context, SkCanvas *canvas, ExternalViewEmbedder *view_embedder, const SkMatrix &root_surface_transformation, bool instrumentation_enabled, bool surface_supports_readback, fml::RefPtr< fml::RasterThreadMerger > raster_thread_merger)
 
virtual ~ScopedFrame ()
 
SkCanvas * canvas ()
 
ExternalViewEmbedderview_embedder ()
 
CompositorContextcontext () const
 
const SkMatrix & root_surface_transformation () const
 
bool surface_supports_readback ()
 
GrDirectContext * gr_context () const
 
virtual RasterStatus Raster (LayerTree &layer_tree, bool ignore_raster_cache)
 

Detailed Description

Definition at line 55 of file compositor_context.h.

Constructor & Destructor Documentation

◆ ScopedFrame()

flutter::CompositorContext::ScopedFrame::ScopedFrame ( CompositorContext context,
GrDirectContext *  gr_context,
SkCanvas *  canvas,
ExternalViewEmbedder view_embedder,
const SkMatrix &  root_surface_transformation,
bool  instrumentation_enabled,
bool  surface_supports_readback,
fml::RefPtr< fml::RasterThreadMerger raster_thread_merger 
)

Definition at line 46 of file compositor_context.cc.

55  : context_(context),
56  gr_context_(gr_context),
57  canvas_(canvas),
58  view_embedder_(view_embedder),
59  root_surface_transformation_(root_surface_transformation),
60  instrumentation_enabled_(instrumentation_enabled),
61  surface_supports_readback_(surface_supports_readback),
62  raster_thread_merger_(raster_thread_merger) {
63  context_.BeginFrame(*this, instrumentation_enabled_);
64 }
const SkMatrix & root_surface_transformation() const

◆ ~ScopedFrame()

flutter::CompositorContext::ScopedFrame::~ScopedFrame ( )
virtual

Definition at line 66 of file compositor_context.cc.

66  {
67  context_.EndFrame(*this, instrumentation_enabled_);
68 }

Member Function Documentation

◆ canvas()

SkCanvas* flutter::CompositorContext::ScopedFrame::canvas ( )
inline

◆ context()

CompositorContext& flutter::CompositorContext::ScopedFrame::context ( ) const
inline

Definition at line 72 of file compositor_context.h.

Referenced by flutter::LayerTree::Paint(), flutter::LayerTree::Preroll(), and flutter_runner::ScopedFrame::ScopedFrame().

72 { return context_; }

◆ gr_context()

GrDirectContext* flutter::CompositorContext::ScopedFrame::gr_context ( ) const
inline

◆ Raster()

RasterStatus flutter::CompositorContext::ScopedFrame::Raster ( flutter::LayerTree layer_tree,
bool  ignore_raster_cache 
)
virtual

Definition at line 70 of file compositor_context.cc.

References canvas(), FML_LOG, flutter::LayerTree::frame_size(), flutter::kResubmit, flutter::kResubmitFrame, flutter::kSkipAndRetry, flutter::kSkipAndRetryFrame, flutter::kSuccess, flutter::LayerTree::Paint(), flutter::ExternalViewEmbedder::PostPrerollAction(), flutter::LayerTree::Preroll(), surface_supports_readback(), and TRACE_EVENT0.

72  {
73  TRACE_EVENT0("flutter", "CompositorContext::ScopedFrame::Raster");
74  bool root_needs_readback = layer_tree.Preroll(*this, ignore_raster_cache);
75  bool needs_save_layer = root_needs_readback && !surface_supports_readback();
76  PostPrerollResult post_preroll_result = PostPrerollResult::kSuccess;
77  if (view_embedder_ && raster_thread_merger_) {
78  post_preroll_result =
79  view_embedder_->PostPrerollAction(raster_thread_merger_);
80  }
81 
82  if (post_preroll_result == PostPrerollResult::kResubmitFrame) {
84  }
85  if (post_preroll_result == PostPrerollResult::kSkipAndRetryFrame) {
87  }
88  // Clearing canvas after preroll reduces one render target switch when preroll
89  // paints some raster cache.
90  if (canvas()) {
91  if (needs_save_layer) {
92  FML_LOG(INFO) << "Using SaveLayer to protect non-readback surface";
93  SkRect bounds = SkRect::Make(layer_tree.frame_size());
94  SkPaint paint;
95  paint.setBlendMode(SkBlendMode::kSrc);
96  canvas()->saveLayer(&bounds, &paint);
97  }
98  canvas()->clear(SK_ColorTRANSPARENT);
99  }
100  layer_tree.Paint(*this, ignore_raster_cache);
101  if (canvas() && needs_save_layer) {
102  canvas()->restore();
103  }
104  return RasterStatus::kSuccess;
105 }
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:75
const SkISize & frame_size() const
Definition: layer_tree.h:49
#define FML_LOG(severity)
Definition: logging.h:65
virtual PostPrerollResult PostPrerollAction(fml::RefPtr< fml::RasterThreadMerger > raster_thread_merger)
bool Preroll(CompositorContext::ScopedFrame &frame, bool ignore_raster_cache=false)
Definition: layer_tree.cc:32
void Paint(CompositorContext::ScopedFrame &frame, bool ignore_raster_cache=false) const
Definition: layer_tree.cc:89

◆ root_surface_transformation()

const SkMatrix& flutter::CompositorContext::ScopedFrame::root_surface_transformation ( ) const
inline

Definition at line 74 of file compositor_context.h.

Referenced by flutter::LayerTree::Preroll().

74  {
75  return root_surface_transformation_;
76  }

◆ surface_supports_readback()

bool flutter::CompositorContext::ScopedFrame::surface_supports_readback ( )
inline

Definition at line 78 of file compositor_context.h.

Referenced by Raster().

78 { return surface_supports_readback_; }

◆ view_embedder()

ExternalViewEmbedder* flutter::CompositorContext::ScopedFrame::view_embedder ( )
inline

Definition at line 70 of file compositor_context.h.

Referenced by flutter::LayerTree::Paint(), and flutter::LayerTree::Preroll().

70 { return view_embedder_; }

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