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