Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 8ccf4ee

Browse files
committed
Fix according to Jim's comments
1 parent 54a623b commit 8ccf4ee

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

flow/layers/container_layer.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ void ContainerLayer::PaintChildren(PaintContext& context) const {
6565
}
6666
}
6767

68+
void ContainerLayer::TryToPrepareRasterCache(PrerollContext* context, Layer* layer, const SkMatrix& matrix) {
69+
if (!context->has_platform_view && context->raster_cache &&
70+
SkRect::Intersects(context->cull_rect, layer->paint_bounds())) {
71+
context->raster_cache->Prepare(context, layer, matrix);
72+
}
73+
}
74+
6875
#if defined(OS_FUCHSIA)
6976

7077
void ContainerLayer::UpdateScene(SceneUpdateContext& context) {

flow/layers/container_layer.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ class ContainerLayer : public Layer {
3737
// For OpacityLayer to restructure to have a single child.
3838
void ClearChildren() { layers_.clear(); }
3939

40+
// Try to prepare the raster cache for a given layer.
41+
//
42+
// The raster cache would fail if either of the followings is true:
43+
// 1. The context has a platform view.
44+
// 2. The context does not have a valid raster cache.
45+
// 3. The layer's paint bounds does not intersect with the cull rect.
46+
//
47+
// We make this a static function instead of a member function that directy
48+
// uses the "this" pointer as the layer because we sometimes need to raster
49+
// cache a child layer and one can't access its child's protected method.
50+
static void TryToPrepareRasterCache(PrerollContext* context, Layer* layer, const SkMatrix& matrix);
51+
4052
private:
4153
std::vector<std::shared_ptr<Layer>> layers_;
4254

flow/layers/image_filter_layer.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ void ImageFilterLayer::Preroll(PrerollContext* context,
2828
set_paint_bounds(child_paint_bounds_);
2929
}
3030

31-
if (!context->has_platform_view && context->raster_cache &&
32-
SkRect::Intersects(context->cull_rect, paint_bounds())) {
33-
SkMatrix ctm = matrix;
34-
context->raster_cache->Prepare(context, this, ctm);
35-
}
31+
TryToPrepareRasterCache(context, this, matrix);
3632
}
3733

3834
void ImageFilterLayer::Paint(PaintContext& context) const {

flow/layers/opacity_layer.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ void OpacityLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
4848

4949
{
5050
set_paint_bounds(paint_bounds().makeOffset(offset_.fX, offset_.fY));
51-
if (!context->has_platform_view && context->raster_cache &&
52-
SkRect::Intersects(context->cull_rect, paint_bounds())) {
53-
SkMatrix ctm = child_matrix;
54-
context->raster_cache->Prepare(context, container, ctm);
55-
}
51+
TryToPrepareRasterCache(context, container, child_matrix);
5652
}
5753
}
5854

flow/raster_cache_unittests.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@ TEST(RasterCache, DeviceRectRoundOut) {
159159
ASSERT_TRUE(cache.Draw(*picture, canvas));
160160

161161
canvas.translate(248, 0);
162-
#ifndef SUPPORT_FRACTIONAL_TRANSLATION
163-
canvas.setMatrix(RasterCache::GetIntegralTransCTM(canvas.getTotalMatrix()));
164-
#endif
165162
ASSERT_TRUE(cache.Draw(*picture, canvas));
166163
}
167164

0 commit comments

Comments
 (0)