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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 | 343 |
344 canvas->save(); | 344 canvas->save(); |
345 | 345 |
346 for (Region::Iterator it(negated_content_region); it.has_rect(); it.next()) | 346 for (Region::Iterator it(negated_content_region); it.has_rect(); it.next()) |
347 canvas->clipRect(gfx::RectToSkRect(it.rect()), SkRegion::kDifference_Op); | 347 canvas->clipRect(gfx::RectToSkRect(it.rect()), SkRegion::kDifference_Op); |
348 | 348 |
349 canvas->scale(contents_scale, contents_scale); | 349 canvas->scale(contents_scale, contents_scale); |
350 canvas->translate(layer_rect_.x(), layer_rect_.y()); | 350 canvas->translate(layer_rect_.x(), layer_rect_.y()); |
351 if (playback_) { | 351 if (playback_) { |
352 playback_->draw(canvas); | 352 playback_->draw(canvas); |
| 353 } else if (callback) { |
| 354 // If we have a callback, we need to call |draw()|, |drawPicture()| doesn't |
| 355 // take a callback. This is used by |AnalysisCanvas| to early out. |
| 356 picture_->draw(canvas, callback); |
353 } else { | 357 } else { |
354 picture_->draw(canvas, callback); | 358 // Prefer to call |drawPicture()| on the canvas since it could place the |
| 359 // entire picture on the canvas instead of parsing the skia operations. |
| 360 canvas->drawPicture(picture_.get()); |
355 } | 361 } |
356 SkIRect bounds; | 362 SkIRect bounds; |
357 canvas->getClipDeviceBounds(&bounds); | 363 canvas->getClipDeviceBounds(&bounds); |
358 canvas->restore(); | 364 canvas->restore(); |
359 TRACE_EVENT_END1( | 365 TRACE_EVENT_END1( |
360 "cc", "Picture::Raster", | 366 "cc", "Picture::Raster", |
361 "num_pixels_rasterized", bounds.width() * bounds.height()); | 367 "num_pixels_rasterized", bounds.width() * bounds.height()); |
362 return bounds.width() * bounds.height(); | 368 return bounds.width() * bounds.height(); |
363 } | 369 } |
364 | 370 |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 scoped_refptr<base::debug::TracedValue> record_data = | 547 scoped_refptr<base::debug::TracedValue> record_data = |
542 new base::debug::TracedValue(); | 548 new base::debug::TracedValue(); |
543 TracedValue::SetIDRef(this, record_data.get(), "picture_id"); | 549 TracedValue::SetIDRef(this, record_data.get(), "picture_id"); |
544 record_data->BeginArray("layer_rect"); | 550 record_data->BeginArray("layer_rect"); |
545 MathUtil::AddToTracedValue(layer_rect_, record_data.get()); | 551 MathUtil::AddToTracedValue(layer_rect_, record_data.get()); |
546 record_data->EndArray(); | 552 record_data->EndArray(); |
547 return record_data; | 553 return record_data; |
548 } | 554 } |
549 | 555 |
550 } // namespace cc | 556 } // namespace cc |
OLD | NEW |