Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp

Issue 2637553002: Stop unnecessary flushing in Canvas2DLayerBridge (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 TRACE_EVENT0("cc", "Canvas2DLayerBridge::flushRecordingOnly"); 778 TRACE_EVENT0("cc", "Canvas2DLayerBridge::flushRecordingOnly");
779 m_recorder->finishRecordingAsPicture()->playback( 779 m_recorder->finishRecordingAsPicture()->playback(
780 getOrCreateSurface()->getCanvas()); 780 getOrCreateSurface()->getCanvas());
781 if (m_isDeferralEnabled) 781 if (m_isDeferralEnabled)
782 startRecording(); 782 startRecording();
783 m_haveRecordedDrawCommands = false; 783 m_haveRecordedDrawCommands = false;
784 } 784 }
785 } 785 }
786 786
787 void Canvas2DLayerBridge::flush() { 787 void Canvas2DLayerBridge::flush() {
788 if (!m_didDrawSinceLastFlush)
xlai (Olivia) 2017/01/16 16:58:19 I have a second thought about this CL: how about w
789 return;
790 TRACE_EVENT0("cc", "Canvas2DLayerBridge::flush");
788 if (!getOrCreateSurface()) 791 if (!getOrCreateSurface())
789 return; 792 return;
790 TRACE_EVENT0("cc", "Canvas2DLayerBridge::flush");
791 flushRecordingOnly(); 793 flushRecordingOnly();
792 getOrCreateSurface()->getCanvas()->flush(); 794 getOrCreateSurface()->getCanvas()->flush();
795 m_didDrawSinceLastFlush = false;
793 } 796 }
794 797
795 void Canvas2DLayerBridge::flushGpu() { 798 void Canvas2DLayerBridge::flushGpu() {
796 TRACE_EVENT0("cc", "Canvas2DLayerBridge::flushGpu");
797 flush(); 799 flush();
798 gpu::gles2::GLES2Interface* gl = contextGL(); 800 gpu::gles2::GLES2Interface* gl = contextGL();
799 if (isAccelerated() && gl) 801 if (isAccelerated() && gl && m_didDrawSinceLastGpuFlush) {
802 TRACE_EVENT0("cc", "Canvas2DLayerBridge::flushGpu");
800 gl->Flush(); 803 gl->Flush();
804 m_didDrawSinceLastGpuFlush = false;
805 }
801 } 806 }
802 807
803 gpu::gles2::GLES2Interface* Canvas2DLayerBridge::contextGL() { 808 gpu::gles2::GLES2Interface* Canvas2DLayerBridge::contextGL() {
804 // Check on m_layer is necessary because contextGL() may be called during 809 // Check on m_layer is necessary because contextGL() may be called during
805 // the destruction of m_layer 810 // the destruction of m_layer
806 if (m_layer && m_accelerationMode != DisableAcceleration && 811 if (m_layer && m_accelerationMode != DisableAcceleration &&
807 !m_destructionInProgress) { 812 !m_destructionInProgress) {
808 // Call checkSurfaceValid to ensure the rate limiter is disabled if the 813 // Call checkSurfaceValid to ensure the rate limiter is disabled if the
809 // context is lost. 814 // context is lost.
810 if (!checkSurfaceValid()) 815 if (!checkSurfaceValid())
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 if (m_recordingPixelCount >= 1051 if (m_recordingPixelCount >=
1047 (m_size.width() * m_size.height() * 1052 (m_size.width() * m_size.height() *
1048 ExpensiveCanvasHeuristicParameters::ExpensiveOverdrawThreshold)) { 1053 ExpensiveCanvasHeuristicParameters::ExpensiveOverdrawThreshold)) {
1049 disableDeferral(DisableDeferralReasonExpensiveOverdrawHeuristic); 1054 disableDeferral(DisableDeferralReasonExpensiveOverdrawHeuristic);
1050 } 1055 }
1051 } 1056 }
1052 if (!m_isRegisteredTaskObserver) { 1057 if (!m_isRegisteredTaskObserver) {
1053 Platform::current()->currentThread()->addTaskObserver(this); 1058 Platform::current()->currentThread()->addTaskObserver(this);
1054 m_isRegisteredTaskObserver = true; 1059 m_isRegisteredTaskObserver = true;
1055 } 1060 }
1061 m_didDrawSinceLastFlush = true;
1062 m_didDrawSinceLastGpuFlush = true;
1056 } 1063 }
1057 1064
1058 void Canvas2DLayerBridge::prepareSurfaceForPaintingIfNeeded() { 1065 void Canvas2DLayerBridge::prepareSurfaceForPaintingIfNeeded() {
1059 getOrCreateSurface(PreferAcceleration); 1066 getOrCreateSurface(PreferAcceleration);
1060 } 1067 }
1061 1068
1062 void Canvas2DLayerBridge::finalizeFrame(const FloatRect& dirtyRect) { 1069 void Canvas2DLayerBridge::finalizeFrame(const FloatRect& dirtyRect) {
1063 DCHECK(!m_destructionInProgress); 1070 DCHECK(!m_destructionInProgress);
1064 if (m_layer && m_accelerationMode != DisableAcceleration) 1071 if (m_layer && m_accelerationMode != DisableAcceleration)
1065 m_layer->layer()->invalidateRect(enclosingIntRect(dirtyRect)); 1072 m_layer->layer()->invalidateRect(enclosingIntRect(dirtyRect));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 default; 1149 default;
1143 1150
1144 void Canvas2DLayerBridge::Logger::reportHibernationEvent( 1151 void Canvas2DLayerBridge::Logger::reportHibernationEvent(
1145 HibernationEvent event) { 1152 HibernationEvent event) {
1146 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, 1153 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram,
1147 ("Canvas.HibernationEvents", HibernationEventCount)); 1154 ("Canvas.HibernationEvents", HibernationEventCount));
1148 hibernationHistogram.count(event); 1155 hibernationHistogram.count(event);
1149 } 1156 }
1150 1157
1151 } // namespace blink 1158 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698