| 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 "public/platform/WebThread.h" |
| 10 #include "third_party/skia/include/core/SkCanvas.h" |
| 11 #include "wtf/LinkedStack.h" |
| 10 #include "wtf/OwnPtr.h" | 12 #include "wtf/OwnPtr.h" |
| 11 #include "wtf/RefPtr.h" | 13 #include "wtf/RefPtr.h" |
| 12 | 14 |
| 13 class SkPicture; | 15 class SkPicture; |
| 14 class SkPictureRecorder; | 16 class SkPictureRecorder; |
| 15 class RecordingImageBufferSurfaceTest; | 17 class RecordingImageBufferSurfaceTest; |
| 16 | 18 |
| 17 namespace blink { | 19 namespace blink { |
| 18 | 20 |
| 19 class ImageBuffer; | 21 class ImageBuffer; |
| 20 | 22 |
| 21 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface { | 23 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface { |
| 22 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface); WTF_MAKE_FAST_ALLOCATED; | 24 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface); WTF_MAKE_FAST_ALLOCATED; |
| 23 public: | 25 public: |
| 24 RecordingImageBufferSurface(const IntSize&, OpacityMode = NonOpaque); | 26 RecordingImageBufferSurface(const IntSize&, OpacityMode = NonOpaque); |
| 25 virtual ~RecordingImageBufferSurface(); | 27 virtual ~RecordingImageBufferSurface(); |
| 26 | 28 |
| 27 // Implementation of ImageBufferSurface interfaces | 29 // Implementation of ImageBufferSurface interfaces |
| 28 virtual SkCanvas* canvas() const OVERRIDE; | 30 virtual SkCanvas* canvas() const OVERRIDE; |
| 29 virtual PassRefPtr<SkPicture> getPicture() OVERRIDE; | 31 virtual PassRefPtr<SkPicture> getPicture() OVERRIDE; |
| 30 virtual bool isValid() const OVERRIDE { return true; } | 32 virtual bool isValid() const OVERRIDE { return true; } |
| 31 virtual void willAccessPixels() OVERRIDE; | 33 virtual void willAccessPixels() OVERRIDE; |
| 32 virtual void finalizeFrame() OVERRIDE; | 34 virtual void finalizeFrame() OVERRIDE; |
| 33 virtual void didClearCanvas() OVERRIDE; | 35 virtual void didClearCanvas() OVERRIDE; |
| 34 virtual void setImageBuffer(ImageBuffer*) OVERRIDE; | 36 virtual void setImageBuffer(ImageBuffer*) OVERRIDE; |
| 35 | 37 |
| 36 private: | 38 private: |
| 39 struct StateRec { |
| 40 public: |
| 41 SkMatrix m_ctm; |
| 42 // FIXME: handle transferring non-rectangular clip to the new frame, crb
ug.com/392614 |
| 43 SkIRect m_clip; |
| 44 }; |
| 45 typedef LinkedStack<StateRec> StateStack; |
| 37 friend class ::RecordingImageBufferSurfaceTest; // for unit testing | 46 friend class ::RecordingImageBufferSurfaceTest; // for unit testing |
| 38 void fallBackToRasterCanvas(); | 47 void fallBackToRasterCanvas(); |
| 39 void initializeCurrentFrame(); | 48 void initializeCurrentFrame(); |
| 40 bool finalizeFrameInternal(); | 49 bool finalizeFrameInternal(); |
| 41 | 50 |
| 51 // saves current clip and transform matrix of canvas |
| 52 bool saveState(SkCanvas*, StateStack*); |
| 53 // we should make sure that we can transfer state in saveState |
| 54 void setCurrentState(SkCanvas*, StateStack*); |
| 55 |
| 42 OwnPtr<SkPictureRecorder> m_currentFrame; | 56 OwnPtr<SkPictureRecorder> m_currentFrame; |
| 43 RefPtr<SkPicture> m_previousFrame; | 57 RefPtr<SkPicture> m_previousFrame; |
| 44 OwnPtr<SkCanvas> m_rasterCanvas; | 58 OwnPtr<SkCanvas> m_rasterCanvas; |
| 45 ImageBuffer* m_imageBuffer; | 59 ImageBuffer* m_imageBuffer; |
| 46 int m_initialSaveCount; | 60 int m_initialSaveCount; |
| 47 bool m_frameWasCleared; | 61 bool m_frameWasCleared; |
| 48 }; | 62 }; |
| 49 | 63 |
| 50 } // namespace blink | 64 } // namespace blink |
| 51 | 65 |
| 52 #endif | 66 #endif |
| OLD | NEW |