Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: cc/picture_pile_impl.cc

Issue 11299324: Make PicturePile pile. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix signed/unsigned mismatch warning Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/picture_pile_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "cc/rendering_stats.h"
8 #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" 9 #include "third_party/skia/include/core/SkSize.h"
10 10
11 namespace cc { 11 namespace cc {
12 12
13 scoped_refptr<PicturePileImpl> PicturePileImpl::Create() { 13 scoped_refptr<PicturePileImpl> PicturePileImpl::Create() {
14 return make_scoped_refptr(new PicturePileImpl()); 14 return make_scoped_refptr(new PicturePileImpl());
15 } 15 }
16 16
17 PicturePileImpl::PicturePileImpl() { 17 PicturePileImpl::PicturePileImpl() {
18 } 18 }
19 19
20 PicturePileImpl::~PicturePileImpl() { 20 PicturePileImpl::~PicturePileImpl() {
21 } 21 }
22 22
23 scoped_refptr<PicturePileImpl> PicturePileImpl::CloneForDrawing() const { 23 scoped_refptr<PicturePileImpl> PicturePileImpl::CloneForDrawing() const {
24 TRACE_EVENT0("cc", "PicturePileImpl::CloneForDrawing"); 24 TRACE_EVENT0("cc", "PicturePileImpl::CloneForDrawing");
25 scoped_refptr<PicturePileImpl> clone = Create(); 25 scoped_refptr<PicturePileImpl> clone = Create();
26 clone->pile_.resize(pile_.size()); 26 for (PicturePile::Pile::const_iterator i = pile_.begin();
27 for (size_t i = 0; i < pile_.size(); ++i) 27 i != pile_.end(); ++i)
28 clone->pile_[i] = pile_[i]->Clone(); 28 clone->pile_.push_back((*i)->Clone());
29 29
30 return clone; 30 return clone;
31 } 31 }
32 32
33 void PicturePileImpl::Raster(SkCanvas* canvas, gfx::Rect rect, 33 void PicturePileImpl::Raster(SkCanvas* canvas, gfx::Rect rect,
34 RenderingStats* stats) { 34 RenderingStats* stats) {
35 base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now(); 35 base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now();
36 36
37 // 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
38 canvas->save(); 38 canvas->save();
39 canvas->translate(-rect.x(), -rect.y()); 39 canvas->translate(-rect.x(), -rect.y());
40 SkRect layer_skrect = SkRect::MakeXYWH(rect.x(), rect.y(), 40 SkRect layer_skrect = SkRect::MakeXYWH(rect.x(), rect.y(),
41 rect.width(), rect.height()); 41 rect.width(), rect.height());
42 canvas->clipRect(layer_skrect); 42 canvas->clipRect(layer_skrect);
43 for (size_t i = 0; i < pile_.size(); ++i) { 43 for (PicturePile::Pile::const_iterator i = pile_.begin();
44 if (!pile_[i]->LayerRect().Intersects(rect)) 44 i != pile_.end(); ++i) {
45 if (!(*i)->LayerRect().Intersects(rect))
45 continue; 46 continue;
46 pile_[i]->Raster(canvas); 47 (*i)->Raster(canvas);
47 48
48 SkISize deviceSize = canvas->getDeviceSize(); 49 SkISize deviceSize = canvas->getDeviceSize();
49 stats->totalPixelsRasterized += deviceSize.width() * deviceSize.height(); 50 stats->totalPixelsRasterized += deviceSize.width() * deviceSize.height();
50 } 51 }
51 canvas->restore(); 52 canvas->restore();
52 53
53 stats->totalRasterizeTimeInSeconds += (base::TimeTicks::Now() - 54 stats->totalRasterizeTimeInSeconds += (base::TimeTicks::Now() -
54 rasterizeBeginTime).InSecondsF(); 55 rasterizeBeginTime).InSecondsF();
55 } 56 }
56 57
57 } // namespace cc 58 } // namespace cc
OLDNEW
« no previous file with comments | « cc/picture_pile_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698