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_RESOURCES_PICTURE_H_ | 5 #ifndef CC_RESOURCES_PICTURE_H_ |
6 #define CC_RESOURCES_PICTURE_H_ | 6 #define CC_RESOURCES_PICTURE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 class ContentLayerClient; | 37 class ContentLayerClient; |
38 | 38 |
39 class CC_EXPORT Picture | 39 class CC_EXPORT Picture |
40 : public base::RefCountedThreadSafe<Picture> { | 40 : public base::RefCountedThreadSafe<Picture> { |
41 public: | 41 public: |
42 typedef std::pair<int, int> PixelRefMapKey; | 42 typedef std::pair<int, int> PixelRefMapKey; |
43 typedef std::vector<SkPixelRef*> PixelRefs; | 43 typedef std::vector<SkPixelRef*> PixelRefs; |
44 typedef base::hash_map<PixelRefMapKey, PixelRefs> PixelRefMap; | 44 typedef base::hash_map<PixelRefMapKey, PixelRefs> PixelRefMap; |
45 | 45 |
46 static scoped_refptr<Picture> Create(gfx::Rect layer_rect); | 46 static scoped_refptr<Picture> Create(const gfx::Rect& layer_rect); |
47 static scoped_refptr<Picture> CreateFromValue(const base::Value* value); | 47 static scoped_refptr<Picture> CreateFromValue(const base::Value* value); |
48 static scoped_refptr<Picture> CreateFromSkpValue(const base::Value* value); | 48 static scoped_refptr<Picture> CreateFromSkpValue(const base::Value* value); |
49 | 49 |
50 gfx::Rect LayerRect() const { return layer_rect_; } | 50 gfx::Rect LayerRect() const { return layer_rect_; } |
51 gfx::Rect OpaqueRect() const { return opaque_rect_; } | 51 gfx::Rect OpaqueRect() const { return opaque_rect_; } |
52 | 52 |
53 // Get thread-safe clone for rasterizing with on a specific thread. | 53 // Get thread-safe clone for rasterizing with on a specific thread. |
54 scoped_refptr<Picture> GetCloneForDrawingOnThread( | 54 scoped_refptr<Picture> GetCloneForDrawingOnThread( |
55 unsigned thread_index) const; | 55 unsigned thread_index) const; |
56 | 56 |
(...skipping 20 matching lines...) Expand all Loading... |
77 | 77 |
78 // Draw the picture directly into the given canvas, without applying any | 78 // Draw the picture directly into the given canvas, without applying any |
79 // clip/scale/layer transformations. | 79 // clip/scale/layer transformations. |
80 void Replay(SkCanvas* canvas); | 80 void Replay(SkCanvas* canvas); |
81 | 81 |
82 scoped_ptr<base::Value> AsValue() const; | 82 scoped_ptr<base::Value> AsValue() const; |
83 | 83 |
84 class CC_EXPORT PixelRefIterator { | 84 class CC_EXPORT PixelRefIterator { |
85 public: | 85 public: |
86 PixelRefIterator(); | 86 PixelRefIterator(); |
87 PixelRefIterator(gfx::Rect layer_rect, const Picture* picture); | 87 PixelRefIterator(const gfx::Rect& layer_rect, const Picture* picture); |
88 ~PixelRefIterator(); | 88 ~PixelRefIterator(); |
89 | 89 |
90 SkPixelRef* operator->() const { | 90 SkPixelRef* operator->() const { |
91 DCHECK_LT(current_index_, current_pixel_refs_->size()); | 91 DCHECK_LT(current_index_, current_pixel_refs_->size()); |
92 return (*current_pixel_refs_)[current_index_]; | 92 return (*current_pixel_refs_)[current_index_]; |
93 } | 93 } |
94 | 94 |
95 SkPixelRef* operator*() const { | 95 SkPixelRef* operator*() const { |
96 DCHECK_LT(current_index_, current_pixel_refs_->size()); | 96 DCHECK_LT(current_index_, current_pixel_refs_->size()); |
97 return (*current_pixel_refs_)[current_index_]; | 97 return (*current_pixel_refs_)[current_index_]; |
(...skipping 15 matching lines...) Expand all Loading... |
113 int current_x_; | 113 int current_x_; |
114 int current_y_; | 114 int current_y_; |
115 }; | 115 }; |
116 | 116 |
117 void EmitTraceSnapshot(); | 117 void EmitTraceSnapshot(); |
118 void EmitTraceSnapshotAlias(Picture* original); | 118 void EmitTraceSnapshotAlias(Picture* original); |
119 | 119 |
120 bool WillPlayBackBitmaps() const { return picture_->willPlayBackBitmaps(); } | 120 bool WillPlayBackBitmaps() const { return picture_->willPlayBackBitmaps(); } |
121 | 121 |
122 private: | 122 private: |
123 explicit Picture(gfx::Rect layer_rect); | 123 explicit Picture(const gfx::Rect& layer_rect); |
124 // This constructor assumes SkPicture is already ref'd and transfers | 124 // This constructor assumes SkPicture is already ref'd and transfers |
125 // ownership to this picture. | 125 // ownership to this picture. |
126 Picture(const skia::RefPtr<SkPicture>&, | 126 Picture(const skia::RefPtr<SkPicture>&, |
127 gfx::Rect layer_rect, | 127 const gfx::Rect& layer_rect, |
128 gfx::Rect opaque_rect, | 128 const gfx::Rect& opaque_rect, |
129 const PixelRefMap& pixel_refs); | 129 const PixelRefMap& pixel_refs); |
130 // This constructor will call AdoptRef on the SkPicture. | 130 // This constructor will call AdoptRef on the SkPicture. |
131 Picture(SkPicture*, | 131 Picture(SkPicture*, |
132 gfx::Rect layer_rect, | 132 const gfx::Rect& layer_rect, |
133 gfx::Rect opaque_rect); | 133 const gfx::Rect& opaque_rect); |
134 ~Picture(); | 134 ~Picture(); |
135 | 135 |
136 gfx::Rect layer_rect_; | 136 gfx::Rect layer_rect_; |
137 gfx::Rect opaque_rect_; | 137 gfx::Rect opaque_rect_; |
138 skia::RefPtr<SkPicture> picture_; | 138 skia::RefPtr<SkPicture> picture_; |
139 | 139 |
140 typedef std::vector<scoped_refptr<Picture> > PictureVector; | 140 typedef std::vector<scoped_refptr<Picture> > PictureVector; |
141 PictureVector clones_; | 141 PictureVector clones_; |
142 | 142 |
143 PixelRefMap pixel_refs_; | 143 PixelRefMap pixel_refs_; |
144 gfx::Point min_pixel_cell_; | 144 gfx::Point min_pixel_cell_; |
145 gfx::Point max_pixel_cell_; | 145 gfx::Point max_pixel_cell_; |
146 gfx::Size cell_size_; | 146 gfx::Size cell_size_; |
147 | 147 |
148 scoped_refptr<base::debug::ConvertableToTraceFormat> | 148 scoped_refptr<base::debug::ConvertableToTraceFormat> |
149 AsTraceableRasterData(float scale) const; | 149 AsTraceableRasterData(float scale) const; |
150 scoped_refptr<base::debug::ConvertableToTraceFormat> | 150 scoped_refptr<base::debug::ConvertableToTraceFormat> |
151 AsTraceableRecordData() const; | 151 AsTraceableRecordData() const; |
152 | 152 |
153 friend class base::RefCountedThreadSafe<Picture>; | 153 friend class base::RefCountedThreadSafe<Picture>; |
154 friend class PixelRefIterator; | 154 friend class PixelRefIterator; |
155 DISALLOW_COPY_AND_ASSIGN(Picture); | 155 DISALLOW_COPY_AND_ASSIGN(Picture); |
156 }; | 156 }; |
157 | 157 |
158 } // namespace cc | 158 } // namespace cc |
159 | 159 |
160 #endif // CC_RESOURCES_PICTURE_H_ | 160 #endif // CC_RESOURCES_PICTURE_H_ |
OLD | NEW |