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 |
Sergey
2014/08/28 09:55:34
I am not sure, that this declarations belong here.
| |
23 // The same with the default state stack size in SkCanvas | |
24 #define INITIAL_STATE_STACK_SIZE 1 | |
25 | |
26 struct StateRec { | |
Justin Novosad
2014/08/28 14:53:00
This struct and the typedef below should be moved
Sergey
2014/09/03 01:50:51
Done.
| |
27 public: | |
28 SkMatrix m_ctm; | |
29 SkRect m_clip; | |
30 }; | |
31 | |
32 typedef Deque<StateRec, INITIAL_STATE_STACK_SIZE> StateStack; | |
33 | |
21 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface { | 34 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface { |
22 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface); WTF_MAKE_FAST_ALLOCATED; | 35 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface); WTF_MAKE_FAST_ALLOCATED; |
23 public: | 36 public: |
24 RecordingImageBufferSurface(const IntSize&, OpacityMode = NonOpaque); | 37 RecordingImageBufferSurface(const IntSize&, OpacityMode = NonOpaque); |
25 virtual ~RecordingImageBufferSurface(); | 38 virtual ~RecordingImageBufferSurface(); |
26 | 39 |
27 // Implementation of ImageBufferSurface interfaces | 40 // Implementation of ImageBufferSurface interfaces |
28 virtual SkCanvas* canvas() const OVERRIDE; | 41 virtual SkCanvas* canvas() const OVERRIDE; |
29 virtual PassRefPtr<SkPicture> getPicture() OVERRIDE; | 42 virtual PassRefPtr<SkPicture> getPicture() OVERRIDE; |
30 virtual bool isValid() const OVERRIDE { return true; } | 43 virtual bool isValid() const OVERRIDE { return true; } |
31 virtual void willAccessPixels() OVERRIDE; | 44 virtual void willAccessPixels() OVERRIDE; |
32 virtual void finalizeFrame() OVERRIDE; | 45 virtual void finalizeFrame() OVERRIDE; |
33 virtual void didClearCanvas() OVERRIDE; | 46 virtual void didClearCanvas() OVERRIDE; |
34 virtual void setImageBuffer(ImageBuffer*) OVERRIDE; | 47 virtual void setImageBuffer(ImageBuffer*) OVERRIDE; |
35 | 48 |
36 private: | 49 private: |
37 friend class ::RecordingImageBufferSurfaceTest; // for unit testing | 50 friend class ::RecordingImageBufferSurfaceTest; // for unit testing |
38 void fallBackToRasterCanvas(); | 51 void fallBackToRasterCanvas(); |
39 void initializeCurrentFrame(); | 52 void initializeCurrentFrame(); |
40 bool finalizeFrameInternal(); | 53 bool finalizeFrameInternal(); |
41 | 54 |
55 // saves current clip and transform matrix of canvas | |
56 bool saveState(SkCanvas*, StateStack*); | |
57 // we should make sure that we can transfer state in saveState | |
58 void setCurrentState(SkCanvas*, StateStack*); | |
59 | |
42 OwnPtr<SkPictureRecorder> m_currentFrame; | 60 OwnPtr<SkPictureRecorder> m_currentFrame; |
43 RefPtr<SkPicture> m_previousFrame; | 61 RefPtr<SkPicture> m_previousFrame; |
44 OwnPtr<SkCanvas> m_rasterCanvas; | 62 OwnPtr<SkCanvas> m_rasterCanvas; |
45 ImageBuffer* m_imageBuffer; | 63 ImageBuffer* m_imageBuffer; |
46 int m_initialSaveCount; | 64 int m_initialSaveCount; |
47 bool m_frameWasCleared; | 65 bool m_frameWasCleared; |
48 }; | 66 }; |
49 | 67 |
50 } // namespace blink | 68 } // namespace blink |
51 | 69 |
52 #endif | 70 #endif |
OLD | NEW |