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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 canvas->save(); | 333 canvas->save(); |
334 | 334 |
335 for (Region::Iterator it(negated_content_region); it.has_rect(); it.next()) | 335 for (Region::Iterator it(negated_content_region); it.has_rect(); it.next()) |
336 canvas->clipRect(gfx::RectToSkRect(it.rect()), SkRegion::kDifference_Op); | 336 canvas->clipRect(gfx::RectToSkRect(it.rect()), SkRegion::kDifference_Op); |
337 | 337 |
338 canvas->scale(contents_scale, contents_scale); | 338 canvas->scale(contents_scale, contents_scale); |
339 canvas->translate(layer_rect_.x(), layer_rect_.y()); | 339 canvas->translate(layer_rect_.x(), layer_rect_.y()); |
340 if (callback) { | 340 if (callback) { |
341 // If we have a callback, we need to call |draw()|, |drawPicture()| doesn't | 341 // If we have a callback, we need to call |draw()|, |drawPicture()| doesn't |
342 // take a callback. This is used by |AnalysisCanvas| to early out. | 342 // take a callback. This is used by |AnalysisCanvas| to early out. |
343 picture_->draw(canvas, callback); | 343 picture_->playback(canvas, callback); |
344 } else { | 344 } else { |
345 // Prefer to call |drawPicture()| on the canvas since it could place the | 345 // Prefer to call |drawPicture()| on the canvas since it could place the |
346 // entire picture on the canvas instead of parsing the skia operations. | 346 // entire picture on the canvas instead of parsing the skia operations. |
347 canvas->drawPicture(picture_.get()); | 347 canvas->drawPicture(picture_.get()); |
348 } | 348 } |
349 SkIRect bounds; | 349 SkIRect bounds; |
350 canvas->getClipDeviceBounds(&bounds); | 350 canvas->getClipDeviceBounds(&bounds); |
351 canvas->restore(); | 351 canvas->restore(); |
352 TRACE_EVENT_END1( | 352 TRACE_EVENT_END1( |
353 "cc", "Picture::Raster", | 353 "cc", "Picture::Raster", |
354 "num_pixels_rasterized", bounds.width() * bounds.height()); | 354 "num_pixels_rasterized", bounds.width() * bounds.height()); |
355 return bounds.width() * bounds.height(); | 355 return bounds.width() * bounds.height(); |
356 } | 356 } |
357 | 357 |
358 void Picture::Replay(SkCanvas* canvas) { | 358 void Picture::Replay(SkCanvas* canvas) { |
359 TRACE_EVENT_BEGIN0("cc", "Picture::Replay"); | 359 TRACE_EVENT_BEGIN0("cc", "Picture::Replay"); |
360 DCHECK(picture_); | 360 DCHECK(picture_); |
361 picture_->draw(canvas); | 361 picture_->playback(canvas); |
362 SkIRect bounds; | 362 SkIRect bounds; |
363 canvas->getClipDeviceBounds(&bounds); | 363 canvas->getClipDeviceBounds(&bounds); |
364 TRACE_EVENT_END1("cc", "Picture::Replay", | 364 TRACE_EVENT_END1("cc", "Picture::Replay", |
365 "num_pixels_replayed", bounds.width() * bounds.height()); | 365 "num_pixels_replayed", bounds.width() * bounds.height()); |
366 } | 366 } |
367 | 367 |
368 scoped_ptr<base::Value> Picture::AsValue() const { | 368 scoped_ptr<base::Value> Picture::AsValue() const { |
369 SkDynamicMemoryWStream stream; | 369 SkDynamicMemoryWStream stream; |
370 picture_->serialize(&stream, &EncodeBitmap); | 370 picture_->serialize(&stream, &EncodeBitmap); |
371 | 371 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 scoped_refptr<base::debug::TracedValue> record_data = | 515 scoped_refptr<base::debug::TracedValue> record_data = |
516 new base::debug::TracedValue(); | 516 new base::debug::TracedValue(); |
517 TracedValue::SetIDRef(this, record_data.get(), "picture_id"); | 517 TracedValue::SetIDRef(this, record_data.get(), "picture_id"); |
518 record_data->BeginArray("layer_rect"); | 518 record_data->BeginArray("layer_rect"); |
519 MathUtil::AddToTracedValue(layer_rect_, record_data.get()); | 519 MathUtil::AddToTracedValue(layer_rect_, record_data.get()); |
520 record_data->EndArray(); | 520 record_data->EndArray(); |
521 return record_data; | 521 return record_data; |
522 } | 522 } |
523 | 523 |
524 } // namespace cc | 524 } // namespace cc |
OLD | NEW |