Chromium Code Reviews| 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> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "cc/cc_export.h" | 12 #include "cc/cc_export.h" |
| 13 #include "skia/ext/lazy_pixel_ref.h" | 13 #include "skia/ext/lazy_pixel_ref.h" |
| 14 #include "skia/ext/refptr.h" | 14 #include "skia/ext/refptr.h" |
| 15 #include "third_party/skia/include/core/SkPixelRef.h" | 15 #include "third_party/skia/include/core/SkPixelRef.h" |
| 16 #include "third_party/skia/include/core/SkTileGridPicture.h" | 16 #include "third_party/skia/include/core/SkTileGridPicture.h" |
| 17 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
| 18 | 18 |
| 19 namespace skia { | |
| 20 class AnalysisCanvas; | |
| 21 } // namespace skia | |
|
reveman
2013/03/07 00:11:28
nit: "// namespace xxx" comments are usually not u
| |
| 22 | |
| 19 namespace cc { | 23 namespace cc { |
| 20 | 24 |
| 21 class ContentLayerClient; | 25 class ContentLayerClient; |
| 22 struct RenderingStats; | 26 struct RenderingStats; |
| 23 | 27 |
| 24 class CC_EXPORT Picture | 28 class CC_EXPORT Picture |
| 25 : public base::RefCountedThreadSafe<Picture> { | 29 : public base::RefCountedThreadSafe<Picture> { |
| 26 public: | 30 public: |
| 27 static scoped_refptr<Picture> Create(gfx::Rect layer_rect); | 31 static scoped_refptr<Picture> Create(gfx::Rect layer_rect); |
| 28 | 32 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 40 // playback on a different thread this can only be called once. | 44 // playback on a different thread this can only be called once. |
| 41 void Record(ContentLayerClient*, RenderingStats*, | 45 void Record(ContentLayerClient*, RenderingStats*, |
| 42 const SkTileGridPicture::TileGridInfo& tileGridInfo); | 46 const SkTileGridPicture::TileGridInfo& tileGridInfo); |
| 43 | 47 |
| 44 // Has Record() been called yet? | 48 // Has Record() been called yet? |
| 45 bool HasRecording() const { return picture_.get() != NULL; } | 49 bool HasRecording() const { return picture_.get() != NULL; } |
| 46 | 50 |
| 47 // Apply this contents scale and raster the content rect into the canvas. | 51 // Apply this contents scale and raster the content rect into the canvas. |
| 48 void Raster(SkCanvas* canvas, gfx::Rect content_rect, float contents_scale); | 52 void Raster(SkCanvas* canvas, gfx::Rect content_rect, float contents_scale); |
| 49 | 53 |
| 50 // Estimate the cost of rasterizing. To predict the cost of a particular | 54 void AnalyzeInRect(skia::AnalysisCanvas* canvas, |
| 51 // call to Raster(), pass this the bounds of the canvas that will | 55 const gfx::Rect& content_rect, |
| 52 // be rastered into. | 56 float contents_scale); |
| 53 bool IsCheapInRect(const gfx::Rect& layer_rect) const; | |
| 54 | 57 |
| 55 void GatherPixelRefs( | 58 void GatherPixelRefs( |
| 56 const gfx::Rect& layer_rect, | 59 const gfx::Rect& layer_rect, |
| 57 std::list<skia::LazyPixelRef*>& pixel_ref_list); | 60 std::list<skia::LazyPixelRef*>& pixel_ref_list); |
| 58 | 61 |
| 59 private: | 62 private: |
| 60 Picture(gfx::Rect layer_rect); | 63 Picture(gfx::Rect layer_rect); |
| 61 // This constructor assumes SkPicture is already ref'd and transfers | 64 // This constructor assumes SkPicture is already ref'd and transfers |
| 62 // ownership to this picture. | 65 // ownership to this picture. |
| 63 Picture(const skia::RefPtr<SkPicture>&, | 66 Picture(const skia::RefPtr<SkPicture>&, |
| 64 gfx::Rect layer_rect, | 67 gfx::Rect layer_rect, |
| 65 gfx::Rect opaque_rect); | 68 gfx::Rect opaque_rect); |
| 66 ~Picture(); | 69 ~Picture(); |
| 67 | 70 |
| 68 gfx::Rect layer_rect_; | 71 gfx::Rect layer_rect_; |
| 69 gfx::Rect opaque_rect_; | 72 gfx::Rect opaque_rect_; |
| 70 skia::RefPtr<SkPicture> picture_; | 73 skia::RefPtr<SkPicture> picture_; |
| 71 | 74 |
| 72 typedef std::vector<scoped_refptr<Picture> > PictureVector; | 75 typedef std::vector<scoped_refptr<Picture> > PictureVector; |
| 73 PictureVector clones_; | 76 PictureVector clones_; |
| 74 | 77 |
| 75 friend class base::RefCountedThreadSafe<Picture>; | 78 friend class base::RefCountedThreadSafe<Picture>; |
| 76 DISALLOW_COPY_AND_ASSIGN(Picture); | 79 DISALLOW_COPY_AND_ASSIGN(Picture); |
| 77 }; | 80 }; |
| 78 | 81 |
| 79 } // namespace cc | 82 } // namespace cc |
| 80 | 83 |
| 81 #endif // CC_PICTURE_H_ | 84 #endif // CC_PICTURE_H_ |
| OLD | NEW |