| 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 "platform/graphics/RecordingImageBufferSurface.h" | 5 #include "platform/graphics/RecordingImageBufferSurface.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include "platform/WebTaskRunner.h" | 8 #include "platform/WebTaskRunner.h" |
| 9 #include "platform/graphics/GraphicsContext.h" | 9 #include "platform/graphics/GraphicsContext.h" |
| 10 #include "platform/graphics/ImageBuffer.h" | 10 #include "platform/graphics/ImageBuffer.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 namespace blink { | 26 namespace blink { |
| 27 | 27 |
| 28 class MockSurfaceFactory : public RecordingImageBufferFallbackSurfaceFactory { | 28 class MockSurfaceFactory : public RecordingImageBufferFallbackSurfaceFactory { |
| 29 public: | 29 public: |
| 30 MockSurfaceFactory() : create_surface_count_(0) {} | 30 MockSurfaceFactory() : create_surface_count_(0) {} |
| 31 | 31 |
| 32 virtual std::unique_ptr<ImageBufferSurface> CreateSurface( | 32 virtual std::unique_ptr<ImageBufferSurface> CreateSurface( |
| 33 const IntSize& size, | 33 const IntSize& size, |
| 34 OpacityMode opacity_mode, | 34 OpacityMode opacity_mode, |
| 35 sk_sp<SkColorSpace> color_space, | 35 const CanvasColorParams& color_params) { |
| 36 SkColorType color_type) { | |
| 37 create_surface_count_++; | 36 create_surface_count_++; |
| 38 return WTF::WrapUnique(new UnacceleratedImageBufferSurface( | 37 return WTF::WrapUnique(new UnacceleratedImageBufferSurface( |
| 39 size, opacity_mode, kInitializeImagePixels, std::move(color_space), | 38 size, opacity_mode, kInitializeImagePixels, color_params)); |
| 40 color_type)); | |
| 41 } | 39 } |
| 42 | 40 |
| 43 virtual ~MockSurfaceFactory() {} | 41 virtual ~MockSurfaceFactory() {} |
| 44 | 42 |
| 45 int CreateSurfaceCount() { return create_surface_count_; } | 43 int CreateSurfaceCount() { return create_surface_count_; } |
| 46 | 44 |
| 47 private: | 45 private: |
| 48 int create_surface_count_; | 46 int create_surface_count_; |
| 49 }; | 47 }; |
| 50 | 48 |
| 51 class RecordingImageBufferSurfaceTest : public Test { | 49 class RecordingImageBufferSurfaceTest : public Test { |
| 52 protected: | 50 protected: |
| 53 RecordingImageBufferSurfaceTest() { | 51 RecordingImageBufferSurfaceTest() { |
| 54 std::unique_ptr<MockSurfaceFactory> surface_factory = | 52 std::unique_ptr<MockSurfaceFactory> surface_factory = |
| 55 WTF::MakeUnique<MockSurfaceFactory>(); | 53 WTF::MakeUnique<MockSurfaceFactory>(); |
| 56 surface_factory_ = surface_factory.get(); | 54 surface_factory_ = surface_factory.get(); |
| 57 std::unique_ptr<RecordingImageBufferSurface> test_surface = | 55 std::unique_ptr<RecordingImageBufferSurface> test_surface = |
| 58 WTF::WrapUnique(new RecordingImageBufferSurface( | 56 WTF::WrapUnique(new RecordingImageBufferSurface( |
| 59 IntSize(10, 10), std::move(surface_factory), kNonOpaque, nullptr)); | 57 IntSize(10, 10), std::move(surface_factory), kNonOpaque)); |
| 60 test_surface_ = test_surface.get(); | 58 test_surface_ = test_surface.get(); |
| 61 // We create an ImageBuffer in order for the testSurface to be | 59 // We create an ImageBuffer in order for the testSurface to be |
| 62 // properly initialized with a GraphicsContext | 60 // properly initialized with a GraphicsContext |
| 63 image_buffer_ = ImageBuffer::Create(std::move(test_surface)); | 61 image_buffer_ = ImageBuffer::Create(std::move(test_surface)); |
| 64 EXPECT_FALSE(!image_buffer_); | 62 EXPECT_FALSE(!image_buffer_); |
| 65 test_surface_->InitializeCurrentFrame(); | 63 test_surface_->InitializeCurrentFrame(); |
| 66 } | 64 } |
| 67 | 65 |
| 68 public: | 66 public: |
| 69 RecordingImageBufferSurface* TestSurface() { return test_surface_; } | 67 RecordingImageBufferSurface* TestSurface() { return test_surface_; } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 clear_flags.setBlendMode(SkBlendMode::kClear); | 133 clear_flags.setBlendMode(SkBlendMode::kClear); |
| 136 Canvas()->drawRect(SkRect::MakeWH(TestSurface()->size().Width(), | 134 Canvas()->drawRect(SkRect::MakeWH(TestSurface()->size().Width(), |
| 137 TestSurface()->size().Height()), | 135 TestSurface()->size().Height()), |
| 138 clear_flags); | 136 clear_flags); |
| 139 TestSurface()->DidDraw(FloatRect(0, 0, 1, 1)); | 137 TestSurface()->DidDraw(FloatRect(0, 0, 1, 1)); |
| 140 TestSurface()->GetRecord(); | 138 TestSurface()->GetRecord(); |
| 141 ExpectDisplayListEnabled(true); | 139 ExpectDisplayListEnabled(true); |
| 142 } | 140 } |
| 143 | 141 |
| 144 } // namespace blink | 142 } // namespace blink |
| OLD | NEW |