Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp |
| diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp |
| index 5ad87f841357bda2150a4ddf0fa980b627260f29..0efabea5065304afbc0f849a5302d3ac50b8cf40 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp |
| +++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp |
| @@ -785,19 +785,24 @@ void Canvas2DLayerBridge::flushRecordingOnly() { |
| } |
| void Canvas2DLayerBridge::flush() { |
| - if (!getOrCreateSurface()) |
| + if (!m_didDrawSinceLastFlush) |
|
xlai (Olivia)
2017/01/16 16:58:19
I have a second thought about this CL: how about w
|
| return; |
| TRACE_EVENT0("cc", "Canvas2DLayerBridge::flush"); |
| + if (!getOrCreateSurface()) |
| + return; |
| flushRecordingOnly(); |
| getOrCreateSurface()->getCanvas()->flush(); |
| + m_didDrawSinceLastFlush = false; |
| } |
| void Canvas2DLayerBridge::flushGpu() { |
| - TRACE_EVENT0("cc", "Canvas2DLayerBridge::flushGpu"); |
| flush(); |
| gpu::gles2::GLES2Interface* gl = contextGL(); |
| - if (isAccelerated() && gl) |
| + if (isAccelerated() && gl && m_didDrawSinceLastGpuFlush) { |
| + TRACE_EVENT0("cc", "Canvas2DLayerBridge::flushGpu"); |
| gl->Flush(); |
| + m_didDrawSinceLastGpuFlush = false; |
| + } |
| } |
| gpu::gles2::GLES2Interface* Canvas2DLayerBridge::contextGL() { |
| @@ -1053,6 +1058,8 @@ void Canvas2DLayerBridge::didDraw(const FloatRect& rect) { |
| Platform::current()->currentThread()->addTaskObserver(this); |
| m_isRegisteredTaskObserver = true; |
| } |
| + m_didDrawSinceLastFlush = true; |
| + m_didDrawSinceLastGpuFlush = true; |
| } |
| void Canvas2DLayerBridge::prepareSurfaceForPaintingIfNeeded() { |