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

Side by Side Diff: cc/picture_layer_impl.cc

Issue 11377176: cc: Add PictureLayerTiling for impl-side painting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 "cc/picture_layer_impl.h" 5 #include "cc/picture_layer_impl.h"
6 6
7 #include "cc/layer_tree_host_impl.h"
8 #include "cc/math_util.h"
9 #include "cc/quad_sink.h"
10 #include "cc/tile_draw_quad.h"
11
7 namespace cc { 12 namespace cc {
8 13
9 PictureLayerImpl::PictureLayerImpl(int id) : 14 PictureLayerImpl::PictureLayerImpl(int id) :
10 LayerImpl(id) { 15 LayerImpl(id) {
11 } 16 }
12 17
13 PictureLayerImpl::~PictureLayerImpl() { 18 PictureLayerImpl::~PictureLayerImpl() {
14 } 19 }
15 20
16 const char* PictureLayerImpl::layerTypeAsString() const { 21 const char* PictureLayerImpl::layerTypeAsString() const {
17 return "PictureLayer"; 22 return "PictureLayer";
18 } 23 }
19 24
20 void PictureLayerImpl::appendQuads(QuadSink&, AppendQuadsData&) { 25 void PictureLayerImpl::appendQuads(QuadSink& quadSink,
21 // TODO(enne): implement me 26 AppendQuadsData& appendQuadsData) {
27
28 const gfx::Rect& visible_rect = visibleContentRect();
29 gfx::Rect content_rect(gfx::Point(), contentBounds());
30
31 if (!tilings_.size())
32 return;
33
34 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQua dState());
35 bool clipped = false;
36 gfx::QuadF target_quad = MathUtil::mapQuad(
37 drawTransform(),
38 gfx::QuadF(visible_rect),
39 clipped);
40 bool isAxisAlignedInTarget = !clipped && target_quad.IsRectilinear();
41 bool useAA = !isAxisAlignedInTarget;
42
43 // TODO(enne): Generate quads from multiple tilings.
44 PictureLayerTiling* tiling = tilings_[0];
45 for (PictureLayerTiling::Iterator iter(tiling, visible_rect); iter; ++iter) {
46 ResourceProvider::ResourceId resource;
47 if (*iter) {
48 resource = iter->GetDrawableResourceId(
49 layerTreeHostImpl()->sourceFrameNumber());
50 }
51
52 if (!resource) {
53 // TODO(enne): draw checkerboards, etc...
54 continue;
55 }
56
57 gfx::Rect geometry_rect = iter.geometry_rect();
58 gfx::Rect texture_rect = iter.texture_rect();
59 gfx::Rect opaque_rect = iter.opaque_rect();
60
61 bool outside_left_edge = geometry_rect.x() == content_rect.x();
62 bool outside_top_edge = geometry_rect.y() == content_rect.y();
63 bool outside_right_edge = geometry_rect.right() == content_rect.right();
64 bool outside_bottom_edge = geometry_rect.bottom() == content_rect.bottom();
65
66 quadSink.append(TileDrawQuad::create(
67 sharedQuadState,
68 geometry_rect,
69 opaque_rect,
70 resource,
71 texture_rect.origin().OffsetFromOrigin(),
72 texture_rect.size(),
73 iter->contents_swizzled(),
74 outside_left_edge && useAA,
75 outside_top_edge && useAA,
76 outside_right_edge && useAA,
77 outside_bottom_edge && useAA).PassAs<DrawQuad>(), appendQuadsData);
78 }
22 } 79 }
23 80
24 void PictureLayerImpl::dumpLayerProperties(std::string*, int indent) const { 81 void PictureLayerImpl::dumpLayerProperties(std::string*, int indent) const {
25 // TODO(enne): implement me 82 // TODO(enne): implement me
26 } 83 }
27 84
85 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling*,
86 gfx::Rect rect) {
87 // TODO(nduca): where does this come from?
88 TileManager* tile_manager;
89
90 return make_scoped_refptr(new Tile(
91 tile_manager,
92 rect.size(),
93 GL_RGBA,
94 rect,
95 NORMAL_TILE_QUALITY));
96 }
97
98 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) {
99 tilings_.clear();
100 for (size_t i = 0; i < other->tilings_.size(); ++i) {
101 scoped_ptr<PictureLayerTiling> clone = other->tilings_[i]->Clone();
102 clone->set_client(this);
103 tilings_.append(clone.Pass());
104 }
105 }
106
107 void PictureLayerImpl::Update() {
108 // TODO(enne): Add more tilings during pinch zoom.
109 if (!tilings_.size()) {
110 gfx::Size tile_size = layerTreeHostImpl()->settings().defaultTileSize;
111
112 scoped_ptr<PictureLayerTiling> tiling = PictureLayerTiling::Create(
113 tile_size);
114 tiling->set_client(this);
115 tiling->set_bounds(contentBounds());
116 tiling->create_tiles(gfx::Rect(gfx::Point(), contentBounds()));
117 tilings_.append(tiling.Pass());
118
119 // TODO(enne): handle invalidations, create new tiles
120 }
121 }
28 122
29 } // namespace cc 123 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698