| 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/canvas2d/CanvasRenderingContext2D.h" | 6 #include "modules/canvas2d/CanvasRenderingContext2D.h" |
| 7 | 7 |
| 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 24 matching lines...) Expand all Loading... |
| 35 class FakeImageSource : public CanvasImageSource { | 35 class FakeImageSource : public CanvasImageSource { |
| 36 public: | 36 public: |
| 37 FakeImageSource(IntSize, BitmapOpacity); | 37 FakeImageSource(IntSize, BitmapOpacity); |
| 38 | 38 |
| 39 PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceImageStatus
*) const override; | 39 PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceImageStatus
*) const override; |
| 40 | 40 |
| 41 bool wouldTaintOrigin(SecurityOrigin* destinationSecurityOrigin) const overr
ide { return false; } | 41 bool wouldTaintOrigin(SecurityOrigin* destinationSecurityOrigin) const overr
ide { return false; } |
| 42 FloatSize elementSize() const override { return FloatSize(m_size); } | 42 FloatSize elementSize() const override { return FloatSize(m_size); } |
| 43 bool isOpaque() const override { return m_isOpaque; } | 43 bool isOpaque() const override { return m_isOpaque; } |
| 44 | 44 |
| 45 virtual ~FakeImageSource() { } | 45 ~FakeImageSource() override { } |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 IntSize m_size; | 48 IntSize m_size; |
| 49 RefPtr<Image> m_image; | 49 RefPtr<Image> m_image; |
| 50 bool m_isOpaque; | 50 bool m_isOpaque; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 FakeImageSource::FakeImageSource(IntSize size, BitmapOpacity opacity) | 53 FakeImageSource::FakeImageSource(IntSize size, BitmapOpacity opacity) |
| 54 : m_size(size) | 54 : m_size(size) |
| 55 , m_isOpaque(opacity == OpaqueBitmap) | 55 , m_isOpaque(opacity == OpaqueBitmap) |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 EXPECT_FALSE(exceptionState.hadException()); | 159 EXPECT_FALSE(exceptionState.hadException()); |
| 160 StringOrCanvasGradientOrCanvasPattern wrappedAlphaGradient; | 160 StringOrCanvasGradientOrCanvasPattern wrappedAlphaGradient; |
| 161 this->alphaGradient().setCanvasGradient(alphaGradient); | 161 this->alphaGradient().setCanvasGradient(alphaGradient); |
| 162 } | 162 } |
| 163 | 163 |
| 164 //============================================================================ | 164 //============================================================================ |
| 165 | 165 |
| 166 class MockImageBufferSurfaceForOverwriteTesting : public UnacceleratedImageBuffe
rSurface { | 166 class MockImageBufferSurfaceForOverwriteTesting : public UnacceleratedImageBuffe
rSurface { |
| 167 public: | 167 public: |
| 168 MockImageBufferSurfaceForOverwriteTesting(const IntSize& size, OpacityMode m
ode) : UnacceleratedImageBufferSurface(size, mode) { } | 168 MockImageBufferSurfaceForOverwriteTesting(const IntSize& size, OpacityMode m
ode) : UnacceleratedImageBufferSurface(size, mode) { } |
| 169 virtual ~MockImageBufferSurfaceForOverwriteTesting() { } | 169 ~MockImageBufferSurfaceForOverwriteTesting() override { } |
| 170 bool isRecording() const override { return true; } // otherwise overwrites a
re not tracked | 170 bool isRecording() const override { return true; } // otherwise overwrites a
re not tracked |
| 171 | 171 |
| 172 MOCK_METHOD0(willOverwriteCanvas, void()); | 172 MOCK_METHOD0(willOverwriteCanvas, void()); |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 //============================================================================ | 175 //============================================================================ |
| 176 | 176 |
| 177 class MockCanvasObserver final : public NoBaseWillBeGarbageCollectedFinalized<Mo
ckCanvasObserver>, public CanvasObserver { | 177 class MockCanvasObserver final : public NoBaseWillBeGarbageCollectedFinalized<Mo
ckCanvasObserver>, public CanvasObserver { |
| 178 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MockCanvasObserver); | 178 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MockCanvasObserver); |
| 179 public: | 179 public: |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 }; | 253 }; |
| 254 static PassOwnPtr<MockSurfaceFactory> create(FallbackExpectation expectation
) { return adoptPtr(new MockSurfaceFactory(expectation)); } | 254 static PassOwnPtr<MockSurfaceFactory> create(FallbackExpectation expectation
) { return adoptPtr(new MockSurfaceFactory(expectation)); } |
| 255 | 255 |
| 256 PassOwnPtr<ImageBufferSurface> createSurface(const IntSize& size, OpacityMod
e mode) override | 256 PassOwnPtr<ImageBufferSurface> createSurface(const IntSize& size, OpacityMod
e mode) override |
| 257 { | 257 { |
| 258 EXPECT_EQ(ExpectFallback, m_expectation); | 258 EXPECT_EQ(ExpectFallback, m_expectation); |
| 259 m_didFallback = true; | 259 m_didFallback = true; |
| 260 return adoptPtr(new UnacceleratedImageBufferSurface(size, mode)); | 260 return adoptPtr(new UnacceleratedImageBufferSurface(size, mode)); |
| 261 } | 261 } |
| 262 | 262 |
| 263 virtual ~MockSurfaceFactory() | 263 ~MockSurfaceFactory() override |
| 264 { | 264 { |
| 265 if (m_expectation == ExpectFallback) { | 265 if (m_expectation == ExpectFallback) { |
| 266 EXPECT_TRUE(m_didFallback); | 266 EXPECT_TRUE(m_didFallback); |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 | 269 |
| 270 private: | 270 private: |
| 271 MockSurfaceFactory(FallbackExpectation expectation) | 271 MockSurfaceFactory(FallbackExpectation expectation) |
| 272 : m_expectation(expectation) | 272 : m_expectation(expectation) |
| 273 , m_didFallback(false) { } | 273 , m_didFallback(false) { } |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 // The canvasChanged notification must be immediate, and not deferred until
paint time | 624 // The canvasChanged notification must be immediate, and not deferred until
paint time |
| 625 // because offscreen canvases, which are not painted, also need to emit noti
fications. | 625 // because offscreen canvases, which are not painted, also need to emit noti
fications. |
| 626 EXPECT_CALL(*observer, canvasChanged(&canvasElement(), FloatRect(0, 0, 1, 1)
)).Times(1); | 626 EXPECT_CALL(*observer, canvasChanged(&canvasElement(), FloatRect(0, 0, 1, 1)
)).Times(1); |
| 627 context2d()->fillRect(0, 0, 1, 1); | 627 context2d()->fillRect(0, 0, 1, 1); |
| 628 Mock::VerifyAndClearExpectations(observer.get()); | 628 Mock::VerifyAndClearExpectations(observer.get()); |
| 629 | 629 |
| 630 canvasElement().removeObserver(observer.get()); | 630 canvasElement().removeObserver(observer.get()); |
| 631 } | 631 } |
| 632 | 632 |
| 633 } // namespace blink | 633 } // namespace blink |
| OLD | NEW |