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

Side by Side Diff: cc/paint/discardable_image_store.cc

Issue 2857923004: cc: Keep PaintImage in DrawImage. (Closed)
Patch Set: dependent branch Created 3 years, 7 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 | « cc/paint/discardable_image_store.h ('k') | cc/paint/draw_image.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/paint/discardable_image_store.h" 5 #include "cc/paint/discardable_image_store.h"
6 6
7 #include "base/containers/adapters.h" 7 #include "base/containers/adapters.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "cc/paint/display_item_list.h" 9 #include "cc/paint/display_item_list.h"
10 #include "third_party/skia/include/utils/SkNoDrawCanvas.h" 10 #include "third_party/skia/include/utils/SkNoDrawCanvas.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 if (shader) { 180 if (shader) {
181 SkMatrix matrix; 181 SkMatrix matrix;
182 SkShader::TileMode xy[2]; 182 SkShader::TileMode xy[2];
183 SkImage* image = shader->isAImage(&matrix, xy); 183 SkImage* image = shader->isAImage(&matrix, xy);
184 if (image) { 184 if (image) {
185 PaintImage paint_image(sk_ref_sp(image), 185 PaintImage paint_image(sk_ref_sp(image),
186 PaintImage::AnimationType::UNKNOWN, 186 PaintImage::AnimationType::UNKNOWN,
187 PaintImage::CompletionState::UNKNOWN); 187 PaintImage::CompletionState::UNKNOWN);
188 // TODO(ericrk): Handle cases where we only need a sub-rect from the 188 // TODO(ericrk): Handle cases where we only need a sub-rect from the
189 // image. crbug.com/671821 189 // image. crbug.com/671821
190 AddImage(paint_image, SkRect::MakeFromIRect(image->bounds()), rect, 190 AddImage(std::move(paint_image), SkRect::MakeFromIRect(image->bounds()),
191 &matrix, flags); 191 rect, &matrix, flags);
192 } 192 }
193 } 193 }
194 } 194 }
195 195
196 void DiscardableImageStore::AddImage(const PaintImage& paint_image, 196 void DiscardableImageStore::AddImage(PaintImage paint_image,
197 const SkRect& src_rect, 197 const SkRect& src_rect,
198 const SkRect& rect, 198 const SkRect& rect,
199 const SkMatrix* local_matrix, 199 const SkMatrix* local_matrix,
200 const PaintFlags& flags) { 200 const PaintFlags& flags) {
201 sk_sp<const SkImage> sk_image = paint_image.sk_image(); 201 if (!paint_image.sk_image()->isLazyGenerated())
202 if (!sk_image->isLazyGenerated())
203 return; 202 return;
204 203
205 const SkRect& clip_rect = SkRect::Make(canvas_->getDeviceClipBounds()); 204 const SkRect& clip_rect = SkRect::Make(canvas_->getDeviceClipBounds());
206 const SkMatrix& ctm = canvas_->getTotalMatrix(); 205 const SkMatrix& ctm = canvas_->getTotalMatrix();
207 206
208 SkRect paint_rect = MapRect(ctm, rect); 207 SkRect paint_rect = MapRect(ctm, rect);
209 bool computed_paint_bounds = 208 bool computed_paint_bounds =
210 canvas_->ComputePaintBounds(paint_rect, ToSkPaint(&flags), &paint_rect); 209 canvas_->ComputePaintBounds(paint_rect, ToSkPaint(&flags), &paint_rect);
211 if (!computed_paint_bounds) { 210 if (!computed_paint_bounds) {
212 // TODO(vmpstr): UMA this case. 211 // TODO(vmpstr): UMA this case.
(...skipping 23 matching lines...) Expand all
236 image_rect.Inset(-1, -1); 235 image_rect.Inset(-1, -1);
237 236
238 // The true target color space will be assigned when it is known, in 237 // The true target color space will be assigned when it is known, in
239 // GetDiscardableImagesInRect. 238 // GetDiscardableImagesInRect.
240 gfx::ColorSpace target_color_space; 239 gfx::ColorSpace target_color_space;
241 240
242 SkMatrix matrix = ctm; 241 SkMatrix matrix = ctm;
243 if (local_matrix) 242 if (local_matrix)
244 matrix.postConcat(*local_matrix); 243 matrix.postConcat(*local_matrix);
245 244
246 // TODO(khushalsagar): Keep PaintImage in DrawImage. 245 (*image_id_to_rect_)[paint_image.sk_image()->uniqueID()].Union(image_rect);
vmpstr 2017/05/09 22:42:54 can you make a comment here to explain why we use
247 (*image_id_to_rect_)[sk_image->uniqueID()].Union(image_rect);
248 image_set_->push_back( 246 image_set_->push_back(
249 std::make_pair(DrawImage(std::move(sk_image), src_irect, filter_quality, 247 std::make_pair(DrawImage(std::move(paint_image), src_irect,
250 matrix, target_color_space), 248 filter_quality, matrix, target_color_space),
251 image_rect)); 249 image_rect));
252 } 250 }
253 251
254 } // namespace cc 252 } // namespace cc
OLDNEW
« no previous file with comments | « cc/paint/discardable_image_store.h ('k') | cc/paint/draw_image.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698