Chromium Code Reviews| 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 #ifndef RecordingImageBufferSurface_h | 5 #ifndef RecordingImageBufferSurface_h |
| 6 #define RecordingImageBufferSurface_h | 6 #define RecordingImageBufferSurface_h |
| 7 | 7 |
| 8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
| 9 #include "platform/graphics/ImageBufferSurface.h" | 9 #include "platform/graphics/ImageBufferSurface.h" |
| 10 #include "public/platform/WebThread.h" | 10 #include "public/platform/WebThread.h" |
| 11 #include "wtf/Allocator.h" | 11 #include "wtf/Allocator.h" |
| 12 #include "wtf/Noncopyable.h" | 12 #include "wtf/Noncopyable.h" |
| 13 #include "wtf/RefPtr.h" | 13 #include "wtf/RefPtr.h" |
| 14 #include <memory> | 14 #include <memory> |
| 15 | 15 |
| 16 class SkCanvas; | 16 class SkCanvas; |
| 17 class SkPicture; | 17 class SkPicture; |
| 18 class SkPictureRecorder; | 18 class SkPictureRecorder; |
| 19 | 19 |
| 20 namespace blink { | 20 namespace blink { |
| 21 | 21 |
| 22 class ImageBuffer; | 22 class ImageBuffer; |
| 23 class RecordingImageBufferSurfaceTest; | 23 class RecordingImageBufferSurfaceTest; |
| 24 | 24 |
| 25 class RecordingImageBufferFallbackSurfaceFactory { | 25 class RecordingImageBufferFallbackSurfaceFactory { |
| 26 USING_FAST_MALLOC(RecordingImageBufferFallbackSurfaceFactory); | 26 USING_FAST_MALLOC(RecordingImageBufferFallbackSurfaceFactory); |
| 27 WTF_MAKE_NONCOPYABLE(RecordingImageBufferFallbackSurfaceFactory); | 27 WTF_MAKE_NONCOPYABLE(RecordingImageBufferFallbackSurfaceFactory); |
| 28 public: | 28 public: |
| 29 virtual std::unique_ptr<ImageBufferSurface> createSurface(const IntSize&, Op acityMode) = 0; | 29 virtual std::unique_ptr<ImageBufferSurface> createSurface(const IntSize&, Op acityMode, sk_sp<SkColorSpace>) = 0; |
| 30 virtual ~RecordingImageBufferFallbackSurfaceFactory() { } | 30 virtual ~RecordingImageBufferFallbackSurfaceFactory() { } |
| 31 protected: | 31 protected: |
| 32 RecordingImageBufferFallbackSurfaceFactory() { } | 32 RecordingImageBufferFallbackSurfaceFactory() { } |
| 33 private: | |
|
chrishtr
2016/08/08 22:04:31
Useless, remove.
Justin Novosad
2016/08/11 19:32:57
Done.
| |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface { | 36 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface { |
| 36 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface); USING_FAST_MALLOC(Recordi ngImageBufferSurface); | 37 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface); USING_FAST_MALLOC(Recordi ngImageBufferSurface); |
| 37 public: | 38 public: |
| 38 // If the fallbackFactory is null the buffer surface should only be used | 39 // If the fallbackFactory is null the buffer surface should only be used |
| 39 // for one frame and should not be used for any operations which need a | 40 // for one frame and should not be used for any operations which need a |
| 40 // raster surface, (i.e. writePixels). | 41 // raster surface, (i.e. writePixels). |
| 41 // Only #getPicture should be used to access the resulting frame. | 42 // Only #getPicture should be used to access the resulting frame. |
| 42 RecordingImageBufferSurface(const IntSize&, std::unique_ptr<RecordingImageBu fferFallbackSurfaceFactory> fallbackFactory = nullptr, OpacityMode = NonOpaque); | 43 RecordingImageBufferSurface(const IntSize&, std::unique_ptr<RecordingImageBu fferFallbackSurfaceFactory> fallbackFactory = nullptr, OpacityMode = NonOpaque, sk_sp<SkColorSpace> = nullptr); |
| 43 ~RecordingImageBufferSurface() override; | 44 ~RecordingImageBufferSurface() override; |
| 44 | 45 |
| 45 // Implementation of ImageBufferSurface interfaces | 46 // Implementation of ImageBufferSurface interfaces |
| 46 SkCanvas* canvas() override; | 47 SkCanvas* canvas() override; |
| 47 void disableDeferral(DisableDeferralReason) override; | 48 void disableDeferral(DisableDeferralReason) override; |
| 48 PassRefPtr<SkPicture> getPicture() override; | 49 PassRefPtr<SkPicture> getPicture() override; |
| 49 void flush(FlushReason) override; | 50 void flush(FlushReason) override; |
| 50 void didDraw(const FloatRect&) override; | 51 void didDraw(const FloatRect&) override; |
| 51 bool isValid() const override { return true; } | 52 bool isValid() const override { return true; } |
| 52 bool isRecording() const override { return !m_fallbackSurface; } | 53 bool isRecording() const override { return !m_fallbackSurface; } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 bool m_frameWasCleared; | 111 bool m_frameWasCleared; |
| 111 bool m_didRecordDrawCommandsInCurrentFrame; | 112 bool m_didRecordDrawCommandsInCurrentFrame; |
| 112 bool m_currentFrameHasExpensiveOp; | 113 bool m_currentFrameHasExpensiveOp; |
| 113 bool m_previousFrameHasExpensiveOp; | 114 bool m_previousFrameHasExpensiveOp; |
| 114 std::unique_ptr<RecordingImageBufferFallbackSurfaceFactory> m_fallbackFactor y; | 115 std::unique_ptr<RecordingImageBufferFallbackSurfaceFactory> m_fallbackFactor y; |
| 115 }; | 116 }; |
| 116 | 117 |
| 117 } // namespace blink | 118 } // namespace blink |
| 118 | 119 |
| 119 #endif | 120 #endif |
| OLD | NEW |