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 #include "cc/resources/picture.h" | 5 #include "cc/resources/picture.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 return true; | 79 return true; |
80 } | 80 } |
81 return false; | 81 return false; |
82 } | 82 } |
83 | 83 |
84 } // namespace | 84 } // namespace |
85 | 85 |
86 scoped_refptr<Picture> Picture::Create( | 86 scoped_refptr<Picture> Picture::Create( |
87 const gfx::Rect& layer_rect, | 87 const gfx::Rect& layer_rect, |
88 ContentLayerClient* client, | 88 ContentLayerClient* client, |
| 89 bool can_use_lcd_text, |
| 90 bool contents_opaque, |
89 const SkTileGridFactory::TileGridInfo& tile_grid_info, | 91 const SkTileGridFactory::TileGridInfo& tile_grid_info, |
90 bool gather_pixel_refs, | 92 bool gather_pixel_refs, |
91 RecordingMode recording_mode) { | 93 RecordingMode recording_mode) { |
92 scoped_refptr<Picture> picture = make_scoped_refptr(new Picture(layer_rect)); | 94 scoped_refptr<Picture> picture = make_scoped_refptr(new Picture(layer_rect)); |
93 | 95 |
94 picture->Record(client, tile_grid_info, recording_mode); | 96 picture->Record(client, |
| 97 can_use_lcd_text, |
| 98 contents_opaque, |
| 99 tile_grid_info, |
| 100 recording_mode); |
95 if (gather_pixel_refs) | 101 if (gather_pixel_refs) |
96 picture->GatherPixelRefs(tile_grid_info); | 102 picture->GatherPixelRefs(tile_grid_info); |
97 | 103 |
98 return picture; | 104 return picture; |
99 } | 105 } |
100 | 106 |
101 Picture::Picture(const gfx::Rect& layer_rect) | 107 Picture::Picture(const gfx::Rect& layer_rect) |
102 : layer_rect_(layer_rect), | 108 : layer_rect_(layer_rect), |
103 cell_size_(layer_rect.size()) { | 109 cell_size_(layer_rect.size()) { |
104 // Instead of recording a trace event for object creation here, we wait for | 110 // Instead of recording a trace event for object creation here, we wait for |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 DCHECK(picture_); | 197 DCHECK(picture_); |
192 return picture_->approximateOpCount(); | 198 return picture_->approximateOpCount(); |
193 } | 199 } |
194 | 200 |
195 bool Picture::HasText() const { | 201 bool Picture::HasText() const { |
196 DCHECK(picture_); | 202 DCHECK(picture_); |
197 return picture_->hasText(); | 203 return picture_->hasText(); |
198 } | 204 } |
199 | 205 |
200 void Picture::Record(ContentLayerClient* painter, | 206 void Picture::Record(ContentLayerClient* painter, |
| 207 bool can_use_lcd_text, |
| 208 bool contents_opaque, |
201 const SkTileGridFactory::TileGridInfo& tile_grid_info, | 209 const SkTileGridFactory::TileGridInfo& tile_grid_info, |
202 RecordingMode recording_mode) { | 210 RecordingMode recording_mode) { |
203 TRACE_EVENT2("cc", | 211 TRACE_EVENT2("cc", |
204 "Picture::Record", | 212 "Picture::Record", |
205 "data", | 213 "data", |
206 AsTraceableRecordData(), | 214 AsTraceableRecordData(), |
207 "recording_mode", | 215 "recording_mode", |
208 recording_mode); | 216 recording_mode); |
209 | 217 |
210 DCHECK(!picture_); | 218 DCHECK(!picture_); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 canvas->save(); | 250 canvas->save(); |
243 canvas->translate(SkFloatToScalar(-layer_rect_.x()), | 251 canvas->translate(SkFloatToScalar(-layer_rect_.x()), |
244 SkFloatToScalar(-layer_rect_.y())); | 252 SkFloatToScalar(-layer_rect_.y())); |
245 | 253 |
246 SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(), | 254 SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(), |
247 layer_rect_.y(), | 255 layer_rect_.y(), |
248 layer_rect_.width(), | 256 layer_rect_.width(), |
249 layer_rect_.height()); | 257 layer_rect_.height()); |
250 canvas->clipRect(layer_skrect); | 258 canvas->clipRect(layer_skrect); |
251 | 259 |
252 painter->PaintContents(canvas.get(), layer_rect_, graphics_context_status); | 260 painter->PaintContents(canvas.get(), |
| 261 layer_rect_, |
| 262 can_use_lcd_text, |
| 263 contents_opaque, |
| 264 graphics_context_status); |
253 | 265 |
254 canvas->restore(); | 266 canvas->restore(); |
255 picture_ = skia::AdoptRef(recorder.endRecording()); | 267 picture_ = skia::AdoptRef(recorder.endRecording()); |
256 DCHECK(picture_); | 268 DCHECK(picture_); |
257 | 269 |
258 EmitTraceSnapshot(); | 270 EmitTraceSnapshot(); |
259 } | 271 } |
260 | 272 |
261 void Picture::GatherPixelRefs( | 273 void Picture::GatherPixelRefs( |
262 const SkTileGridFactory::TileGridInfo& tile_grid_info) { | 274 const SkTileGridFactory::TileGridInfo& tile_grid_info) { |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 scoped_refptr<base::debug::TracedValue> record_data = | 523 scoped_refptr<base::debug::TracedValue> record_data = |
512 new base::debug::TracedValue(); | 524 new base::debug::TracedValue(); |
513 TracedValue::SetIDRef(this, record_data.get(), "picture_id"); | 525 TracedValue::SetIDRef(this, record_data.get(), "picture_id"); |
514 record_data->BeginArray("layer_rect"); | 526 record_data->BeginArray("layer_rect"); |
515 MathUtil::AddToTracedValue(layer_rect_, record_data.get()); | 527 MathUtil::AddToTracedValue(layer_rect_, record_data.get()); |
516 record_data->EndArray(); | 528 record_data->EndArray(); |
517 return record_data; | 529 return record_data; |
518 } | 530 } |
519 | 531 |
520 } // namespace cc | 532 } // namespace cc |
OLD | NEW |