| 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/ImageBufferSurface.h" | 8 #include "platform/graphics/ImageBufferSurface.h" |
| 9 #include "public/platform/WebThread.h" |
| 9 #include "wtf/OwnPtr.h" | 10 #include "wtf/OwnPtr.h" |
| 10 #include "wtf/RefPtr.h" | 11 #include "wtf/RefPtr.h" |
| 11 | 12 |
| 12 class SkPicture; | 13 class SkPicture; |
| 13 class SkPictureRecorder; | 14 class SkPictureRecorder; |
| 14 class RecordingImageBufferSurfaceTest; | 15 class RecordingImageBufferSurfaceTest; |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 17 | 18 |
| 18 class GraphicsContext; | 19 class GraphicsContext; |
| 19 | 20 |
| 20 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface { | 21 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface, p
ublic blink::WebThread::TaskObserver { |
| 21 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface); WTF_MAKE_FAST_ALLOCATED; | 22 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface); WTF_MAKE_FAST_ALLOCATED; |
| 22 public: | 23 public: |
| 23 RecordingImageBufferSurface(const IntSize&, OpacityMode = NonOpaque); | 24 RecordingImageBufferSurface(const IntSize&, OpacityMode = NonOpaque); |
| 24 virtual ~RecordingImageBufferSurface(); | 25 virtual ~RecordingImageBufferSurface(); |
| 25 | 26 |
| 26 // Implementation of ImageBufferSurface interfaces | 27 // Implementation of ImageBufferSurface interfaces |
| 27 virtual SkCanvas* canvas() const OVERRIDE; | 28 virtual SkCanvas* canvas() const OVERRIDE; |
| 28 virtual PassRefPtr<SkPicture> getPicture() OVERRIDE; | 29 virtual PassRefPtr<SkPicture> getPicture() OVERRIDE; |
| 29 virtual bool isValid() const OVERRIDE { return true; } | 30 virtual bool isValid() const OVERRIDE { return true; } |
| 30 virtual void willReadback() OVERRIDE; | 31 virtual void willReadback() OVERRIDE; |
| 31 virtual void willUse() OVERRIDE; | 32 virtual void didDraw() OVERRIDE; |
| 32 virtual void didClearCanvas() OVERRIDE; | 33 virtual void didClearCanvas() OVERRIDE; |
| 33 virtual void setImageBuffer(ImageBuffer*) OVERRIDE; | 34 virtual void setImageBuffer(ImageBuffer*) OVERRIDE; |
| 34 | 35 |
| 35 private: | 36 private: |
| 36 friend class ::RecordingImageBufferSurfaceTest; // for unit testing | 37 friend class ::RecordingImageBufferSurfaceTest; // for unit testing |
| 37 void fallBackToRasterCanvas(); | 38 void fallBackToRasterCanvas(); |
| 38 void initializeCurrentFrame(); | 39 void initializeCurrentFrame(); |
| 39 bool handleOpaqueFrame(); | 40 bool finalizeFrame(); |
| 41 |
| 42 // Implementation of WebThread::TaskObserver methods |
| 43 virtual void willProcessTask() OVERRIDE; |
| 44 virtual void didProcessTask() OVERRIDE; |
| 40 | 45 |
| 41 OwnPtr<SkPictureRecorder> m_currentFrame; | 46 OwnPtr<SkPictureRecorder> m_currentFrame; |
| 42 RefPtr<SkPicture> m_previousFrame; | 47 RefPtr<SkPicture> m_previousFrame; |
| 43 OwnPtr<SkCanvas> m_rasterCanvas; | 48 OwnPtr<SkCanvas> m_rasterCanvas; |
| 44 GraphicsContext* m_graphicsContext; | 49 GraphicsContext* m_graphicsContext; |
| 45 int m_initialSaveCount; | 50 int m_initialSaveCount; |
| 46 bool m_frameWasCleared; | 51 bool m_frameWasCleared; |
| 47 bool m_surfaceUsedSincePreviousFrameWasPresented; | 52 bool m_recordedSinceLastFrameWasFinalized; |
| 48 }; | 53 }; |
| 49 | 54 |
| 50 } // namespace blink | 55 } // namespace blink |
| 51 | 56 |
| 52 #endif | 57 #endif |
| OLD | NEW |