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

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

Issue 2171513003: Re-enable canvas optimization for getImageData with new codepath (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 4 years, 5 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/Canvas2DLayerBridge.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 "core/fetch/MemoryCache.h" 7 #include "core/fetch/MemoryCache.h"
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/frame/ImageBitmap.h" 9 #include "core/frame/ImageBitmap.h"
10 #include "core/html/HTMLCanvasElement.h" 10 #include "core/html/HTMLCanvasElement.h"
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 RuntimeEnabledFeatures::setCanvas2dFixedRenderingModeEnabled(false); 772 RuntimeEnabledFeatures::setCanvas2dFixedRenderingModeEnabled(false);
773 773
774 createContext(NonOpaque); 774 createContext(NonOpaque);
775 FakeGLES2Interface gl; 775 FakeGLES2Interface gl;
776 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider(new FakeWe bGraphicsContext3DProvider(&gl)); 776 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider(new FakeWe bGraphicsContext3DProvider(&gl));
777 IntSize size(300, 300); 777 IntSize size(300, 300);
778 RefPtr<Canvas2DLayerBridge> bridge = makeBridge(std::move(contextProvider), size, Canvas2DLayerBridge::EnableAcceleration); 778 RefPtr<Canvas2DLayerBridge> bridge = makeBridge(std::move(contextProvider), size, Canvas2DLayerBridge::EnableAcceleration);
779 std::unique_ptr<Canvas2DImageBufferSurface> surface(new Canvas2DImageBufferS urface(bridge, size)); 779 std::unique_ptr<Canvas2DImageBufferSurface> surface(new Canvas2DImageBufferS urface(bridge, size));
780 canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); 780 canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface));
781 781
782 EXPECT_TRUE(bridge->isAccelerated()); 782 EXPECT_TRUE(canvasElement().buffer()->isAccelerated());
783 EXPECT_EQ(1u, getGlobalAcceleratedImageBufferCount()); 783 EXPECT_EQ(1u, getGlobalAcceleratedImageBufferCount());
784 EXPECT_EQ(720000, getGlobalGPUMemoryUsage()); 784 EXPECT_EQ(720000, getGlobalGPUMemoryUsage());
785 785
786 TrackExceptionState exceptionState; 786 TrackExceptionState exceptionState;
787 context2d()->getImageData(0, 0, 1, 1, exceptionState); 787 context2d()->getImageData(0, 0, 1, 1, exceptionState);
788 788
789 EXPECT_FALSE(exceptionState.hadException()); 789 EXPECT_FALSE(exceptionState.hadException());
790 if (ExpensiveCanvasHeuristicParameters::GetImageDataForcesNoAcceleration) { 790 if (ExpensiveCanvasHeuristicParameters::GetImageDataForcesNoAcceleration) {
791 EXPECT_FALSE(bridge->isAccelerated()); 791 EXPECT_FALSE(canvasElement().buffer()->isAccelerated());
792 EXPECT_EQ(0u, getGlobalAcceleratedImageBufferCount()); 792 EXPECT_EQ(0u, getGlobalAcceleratedImageBufferCount());
793 EXPECT_EQ(0, getGlobalGPUMemoryUsage()); 793 EXPECT_EQ(0, getGlobalGPUMemoryUsage());
794 } else { 794 } else {
795 EXPECT_TRUE(bridge->isAccelerated()); 795 EXPECT_TRUE(canvasElement().buffer()->isAccelerated());
796 EXPECT_EQ(1u, getGlobalAcceleratedImageBufferCount()); 796 EXPECT_EQ(1u, getGlobalAcceleratedImageBufferCount());
797 EXPECT_EQ(720000, getGlobalGPUMemoryUsage()); 797 EXPECT_EQ(720000, getGlobalGPUMemoryUsage());
798 } 798 }
799 799
800 // Restore global state to prevent side-effects on other tests 800 // Restore global state to prevent side-effects on other tests
801 RuntimeEnabledFeatures::setCanvas2dFixedRenderingModeEnabled(savedFixedRende ringMode); 801 RuntimeEnabledFeatures::setCanvas2dFixedRenderingModeEnabled(savedFixedRende ringMode);
802 } 802 }
803 803
804 TEST_F(CanvasRenderingContext2DTest, IsAccelerationOptimalForCanvasContentHeuris tic) 804 TEST_F(CanvasRenderingContext2DTest, IsAccelerationOptimalForCanvasContentHeuris tic)
805 { 805 {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 EXPECT_FALSE(canvasElement().buffer()->isAccelerated()); 847 EXPECT_FALSE(canvasElement().buffer()->isAccelerated());
848 848
849 context->fillRect(10, 10, 100, 100); 849 context->fillRect(10, 10, 100, 100);
850 850
851 EXPECT_EQ(0, getCurrentGPUMemoryUsage()); 851 EXPECT_EQ(0, getCurrentGPUMemoryUsage());
852 EXPECT_EQ(0, getGlobalGPUMemoryUsage()); 852 EXPECT_EQ(0, getGlobalGPUMemoryUsage());
853 EXPECT_EQ(0u, getGlobalAcceleratedImageBufferCount()); 853 EXPECT_EQ(0u, getGlobalAcceleratedImageBufferCount());
854 } 854 }
855 855
856 } // namespace blink 856 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698