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

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DTest.cpp

Issue 2687073003: Make disabling 2d canvas GPU acceleration for getImageData less aggressive. (Closed)
Patch Set: Address comments Created 3 years, 10 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 | « no previous file | third_party/WebKit/Source/platform/graphics/ExpensiveCanvasHeuristicParameters.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/canvas2d/CanvasRenderingContext2D.h" 5 #include "modules/canvas2d/CanvasRenderingContext2D.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "bindings/core/v8/V8BindingForTesting.h" 8 #include "bindings/core/v8/V8BindingForTesting.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/frame/FrameView.h" 10 #include "core/frame/FrameView.h"
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 Canvas2DLayerBridge::EnableAcceleration); 981 Canvas2DLayerBridge::EnableAcceleration);
982 std::unique_ptr<Canvas2DImageBufferSurface> surface( 982 std::unique_ptr<Canvas2DImageBufferSurface> surface(
983 new Canvas2DImageBufferSurface(bridge, size)); 983 new Canvas2DImageBufferSurface(bridge, size));
984 canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); 984 canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface));
985 985
986 EXPECT_TRUE(canvasElement().buffer()->isAccelerated()); 986 EXPECT_TRUE(canvasElement().buffer()->isAccelerated());
987 EXPECT_EQ(1u, getGlobalAcceleratedImageBufferCount()); 987 EXPECT_EQ(1u, getGlobalAcceleratedImageBufferCount());
988 EXPECT_EQ(720000, getGlobalGPUMemoryUsage()); 988 EXPECT_EQ(720000, getGlobalGPUMemoryUsage());
989 989
990 DummyExceptionStateForTesting exceptionState; 990 DummyExceptionStateForTesting exceptionState;
991 for (int i = 0;
992 i <
993 ExpensiveCanvasHeuristicParameters::GPUReadbackMinSuccessiveFrames - 1;
994 i++) {
995 context2d()->getImageData(0, 0, 1, 1, exceptionState);
996 canvasElement().finalizeFrame();
997
998 EXPECT_FALSE(exceptionState.hadException());
999 EXPECT_TRUE(canvasElement().buffer()->isAccelerated());
1000 EXPECT_EQ(1u, getGlobalAcceleratedImageBufferCount());
1001 EXPECT_EQ(720000, getGlobalGPUMemoryUsage());
1002 }
1003
991 context2d()->getImageData(0, 0, 1, 1, exceptionState); 1004 context2d()->getImageData(0, 0, 1, 1, exceptionState);
1005 canvasElement().finalizeFrame();
992 1006
993 EXPECT_FALSE(exceptionState.hadException()); 1007 EXPECT_FALSE(exceptionState.hadException());
994 if (ExpensiveCanvasHeuristicParameters::GetImageDataForcesNoAcceleration) { 1008 if (ExpensiveCanvasHeuristicParameters::GPUReadbackForcesNoAcceleration) {
995 EXPECT_FALSE(canvasElement().buffer()->isAccelerated()); 1009 EXPECT_FALSE(canvasElement().buffer()->isAccelerated());
996 EXPECT_EQ(0u, getGlobalAcceleratedImageBufferCount()); 1010 EXPECT_EQ(0u, getGlobalAcceleratedImageBufferCount());
997 EXPECT_EQ(0, getGlobalGPUMemoryUsage()); 1011 EXPECT_EQ(0, getGlobalGPUMemoryUsage());
998 } else { 1012 } else {
999 EXPECT_TRUE(canvasElement().buffer()->isAccelerated()); 1013 EXPECT_TRUE(canvasElement().buffer()->isAccelerated());
1000 EXPECT_EQ(1u, getGlobalAcceleratedImageBufferCount()); 1014 EXPECT_EQ(1u, getGlobalAcceleratedImageBufferCount());
1001 EXPECT_EQ(720000, getGlobalGPUMemoryUsage()); 1015 EXPECT_EQ(720000, getGlobalGPUMemoryUsage());
1002 } 1016 }
1003 1017
1004 // Restore global state to prevent side-effects on other tests 1018 // Restore global state to prevent side-effects on other tests
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 1365
1352 RuntimeEnabledFeatures::setExperimentalCanvasFeaturesEnabled( 1366 RuntimeEnabledFeatures::setExperimentalCanvasFeaturesEnabled(
1353 experimentalCanvasFeaturesRuntimeFlag); 1367 experimentalCanvasFeaturesRuntimeFlag);
1354 RuntimeEnabledFeatures::setColorCorrectRenderingEnabled( 1368 RuntimeEnabledFeatures::setColorCorrectRenderingEnabled(
1355 colorCorrectRenderingRuntimeFlag); 1369 colorCorrectRenderingRuntimeFlag);
1356 RuntimeEnabledFeatures::setColorCorrectRenderingDefaultModeEnabled( 1370 RuntimeEnabledFeatures::setColorCorrectRenderingDefaultModeEnabled(
1357 colorCorrectRenderingDefaultModeRuntimeFlag); 1371 colorCorrectRenderingDefaultModeRuntimeFlag);
1358 } 1372 }
1359 1373
1360 } // namespace blink 1374 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/ExpensiveCanvasHeuristicParameters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698