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

Side by Side Diff: cc/picture_pile.cc

Issue 11293188: cc: Make Picture/PicturePile handle recording/raster (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix android_dbg Created 8 years, 1 month 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 | Annotate | Revision Log
« cc/picture.cc ('K') | « cc/picture_pile.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 "config.h" 5 #include "config.h"
6 6
7 #include <algorithm>
8
7 #include "cc/picture_pile.h" 9 #include "cc/picture_pile.h"
10 #include "third_party/skia/include/core/SkCanvas.h"
8 11
9 namespace cc { 12 namespace cc {
10 13
11 PicturePile::PicturePile() { 14 PicturePile::PicturePile() {
12 } 15 }
13 16
14 PicturePile::~PicturePile() { 17 PicturePile::~PicturePile() {
15 } 18 }
16 19
17 void PicturePile::invalidate(gfx::Rect rect) { 20 void PicturePile::Invalidate(gfx::Rect rect) {
18 // TODO(enne) 21 invalidation_.Union(rect);
19 } 22 }
20 23
21 void PicturePile::resize(gfx::Size size) { 24 class OutOfBoundsPredicate {
22 // TODO(enne) 25 public:
26 OutOfBoundsPredicate(gfx::Size size) : layer_rect_(gfx::Point(), size) { }
27 bool operator()(const scoped_refptr<Picture>& picture) {
28 return !picture->LayerRect().Intersects(layer_rect_);
29 }
30 gfx::Rect layer_rect_;
31 };
32
33 void PicturePile::Resize(gfx::Size size) {
34 if (size.width() > size_.width()) {
35 gfx::Rect invalid(
36 size_.width(),
37 0,
38 size.width() - size_.width(),
39 size.height());
40 Invalidate(invalid);
41 }
42 if (size.height() > size_.height()) {
43 gfx::Rect invalid(
44 0,
45 size_.height(),
46 size.width(),
47 size.height() - size_.height());
48 Invalidate(invalid);
49 }
50
51 // Remove pictures that aren't in bounds anymore.
52 if (size.width() < size_.width() || size.height() < size_.height()) {
53 OutOfBoundsPredicate oob(size);
54 pile_.erase(std::remove_if(pile_.begin(), pile_.end(), oob), pile_.end());
55 }
56
57 size_ = size;
23 } 58 }
24 59
25 void PicturePile::update(ContentLayerClient* painter) { 60 void PicturePile::Update(ContentLayerClient* painter, RenderingStats& stats) {
26 // TODO(enne) 61 // WebKit paints (i.e. recording) can cause invalidations, so record previous.
62 invalidation_.Swap(prev_invalidation_);
63 invalidation_.Clear();
64
65 // TODO(enne): Add things to the pile, consolidate if needed, etc...
66 if (pile_.size() == 0)
67 pile_.push_back(Picture::Create());
68 pile_[0]->Record(painter, gfx::Rect(gfx::Point(), size_), stats);
27 } 69 }
28 70
29 void PicturePile::pushPropertiesTo(PicturePile& other) { 71 void PicturePile::CopyAllButPile(PicturePile& from, PicturePile& to) {
30 other.size_ = size_; 72 to.size_ = from.size_;
73 to.invalidation_ = from.invalidation_;
74 to.prev_invalidation_ = from.prev_invalidation_;
75 }
76
77 void PicturePile::PushPropertiesTo(PicturePile& other) {
78 CopyAllButPile(*this, other);
79
31 other.pile_.resize(pile_.size()); 80 other.pile_.resize(pile_.size());
32 for (size_t i = 0; i < pile_.size(); ++i) 81 for (size_t i = 0; i < pile_.size(); ++i)
33 other.pile_[i] = pile_[i]; 82 other.pile_[i] = pile_[i];
34 } 83 }
35 84
85 scoped_ptr<PicturePile> PicturePile::CloneForDrawing() {
86 scoped_ptr<PicturePile> clone = make_scoped_ptr(new PicturePile);
87 CopyAllButPile(*this, *clone);
88
89 clone->pile_.resize(pile_.size());
90 for (size_t i = 0; i < pile_.size(); ++i)
91 clone->pile_[i] = pile_[i]->Clone();
92
93 return clone.Pass();
94 }
95
96 void PicturePile::Raster(SkCanvas* canvas, gfx::Rect rect) {
97 // TODO(enne): do this more efficiently, i.e. top down with Skia clips
98 canvas->save();
99 SkRect layer_skrect = SkRect::MakeXYWH(rect.x(), rect.y(),
100 rect.width(), rect.height());
101 canvas->clipRect(layer_skrect);
102 for (size_t i = 0; i < pile_.size(); ++i) {
103 if (!pile_[i]->LayerRect().Intersects(rect))
104 continue;
105 pile_[i]->Raster(canvas);
106 }
107 canvas->restore();
108 }
109
36 } // namespace cc 110 } // namespace cc
OLDNEW
« cc/picture.cc ('K') | « cc/picture_pile.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698