| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 const SkTileGridFactory::TileGridInfo& tile_grid_info, | 89 const SkTileGridFactory::TileGridInfo& tile_grid_info, |
| 90 bool gather_pixel_refs, | 90 bool gather_pixel_refs, |
| 91 bool can_use_lcd_text, |
| 91 int num_raster_threads, | 92 int num_raster_threads, |
| 92 RecordingMode recording_mode) { | 93 RecordingMode recording_mode) { |
| 93 scoped_refptr<Picture> picture = make_scoped_refptr(new Picture(layer_rect)); | 94 scoped_refptr<Picture> picture = make_scoped_refptr(new Picture(layer_rect)); |
| 94 | 95 |
| 95 picture->Record(client, tile_grid_info, recording_mode); | 96 picture->Record(client, tile_grid_info, can_use_lcd_text, recording_mode); |
| 96 if (gather_pixel_refs) | 97 if (gather_pixel_refs) |
| 97 picture->GatherPixelRefs(tile_grid_info); | 98 picture->GatherPixelRefs(tile_grid_info); |
| 98 picture->CloneForDrawing(num_raster_threads); | 99 picture->CloneForDrawing(num_raster_threads); |
| 99 | 100 |
| 100 return picture; | 101 return picture; |
| 101 } | 102 } |
| 102 | 103 |
| 103 Picture::Picture(const gfx::Rect& layer_rect) | 104 Picture::Picture(const gfx::Rect& layer_rect) |
| 104 : layer_rect_(layer_rect), | 105 : layer_rect_(layer_rect), |
| 105 cell_size_(layer_rect.size()) { | 106 cell_size_(layer_rect.size()) { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 clones_.push_back(clone); | 244 clones_.push_back(clone); |
| 244 | 245 |
| 245 clone->EmitTraceSnapshotAlias(this); | 246 clone->EmitTraceSnapshotAlias(this); |
| 246 clone->raster_thread_checker_.DetachFromThread(); | 247 clone->raster_thread_checker_.DetachFromThread(); |
| 247 } | 248 } |
| 248 } | 249 } |
| 249 } | 250 } |
| 250 | 251 |
| 251 void Picture::Record(ContentLayerClient* painter, | 252 void Picture::Record(ContentLayerClient* painter, |
| 252 const SkTileGridFactory::TileGridInfo& tile_grid_info, | 253 const SkTileGridFactory::TileGridInfo& tile_grid_info, |
| 254 bool can_use_lcd_text, |
| 253 RecordingMode recording_mode) { | 255 RecordingMode recording_mode) { |
| 254 TRACE_EVENT2("cc", | 256 TRACE_EVENT2("cc", |
| 255 "Picture::Record", | 257 "Picture::Record", |
| 256 "data", | 258 "data", |
| 257 AsTraceableRecordData(), | 259 AsTraceableRecordData(), |
| 258 "recording_mode", | 260 "recording_mode", |
| 259 recording_mode); | 261 recording_mode); |
| 260 | 262 |
| 261 DCHECK(!picture_); | 263 DCHECK(!picture_); |
| 262 DCHECK(!tile_grid_info.fTileInterval.isEmpty()); | 264 DCHECK(!tile_grid_info.fTileInterval.isEmpty()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 canvas->translate(SkFloatToScalar(-layer_rect_.x()), | 306 canvas->translate(SkFloatToScalar(-layer_rect_.x()), |
| 305 SkFloatToScalar(-layer_rect_.y())); | 307 SkFloatToScalar(-layer_rect_.y())); |
| 306 | 308 |
| 307 SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(), | 309 SkRect layer_skrect = SkRect::MakeXYWH(layer_rect_.x(), |
| 308 layer_rect_.y(), | 310 layer_rect_.y(), |
| 309 layer_rect_.width(), | 311 layer_rect_.width(), |
| 310 layer_rect_.height()); | 312 layer_rect_.height()); |
| 311 canvas->clipRect(layer_skrect); | 313 canvas->clipRect(layer_skrect); |
| 312 | 314 |
| 313 gfx::RectF opaque_layer_rect; | 315 gfx::RectF opaque_layer_rect; |
| 314 painter->PaintContents( | 316 painter->PaintContents(canvas.get(), |
| 315 canvas.get(), layer_rect_, &opaque_layer_rect, graphics_context_status); | 317 layer_rect_, |
| 318 can_use_lcd_text, |
| 319 &opaque_layer_rect, |
| 320 graphics_context_status); |
| 316 | 321 |
| 317 canvas->restore(); | 322 canvas->restore(); |
| 318 picture_ = skia::AdoptRef(recorder.endRecording()); | 323 picture_ = skia::AdoptRef(recorder.endRecording()); |
| 319 DCHECK(picture_); | 324 DCHECK(picture_); |
| 320 | 325 |
| 321 if (recording) { | 326 if (recording) { |
| 322 // SkRecording requires it's the only one holding onto canvas before we | 327 // SkRecording requires it's the only one holding onto canvas before we |
| 323 // may call releasePlayback(). (This helps enforce thread-safety.) | 328 // may call releasePlayback(). (This helps enforce thread-safety.) |
| 324 canvas.clear(); | 329 canvas.clear(); |
| 325 playback_.reset(recording->releasePlayback()); | 330 playback_.reset(recording->releasePlayback()); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 | 601 |
| 597 scoped_refptr<base::debug::ConvertableToTraceFormat> | 602 scoped_refptr<base::debug::ConvertableToTraceFormat> |
| 598 Picture::AsTraceableRecordData() const { | 603 Picture::AsTraceableRecordData() const { |
| 599 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); | 604 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); |
| 600 record_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); | 605 record_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); |
| 601 record_data->Set("layer_rect", MathUtil::AsValue(layer_rect_).release()); | 606 record_data->Set("layer_rect", MathUtil::AsValue(layer_rect_).release()); |
| 602 return TracedValue::FromValue(record_data.release()); | 607 return TracedValue::FromValue(record_data.release()); |
| 603 } | 608 } |
| 604 | 609 |
| 605 } // namespace cc | 610 } // namespace cc |
| OLD | NEW |