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

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: rebase & introduce ResizeResource. 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
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 iter; 105 iter;
105 ++iter) { 106 ++iter) {
106 SkColor color; 107 SkColor color;
107 float width; 108 float width;
108 if (*iter && iter->drawing_info().IsReadyToDraw()) { 109 if (*iter && iter->drawing_info().IsReadyToDraw()) {
109 ManagedTileState::DrawingInfo::Mode mode = iter->drawing_info().mode(); 110 ManagedTileState::DrawingInfo::Mode mode = iter->drawing_info().mode();
110 if (mode == ManagedTileState::DrawingInfo::SOLID_COLOR_MODE || 111 if (mode == ManagedTileState::DrawingInfo::SOLID_COLOR_MODE ||
111 mode == ManagedTileState::DrawingInfo::TRANSPARENT_MODE) { 112 mode == ManagedTileState::DrawingInfo::TRANSPARENT_MODE) {
112 color = DebugColors::SolidColorTileBorderColor(); 113 color = DebugColors::SolidColorTileBorderColor();
113 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); 114 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl());
115 } else if (mode == ManagedTileState::DrawingInfo::PICTURE_PILE_MODE) {
116 color = DebugColors::PictureTileBorderColor();
117 width = DebugColors::PictureTileBorderWidth(layer_tree_impl());
114 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { 118 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) {
115 color = DebugColors::HighResTileBorderColor(); 119 color = DebugColors::HighResTileBorderColor();
116 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); 120 width = DebugColors::HighResTileBorderWidth(layer_tree_impl());
117 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { 121 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) {
118 color = DebugColors::LowResTileBorderColor(); 122 color = DebugColors::LowResTileBorderColor();
119 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); 123 width = DebugColors::LowResTileBorderWidth(layer_tree_impl());
120 } else if (iter->contents_scale() > contents_scale_x()) { 124 } else if (iter->contents_scale() > contents_scale_x()) {
121 color = DebugColors::ExtraHighResTileBorderColor(); 125 color = DebugColors::ExtraHighResTileBorderColor();
122 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); 126 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl());
123 } else { 127 } else {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 quad->SetNew(sharedQuadState, geometry_rect, background_color()); 166 quad->SetNew(sharedQuadState, geometry_rect, background_color());
163 if (quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData)) 167 if (quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData))
164 appendQuadsData->numMissingTiles++; 168 appendQuadsData->numMissingTiles++;
165 } 169 }
166 170
167 appendQuadsData->hadIncompleteTile = true; 171 appendQuadsData->hadIncompleteTile = true;
168 continue; 172 continue;
169 } 173 }
170 174
171 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info(); 175 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info();
172 switch (drawing_info.mode()) { 176 const ManagedTileState::DrawingInfo::Mode mode = drawing_info.mode();
danakj 2013/03/22 18:02:41 don't use const for non-pointer/reference local va
Leandro Graciá Gil 2013/03/22 20:40:58 Done.
177 if (mode == ManagedTileState::DrawingInfo::TEXTURE_MODE ||
178 mode == ManagedTileState::DrawingInfo::PICTURE_PILE_MODE) {
179 if (iter->contents_scale() != ideal_contents_scale_)
180 appendQuadsData->hadIncompleteTile = true;
181 }
182
183 switch (mode) {
173 case ManagedTileState::DrawingInfo::TEXTURE_MODE: { 184 case ManagedTileState::DrawingInfo::TEXTURE_MODE: {
174 if (iter->contents_scale() != ideal_contents_scale_)
175 appendQuadsData->hadIncompleteTile = true;
176
177 gfx::RectF texture_rect = iter.texture_rect(); 185 gfx::RectF texture_rect = iter.texture_rect();
178 gfx::Rect opaque_rect = iter->opaque_rect(); 186 gfx::Rect opaque_rect = iter->opaque_rect();
179 opaque_rect.Intersect(content_rect); 187 opaque_rect.Intersect(content_rect);
180 188
181 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); 189 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create();
182 quad->SetNew(sharedQuadState, 190 quad->SetNew(sharedQuadState,
183 geometry_rect, 191 geometry_rect,
184 opaque_rect, 192 opaque_rect,
185 drawing_info.get_resource_id(), 193 drawing_info.get_resource_id(),
186 texture_rect, 194 texture_rect,
187 iter.texture_size(), 195 iter.texture_size(),
188 drawing_info.contents_swizzled()); 196 drawing_info.contents_swizzled());
189 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData); 197 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData);
190 break; 198 break;
191 } 199 }
200
danakj 2013/03/22 18:02:41 nit: no blank lines between cases
Leandro Graciá Gil 2013/03/22 20:40:58 Done.
201 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: {
202 gfx::RectF texture_rect = iter.texture_rect();
203 gfx::Rect opaque_rect = iter->opaque_rect();
204 opaque_rect.Intersect(content_rect);
205
206 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create();
207 quad->SetNew(sharedQuadState,
208 geometry_rect,
209 opaque_rect,
210 texture_rect,
211 iter.texture_size(),
212 drawing_info.contents_swizzled(),
vmpstr 2013/03/22 18:29:32 I think contents_swizzled might not be set for pic
Leandro Graciá Gil 2013/03/22 20:40:58 Good catch! Fixed.
213 iter->content_rect(),
214 iter->contents_scale(),
215 pile_);
216 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData);
217 break;
218 }
219
danakj 2013/03/22 18:02:41 nit: and here
Leandro Graciá Gil 2013/03/22 20:40:58 Done.
192 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { 220 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: {
193 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); 221 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
194 quad->SetNew(sharedQuadState, 222 quad->SetNew(sharedQuadState,
195 geometry_rect, 223 geometry_rect,
196 drawing_info.get_solid_color()); 224 drawing_info.get_solid_color());
197 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData); 225 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData);
198 break; 226 break;
199 } 227 }
200 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: 228 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE:
201 break; 229 break;
202 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE:
203 // TODO: crbug.com/173011 would fill this part in.
204 default: 230 default:
205 NOTREACHED(); 231 NOTREACHED();
206 } 232 }
207 233
208 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) 234 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling())
209 seen_tilings.push_back(iter.CurrentTiling()); 235 seen_tilings.push_back(iter.CurrentTiling());
210 } 236 }
211 237
212 // Aggressively remove any tilings that are not seen to save memory. Note 238 // Aggressively remove any tilings that are not seen to save memory. Note
213 // that this is at the expense of doing cause more frequent re-painting. A 239 // that this is at the expense of doing cause more frequent re-painting. A
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { 827 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const {
802 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 828 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
803 LayerImpl::AsValueInto(state.get()); 829 LayerImpl::AsValueInto(state.get());
804 830
805 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); 831 state->SetDouble("ideal_contents_scale", ideal_contents_scale_);
806 state->Set("tilings", tilings_->AsValue().release()); 832 state->Set("tilings", tilings_->AsValue().release());
807 return state.PassAs<base::Value>(); 833 return state.PassAs<base::Value>();
808 } 834 }
809 835
810 } // namespace cc 836 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698