| 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 "base/debug/trace_event.h" | 5 #include "base/debug/trace_event.h" |
| 6 #include "cc/picture_pile_impl.h" | 6 #include "cc/picture_pile_impl.h" |
| 7 #include "cc/rendering_stats.h" |
| 7 #include "third_party/skia/include/core/SkCanvas.h" | 8 #include "third_party/skia/include/core/SkCanvas.h" |
| 9 #include "third_party/skia/include/core/SkSize.h" |
| 8 | 10 |
| 9 namespace cc { | 11 namespace cc { |
| 10 | 12 |
| 11 scoped_refptr<PicturePileImpl> PicturePileImpl::Create() { | 13 scoped_refptr<PicturePileImpl> PicturePileImpl::Create() { |
| 12 return make_scoped_refptr(new PicturePileImpl()); | 14 return make_scoped_refptr(new PicturePileImpl()); |
| 13 } | 15 } |
| 14 | 16 |
| 15 PicturePileImpl::PicturePileImpl() { | 17 PicturePileImpl::PicturePileImpl() { |
| 16 } | 18 } |
| 17 | 19 |
| 18 PicturePileImpl::~PicturePileImpl() { | 20 PicturePileImpl::~PicturePileImpl() { |
| 19 } | 21 } |
| 20 | 22 |
| 21 scoped_refptr<PicturePileImpl> PicturePileImpl::CloneForDrawing() const { | 23 scoped_refptr<PicturePileImpl> PicturePileImpl::CloneForDrawing() const { |
| 22 TRACE_EVENT0("cc", "PicturePileImpl::CloneForDrawing"); | 24 TRACE_EVENT0("cc", "PicturePileImpl::CloneForDrawing"); |
| 23 scoped_refptr<PicturePileImpl> clone = Create(); | 25 scoped_refptr<PicturePileImpl> clone = Create(); |
| 24 clone->pile_.resize(pile_.size()); | 26 clone->pile_.resize(pile_.size()); |
| 25 for (size_t i = 0; i < pile_.size(); ++i) | 27 for (size_t i = 0; i < pile_.size(); ++i) |
| 26 clone->pile_[i] = pile_[i]->Clone(); | 28 clone->pile_[i] = pile_[i]->Clone(); |
| 27 | 29 |
| 28 return clone; | 30 return clone; |
| 29 } | 31 } |
| 30 | 32 |
| 31 void PicturePileImpl::Raster(SkCanvas* canvas, gfx::Rect rect) { | 33 void PicturePileImpl::Raster(SkCanvas* canvas, gfx::Rect rect, |
| 34 RenderingStats* stats) { |
| 35 base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now(); |
| 36 |
| 32 // TODO(enne): do this more efficiently, i.e. top down with Skia clips | 37 // TODO(enne): do this more efficiently, i.e. top down with Skia clips |
| 33 canvas->save(); | 38 canvas->save(); |
| 34 canvas->translate(-rect.x(), -rect.y()); | 39 canvas->translate(-rect.x(), -rect.y()); |
| 35 SkRect layer_skrect = SkRect::MakeXYWH(rect.x(), rect.y(), | 40 SkRect layer_skrect = SkRect::MakeXYWH(rect.x(), rect.y(), |
| 36 rect.width(), rect.height()); | 41 rect.width(), rect.height()); |
| 37 canvas->clipRect(layer_skrect); | 42 canvas->clipRect(layer_skrect); |
| 38 for (size_t i = 0; i < pile_.size(); ++i) { | 43 for (size_t i = 0; i < pile_.size(); ++i) { |
| 39 if (!pile_[i]->LayerRect().Intersects(rect)) | 44 if (!pile_[i]->LayerRect().Intersects(rect)) |
| 40 continue; | 45 continue; |
| 41 pile_[i]->Raster(canvas); | 46 pile_[i]->Raster(canvas); |
| 47 |
| 48 SkISize deviceSize = canvas->getDeviceSize(); |
| 49 stats->totalPixelsRasterized += deviceSize.width() * deviceSize.height(); |
| 42 } | 50 } |
| 43 canvas->restore(); | 51 canvas->restore(); |
| 52 |
| 53 stats->totalRasterizeTimeInSeconds += (base::TimeTicks::Now() - |
| 54 rasterizeBeginTime).InSecondsF(); |
| 44 } | 55 } |
| 45 | 56 |
| 46 } // namespace cc | 57 } // namespace cc |
| OLD | NEW |