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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 static scoped_refptr<Picture> Create( | 56 static scoped_refptr<Picture> Create( |
57 const gfx::Rect& layer_rect, | 57 const gfx::Rect& layer_rect, |
58 ContentLayerClient* client, | 58 ContentLayerClient* client, |
59 const SkTileGridFactory::TileGridInfo& tile_grid_info, | 59 const SkTileGridFactory::TileGridInfo& tile_grid_info, |
60 bool gather_pixels_refs, | 60 bool gather_pixels_refs, |
61 RecordingMode recording_mode); | 61 RecordingMode recording_mode); |
62 static scoped_refptr<Picture> CreateFromValue(const base::Value* value); | 62 static scoped_refptr<Picture> CreateFromValue(const base::Value* value); |
63 static scoped_refptr<Picture> CreateFromSkpValue(const base::Value* value); | 63 static scoped_refptr<Picture> CreateFromSkpValue(const base::Value* value); |
64 | 64 |
65 gfx::Rect LayerRect() const { return layer_rect_; } | 65 gfx::Rect LayerRect() const { return layer_rect_; } |
66 gfx::Rect OpaqueRect() const { return opaque_rect_; } | |
67 | 66 |
68 // Has Record() been called yet? | 67 // Has Record() been called yet? |
69 bool HasRecording() const { return picture_.get() != NULL; } | 68 bool HasRecording() const { return picture_.get() != NULL; } |
70 | 69 |
71 bool IsSuitableForGpuRasterization() const; | 70 bool IsSuitableForGpuRasterization() const; |
72 int ApproximateOpCount() const; | 71 int ApproximateOpCount() const; |
73 | 72 |
74 bool HasText() const; | 73 bool HasText() const; |
75 | 74 |
76 // Apply this scale and raster the negated region into the canvas. | 75 // Apply this scale and raster the negated region into the canvas. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 void EmitTraceSnapshotAlias(Picture* original) const; | 127 void EmitTraceSnapshotAlias(Picture* original) const; |
129 | 128 |
130 bool WillPlayBackBitmaps() const { return picture_->willPlayBackBitmaps(); } | 129 bool WillPlayBackBitmaps() const { return picture_->willPlayBackBitmaps(); } |
131 | 130 |
132 private: | 131 private: |
133 explicit Picture(const gfx::Rect& layer_rect); | 132 explicit Picture(const gfx::Rect& layer_rect); |
134 // This constructor assumes SkPicture is already ref'd and transfers | 133 // This constructor assumes SkPicture is already ref'd and transfers |
135 // ownership to this picture. | 134 // ownership to this picture. |
136 Picture(const skia::RefPtr<SkPicture>&, | 135 Picture(const skia::RefPtr<SkPicture>&, |
137 const gfx::Rect& layer_rect, | 136 const gfx::Rect& layer_rect, |
138 const gfx::Rect& opaque_rect, | |
139 const PixelRefMap& pixel_refs); | 137 const PixelRefMap& pixel_refs); |
140 // This constructor will call AdoptRef on the SkPicture. | 138 // This constructor will call AdoptRef on the SkPicture. |
141 Picture(SkPicture*, | 139 Picture(SkPicture*, const gfx::Rect& layer_rect); |
142 const gfx::Rect& layer_rect, | |
143 const gfx::Rect& opaque_rect); | |
144 ~Picture(); | 140 ~Picture(); |
145 | 141 |
146 // Record a paint operation. To be able to safely use this SkPicture for | 142 // Record a paint operation. To be able to safely use this SkPicture for |
147 // playback on a different thread this can only be called once. | 143 // playback on a different thread this can only be called once. |
148 void Record(ContentLayerClient* client, | 144 void Record(ContentLayerClient* client, |
149 const SkTileGridFactory::TileGridInfo& tile_grid_info, | 145 const SkTileGridFactory::TileGridInfo& tile_grid_info, |
150 RecordingMode recording_mode); | 146 RecordingMode recording_mode); |
151 | 147 |
152 // Gather pixel refs from recording. | 148 // Gather pixel refs from recording. |
153 void GatherPixelRefs(const SkTileGridFactory::TileGridInfo& tile_grid_info); | 149 void GatherPixelRefs(const SkTileGridFactory::TileGridInfo& tile_grid_info); |
154 | 150 |
155 gfx::Rect layer_rect_; | 151 gfx::Rect layer_rect_; |
156 gfx::Rect opaque_rect_; | |
157 skia::RefPtr<SkPicture> picture_; | 152 skia::RefPtr<SkPicture> picture_; |
158 scoped_ptr<const EXPERIMENTAL::SkPlayback> playback_; | 153 scoped_ptr<const EXPERIMENTAL::SkPlayback> playback_; |
159 | 154 |
160 PixelRefMap pixel_refs_; | 155 PixelRefMap pixel_refs_; |
161 gfx::Point min_pixel_cell_; | 156 gfx::Point min_pixel_cell_; |
162 gfx::Point max_pixel_cell_; | 157 gfx::Point max_pixel_cell_; |
163 gfx::Size cell_size_; | 158 gfx::Size cell_size_; |
164 | 159 |
165 scoped_refptr<base::debug::ConvertableToTraceFormat> | 160 scoped_refptr<base::debug::ConvertableToTraceFormat> |
166 AsTraceableRasterData(float scale) const; | 161 AsTraceableRasterData(float scale) const; |
167 scoped_refptr<base::debug::ConvertableToTraceFormat> | 162 scoped_refptr<base::debug::ConvertableToTraceFormat> |
168 AsTraceableRecordData() const; | 163 AsTraceableRecordData() const; |
169 | 164 |
170 friend class base::RefCountedThreadSafe<Picture>; | 165 friend class base::RefCountedThreadSafe<Picture>; |
171 friend class PixelRefIterator; | 166 friend class PixelRefIterator; |
172 DISALLOW_COPY_AND_ASSIGN(Picture); | 167 DISALLOW_COPY_AND_ASSIGN(Picture); |
173 }; | 168 }; |
174 | 169 |
175 } // namespace cc | 170 } // namespace cc |
176 | 171 |
177 #endif // CC_RESOURCES_PICTURE_H_ | 172 #endif // CC_RESOURCES_PICTURE_H_ |
OLD | NEW |