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

Side by Side Diff: cc/picture_layer_impl.cc

Issue 11417111: cc: Add PictureLayerTilingSet to manage PictureLayerTiling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win_rel 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
« no previous file with comments | « cc/picture_layer_impl.h ('k') | cc/picture_layer_tiling.h » ('j') | 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 "cc/picture_layer_impl.h" 5 #include "cc/picture_layer_impl.h"
6 6
7 #include "cc/layer_tree_host_impl.h" 7 #include "cc/layer_tree_host_impl.h"
8 #include "cc/math_util.h" 8 #include "cc/math_util.h"
9 #include "cc/quad_sink.h" 9 #include "cc/quad_sink.h"
10 #include "cc/tile_draw_quad.h" 10 #include "cc/tile_draw_quad.h"
11 11
12 namespace cc { 12 namespace cc {
13 13
14 PictureLayerImpl::PictureLayerImpl(int id) : 14 PictureLayerImpl::PictureLayerImpl(int id) :
15 LayerImpl(id) { 15 LayerImpl(id),
16 tilings_(this) {
16 } 17 }
17 18
18 PictureLayerImpl::~PictureLayerImpl() { 19 PictureLayerImpl::~PictureLayerImpl() {
19 } 20 }
20 21
21 const char* PictureLayerImpl::layerTypeAsString() const { 22 const char* PictureLayerImpl::layerTypeAsString() const {
22 return "PictureLayer"; 23 return "PictureLayer";
23 } 24 }
24 25
25 void PictureLayerImpl::appendQuads(QuadSink& quadSink, 26 void PictureLayerImpl::appendQuads(QuadSink& quadSink,
26 AppendQuadsData& appendQuadsData) { 27 AppendQuadsData& appendQuadsData) {
27 28
28 const gfx::Rect& visible_rect = visibleContentRect(); 29 const gfx::Rect& rect = visibleContentRect();
29 gfx::Rect content_rect(gfx::Point(), contentBounds()); 30 gfx::Rect content_rect(gfx::Point(), contentBounds());
30 31
31 if (!tilings_.size())
32 return;
33
34 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQua dState()); 32 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQua dState());
35 bool clipped = false; 33 bool clipped = false;
36 gfx::QuadF target_quad = MathUtil::mapQuad( 34 gfx::QuadF target_quad = MathUtil::mapQuad(
37 drawTransform(), 35 drawTransform(),
38 gfx::QuadF(visible_rect), 36 gfx::QuadF(rect),
39 clipped); 37 clipped);
40 bool isAxisAlignedInTarget = !clipped && target_quad.IsRectilinear(); 38 bool isAxisAlignedInTarget = !clipped && target_quad.IsRectilinear();
41 bool useAA = !isAxisAlignedInTarget; 39 bool useAA = !isAxisAlignedInTarget;
42 40
43 // TODO(enne): Generate quads from multiple tilings. 41 for (PictureLayerTilingSet::Iterator iter(&tilings_, contentsScaleX(), rect);
44 PictureLayerTiling* tiling = tilings_[0]; 42 iter;
45 for (PictureLayerTiling::Iterator iter(tiling, visible_rect); iter; ++iter) { 43 ++iter) {
46 ResourceProvider::ResourceId resource; 44 ResourceProvider::ResourceId resource;
47 if (*iter) 45 if (*iter)
48 resource = iter->resource_id(); 46 resource = iter->resource_id();
49 47
50 if (!resource) { 48 if (!resource) {
51 // TODO(enne): draw checkerboards, etc... 49 // TODO(enne): draw checkerboards, etc...
52 continue; 50 continue;
53 } 51 }
54 52
55 gfx::Rect geometry_rect = iter.geometry_rect(); 53 gfx::Rect geometry_rect = iter.geometry_rect();
56 gfx::RectF texture_rect = iter.texture_rect(); 54 gfx::RectF texture_rect = iter.texture_rect();
57 gfx::Rect opaque_rect = iter.opaque_rect(); 55 gfx::Rect opaque_rect = iter->opaque_rect();
56 opaque_rect.Intersect(content_rect);
58 57
59 bool outside_left_edge = geometry_rect.x() == content_rect.x(); 58 bool outside_left_edge = geometry_rect.x() == content_rect.x();
60 bool outside_top_edge = geometry_rect.y() == content_rect.y(); 59 bool outside_top_edge = geometry_rect.y() == content_rect.y();
61 bool outside_right_edge = geometry_rect.right() == content_rect.right(); 60 bool outside_right_edge = geometry_rect.right() == content_rect.right();
62 bool outside_bottom_edge = geometry_rect.bottom() == content_rect.bottom(); 61 bool outside_bottom_edge = geometry_rect.bottom() == content_rect.bottom();
63 62
64 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); 63 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create();
65 quad->SetNew(sharedQuadState, 64 quad->SetNew(sharedQuadState,
66 geometry_rect, 65 geometry_rect,
67 opaque_rect, 66 opaque_rect,
(...skipping 20 matching lines...) Expand all
88 87
89 return make_scoped_refptr(new Tile( 88 return make_scoped_refptr(new Tile(
90 tile_manager, 89 tile_manager,
91 &pile_, 90 &pile_,
92 rect.size(), 91 rect.size(),
93 GL_RGBA, 92 GL_RGBA,
94 rect)); 93 rect));
95 } 94 }
96 95
97 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { 96 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) {
98 tilings_.clear(); 97 tilings_.CloneFrom(other->tilings_);
99 for (size_t i = 0; i < other->tilings_.size(); ++i) {
100 scoped_ptr<PictureLayerTiling> clone = other->tilings_[i]->Clone();
101 clone->set_client(this);
102 tilings_.append(clone.Pass());
103 }
104 } 98 }
105 99
106 void PictureLayerImpl::Update() { 100 void PictureLayerImpl::Update() {
101 tilings_.SetLayerBounds(bounds());
107 // TODO(enne): Add more tilings during pinch zoom. 102 // TODO(enne): Add more tilings during pinch zoom.
108 if (!tilings_.size()) { 103 if (!tilings_.num_tilings()) {
109 gfx::Size tile_size = layerTreeHostImpl()->settings().defaultTileSize; 104 gfx::Size tile_size = layerTreeHostImpl()->settings().defaultTileSize;
110 105 tilings_.AddTiling(contentsScaleX(), tile_size);
111 scoped_ptr<PictureLayerTiling> tiling = PictureLayerTiling::Create(
112 tile_size);
113 tiling->set_client(this);
114 tiling->SetBounds(contentBounds());
115 tiling->create_tiles(gfx::Rect(gfx::Point(), contentBounds()));
116 tilings_.append(tiling.Pass());
117
118 // TODO(enne): handle invalidations, create new tiles 106 // TODO(enne): handle invalidations, create new tiles
119 } 107 }
120 } 108 }
121 109
122 } // namespace cc 110 } // namespace cc
OLDNEW
« no previous file with comments | « cc/picture_layer_impl.h ('k') | cc/picture_layer_tiling.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698