| 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 <memory> | 7 #include <memory> |
| 8 #include "bindings/core/v8/V8BindingForCore.h" | 8 #include "bindings/core/v8/V8BindingForCore.h" |
| 9 #include "bindings/core/v8/V8BindingForTesting.h" | 9 #include "bindings/core/v8/V8BindingForTesting.h" |
| 10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 auto surface = WTF::MakeUnique<RecordingImageBufferSurface>( | 825 auto surface = WTF::MakeUnique<RecordingImageBufferSurface>( |
| 826 IntSize(10, 10), RecordingImageBufferSurface::kAllowFallback, kOpaque); | 826 IntSize(10, 10), RecordingImageBufferSurface::kAllowFallback, kOpaque); |
| 827 auto* surface_ptr = surface.get(); | 827 auto* surface_ptr = surface.get(); |
| 828 CanvasElement().CreateImageBufferUsingSurfaceForTesting(std::move(surface)); | 828 CanvasElement().CreateImageBufferUsingSurfaceForTesting(std::move(surface)); |
| 829 | 829 |
| 830 Context2d()->fillText("Text", 0, 5); | 830 Context2d()->fillText("Text", 0, 5); |
| 831 | 831 |
| 832 EXPECT_FALSE(surface_ptr->IsRecording()); | 832 EXPECT_FALSE(surface_ptr->IsRecording()); |
| 833 } | 833 } |
| 834 | 834 |
| 835 TEST_F(CanvasRenderingContext2DTest, | |
| 836 NonOpaqueDisplayListDoesNotFallBackForText) { | |
| 837 CreateContext(kNonOpaque); | |
| 838 auto surface = WTF::MakeUnique<RecordingImageBufferSurface>( | |
| 839 IntSize(10, 10), RecordingImageBufferSurface::kAllowFallback, kNonOpaque); | |
| 840 auto* surface_ptr = surface.get(); | |
| 841 CanvasElement().CreateImageBufferUsingSurfaceForTesting(std::move(surface)); | |
| 842 | |
| 843 Context2d()->fillText("Text", 0, 5); | |
| 844 | |
| 845 EXPECT_TRUE(surface_ptr->IsRecording()); | |
| 846 } | |
| 847 | |
| 848 TEST_F(CanvasRenderingContext2DTest, ImageResourceLifetime) { | 835 TEST_F(CanvasRenderingContext2DTest, ImageResourceLifetime) { |
| 849 NonThrowableExceptionState non_throwable_exception_state; | 836 NonThrowableExceptionState non_throwable_exception_state; |
| 850 Element* canvas_element = | 837 Element* canvas_element = |
| 851 GetDocument().createElement("canvas", non_throwable_exception_state); | 838 GetDocument().createElement("canvas", non_throwable_exception_state); |
| 852 EXPECT_FALSE(non_throwable_exception_state.HadException()); | 839 EXPECT_FALSE(non_throwable_exception_state.HadException()); |
| 853 HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(canvas_element); | 840 HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(canvas_element); |
| 854 canvas->SetSize(IntSize(40, 40)); | 841 canvas->SetSize(IntSize(40, 40)); |
| 855 ImageBitmap* image_bitmap_derived = nullptr; | 842 ImageBitmap* image_bitmap_derived = nullptr; |
| 856 { | 843 { |
| 857 const ImageBitmapOptions default_options; | 844 const ImageBitmapOptions default_options; |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1698 | 1685 |
| 1699 // Wake up again, which should request a compositing update synchronously. | 1686 // Wake up again, which should request a compositing update synchronously. |
| 1700 GetDocument().GetPage()->SetVisibilityState(kPageVisibilityStateVisible, | 1687 GetDocument().GetPage()->SetVisibilityState(kPageVisibilityStateVisible, |
| 1701 false); | 1688 false); |
| 1702 EXPECT_EQ(!!CANVAS2D_HIBERNATION_ENABLED, | 1689 EXPECT_EQ(!!CANVAS2D_HIBERNATION_ENABLED, |
| 1703 layer->NeedsCompositingInputsUpdate()); | 1690 layer->NeedsCompositingInputsUpdate()); |
| 1704 RunUntilIdle(); // Clear task queue. | 1691 RunUntilIdle(); // Clear task queue. |
| 1705 } | 1692 } |
| 1706 | 1693 |
| 1707 } // namespace blink | 1694 } // namespace blink |
| OLD | NEW |