Allow surface implementations to control when the raster cache may be enabled. (flutter/engine#32213)

This commit is contained in:
Chinmay Garde
2022-03-23 10:23:14 -07:00
committed by GitHub
parent 0f0e05173e
commit 3088a62e29
5 changed files with 19 additions and 2 deletions

View File

@@ -22,4 +22,8 @@ bool Surface::AllowsDrawingWhenGpuDisabled() const {
return true;
}
bool Surface::EnableRasterCache() const {
return true;
}
} // namespace flutter

View File

@@ -35,6 +35,8 @@ class Surface {
virtual bool AllowsDrawingWhenGpuDisabled() const;
virtual bool EnableRasterCache() const;
private:
FML_DISALLOW_COPY_AND_ASSIGN(Surface);
};

View File

@@ -576,8 +576,11 @@ RasterStatus Rasterizer::DrawToSurfaceUnsafe(
}
}
RasterStatus raster_status =
compositor_frame->Raster(layer_tree, false, damage.get());
RasterStatus raster_status = compositor_frame->Raster(
layer_tree, // layer tree
!surface_->EnableRasterCache(), // ignore raster cache
damage.get() // frame damage
);
if (raster_status == RasterStatus::kFailed ||
raster_status == RasterStatus::kSkipAndRetry) {
return raster_status;

View File

@@ -43,6 +43,9 @@ class SK_API_AVAILABLE_CA_METAL_LAYER GPUSurfaceMetalImpeller : public Surface {
// |Surface|
bool AllowsDrawingWhenGpuDisabled() const override;
// |Surface|
bool EnableRasterCache() const override;
FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceMetalImpeller);
};

View File

@@ -121,4 +121,9 @@ bool GPUSurfaceMetalImpeller::AllowsDrawingWhenGpuDisabled() const {
return delegate_->AllowsDrawingWhenGpuDisabled();
}
// |Surface|
bool GPUSurfaceMetalImpeller::EnableRasterCache() const {
return false;
}
} // namespace flutter