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

Side by Side Diff: cc/layers/picture_layer_impl.cc

Issue 12642010: Implement on demand quad rasterization for PicturePiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit fix. Created 7 years, 9 months 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/debug/debug_colors.cc ('k') | cc/output/gl_renderer.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/layers/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "cc/base/math_util.h" 8 #include "cc/base/math_util.h"
9 #include "cc/base/util.h" 9 #include "cc/base/util.h"
10 #include "cc/debug/debug_colors.h" 10 #include "cc/debug/debug_colors.h"
11 #include "cc/layers/append_quads_data.h" 11 #include "cc/layers/append_quads_data.h"
12 #include "cc/layers/quad_sink.h" 12 #include "cc/layers/quad_sink.h"
13 #include "cc/quads/checkerboard_draw_quad.h" 13 #include "cc/quads/checkerboard_draw_quad.h"
14 #include "cc/quads/debug_border_draw_quad.h" 14 #include "cc/quads/debug_border_draw_quad.h"
15 #include "cc/quads/picture_draw_quad.h"
15 #include "cc/quads/solid_color_draw_quad.h" 16 #include "cc/quads/solid_color_draw_quad.h"
16 #include "cc/quads/tile_draw_quad.h" 17 #include "cc/quads/tile_draw_quad.h"
17 #include "cc/trees/layer_tree_impl.h" 18 #include "cc/trees/layer_tree_impl.h"
18 #include "ui/gfx/quad_f.h" 19 #include "ui/gfx/quad_f.h"
19 #include "ui/gfx/rect_conversions.h" 20 #include "ui/gfx/rect_conversions.h"
20 #include "ui/gfx/size_conversions.h" 21 #include "ui/gfx/size_conversions.h"
21 22
22 namespace { 23 namespace {
23 const float kMaxScaleRatioDuringPinch = 2.0f; 24 const float kMaxScaleRatioDuringPinch = 2.0f;
24 } 25 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 iter; 111 iter;
111 ++iter) { 112 ++iter) {
112 SkColor color; 113 SkColor color;
113 float width; 114 float width;
114 if (*iter && iter->drawing_info().IsReadyToDraw()) { 115 if (*iter && iter->drawing_info().IsReadyToDraw()) {
115 ManagedTileState::DrawingInfo::Mode mode = iter->drawing_info().mode(); 116 ManagedTileState::DrawingInfo::Mode mode = iter->drawing_info().mode();
116 if (mode == ManagedTileState::DrawingInfo::SOLID_COLOR_MODE || 117 if (mode == ManagedTileState::DrawingInfo::SOLID_COLOR_MODE ||
117 mode == ManagedTileState::DrawingInfo::TRANSPARENT_MODE) { 118 mode == ManagedTileState::DrawingInfo::TRANSPARENT_MODE) {
118 color = DebugColors::SolidColorTileBorderColor(); 119 color = DebugColors::SolidColorTileBorderColor();
119 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); 120 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl());
121 } else if (mode == ManagedTileState::DrawingInfo::PICTURE_PILE_MODE) {
122 color = DebugColors::PictureTileBorderColor();
123 width = DebugColors::PictureTileBorderWidth(layer_tree_impl());
120 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { 124 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) {
121 color = DebugColors::HighResTileBorderColor(); 125 color = DebugColors::HighResTileBorderColor();
122 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); 126 width = DebugColors::HighResTileBorderWidth(layer_tree_impl());
123 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { 127 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) {
124 color = DebugColors::LowResTileBorderColor(); 128 color = DebugColors::LowResTileBorderColor();
125 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); 129 width = DebugColors::LowResTileBorderWidth(layer_tree_impl());
126 } else if (iter->contents_scale() > contents_scale_x()) { 130 } else if (iter->contents_scale() > contents_scale_x()) {
127 color = DebugColors::ExtraHighResTileBorderColor(); 131 color = DebugColors::ExtraHighResTileBorderColor();
128 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); 132 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl());
129 } else { 133 } else {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 quad->SetNew(shared_quad_state, geometry_rect, background_color()); 173 quad->SetNew(shared_quad_state, geometry_rect, background_color());
170 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) 174 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data))
171 append_quads_data->num_missing_tiles++; 175 append_quads_data->num_missing_tiles++;
172 } 176 }
173 177
174 append_quads_data->had_incomplete_tile = true; 178 append_quads_data->had_incomplete_tile = true;
175 continue; 179 continue;
176 } 180 }
177 181
178 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info(); 182 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info();
179 switch (drawing_info.mode()) { 183 ManagedTileState::DrawingInfo::Mode mode = drawing_info.mode();
180 case ManagedTileState::DrawingInfo::TEXTURE_MODE: { 184 if (mode == ManagedTileState::DrawingInfo::RESOURCE_MODE ||
181 if (iter->contents_scale() != ideal_contents_scale_) 185 mode == ManagedTileState::DrawingInfo::PICTURE_PILE_MODE) {
enne (OOO) 2013/03/26 18:39:23 I'm not sure I agree with setting had_incomplete_t
Leandro GraciĆ” Gil 2013/03/26 18:50:12 I see your point. I'm moving this out of the PICTU
182 append_quads_data->had_incomplete_tile = true; 186 if (iter->contents_scale() != ideal_contents_scale_)
187 append_quads_data->had_incomplete_tile = true;
188 }
183 189
190 switch (mode) {
191 case ManagedTileState::DrawingInfo::RESOURCE_MODE: {
184 gfx::RectF texture_rect = iter.texture_rect(); 192 gfx::RectF texture_rect = iter.texture_rect();
185 gfx::Rect opaque_rect = iter->opaque_rect(); 193 gfx::Rect opaque_rect = iter->opaque_rect();
186 opaque_rect.Intersect(content_rect); 194 opaque_rect.Intersect(content_rect);
187 195
188 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); 196 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create();
189 quad->SetNew(shared_quad_state, 197 quad->SetNew(shared_quad_state,
190 geometry_rect, 198 geometry_rect,
191 opaque_rect, 199 opaque_rect,
192 drawing_info.get_resource_id(), 200 drawing_info.get_resource_id(),
193 texture_rect, 201 texture_rect,
194 iter.texture_size(), 202 iter.texture_size(),
195 drawing_info.contents_swizzled()); 203 drawing_info.contents_swizzled());
196 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); 204 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data);
197 break; 205 break;
198 } 206 }
207 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: {
208 gfx::RectF texture_rect = iter.texture_rect();
209 gfx::Rect opaque_rect = iter->opaque_rect();
210 opaque_rect.Intersect(content_rect);
211
212 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create();
213 quad->SetNew(shared_quad_state,
214 geometry_rect,
215 opaque_rect,
216 texture_rect,
217 iter.texture_size(),
218 drawing_info.contents_swizzled(),
219 iter->content_rect(),
220 iter->contents_scale(),
221 pile_);
222 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data);
223 break;
224 }
199 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { 225 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: {
200 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); 226 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
201 quad->SetNew(shared_quad_state, 227 quad->SetNew(shared_quad_state,
202 geometry_rect, 228 geometry_rect,
203 drawing_info.get_solid_color()); 229 drawing_info.get_solid_color());
204 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); 230 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data);
205 break; 231 break;
206 } 232 }
207 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: 233 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE:
208 break; 234 break;
209 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE:
210 // TODO: crbug.com/173011 would fill this part in.
211 default: 235 default:
212 NOTREACHED(); 236 NOTREACHED();
213 } 237 }
214 238
215 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) 239 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling())
216 seen_tilings.push_back(iter.CurrentTiling()); 240 seen_tilings.push_back(iter.CurrentTiling());
217 } 241 }
218 242
219 // Aggressively remove any tilings that are not seen to save memory. Note 243 // Aggressively remove any tilings that are not seen to save memory. Note
220 // that this is at the expense of doing cause more frequent re-painting. A 244 // that this is at the expense of doing cause more frequent re-painting. A
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { 502 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const {
479 gfx::Rect content_rect(content_bounds()); 503 gfx::Rect content_rect(content_bounds());
480 float scale = contents_scale_x(); 504 float scale = contents_scale_x();
481 for (PictureLayerTilingSet::Iterator 505 for (PictureLayerTilingSet::Iterator
482 iter(tilings_.get(), scale, content_rect, ideal_contents_scale_); 506 iter(tilings_.get(), scale, content_rect, ideal_contents_scale_);
483 iter; 507 iter;
484 ++iter) { 508 ++iter) {
485 // Mask resource not ready yet. 509 // Mask resource not ready yet.
486 if (!*iter || 510 if (!*iter ||
487 iter->drawing_info().mode() != 511 iter->drawing_info().mode() !=
488 ManagedTileState::DrawingInfo::TEXTURE_MODE || 512 ManagedTileState::DrawingInfo::RESOURCE_MODE ||
489 !iter->drawing_info().IsReadyToDraw()) 513 !iter->drawing_info().IsReadyToDraw())
490 return 0; 514 return 0;
491 // Masks only supported if they fit on exactly one tile. 515 // Masks only supported if they fit on exactly one tile.
492 if (iter.geometry_rect() != content_rect) 516 if (iter.geometry_rect() != content_rect)
493 return 0; 517 return 0;
494 return iter->drawing_info().get_resource_id(); 518 return iter->drawing_info().get_resource_id();
495 } 519 }
496 return 0; 520 return 0;
497 } 521 }
498 522
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { 864 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const {
841 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 865 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
842 LayerImpl::AsValueInto(state.get()); 866 LayerImpl::AsValueInto(state.get());
843 867
844 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); 868 state->SetDouble("ideal_contents_scale", ideal_contents_scale_);
845 state->Set("tilings", tilings_->AsValue().release()); 869 state->Set("tilings", tilings_->AsValue().release());
846 return state.PassAs<base::Value>(); 870 return state.PassAs<base::Value>();
847 } 871 }
848 872
849 } // namespace cc 873 } // namespace cc
OLDNEW
« no previous file with comments | « cc/debug/debug_colors.cc ('k') | cc/output/gl_renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698