OLD | NEW |
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/dom/Document.h" | 7 #include "core/dom/Document.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 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 NonOpaque, nullptr)); | 815 NonOpaque, nullptr)); |
816 canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); | 816 canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); |
817 | 817 |
818 context2d()->fillRect(0, 0, 1, 1); // To have a non-empty dirty rect | 818 context2d()->fillRect(0, 0, 1, 1); // To have a non-empty dirty rect |
819 for (int i = 0; | 819 for (int i = 0; |
820 i < ExpensiveCanvasHeuristicParameters::ExpensiveRecordingStackDepth - 1; | 820 i < ExpensiveCanvasHeuristicParameters::ExpensiveRecordingStackDepth - 1; |
821 ++i) { | 821 ++i) { |
822 context2d()->save(); | 822 context2d()->save(); |
823 context2d()->translate(1.0f, 0.0f); | 823 context2d()->translate(1.0f, 0.0f); |
824 } | 824 } |
825 canvasElement().doDeferredPaintInvalidation(); // To close the current frame | 825 canvasElement().finalizeFrame(); // To close the current frame |
826 } | 826 } |
827 | 827 |
828 TEST_F(CanvasRenderingContext2DTest, FallbackWithLargeState) { | 828 TEST_F(CanvasRenderingContext2DTest, FallbackWithLargeState) { |
829 createContext(NonOpaque); | 829 createContext(NonOpaque); |
830 std::unique_ptr<RecordingImageBufferSurface> surface = | 830 std::unique_ptr<RecordingImageBufferSurface> surface = |
831 WTF::wrapUnique(new RecordingImageBufferSurface( | 831 WTF::wrapUnique(new RecordingImageBufferSurface( |
832 IntSize(10, 10), | 832 IntSize(10, 10), |
833 MockSurfaceFactory::create(MockSurfaceFactory::ExpectFallback), | 833 MockSurfaceFactory::create(MockSurfaceFactory::ExpectFallback), |
834 NonOpaque, nullptr)); | 834 NonOpaque, nullptr)); |
835 canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); | 835 canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); |
836 | 836 |
837 context2d()->fillRect(0, 0, 1, 1); // To have a non-empty dirty rect | 837 context2d()->fillRect(0, 0, 1, 1); // To have a non-empty dirty rect |
838 for (int i = 0; | 838 for (int i = 0; |
839 i < ExpensiveCanvasHeuristicParameters::ExpensiveRecordingStackDepth; | 839 i < ExpensiveCanvasHeuristicParameters::ExpensiveRecordingStackDepth; |
840 ++i) { | 840 ++i) { |
841 context2d()->save(); | 841 context2d()->save(); |
842 context2d()->translate(1.0f, 0.0f); | 842 context2d()->translate(1.0f, 0.0f); |
843 } | 843 } |
844 canvasElement().doDeferredPaintInvalidation(); // To close the current frame | 844 canvasElement().finalizeFrame(); // To close the current frame |
845 } | 845 } |
846 | 846 |
847 TEST_F(CanvasRenderingContext2DTest, OpaqueDisplayListFallsBackForText) { | 847 TEST_F(CanvasRenderingContext2DTest, OpaqueDisplayListFallsBackForText) { |
848 // Verify that drawing text to an opaque canvas, which is expected to | 848 // Verify that drawing text to an opaque canvas, which is expected to |
849 // render with subpixel text anti-aliasing, results in falling out | 849 // render with subpixel text anti-aliasing, results in falling out |
850 // of display list mode because the current diplay list implementation | 850 // of display list mode because the current diplay list implementation |
851 // does not support pixel geometry settings. | 851 // does not support pixel geometry settings. |
852 // See: crbug.com/583809 | 852 // See: crbug.com/583809 |
853 createContext(Opaque); | 853 createContext(Opaque); |
854 std::unique_ptr<RecordingImageBufferSurface> surface = | 854 std::unique_ptr<RecordingImageBufferSurface> surface = |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 | 1360 |
1361 RuntimeEnabledFeatures::setExperimentalCanvasFeaturesEnabled( | 1361 RuntimeEnabledFeatures::setExperimentalCanvasFeaturesEnabled( |
1362 experimentalCanvasFeaturesRuntimeFlag); | 1362 experimentalCanvasFeaturesRuntimeFlag); |
1363 RuntimeEnabledFeatures::setColorCorrectRenderingEnabled( | 1363 RuntimeEnabledFeatures::setColorCorrectRenderingEnabled( |
1364 colorCorrectRenderingRuntimeFlag); | 1364 colorCorrectRenderingRuntimeFlag); |
1365 RuntimeEnabledFeatures::setColorCorrectRenderingDefaultModeEnabled( | 1365 RuntimeEnabledFeatures::setColorCorrectRenderingDefaultModeEnabled( |
1366 colorCorrectRenderingDefaultModeRuntimeFlag); | 1366 colorCorrectRenderingDefaultModeRuntimeFlag); |
1367 } | 1367 } |
1368 | 1368 |
1369 } // namespace blink | 1369 } // namespace blink |
OLD | NEW |