| 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/analysis_canvas.h" |
| 13 #include "skia/ext/lazy_pixel_ref.h" | 14 #include "skia/ext/lazy_pixel_ref.h" |
| 14 #include "skia/ext/refptr.h" | 15 #include "skia/ext/refptr.h" |
| 15 #include "third_party/skia/include/core/SkPicture.h" | 16 #include "third_party/skia/include/core/SkPicture.h" |
| 16 #include "third_party/skia/include/core/SkPixelRef.h" | 17 #include "third_party/skia/include/core/SkPixelRef.h" |
| 17 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
| 18 | 19 |
| 19 namespace cc { | 20 namespace cc { |
| 20 | 21 |
| 21 class ContentLayerClient; | 22 class ContentLayerClient; |
| 22 struct RenderingStats; | 23 struct RenderingStats; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 35 // Record a paint operation. To be able to safely use this SkPicture for | 36 // Record a paint operation. To be able to safely use this SkPicture for |
| 36 // playback on a different thread this can only be called once. | 37 // playback on a different thread this can only be called once. |
| 37 void Record(ContentLayerClient*, RenderingStats*); | 38 void Record(ContentLayerClient*, RenderingStats*); |
| 38 | 39 |
| 39 // Has Record() been called yet? | 40 // Has Record() been called yet? |
| 40 bool HasRecording() const { return picture_.get() != NULL; } | 41 bool HasRecording() const { return picture_.get() != NULL; } |
| 41 | 42 |
| 42 // Apply this contents scale and raster the content rect into the canvas. | 43 // Apply this contents scale and raster the content rect into the canvas. |
| 43 void Raster(SkCanvas* canvas, gfx::Rect content_rect, float contents_scale); | 44 void Raster(SkCanvas* canvas, gfx::Rect content_rect, float contents_scale); |
| 44 | 45 |
| 45 // Estimate the cost of rasterizing. To predict the cost of a particular | 46 void AnalyzeInRect(skia::AnalysisCanvas* canvas, |
| 46 // call to Raster(), pass this the bounds of the canvas that will | 47 const gfx::Rect& content_rect, |
| 47 // be rastered into. | 48 float contents_scale, |
| 48 bool IsCheapInRect(const gfx::Rect& layer_rect) const; | 49 bool* is_solid, |
| 50 SkColor* solid_color, |
| 51 bool* is_transparent, |
| 52 bool* is_cheap); |
| 49 | 53 |
| 50 void GatherPixelRefs( | 54 void GatherPixelRefs( |
| 51 const gfx::Rect& layer_rect, | 55 const gfx::Rect& layer_rect, |
| 52 std::list<skia::LazyPixelRef*>& pixel_ref_list); | 56 std::list<skia::LazyPixelRef*>& pixel_ref_list); |
| 53 | 57 |
| 54 private: | 58 private: |
| 55 Picture(gfx::Rect layer_rect); | 59 Picture(gfx::Rect layer_rect); |
| 56 // This constructor assumes SkPicture is already ref'd and transfers | 60 // This constructor assumes SkPicture is already ref'd and transfers |
| 57 // ownership to this picture. | 61 // ownership to this picture. |
| 58 Picture(const skia::RefPtr<SkPicture>&, | 62 Picture(const skia::RefPtr<SkPicture>&, |
| 59 gfx::Rect layer_rect, | 63 gfx::Rect layer_rect, |
| 60 gfx::Rect opaque_rect); | 64 gfx::Rect opaque_rect); |
| 61 ~Picture(); | 65 ~Picture(); |
| 62 | 66 |
| 63 gfx::Rect layer_rect_; | 67 gfx::Rect layer_rect_; |
| 64 gfx::Rect opaque_rect_; | 68 gfx::Rect opaque_rect_; |
| 65 skia::RefPtr<SkPicture> picture_; | 69 skia::RefPtr<SkPicture> picture_; |
| 66 | 70 |
| 67 friend class base::RefCountedThreadSafe<Picture>; | 71 friend class base::RefCountedThreadSafe<Picture>; |
| 68 DISALLOW_COPY_AND_ASSIGN(Picture); | 72 DISALLOW_COPY_AND_ASSIGN(Picture); |
| 69 }; | 73 }; |
| 70 | 74 |
| 71 } // namespace cc | 75 } // namespace cc |
| 72 | 76 |
| 73 #endif // CC_PICTURE_H_ | 77 #endif // CC_PICTURE_H_ |
| OLD | NEW |