Chromium Code Reviews| 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 "third_party/skia/include/core/SkCanvas.h" | 7 #include "third_party/skia/include/core/SkCanvas.h" |
| 8 | 8 |
| 9 namespace cc { | 9 namespace cc { |
| 10 | 10 |
| 11 scoped_refptr<PicturePileImpl> PicturePileImpl::Create() { | 11 scoped_refptr<PicturePileImpl> PicturePileImpl::Create() { |
| 12 return make_scoped_refptr(new PicturePileImpl()); | 12 return make_scoped_refptr(new PicturePileImpl()); |
| 13 } | 13 } |
| 14 | 14 |
| 15 PicturePileImpl::PicturePileImpl() { | 15 PicturePileImpl::PicturePileImpl() : |
| 16 rasterize_time_in_seconds_(0) { | |
| 16 } | 17 } |
| 17 | 18 |
| 18 PicturePileImpl::~PicturePileImpl() { | 19 PicturePileImpl::~PicturePileImpl() { |
| 19 } | 20 } |
| 20 | 21 |
| 21 scoped_refptr<PicturePileImpl> PicturePileImpl::CloneForDrawing() const { | 22 scoped_refptr<PicturePileImpl> PicturePileImpl::CloneForDrawing() const { |
| 22 TRACE_EVENT0("cc", "PicturePileImpl::CloneForDrawing"); | 23 TRACE_EVENT0("cc", "PicturePileImpl::CloneForDrawing"); |
| 23 scoped_refptr<PicturePileImpl> clone = Create(); | 24 scoped_refptr<PicturePileImpl> clone = Create(); |
| 24 clone->pile_.resize(pile_.size()); | 25 clone->pile_.resize(pile_.size()); |
| 25 for (size_t i = 0; i < pile_.size(); ++i) | 26 for (size_t i = 0; i < pile_.size(); ++i) |
| 26 clone->pile_[i] = pile_[i]->Clone(); | 27 clone->pile_[i] = pile_[i]->Clone(); |
| 27 | 28 |
| 28 return clone; | 29 return clone; |
| 29 } | 30 } |
| 30 | 31 |
| 31 void PicturePileImpl::Raster(SkCanvas* canvas, gfx::Rect rect) { | 32 void PicturePileImpl::Raster(SkCanvas* canvas, gfx::Rect rect) { |
|
nduca
2012/11/29 18:16:30
Lets pass in a ref to Stats object and accumulate
Tom Hudson
2012/11/29 19:16:11
I hit "Done" when I was working in PicturePileImpl
reveman
2012/11/29 19:27:03
you can allocate storage for the stat in TileManag
| |
| 33 base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now(); | |
| 34 | |
| 32 // TODO(enne): do this more efficiently, i.e. top down with Skia clips | 35 // TODO(enne): do this more efficiently, i.e. top down with Skia clips |
| 33 canvas->save(); | 36 canvas->save(); |
| 34 canvas->translate(-rect.x(), -rect.y()); | 37 canvas->translate(-rect.x(), -rect.y()); |
| 35 SkRect layer_skrect = SkRect::MakeXYWH(rect.x(), rect.y(), | 38 SkRect layer_skrect = SkRect::MakeXYWH(rect.x(), rect.y(), |
| 36 rect.width(), rect.height()); | 39 rect.width(), rect.height()); |
| 37 canvas->clipRect(layer_skrect); | 40 canvas->clipRect(layer_skrect); |
| 38 for (size_t i = 0; i < pile_.size(); ++i) { | 41 for (size_t i = 0; i < pile_.size(); ++i) { |
| 39 if (!pile_[i]->LayerRect().Intersects(rect)) | 42 if (!pile_[i]->LayerRect().Intersects(rect)) |
| 40 continue; | 43 continue; |
| 41 pile_[i]->Raster(canvas); | 44 pile_[i]->Raster(canvas); |
| 42 } | 45 } |
| 43 canvas->restore(); | 46 canvas->restore(); |
| 47 | |
| 48 rasterize_time_in_seconds_ += (base::TimeTicks::Now() - rasterizeBeginTime).In SecondsF(); | |
| 49 } | |
| 50 | |
| 51 double PicturePileImpl::rasterizeTime() { | |
| 52 return rasterize_time_in_seconds_; | |
| 44 } | 53 } |
| 45 | 54 |
| 46 } // namespace cc | 55 } // namespace cc |
| OLD | NEW |