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

Side by Side Diff: cc/picture_layer_impl.cc

Issue 12353003: cc: Refactored Tile::GetResourceId (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more changes 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/picture_layer_impl.h" 5 #include "cc/picture_layer_impl.h"
6 6
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "cc/append_quads_data.h" 8 #include "cc/append_quads_data.h"
9 #include "cc/checkerboard_draw_quad.h" 9 #include "cc/checkerboard_draw_quad.h"
10 #include "cc/debug_border_draw_quad.h" 10 #include "cc/debug_border_draw_quad.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 if (showDebugBorders()) { 108 if (showDebugBorders()) {
109 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), 109 for (PictureLayerTilingSet::Iterator iter(tilings_.get(),
110 contentsScaleX(), 110 contentsScaleX(),
111 rect, 111 rect,
112 ideal_contents_scale_, 112 ideal_contents_scale_,
113 layerDeviceAlignment); 113 layerDeviceAlignment);
114 iter; 114 iter;
115 ++iter) { 115 ++iter) {
116 SkColor color; 116 SkColor color;
117 float width; 117 float width;
118 if (*iter && iter->GetResourceId()) { 118 if (*iter && iter->drawing_info().IsReadyToDraw()) {
119 if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { 119 if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) {
120 color = DebugColors::HighResTileBorderColor(); 120 color = DebugColors::HighResTileBorderColor();
121 width = DebugColors::HighResTileBorderWidth(layerTreeImpl()); 121 width = DebugColors::HighResTileBorderWidth(layerTreeImpl());
122 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { 122 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) {
123 color = DebugColors::LowResTileBorderColor(); 123 color = DebugColors::LowResTileBorderColor();
124 width = DebugColors::LowResTileBorderWidth(layerTreeImpl()); 124 width = DebugColors::LowResTileBorderWidth(layerTreeImpl());
125 } else if (iter->contents_scale() > contentsScaleX()) { 125 } else if (iter->contents_scale() > contentsScaleX()) {
126 color = DebugColors::ExtraHighResTileBorderColor(); 126 color = DebugColors::ExtraHighResTileBorderColor();
127 width = DebugColors::ExtraHighResTileBorderWidth(layerTreeImpl()); 127 width = DebugColors::ExtraHighResTileBorderWidth(layerTreeImpl());
128 } else { 128 } else {
(...skipping 17 matching lines...) Expand all
146 // unused can be considered for removal. 146 // unused can be considered for removal.
147 std::vector<PictureLayerTiling*> seen_tilings; 147 std::vector<PictureLayerTiling*> seen_tilings;
148 148
149 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), 149 for (PictureLayerTilingSet::Iterator iter(tilings_.get(),
150 contentsScaleX(), 150 contentsScaleX(),
151 rect, 151 rect,
152 ideal_contents_scale_, 152 ideal_contents_scale_,
153 layerDeviceAlignment); 153 layerDeviceAlignment);
154 iter; 154 iter;
155 ++iter) { 155 ++iter) {
156 ResourceProvider::ResourceId resource = 0;
157 if (*iter)
158 resource = iter->GetResourceId();
159 156
160 gfx::Rect geometry_rect = iter.geometry_rect(); 157 gfx::Rect geometry_rect = iter.geometry_rect();
161 158 if (!*iter || !iter->drawing_info().IsReadyToDraw()) {
162 if (!resource) {
163 if (drawCheckerboardForMissingTiles()) { 159 if (drawCheckerboardForMissingTiles()) {
164 // TODO(enne): Figure out how to show debug "invalidated checker" color 160 // TODO(enne): Figure out how to show debug "invalidated checker" color
165 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); 161 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create();
166 SkColor color = DebugColors::DefaultCheckerboardColor(); 162 SkColor color = DebugColors::DefaultCheckerboardColor();
167 quad->SetNew(sharedQuadState, geometry_rect, color); 163 quad->SetNew(sharedQuadState, geometry_rect, color);
168 if (quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData)) 164 if (quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData))
169 appendQuadsData.numMissingTiles++; 165 appendQuadsData.numMissingTiles++;
170 } else { 166 } else {
171 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); 167 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
172 quad->SetNew(sharedQuadState, geometry_rect, backgroundColor()); 168 quad->SetNew(sharedQuadState, geometry_rect, backgroundColor());
173 if (quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData)) 169 if (quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData))
174 appendQuadsData.numMissingTiles++; 170 appendQuadsData.numMissingTiles++;
175 } 171 }
176 172
177 appendQuadsData.hadIncompleteTile = true; 173 appendQuadsData.hadIncompleteTile = true;
178 continue; 174 continue;
179 } 175 }
180 176
181 if (iter->contents_scale() != ideal_contents_scale_) 177 const TileDrawingInfo& drawing_info = iter->drawing_info();
182 appendQuadsData.hadIncompleteTile = true; 178 switch (drawing_info.mode()) {
179 case TileDrawingInfo::TEXTURE_MODE: {
180 if (iter->contents_scale() != ideal_contents_scale_)
181 appendQuadsData.hadIncompleteTile = true;
183 182
184 gfx::RectF texture_rect = iter.texture_rect(); 183 gfx::RectF texture_rect = iter.texture_rect();
185 gfx::Rect opaque_rect = iter->opaque_rect(); 184 gfx::Rect opaque_rect = iter->opaque_rect();
186 opaque_rect.Intersect(content_rect); 185 opaque_rect.Intersect(content_rect);
187 186
188 bool outside_left_edge = geometry_rect.x() == content_rect.x(); 187 bool outside_left_edge = geometry_rect.x() == content_rect.x();
189 bool outside_top_edge = geometry_rect.y() == content_rect.y(); 188 bool outside_top_edge = geometry_rect.y() == content_rect.y();
190 bool outside_right_edge = geometry_rect.right() == content_rect.right(); 189 bool outside_right_edge = geometry_rect.right() == content_rect.right();
191 bool outside_bottom_edge = geometry_rect.bottom() == content_rect.bottom(); 190 bool outside_bottom_edge = geometry_rect.bottom() == content_rect.bottom ();
192 191
193 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); 192 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create();
194 quad->SetNew(sharedQuadState, 193 quad->SetNew(sharedQuadState,
195 geometry_rect, 194 geometry_rect,
196 opaque_rect, 195 opaque_rect,
197 resource, 196 drawing_info.get_resource_id(),
198 texture_rect, 197 texture_rect,
199 iter.texture_size(), 198 iter.texture_size(),
200 iter->contents_swizzled(), 199 drawing_info.contents_swizzled(),
201 outside_left_edge && useAA, 200 outside_left_edge && useAA,
202 outside_top_edge && useAA, 201 outside_top_edge && useAA,
203 outside_right_edge && useAA, 202 outside_right_edge && useAA,
204 outside_bottom_edge && useAA); 203 outside_bottom_edge && useAA);
205 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); 204 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData);
205 break;
206 }
207 case TileDrawingInfo::SOLID_COLOR_MODE: {
208 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
209 quad->SetNew(sharedQuadState,
210 geometry_rect,
211 drawing_info.get_solid_color());
212 break;
213 }
214 case TileDrawingInfo::TRANSPARENT_MODE:
215 break;
216 case TileDrawingInfo::PICTURE_PILE_MODE:
217 // TODO: crbug.com/173011 would fill this part in.
218 default:
219 NOTREACHED();
220 }
206 221
207 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) 222 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling())
208 seen_tilings.push_back(iter.CurrentTiling()); 223 seen_tilings.push_back(iter.CurrentTiling());
209 } 224 }
210 225
211 // Aggressively remove any tilings that are not seen to save memory. Note 226 // Aggressively remove any tilings that are not seen to save memory. Note
212 // that this is at the expense of doing cause more frequent re-painting. A 227 // that this is at the expense of doing cause more frequent re-painting. A
213 // better scheme would be to maintain a tighter visibleContentRect for the 228 // better scheme would be to maintain a tighter visibleContentRect for the
214 // finer tilings. 229 // finer tilings.
215 CleanUpTilingsOnActiveLayer(seen_tilings); 230 CleanUpTilingsOnActiveLayer(seen_tilings);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 gfx::Rect content_rect(gfx::Point(), contentBounds()); 481 gfx::Rect content_rect(gfx::Point(), contentBounds());
467 float scale = contentsScaleX(); 482 float scale = contentsScaleX();
468 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), 483 for (PictureLayerTilingSet::Iterator iter(tilings_.get(),
469 scale, 484 scale,
470 content_rect, 485 content_rect,
471 ideal_contents_scale_, 486 ideal_contents_scale_,
472 PictureLayerTiling::LayerDeviceAlign mentUnknown); 487 PictureLayerTiling::LayerDeviceAlign mentUnknown);
473 iter; 488 iter;
474 ++iter) { 489 ++iter) {
475 // Mask resource not ready yet. 490 // Mask resource not ready yet.
476 if (!*iter || !iter->GetResourceId()) 491 if (!*iter ||
492 !iter->drawing_info().mode() != TileDrawingInfo::TEXTURE_MODE ||
493 !iter->drawing_info().IsReadyToDraw())
477 return 0; 494 return 0;
478 // Masks only supported if they fit on exactly one tile. 495 // Masks only supported if they fit on exactly one tile.
479 if (iter.geometry_rect() != content_rect) 496 if (iter.geometry_rect() != content_rect)
480 return 0; 497 return 0;
481 return iter->GetResourceId(); 498 return iter->drawing_info().get_resource_id();
482 } 499 }
483 return 0; 500 return 0;
484 } 501 }
485 502
486 bool PictureLayerImpl::areVisibleResourcesReady() const { 503 bool PictureLayerImpl::areVisibleResourcesReady() const {
487 DCHECK(layerTreeImpl()->IsPendingTree()); 504 DCHECK(layerTreeImpl()->IsPendingTree());
488 DCHECK(ideal_contents_scale_); 505 DCHECK(ideal_contents_scale_);
489 506
490 const gfx::Rect& rect = visibleContentRect(); 507 const gfx::Rect& rect = visibleContentRect();
491 508
(...skipping 23 matching lines...) Expand all
515 if (tiling->contents_scale() < min_acceptable_scale) 532 if (tiling->contents_scale() < min_acceptable_scale)
516 continue; 533 continue;
517 534
518 for (PictureLayerTiling::Iterator iter(tiling, 535 for (PictureLayerTiling::Iterator iter(tiling,
519 contentsScaleX(), 536 contentsScaleX(),
520 rect, 537 rect,
521 PictureLayerTiling::LayerDeviceAlignm entUnknown); 538 PictureLayerTiling::LayerDeviceAlignm entUnknown);
522 iter; 539 iter;
523 ++iter) { 540 ++iter) {
524 // A null tile (i.e. no recording) is considered "ready". 541 // A null tile (i.e. no recording) is considered "ready".
525 if (!*iter || iter->GetResourceId()) 542 if (!*iter || iter->drawing_info().IsReadyToDraw())
526 missing_region.Subtract(iter.geometry_rect()); 543 missing_region.Subtract(iter.geometry_rect());
527 } 544 }
528 } 545 }
529 546
530 return missing_region.IsEmpty(); 547 return missing_region.IsEmpty();
531 } 548 }
532 549
533 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { 550 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) {
534 DCHECK(contents_scale >= MinimumContentsScale()); 551 DCHECK(contents_scale >= MinimumContentsScale());
535 552
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { 810 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const {
794 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 811 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
795 LayerImpl::AsValueInto(state.get()); 812 LayerImpl::AsValueInto(state.get());
796 813
797 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); 814 state->SetDouble("ideal_contents_scale", ideal_contents_scale_);
798 state->Set("tilings", tilings_->AsValue().release()); 815 state->Set("tilings", tilings_->AsValue().release());
799 return state.PassAs<base::Value>(); 816 return state.PassAs<base::Value>();
800 } 817 }
801 818
802 } // namespace cc 819 } // namespace cc
OLDNEW
« no previous file with comments | « cc/cc.gyp ('k') | cc/picture_layer_tiling_set.cc » ('j') | cc/tile.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698