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

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

Issue 2547013002: Add Intel macOS workaround for WebGL2 canvas_sub_rectangle tests (Closed)
Patch Set: add comments Created 4 years 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
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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 182 }
183 m_recordingPixelCount = 0; 183 m_recordingPixelCount = 0;
184 } 184 }
185 185
186 void Canvas2DLayerBridge::setLoggerForTesting(std::unique_ptr<Logger> logger) { 186 void Canvas2DLayerBridge::setLoggerForTesting(std::unique_ptr<Logger> logger) {
187 m_logger = std::move(logger); 187 m_logger = std::move(logger);
188 } 188 }
189 189
190 bool Canvas2DLayerBridge::shouldAccelerate(AccelerationHint hint) const { 190 bool Canvas2DLayerBridge::shouldAccelerate(AccelerationHint hint) const {
191 bool accelerate; 191 bool accelerate;
192 if (m_softwareRenderingWhileHidden) 192 if (m_softwareRenderingWhileHidden) {
193 accelerate = false; 193 accelerate = false;
194 else if (m_accelerationMode == ForceAccelerationForTesting) 194 } else if (m_accelerationMode == ForceAccelerationForTesting) {
195 accelerate = true; 195 accelerate = true;
196 else if (m_accelerationMode == DisableAcceleration) 196 } else if (m_accelerationMode == DisableAcceleration) {
197 accelerate = false; 197 accelerate = false;
198 else 198 } else {
199 accelerate = hint == PreferAcceleration || 199 accelerate = hint == PreferAcceleration ||
200 hint == PreferAccelerationAfterVisibilityChange; 200 hint == PreferAccelerationAfterVisibilityChange ||
201 hint == PreferAccelerationWithExtraSurfaceCopy;
202 }
201 203
202 if (accelerate && 204 if (accelerate &&
203 (!m_contextProvider || 205 (!m_contextProvider ||
204 m_contextProvider->contextGL()->GetGraphicsResetStatusKHR() != 206 m_contextProvider->contextGL()->GetGraphicsResetStatusKHR() !=
205 GL_NO_ERROR)) 207 GL_NO_ERROR))
206 accelerate = false; 208 accelerate = false;
207 return accelerate; 209 return accelerate;
208 } 210 }
209 211
210 bool Canvas2DLayerBridge::isAccelerated() const { 212 bool Canvas2DLayerBridge::isAccelerated() const {
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 CanvasMetrics::countCanvasContextUsage( 535 CanvasMetrics::countCanvasContextUsage(
534 CanvasMetrics::GPUAccelerated2DCanvasSurfaceCreationFailed); 536 CanvasMetrics::GPUAccelerated2DCanvasSurfaceCreationFailed);
535 m_surfaceCreationFailedAtLeastOnce = true; 537 m_surfaceCreationFailedAtLeastOnce = true;
536 } 538 }
537 } 539 }
538 540
539 SkSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint) { 541 SkSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint) {
540 if (m_surface) 542 if (m_surface)
541 return m_surface.get(); 543 return m_surface.get();
542 544
543 if (m_layer && !isHibernating() && hint == PreferAcceleration && 545 if (m_layer && !isHibernating() &&
546 (hint == PreferAcceleration ||
547 hint == PreferAccelerationWithExtraSurfaceCopy) &&
544 m_accelerationMode != DisableAcceleration) { 548 m_accelerationMode != DisableAcceleration) {
545 return nullptr; // re-creation will happen through restore() 549 return nullptr; // re-creation will happen through restore()
546 } 550 }
547 551
548 bool wantAcceleration = shouldAccelerate(hint); 552 bool wantAcceleration = shouldAccelerate(hint);
549 if (CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU && isHidden() && 553 if (CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU && isHidden() &&
550 wantAcceleration) { 554 wantAcceleration) {
551 wantAcceleration = false; 555 wantAcceleration = false;
552 m_softwareRenderingWhileHidden = true; 556 m_softwareRenderingWhileHidden = true;
553 } 557 }
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 return nullptr; 1110 return nullptr;
1107 if (!getOrCreateSurface(hint)) 1111 if (!getOrCreateSurface(hint))
1108 return nullptr; 1112 return nullptr;
1109 flush(); 1113 flush();
1110 // A readback operation may alter the texture parameters, which may affect 1114 // A readback operation may alter the texture parameters, which may affect
1111 // the compositor's behavior. Therefore, we must trigger copy-on-write 1115 // the compositor's behavior. Therefore, we must trigger copy-on-write
1112 // even though we are not technically writing to the texture, only to its 1116 // even though we are not technically writing to the texture, only to its
1113 // parameters. 1117 // parameters.
1114 getOrCreateSurface()->notifyContentWillChange( 1118 getOrCreateSurface()->notifyContentWillChange(
1115 SkSurface::kRetain_ContentChangeMode); 1119 SkSurface::kRetain_ContentChangeMode);
1120
1121 // Create a new SkSurface compatible with m_surface, and discard it
1122 // immediately. This nonsense operation can suppress the flaky error, which
1123 // will likely happen when later reading or peeking pixels back from the image
1124 // snapshot, on Intel MacOS platform(crbug.com/665656).
qiankun 2016/12/05 08:25:31 Brian & Eric, we found this workaround but we didn
bsalomon 2016/12/05 14:12:41 Sorry, but I don't think we've encountered this pa
1125 if (hint == PreferAccelerationWithExtraSurfaceCopy)
Justin Novosad 2016/12/05 20:54:01 This is a misuse of "hint". As it's name suggests,
1126 m_surface->makeSurface(m_surface->getCanvas()->imageInfo()).reset();
Zhenyao Mo 2016/12/05 18:13:36 This seems a big perf regression. If we only enco
1127
1116 return m_surface->makeImageSnapshot(); 1128 return m_surface->makeImageSnapshot();
1117 } 1129 }
1118 1130
1119 void Canvas2DLayerBridge::willOverwriteCanvas() { 1131 void Canvas2DLayerBridge::willOverwriteCanvas() {
1120 skipQueuedDrawCommands(); 1132 skipQueuedDrawCommands();
1121 } 1133 }
1122 1134
1123 #if USE_IOSURFACE_FOR_2D_CANVAS 1135 #if USE_IOSURFACE_FOR_2D_CANVAS
1124 Canvas2DLayerBridge::ImageInfo::ImageInfo( 1136 Canvas2DLayerBridge::ImageInfo::ImageInfo(
1125 std::unique_ptr<gfx::GpuMemoryBuffer> gpuMemoryBuffer, 1137 std::unique_ptr<gfx::GpuMemoryBuffer> gpuMemoryBuffer,
(...skipping 15 matching lines...) Expand all
1141 default; 1153 default;
1142 1154
1143 void Canvas2DLayerBridge::Logger::reportHibernationEvent( 1155 void Canvas2DLayerBridge::Logger::reportHibernationEvent(
1144 HibernationEvent event) { 1156 HibernationEvent event) {
1145 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, 1157 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram,
1146 ("Canvas.HibernationEvents", HibernationEventCount)); 1158 ("Canvas.HibernationEvents", HibernationEventCount));
1147 hibernationHistogram.count(event); 1159 hibernationHistogram.count(event);
1148 } 1160 }
1149 1161
1150 } // namespace blink 1162 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698