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::approximateOpCount() 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 int Picture::AnalysisRaster(SkCanvas* canvas, SkDrawPictureCallback* callback) { | |
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, callback); | |
436 } | |
437 SkIRect bounds; | |
438 canvas->getClipDeviceBounds(&bounds); | |
439 canvas->restore(); | |
440 return bounds.width() * bounds.height(); | |
vmpstr
2014/08/19 23:55:37
If you're not using this, then let's just make thi
hendrikw
2014/08/20 00:34:05
ok, I also removed the callback, also not using th
| |
441 } | |
442 | |
420 void Picture::Replay(SkCanvas* canvas) { | 443 void Picture::Replay(SkCanvas* canvas) { |
421 if (!playback_) | 444 if (!playback_) |
422 DCHECK(raster_thread_checker_.CalledOnValidThread()); | 445 DCHECK(raster_thread_checker_.CalledOnValidThread()); |
423 TRACE_EVENT_BEGIN0("cc", "Picture::Replay"); | 446 TRACE_EVENT_BEGIN0("cc", "Picture::Replay"); |
424 DCHECK(picture_); | 447 DCHECK(picture_); |
425 | 448 |
426 if (playback_) { | 449 if (playback_) { |
427 playback_->draw(canvas); | 450 playback_->draw(canvas); |
428 } else { | 451 } else { |
429 picture_->draw(canvas); | 452 picture_->draw(canvas); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 scoped_refptr<base::debug::TracedValue> record_data = | 622 scoped_refptr<base::debug::TracedValue> record_data = |
600 new base::debug::TracedValue(); | 623 new base::debug::TracedValue(); |
601 TracedValue::SetIDRef(this, record_data.get(), "picture_id"); | 624 TracedValue::SetIDRef(this, record_data.get(), "picture_id"); |
602 record_data->BeginArray("layer_rect"); | 625 record_data->BeginArray("layer_rect"); |
603 MathUtil::AddToTracedValue(layer_rect_, record_data.get()); | 626 MathUtil::AddToTracedValue(layer_rect_, record_data.get()); |
604 record_data->EndArray(); | 627 record_data->EndArray(); |
605 return record_data; | 628 return record_data; |
606 } | 629 } |
607 | 630 |
608 } // namespace cc | 631 } // namespace cc |
OLD | NEW |