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

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

Issue 15995033: cc: Low quality support for low res tiles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unittest fix Created 7 years, 6 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
« no previous file with comments | « no previous file | cc/resources/managed_tile_state.h » ('j') | cc/resources/managed_tile_state.cc » ('J')
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 draw_transform(), 156 draw_transform(),
157 gfx::QuadF(rect), 157 gfx::QuadF(rect),
158 &clipped); 158 &clipped);
159 if (ShowDebugBorders()) { 159 if (ShowDebugBorders()) {
160 for (PictureLayerTilingSet::CoverageIterator iter( 160 for (PictureLayerTilingSet::CoverageIterator iter(
161 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); 161 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_);
162 iter; 162 iter;
163 ++iter) { 163 ++iter) {
164 SkColor color; 164 SkColor color;
165 float width; 165 float width;
166 if (*iter && iter->tile_version().IsReadyToDraw()) { 166 TileRasterMode raster_mode;
167 ManagedTileState::TileVersion::Mode mode = iter->tile_version().mode(); 167 if (*iter && iter->IsReadyToDraw(&raster_mode)) {
168 ManagedTileState::TileVersion::Mode mode =
169 iter->tile_version(raster_mode).mode();
168 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { 170 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) {
169 color = DebugColors::SolidColorTileBorderColor(); 171 color = DebugColors::SolidColorTileBorderColor();
170 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); 172 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl());
171 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) { 173 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) {
172 color = DebugColors::PictureTileBorderColor(); 174 color = DebugColors::PictureTileBorderColor();
173 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); 175 width = DebugColors::PictureTileBorderWidth(layer_tree_impl());
174 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { 176 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) {
175 color = DebugColors::HighResTileBorderColor(); 177 color = DebugColors::HighResTileBorderColor();
176 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); 178 width = DebugColors::HighResTileBorderWidth(layer_tree_impl());
177 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { 179 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) {
(...skipping 22 matching lines...) Expand all
200 202
201 // Keep track of the tilings that were used so that tilings that are 203 // Keep track of the tilings that were used so that tilings that are
202 // unused can be considered for removal. 204 // unused can be considered for removal.
203 std::vector<PictureLayerTiling*> seen_tilings; 205 std::vector<PictureLayerTiling*> seen_tilings;
204 206
205 for (PictureLayerTilingSet::CoverageIterator iter( 207 for (PictureLayerTilingSet::CoverageIterator iter(
206 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); 208 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_);
207 iter; 209 iter;
208 ++iter) { 210 ++iter) {
209 gfx::Rect geometry_rect = iter.geometry_rect(); 211 gfx::Rect geometry_rect = iter.geometry_rect();
210 if (!*iter || !iter->tile_version().IsReadyToDraw()) { 212 if (!*iter || !iter->IsReadyToDraw(NULL)) {
211 if (DrawCheckerboardForMissingTiles()) { 213 if (DrawCheckerboardForMissingTiles()) {
212 // TODO(enne): Figure out how to show debug "invalidated checker" color 214 // TODO(enne): Figure out how to show debug "invalidated checker" color
213 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); 215 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create();
214 SkColor color = DebugColors::DefaultCheckerboardColor(); 216 SkColor color = DebugColors::DefaultCheckerboardColor();
215 quad->SetNew(shared_quad_state, geometry_rect, color); 217 quad->SetNew(shared_quad_state, geometry_rect, color);
216 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) 218 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data))
217 append_quads_data->num_missing_tiles++; 219 append_quads_data->num_missing_tiles++;
218 } else { 220 } else {
219 SkColor color = SafeOpaqueBackgroundColor(); 221 SkColor color = SafeOpaqueBackgroundColor();
220 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); 222 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
221 quad->SetNew(shared_quad_state, geometry_rect, color, false); 223 quad->SetNew(shared_quad_state, geometry_rect, color, false);
222 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) 224 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data))
223 append_quads_data->num_missing_tiles++; 225 append_quads_data->num_missing_tiles++;
224 } 226 }
225 227
226 append_quads_data->had_incomplete_tile = true; 228 append_quads_data->had_incomplete_tile = true;
227 continue; 229 continue;
228 } 230 }
229 231
230 const ManagedTileState::TileVersion& tile_version = iter->tile_version(); 232 TileRasterMode raster_mode;
233 iter->IsReadyToDraw(&raster_mode);
reveman 2013/06/06 06:02:02 can we consolidate this with the IsReadyToDraw cal
vmpstr 2013/06/06 15:20:22 Done.
234 const ManagedTileState::TileVersion& tile_version =
235 iter->tile_version(raster_mode);
231 switch (tile_version.mode()) { 236 switch (tile_version.mode()) {
232 case ManagedTileState::TileVersion::RESOURCE_MODE: { 237 case ManagedTileState::TileVersion::RESOURCE_MODE: {
233 gfx::RectF texture_rect = iter.texture_rect(); 238 gfx::RectF texture_rect = iter.texture_rect();
234 gfx::Rect opaque_rect = iter->opaque_rect(); 239 gfx::Rect opaque_rect = iter->opaque_rect();
235 opaque_rect.Intersect(content_rect); 240 opaque_rect.Intersect(content_rect);
236 241
237 if (iter->contents_scale() != ideal_contents_scale_) 242 if (iter->contents_scale() != ideal_contents_scale_)
238 append_quads_data->had_incomplete_tile = true; 243 append_quads_data->had_incomplete_tile = true;
239 244
240 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); 245 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create();
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 } 611 }
607 612
608 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { 613 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const {
609 gfx::Rect content_rect(content_bounds()); 614 gfx::Rect content_rect(content_bounds());
610 float scale = contents_scale_x(); 615 float scale = contents_scale_x();
611 for (PictureLayerTilingSet::CoverageIterator 616 for (PictureLayerTilingSet::CoverageIterator
612 iter(tilings_.get(), scale, content_rect, ideal_contents_scale_); 617 iter(tilings_.get(), scale, content_rect, ideal_contents_scale_);
613 iter; 618 iter;
614 ++iter) { 619 ++iter) {
615 // Mask resource not ready yet. 620 // Mask resource not ready yet.
616 if (!*iter || 621 TileRasterMode raster_mode;
617 iter->tile_version().mode() != 622 if (!*iter || !iter->IsReadyToDraw(&raster_mode))
618 ManagedTileState::TileVersion::RESOURCE_MODE ||
619 !iter->tile_version().IsReadyToDraw())
620 return 0; 623 return 0;
624
625 if (iter->tile_version(raster_mode).mode() !=
626 ManagedTileState::TileVersion::RESOURCE_MODE)
627 return 0;
628
621 // Masks only supported if they fit on exactly one tile. 629 // Masks only supported if they fit on exactly one tile.
622 if (iter.geometry_rect() != content_rect) 630 if (iter.geometry_rect() != content_rect)
623 return 0; 631 return 0;
624 return iter->tile_version().get_resource_id(); 632
633 return iter->tile_version(raster_mode).get_resource_id();
625 } 634 }
626 return 0; 635 return 0;
627 } 636 }
628 637
629 void PictureLayerImpl::MarkVisibleResourcesAsRequired() const { 638 void PictureLayerImpl::MarkVisibleResourcesAsRequired() const {
630 DCHECK(layer_tree_impl()->IsPendingTree()); 639 DCHECK(layer_tree_impl()->IsPendingTree());
631 DCHECK(!layer_tree_impl()->needs_update_draw_properties()); 640 DCHECK(!layer_tree_impl()->needs_update_draw_properties());
632 DCHECK(ideal_contents_scale_); 641 DCHECK(ideal_contents_scale_);
633 DCHECK_GT(tilings_->num_tilings(), 0u); 642 DCHECK_GT(tilings_->num_tilings(), 0u);
634 643
(...skipping 29 matching lines...) Expand all
664 if (tiling->resolution() == HIGH_RESOLUTION) { 673 if (tiling->resolution() == HIGH_RESOLUTION) {
665 DCHECK(!high_res) << "There can only be one high res tiling"; 674 DCHECK(!high_res) << "There can only be one high res tiling";
666 high_res = tiling; 675 high_res = tiling;
667 continue; 676 continue;
668 } 677 }
669 for (PictureLayerTiling::CoverageIterator iter(tiling, 678 for (PictureLayerTiling::CoverageIterator iter(tiling,
670 contents_scale_x(), 679 contents_scale_x(),
671 rect); 680 rect);
672 iter; 681 iter;
673 ++iter) { 682 ++iter) {
674 if (!*iter || !iter->tile_version().IsReadyToDraw()) 683 if (!*iter || !iter->IsReadyToDraw(NULL))
675 continue; 684 continue;
676 685
677 // This iteration is over the visible content rect which is potentially 686 // This iteration is over the visible content rect which is potentially
678 // less conservative than projecting the viewport into the layer. 687 // less conservative than projecting the viewport into the layer.
679 // Ignore tiles that are know to be outside the viewport. 688 // Ignore tiles that are know to be outside the viewport.
680 if (iter->priority(PENDING_TREE).distance_to_visible_in_pixels != 0) 689 if (iter->priority(PENDING_TREE).distance_to_visible_in_pixels != 0)
681 continue; 690 continue;
682 691
683 missing_region.Subtract(iter.geometry_rect()); 692 missing_region.Subtract(iter.geometry_rect());
684 iter->mark_required_for_activation(); 693 iter->mark_required_for_activation();
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 state->Set("tilings", tilings_->AsValue().release()); 1022 state->Set("tilings", tilings_->AsValue().release());
1014 state->Set("pictures", pile_->AsValue().release()); 1023 state->Set("pictures", pile_->AsValue().release());
1015 state->Set("invalidation", invalidation_.AsValue().release()); 1024 state->Set("invalidation", invalidation_.AsValue().release());
1016 } 1025 }
1017 1026
1018 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { 1027 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const {
1019 return tilings_->GPUMemoryUsageInBytes(); 1028 return tilings_->GPUMemoryUsageInBytes();
1020 } 1029 }
1021 1030
1022 } // namespace cc 1031 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/resources/managed_tile_state.h » ('j') | cc/resources/managed_tile_state.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698