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