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

Side by Side Diff: cc/playback/discardable_image_map.cc

Issue 2743203006: cc: Outset image rects by 1 for the purposes of the rtree. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | cc/playback/discardable_image_map_unittest.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/playback/discardable_image_map.h" 5 #include "cc/playback/discardable_image_map.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 return false; 165 return false;
166 *paint_bounds = 166 *paint_bounds =
167 current_paint->computeFastBounds(*paint_bounds, paint_bounds); 167 current_paint->computeFastBounds(*paint_bounds, paint_bounds);
168 } 168 }
169 169
170 for (const auto& paint : base::Reversed(saved_paints_)) { 170 for (const auto& paint : base::Reversed(saved_paints_)) {
171 if (!paint.canComputeFastBounds()) 171 if (!paint.canComputeFastBounds())
172 return false; 172 return false;
173 *paint_bounds = paint.computeFastBounds(*paint_bounds, paint_bounds); 173 *paint_bounds = paint.computeFastBounds(*paint_bounds, paint_bounds);
174 } 174 }
175
175 return true; 176 return true;
176 } 177 }
177 178
178 void AddImage(sk_sp<const SkImage> image, 179 void AddImage(sk_sp<const SkImage> image,
179 const SkRect& src_rect, 180 const SkRect& src_rect,
180 const SkRect& rect, 181 const SkRect& rect,
181 const SkMatrix& matrix, 182 const SkMatrix& matrix,
182 const SkPaint* paint) { 183 const SkPaint* paint) {
183 if (!image->isLazyGenerated()) 184 if (!image->isLazyGenerated())
184 return; 185 return;
(...skipping 10 matching lines...) Expand all
195 196
196 SkFilterQuality filter_quality = kNone_SkFilterQuality; 197 SkFilterQuality filter_quality = kNone_SkFilterQuality;
197 if (paint) { 198 if (paint) {
198 filter_quality = paint->getFilterQuality(); 199 filter_quality = paint->getFilterQuality();
199 } 200 }
200 201
201 SkIRect src_irect; 202 SkIRect src_irect;
202 src_rect.roundOut(&src_irect); 203 src_rect.roundOut(&src_irect);
203 gfx::Rect image_rect = SafeClampPaintRectToSize(paint_rect, canvas_size_); 204 gfx::Rect image_rect = SafeClampPaintRectToSize(paint_rect, canvas_size_);
204 205
206 // During raster, we use the device clip bounds on the canvas, which outsets
207 // the actual clip by 1 due to the possibility of antialiasing. Account for
208 // this here by outsetting the image rect by 1. Note that this only affects
209 // queries into the rtree, which will now return images that only touch the
210 // bounds of the query rect.
211 //
212 // Note that it's not sufficient for us to inset the device clip bounds at
213 // raster time, since we might be sending a larger-than-one-item display
214 // item to skia, which means that skia will internally determine whether to
215 // raster the picture (using device clip bounds that are outset).
216 image_rect.Inset(-1, -1);
217
205 (*image_id_to_rect_)[image->uniqueID()].Union(image_rect); 218 (*image_id_to_rect_)[image->uniqueID()].Union(image_rect);
206 image_set_->push_back(std::make_pair( 219 image_set_->push_back(std::make_pair(
207 DrawImage(std::move(image), src_irect, filter_quality, matrix), 220 DrawImage(std::move(image), src_irect, filter_quality, matrix),
208 image_rect)); 221 image_rect));
209 } 222 }
210 223
211 // Currently this function only handles extracting images from SkImageShaders 224 // Currently this function only handles extracting images from SkImageShaders
212 // embedded in SkPaints. Other embedded image cases, such as SkPictures, 225 // embedded in SkPaints. Other embedded image cases, such as SkPictures,
213 // are not yet handled. 226 // are not yet handled.
214 void AddPaintImage(const SkRect& rect, const SkPaint& paint) { 227 void AddPaintImage(const SkRect& rect, const SkPaint& paint) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 DiscardableImageMap* image_map, 287 DiscardableImageMap* image_map,
275 const gfx::Size& bounds) 288 const gfx::Size& bounds)
276 : image_map_(image_map), 289 : image_map_(image_map),
277 metadata_canvas_(image_map->BeginGeneratingMetadata(bounds)) {} 290 metadata_canvas_(image_map->BeginGeneratingMetadata(bounds)) {}
278 291
279 DiscardableImageMap::ScopedMetadataGenerator::~ScopedMetadataGenerator() { 292 DiscardableImageMap::ScopedMetadataGenerator::~ScopedMetadataGenerator() {
280 image_map_->EndGeneratingMetadata(); 293 image_map_->EndGeneratingMetadata();
281 } 294 }
282 295
283 } // namespace cc 296 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/playback/discardable_image_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698