Depend on stored sync session GUID for Android.
[chromium-blink-merge.git] / cc / picture_pile_impl.cc
blob216643bf84b84b4745d56a2d750351b56ed60e59
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
3 // found in the LICENSE file.
5 #include "base/debug/trace_event.h"
6 #include "cc/picture_pile_impl.h"
7 #include "cc/rendering_stats.h"
8 #include "third_party/skia/include/core/SkCanvas.h"
9 #include "third_party/skia/include/core/SkSize.h"
11 namespace cc {
13 scoped_refptr<PicturePileImpl> PicturePileImpl::Create() {
14 return make_scoped_refptr(new PicturePileImpl());
17 PicturePileImpl::PicturePileImpl() {
20 PicturePileImpl::~PicturePileImpl() {
23 scoped_refptr<PicturePileImpl> PicturePileImpl::CloneForDrawing() const {
24 TRACE_EVENT0("cc", "PicturePileImpl::CloneForDrawing");
25 scoped_refptr<PicturePileImpl> clone = Create();
26 for (PicturePile::Pile::const_iterator i = pile_.begin();
27 i != pile_.end(); ++i)
28 clone->pile_.push_back((*i)->Clone());
30 return clone;
33 void PicturePileImpl::Raster(SkCanvas* canvas, gfx::Rect rect,
34 RenderingStats* stats) {
35 base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now();
37 // TODO(enne): do this more efficiently, i.e. top down with Skia clips
38 canvas->save();
39 canvas->translate(-rect.x(), -rect.y());
40 SkRect layer_skrect = SkRect::MakeXYWH(rect.x(), rect.y(),
41 rect.width(), rect.height());
42 canvas->clipRect(layer_skrect);
43 for (PicturePile::Pile::const_iterator i = pile_.begin();
44 i != pile_.end(); ++i) {
45 if (!(*i)->LayerRect().Intersects(rect))
46 continue;
47 (*i)->Raster(canvas);
49 SkISize deviceSize = canvas->getDeviceSize();
50 stats->totalPixelsRasterized += deviceSize.width() * deviceSize.height();
52 canvas->restore();
54 stats->totalRasterizeTimeInSeconds += (base::TimeTicks::Now() -
55 rasterizeBeginTime).InSecondsF();
58 } // namespace cc