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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 // TODO(alokp): SkPicture::suitableForGpuRasterization needs a GrContext. | 210 // TODO(alokp): SkPicture::suitableForGpuRasterization needs a GrContext. |
211 // Ideally this GrContext should be the same as that for rasterizing this | 211 // Ideally this GrContext should be the same as that for rasterizing this |
212 // picture. But we are on the main thread while the rasterization context | 212 // picture. But we are on the main thread while the rasterization context |
213 // may be on the compositor or raster thread. | 213 // may be on the compositor or raster thread. |
214 // SkPicture::suitableForGpuRasterization is not implemented yet. | 214 // SkPicture::suitableForGpuRasterization is not implemented yet. |
215 // Pass a NULL context for now and discuss with skia folks if the context | 215 // Pass a NULL context for now and discuss with skia folks if the context |
216 // is really needed. | 216 // is really needed. |
217 return picture_->suitableForGpuRasterization(NULL); | 217 return picture_->suitableForGpuRasterization(NULL); |
218 } | 218 } |
219 | 219 |
220 int Picture::GetApproximateOpCount() const { | |
221 DCHECK(picture_); | |
222 return picture_->approximateOpCount(); | |
223 } | |
224 | |
220 void Picture::CloneForDrawing(int num_threads) { | 225 void Picture::CloneForDrawing(int num_threads) { |
221 TRACE_EVENT1("cc", "Picture::CloneForDrawing", "num_threads", num_threads); | 226 TRACE_EVENT1("cc", "Picture::CloneForDrawing", "num_threads", num_threads); |
222 | 227 |
223 // We don't need clones to draw from multiple threads with SkRecord. | 228 // We don't need clones to draw from multiple threads with SkRecord. |
224 if (playback_) { | 229 if (playback_) { |
225 return; | 230 return; |
226 } | 231 } |
227 | 232 |
228 DCHECK(picture_); | 233 DCHECK(picture_); |
229 DCHECK(clones_.empty()); | 234 DCHECK(clones_.empty()); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
410 } | 415 } |
411 SkIRect bounds; | 416 SkIRect bounds; |
412 canvas->getClipDeviceBounds(&bounds); | 417 canvas->getClipDeviceBounds(&bounds); |
413 canvas->restore(); | 418 canvas->restore(); |
414 TRACE_EVENT_END1( | 419 TRACE_EVENT_END1( |
415 "cc", "Picture::Raster", | 420 "cc", "Picture::Raster", |
416 "num_pixels_rasterized", bounds.width() * bounds.height()); | 421 "num_pixels_rasterized", bounds.width() * bounds.height()); |
417 return bounds.width() * bounds.height(); | 422 return bounds.width() * bounds.height(); |
418 } | 423 } |
419 | 424 |
425 void Picture::RasterForAnalysis(SkCanvas* canvas) { | |
426 TRACE_EVENT0("cc", "Picture::AnalysisRaster"); | |
427 DCHECK(picture_); | |
428 | |
429 canvas->save(); | |
430 | |
431 canvas->translate(layer_rect_.x(), layer_rect_.y()); | |
432 if (playback_) { | |
433 playback_->draw(canvas); | |
434 } else { | |
435 picture_->draw(canvas, NULL); | |
vmpstr
2014/08/20 16:12:00
Make a comment here please explaining why we don't
hendrikw
2014/08/20 20:46:55
Acknowledged.
| |
436 } | |
437 canvas->restore(); | |
438 } | |
439 | |
420 void Picture::Replay(SkCanvas* canvas) { | 440 void Picture::Replay(SkCanvas* canvas) { |
421 if (!playback_) | 441 if (!playback_) |
422 DCHECK(raster_thread_checker_.CalledOnValidThread()); | 442 DCHECK(raster_thread_checker_.CalledOnValidThread()); |
423 TRACE_EVENT_BEGIN0("cc", "Picture::Replay"); | 443 TRACE_EVENT_BEGIN0("cc", "Picture::Replay"); |
424 DCHECK(picture_); | 444 DCHECK(picture_); |
425 | 445 |
426 if (playback_) { | 446 if (playback_) { |
427 playback_->draw(canvas); | 447 playback_->draw(canvas); |
428 } else { | 448 } else { |
429 picture_->draw(canvas); | 449 picture_->draw(canvas); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 scoped_refptr<base::debug::TracedValue> record_data = | 619 scoped_refptr<base::debug::TracedValue> record_data = |
600 new base::debug::TracedValue(); | 620 new base::debug::TracedValue(); |
601 TracedValue::SetIDRef(this, record_data.get(), "picture_id"); | 621 TracedValue::SetIDRef(this, record_data.get(), "picture_id"); |
602 record_data->BeginArray("layer_rect"); | 622 record_data->BeginArray("layer_rect"); |
603 MathUtil::AddToTracedValue(layer_rect_, record_data.get()); | 623 MathUtil::AddToTracedValue(layer_rect_, record_data.get()); |
604 record_data->EndArray(); | 624 record_data->EndArray(); |
605 return record_data; | 625 return record_data; |
606 } | 626 } |
607 | 627 |
608 } // namespace cc | 628 } // namespace cc |
OLD | NEW |