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/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/Deque.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 |
| 23 // The same with the default state stack size in SkCanvas | |
| 24 #define INITIAL_STATE_STACK_SIZE 1 | |
|
zino
2014/09/03 10:50:17
Should we use WTF::Deque? I think it is better to
Sergey
2014/09/04 10:26:50
Junov, what do you think? I would probably agree w
| |
| 25 | |
| 21 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface { | 26 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface { |
| 22 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface); WTF_MAKE_FAST_ALLOCATED; | 27 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface); WTF_MAKE_FAST_ALLOCATED; |
| 23 public: | 28 public: |
| 24 RecordingImageBufferSurface(const IntSize&, OpacityMode = NonOpaque); | 29 RecordingImageBufferSurface(const IntSize&, OpacityMode = NonOpaque); |
| 25 virtual ~RecordingImageBufferSurface(); | 30 virtual ~RecordingImageBufferSurface(); |
| 26 | 31 |
| 27 // Implementation of ImageBufferSurface interfaces | 32 // Implementation of ImageBufferSurface interfaces |
| 28 virtual SkCanvas* canvas() const OVERRIDE; | 33 virtual SkCanvas* canvas() const OVERRIDE; |
| 29 virtual PassRefPtr<SkPicture> getPicture() OVERRIDE; | 34 virtual PassRefPtr<SkPicture> getPicture() OVERRIDE; |
| 30 virtual bool isValid() const OVERRIDE { return true; } | 35 virtual bool isValid() const OVERRIDE { return true; } |
| 31 virtual void willAccessPixels() OVERRIDE; | 36 virtual void willAccessPixels() OVERRIDE; |
| 32 virtual void finalizeFrame() OVERRIDE; | 37 virtual void finalizeFrame() OVERRIDE; |
| 33 virtual void didClearCanvas() OVERRIDE; | 38 virtual void didClearCanvas() OVERRIDE; |
| 34 virtual void setImageBuffer(ImageBuffer*) OVERRIDE; | 39 virtual void setImageBuffer(ImageBuffer*) OVERRIDE; |
| 35 | 40 |
| 36 private: | 41 private: |
| 42 struct StateRec { | |
| 43 public: | |
|
zino
2014/09/03 10:50:17
Is this Blink coding rule?
If not so, I think this
Sergey
2014/09/11 12:58:53
Probably not required here at all.
| |
| 44 SkMatrix m_ctm; | |
| 45 SkRect m_clip; | |
|
zino
2014/09/03 10:50:18
If you use getDeviceClipBounds(), you should proba
Sergey
2014/09/11 12:58:52
Probably not required here at all.
| |
| 46 }; | |
| 47 typedef Deque<StateRec, INITIAL_STATE_STACK_SIZE> StateStack; | |
| 37 friend class ::RecordingImageBufferSurfaceTest; // for unit testing | 48 friend class ::RecordingImageBufferSurfaceTest; // for unit testing |
| 38 void fallBackToRasterCanvas(); | 49 void fallBackToRasterCanvas(); |
| 39 void initializeCurrentFrame(); | 50 void initializeCurrentFrame(); |
| 40 bool finalizeFrameInternal(); | 51 bool finalizeFrameInternal(); |
| 41 | 52 |
| 53 // saves current clip and transform matrix of canvas | |
| 54 bool saveState(SkCanvas*, StateStack*); | |
| 55 // we should make sure that we can transfer state in saveState | |
| 56 void setCurrentState(SkCanvas*, StateStack*); | |
| 57 | |
| 42 OwnPtr<SkPictureRecorder> m_currentFrame; | 58 OwnPtr<SkPictureRecorder> m_currentFrame; |
| 43 RefPtr<SkPicture> m_previousFrame; | 59 RefPtr<SkPicture> m_previousFrame; |
| 44 OwnPtr<SkCanvas> m_rasterCanvas; | 60 OwnPtr<SkCanvas> m_rasterCanvas; |
| 45 ImageBuffer* m_imageBuffer; | 61 ImageBuffer* m_imageBuffer; |
| 46 int m_initialSaveCount; | 62 int m_initialSaveCount; |
| 47 bool m_frameWasCleared; | 63 bool m_frameWasCleared; |
| 48 }; | 64 }; |
| 49 | 65 |
| 50 } // namespace blink | 66 } // namespace blink |
| 51 | 67 |
| 52 #endif | 68 #endif |
| OLD | NEW |