diff --git a/flow/paint_context.cc b/flow/paint_context.cc index ffa4b7c5f..0cc2e9923 100644 --- a/flow/paint_context.cc +++ b/flow/paint_context.cc @@ -49,4 +49,8 @@ PaintContext::ScopedFrame::~ScopedFrame() { PaintContext::~PaintContext() { } +void PaintContext::OnGrContextDestroyed() { + raster_cache_.Clear(); +} + } // namespace flow diff --git a/flow/paint_context.h b/flow/paint_context.h index e0fb8fade..3177050d2 100644 --- a/flow/paint_context.h +++ b/flow/paint_context.h @@ -51,6 +51,8 @@ class PaintContext { SkCanvas& canvas, bool instrumentation_enabled = true); + void OnGrContextDestroyed(); + RasterCache& raster_cache() { return raster_cache_; } const instrumentation::Counter& frame_count() const { return frame_count_; } const instrumentation::Stopwatch& frame_time() const { return frame_time_; } diff --git a/flow/raster_cache.cc b/flow/raster_cache.cc index 4a2b71f34..0e1f7da0e 100644 --- a/flow/raster_cache.cc +++ b/flow/raster_cache.cc @@ -112,4 +112,8 @@ void RasterCache::SweepAfterFrame() { cache_.erase(it); } +void RasterCache::Clear() { + cache_.clear(); +} + } // namespace flow diff --git a/flow/raster_cache.h b/flow/raster_cache.h index 884794f98..633339f12 100644 --- a/flow/raster_cache.h +++ b/flow/raster_cache.h @@ -25,6 +25,8 @@ class RasterCache { GrContext* context, SkPicture* picture, const SkMatrix& ctm); void SweepAfterFrame(); + void Clear(); + private: struct Entry { Entry(); diff --git a/sky/shell/gpu/direct/rasterizer_direct.cc b/sky/shell/gpu/direct/rasterizer_direct.cc index 2ab63b9f9..40438db88 100644 --- a/sky/shell/gpu/direct/rasterizer_direct.cc +++ b/sky/shell/gpu/direct/rasterizer_direct.cc @@ -130,6 +130,7 @@ void RasterizerDirect::Draw(uint64_t layer_tree_ptr, void RasterizerDirect::OnOutputSurfaceDestroyed() { if (context_) { CHECK(context_->MakeCurrent(surface_.get())); + paint_context_.OnGrContextDestroyed(); ganesh_canvas_.SetGrGLInterface(nullptr); context_ = nullptr; }