1111
1212namespace flutter {
1313
14- LayerTree::LayerTree (const SkISize& frame_size, float frame_device_pixel_ratio )
14+ LayerTree::LayerTree (const SkISize& frame_size, float device_pixel_ratio )
1515 : frame_size_(frame_size),
16- frame_device_pixel_ratio_ (frame_device_pixel_ratio ),
16+ device_pixel_ratio_ (device_pixel_ratio ),
1717 rasterizer_tracing_threshold_(0 ),
1818 checkerboard_raster_cache_images_(false ),
19- checkerboard_offscreen_layers_(false ) {}
19+ checkerboard_offscreen_layers_(false ) {
20+ FML_CHECK (device_pixel_ratio_ != 0 .0f );
21+ }
2022
2123void LayerTree::RecordBuildTime (fml::TimePoint build_start,
2224 fml::TimePoint target_time) {
@@ -51,7 +53,7 @@ bool LayerTree::Preroll(CompositorContext::ScopedFrame& frame,
5153 frame.context ().ui_time (),
5254 frame.context ().texture_registry (),
5355 checkerboard_offscreen_layers_,
54- frame_device_pixel_ratio_ };
56+ device_pixel_ratio_ };
5557
5658 root_layer_->Preroll (&context, frame.root_surface_transformation ());
5759 return context.surface_needs_readback ;
@@ -62,19 +64,8 @@ void LayerTree::UpdateScene(SceneUpdateContext& context,
6264 scenic::ContainerNode& container) {
6365 TRACE_EVENT0 (" flutter" , " LayerTree::UpdateScene" );
6466
65- // Ensure the context is aware of the view metrics.
66- context.set_dimensions (frame_size_, frame_device_pixel_ratio_);
67-
68- const auto & metrics = context.metrics ();
69- FML_DCHECK (metrics->scale_x > 0 .0f );
70- FML_DCHECK (metrics->scale_y > 0 .0f );
71- FML_DCHECK (metrics->scale_z > 0 .0f );
72-
73- SceneUpdateContext::Transform transform (context, // context
74- 1 .0f / metrics->scale_x , // X
75- 1 .0f / metrics->scale_y , // Y
76- 1 .0f / metrics->scale_z // Z
77- );
67+ const float inv_dpr = 1 .0f / device_pixel_ratio_;
68+ SceneUpdateContext::Transform transform (context, inv_dpr, inv_dpr, 1 .0f );
7869
7970 SceneUpdateContext::Frame frame (
8071 context,
@@ -120,7 +111,7 @@ void LayerTree::Paint(CompositorContext::ScopedFrame& frame,
120111 frame.context ().texture_registry (),
121112 ignore_raster_cache ? nullptr : &frame.context ().raster_cache (),
122113 checkerboard_offscreen_layers_,
123- frame_device_pixel_ratio_ };
114+ device_pixel_ratio_ };
124115
125116 if (root_layer_->needs_painting ())
126117 root_layer_->Paint (context);
@@ -144,18 +135,18 @@ sk_sp<SkPicture> LayerTree::Flatten(const SkRect& bounds) {
144135 root_surface_transformation.reset ();
145136
146137 PrerollContext preroll_context{
147- nullptr , // raster_cache (don't consult the cache)
148- nullptr , // gr_context (used for the raster cache)
149- nullptr , // external view embedder
150- unused_stack, // mutator stack
151- nullptr , // SkColorSpace* dst_color_space
152- kGiantRect , // SkRect cull_rect
153- false , // layer reads from surface
154- unused_stopwatch, // frame time (dont care)
155- unused_stopwatch, // engine time (dont care)
156- unused_texture_registry, // texture registry (not supported)
157- false , // checkerboard_offscreen_layers
158- frame_device_pixel_ratio_ // ratio between logical and physical
138+ nullptr , // raster_cache (don't consult the cache)
139+ nullptr , // gr_context (used for the raster cache)
140+ nullptr , // external view embedder
141+ unused_stack, // mutator stack
142+ nullptr , // SkColorSpace* dst_color_space
143+ kGiantRect , // SkRect cull_rect
144+ false , // layer reads from surface
145+ unused_stopwatch, // frame time (dont care)
146+ unused_stopwatch, // engine time (dont care)
147+ unused_texture_registry, // texture registry (not supported)
148+ false , // checkerboard_offscreen_layers
149+ device_pixel_ratio_ // ratio between logical and physical
159150 };
160151
161152 SkISize canvas_size = canvas->getBaseLayerSize ();
@@ -167,12 +158,12 @@ sk_sp<SkPicture> LayerTree::Flatten(const SkRect& bounds) {
167158 canvas, // canvas
168159 nullptr ,
169160 nullptr ,
170- unused_stopwatch, // frame time (dont care)
171- unused_stopwatch, // engine time (dont care)
172- unused_texture_registry, // texture registry (not supported)
173- nullptr , // raster cache
174- false , // checkerboard offscreen layers
175- frame_device_pixel_ratio_ // ratio between logical and physical
161+ unused_stopwatch, // frame time (dont care)
162+ unused_stopwatch, // engine time (dont care)
163+ unused_texture_registry, // texture registry (not supported)
164+ nullptr , // raster cache
165+ false , // checkerboard offscreen layers
166+ device_pixel_ratio_ // ratio between logical and physical
176167 };
177168
178169 // Even if we don't have a root layer, we still need to create an empty
0 commit comments