OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 CC_PICTURE_H_ | 5 #ifndef CC_PICTURE_H_ |
6 #define CC_PICTURE_H_ | 6 #define CC_PICTURE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "cc/cc_export.h" | 10 #include "cc/cc_export.h" |
11 #include "third_party/skia/include/core/SkPicture.h" | 11 #include "third_party/skia/include/core/SkPicture.h" |
12 #include "ui/gfx/rect.h" | 12 #include "ui/gfx/rect.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 | 15 |
16 class ContentLayerClient; | 16 class ContentLayerClient; |
17 struct RenderingStats; | 17 struct RenderingStats; |
18 | 18 |
19 class CC_EXPORT Picture | 19 class CC_EXPORT Picture |
20 : public base::RefCountedThreadSafe<Picture> { | 20 : public base::RefCountedThreadSafe<Picture> { |
21 public: | 21 public: |
22 static scoped_refptr<Picture> Create(); | 22 static scoped_refptr<Picture> Create(gfx::Rect layer_rect); |
23 | 23 |
24 const gfx::Rect& LayerRect() const { return layer_rect_; } | 24 const gfx::Rect& LayerRect() const { return layer_rect_; } |
25 const gfx::Rect& OpaqueRect() const { return opaque_rect_; } | 25 const gfx::Rect& OpaqueRect() const { return opaque_rect_; } |
26 | 26 |
27 // Make a thread-safe clone for rasterizing with. | 27 // Make a thread-safe clone for rasterizing with. |
28 scoped_refptr<Picture> Clone(); | 28 scoped_refptr<Picture> Clone() const; |
29 | 29 |
30 // Record a paint operation. To be able to safely use this SkPicture for | 30 // Record a paint operation. To be able to safely use this SkPicture for |
31 // playback on a different thread this can only be called once. | 31 // playback on a different thread this can only be called once. |
32 void Record(ContentLayerClient*, gfx::Rect layer_rect, RenderingStats&); | 32 void Record(ContentLayerClient*, RenderingStats&); |
| 33 |
| 34 // Has Record() been called yet? |
| 35 bool HasRecording() const { return picture_.get(); } |
33 | 36 |
34 // Raster this Picture's layer_rect into the given canvas. | 37 // Raster this Picture's layer_rect into the given canvas. |
35 // Assumes contentsScale have already been applied. | 38 // Assumes contentsScale have already been applied. |
36 void Raster(SkCanvas* canvas); | 39 void Raster(SkCanvas* canvas); |
37 | 40 |
38 private: | 41 private: |
39 Picture(); | 42 Picture(gfx::Rect layer_rect); |
40 // This constructor assumes SkPicture is already ref'd and transfers | 43 // This constructor assumes SkPicture is already ref'd and transfers |
41 // ownership to this picture. | 44 // ownership to this picture. |
42 Picture(SkPicture*, gfx::Rect layer_rect, gfx::Rect opaque_rect); | 45 Picture(SkPicture*, gfx::Rect layer_rect, gfx::Rect opaque_rect); |
43 ~Picture(); | 46 ~Picture(); |
44 | 47 |
45 gfx::Rect layer_rect_; | 48 gfx::Rect layer_rect_; |
46 gfx::Rect opaque_rect_; | 49 gfx::Rect opaque_rect_; |
47 SkAutoTUnref<SkPicture> picture_; | 50 SkAutoTUnref<SkPicture> picture_; |
48 | 51 |
49 friend class base::RefCountedThreadSafe<Picture>; | 52 friend class base::RefCountedThreadSafe<Picture>; |
50 DISALLOW_COPY_AND_ASSIGN(Picture); | 53 DISALLOW_COPY_AND_ASSIGN(Picture); |
51 }; | 54 }; |
52 | 55 |
53 } // namespace cc | 56 } // namespace cc |
54 | 57 |
55 #endif // CC_PICTURE_H_ | 58 #endif // CC_PICTURE_H_ |
OLD | NEW |