Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: cc/picture.h

Issue 12316084: cc: Consolidate the analysis_canvas operations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tomhudson's review Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/SkPicture.h" 15 #include "third_party/skia/include/core/SkPicture.h"
16 #include "third_party/skia/include/core/SkPixelRef.h" 16 #include "third_party/skia/include/core/SkPixelRef.h"
17 #include "ui/gfx/rect.h" 17 #include "ui/gfx/rect.h"
18 18
19 namespace skia {
20 class AnalysisCanvas;
21 } // namespace skia
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
29 const gfx::Rect& LayerRect() const { return layer_rect_; } 33 const gfx::Rect& LayerRect() const { return layer_rect_; }
30 const gfx::Rect& OpaqueRect() const { return opaque_rect_; } 34 const gfx::Rect& OpaqueRect() const { return opaque_rect_; }
31 35
32 // Make a thread-safe clone for rasterizing with. 36 // Make a thread-safe clone for rasterizing with.
33 scoped_refptr<Picture> Clone() const; 37 scoped_refptr<Picture> Clone() const;
34 38
35 // Record a paint operation. To be able to safely use this SkPicture for 39 // 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. 40 // playback on a different thread this can only be called once.
37 void Record(ContentLayerClient*, RenderingStats*); 41 void Record(ContentLayerClient*, RenderingStats*);
38 42
39 // Has Record() been called yet? 43 // Has Record() been called yet?
40 bool HasRecording() const { return picture_.get() != NULL; } 44 bool HasRecording() const { return picture_.get() != NULL; }
41 45
42 // Apply this contents scale and raster the content rect into the canvas. 46 // Apply this contents scale and raster the content rect into the canvas.
43 void Raster(SkCanvas* canvas, gfx::Rect content_rect, float contents_scale); 47 void Raster(SkCanvas* canvas, gfx::Rect content_rect, float contents_scale);
44 48
45 // Estimate the cost of rasterizing. To predict the cost of a particular 49 struct Analysis {
46 // call to Raster(), pass this the bounds of the canvas that will 50 bool is_solid_color_;
47 // be rastered into. 51 SkColor solid_color_;
48 bool IsCheapInRect(const gfx::Rect& layer_rect) const; 52 bool is_transparent_;
53 bool is_cheap_;
54 };
55
56 void AnalyzeInRect(skia::AnalysisCanvas* canvas,
57 const gfx::Rect& content_rect,
58 float contents_scale,
59 Analysis* analysis);
49 60
50 void GatherPixelRefs( 61 void GatherPixelRefs(
51 const gfx::Rect& layer_rect, 62 const gfx::Rect& layer_rect,
52 std::list<skia::LazyPixelRef*>& pixel_ref_list); 63 std::list<skia::LazyPixelRef*>& pixel_ref_list);
53 64
54 private: 65 private:
55 Picture(gfx::Rect layer_rect); 66 Picture(gfx::Rect layer_rect);
56 // This constructor assumes SkPicture is already ref'd and transfers 67 // This constructor assumes SkPicture is already ref'd and transfers
57 // ownership to this picture. 68 // ownership to this picture.
58 Picture(const skia::RefPtr<SkPicture>&, 69 Picture(const skia::RefPtr<SkPicture>&,
59 gfx::Rect layer_rect, 70 gfx::Rect layer_rect,
60 gfx::Rect opaque_rect); 71 gfx::Rect opaque_rect);
61 ~Picture(); 72 ~Picture();
62 73
63 gfx::Rect layer_rect_; 74 gfx::Rect layer_rect_;
64 gfx::Rect opaque_rect_; 75 gfx::Rect opaque_rect_;
65 skia::RefPtr<SkPicture> picture_; 76 skia::RefPtr<SkPicture> picture_;
66 77
67 friend class base::RefCountedThreadSafe<Picture>; 78 friend class base::RefCountedThreadSafe<Picture>;
68 DISALLOW_COPY_AND_ASSIGN(Picture); 79 DISALLOW_COPY_AND_ASSIGN(Picture);
69 }; 80 };
70 81
71 } // namespace cc 82 } // namespace cc
72 83
73 #endif // CC_PICTURE_H_ 84 #endif // CC_PICTURE_H_
OLDNEW
« no previous file with comments | « cc/layer_tree_settings.cc ('k') | cc/picture.cc » ('j') | cc/picture_layer_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698