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

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

Issue 2857923004: cc: Keep PaintImage in DrawImage. (Closed)
Patch Set: rebased 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
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 if (shader) { 181 if (shader) {
182 SkMatrix matrix; 182 SkMatrix matrix;
183 SkShader::TileMode xy[2]; 183 SkShader::TileMode xy[2];
184 SkImage* image = shader->isAImage(&matrix, xy); 184 SkImage* image = shader->isAImage(&matrix, xy);
185 if (image) { 185 if (image) {
186 PaintImage paint_image(unknown_stable_id_, sk_ref_sp(image), 186 PaintImage paint_image(unknown_stable_id_, sk_ref_sp(image),
187 PaintImage::AnimationType::UNKNOWN, 187 PaintImage::AnimationType::UNKNOWN,
188 PaintImage::CompletionState::UNKNOWN); 188 PaintImage::CompletionState::UNKNOWN);
189 // TODO(ericrk): Handle cases where we only need a sub-rect from the 189 // TODO(ericrk): Handle cases where we only need a sub-rect from the
190 // image. crbug.com/671821 190 // image. crbug.com/671821
191 AddImage(paint_image, SkRect::MakeFromIRect(image->bounds()), rect, 191 AddImage(std::move(paint_image), SkRect::MakeFromIRect(image->bounds()),
192 &matrix, flags); 192 rect, &matrix, flags);
193 } 193 }
194 } 194 }
195 } 195 }
196 196
197 void DiscardableImageStore::AddImage(const PaintImage& paint_image, 197 void DiscardableImageStore::AddImage(PaintImage paint_image,
198 const SkRect& src_rect, 198 const SkRect& src_rect,
199 const SkRect& rect, 199 const SkRect& rect,
200 const SkMatrix* local_matrix, 200 const SkMatrix* local_matrix,
201 const PaintFlags& flags) { 201 const PaintFlags& flags) {
202 sk_sp<const SkImage> sk_image = paint_image.sk_image(); 202 if (!paint_image.sk_image()->isLazyGenerated())
203 if (!sk_image->isLazyGenerated())
204 return; 203 return;
205 204
206 const SkRect& clip_rect = SkRect::Make(canvas_->getDeviceClipBounds()); 205 const SkRect& clip_rect = SkRect::Make(canvas_->getDeviceClipBounds());
207 const SkMatrix& ctm = canvas_->getTotalMatrix(); 206 const SkMatrix& ctm = canvas_->getTotalMatrix();
208 207
209 SkRect paint_rect = MapRect(ctm, rect); 208 SkRect paint_rect = MapRect(ctm, rect);
210 bool computed_paint_bounds = 209 bool computed_paint_bounds =
211 canvas_->ComputePaintBounds(paint_rect, ToSkPaint(&flags), &paint_rect); 210 canvas_->ComputePaintBounds(paint_rect, ToSkPaint(&flags), &paint_rect);
212 if (!computed_paint_bounds) { 211 if (!computed_paint_bounds) {
213 // TODO(vmpstr): UMA this case. 212 // TODO(vmpstr): UMA this case.
(...skipping 23 matching lines...) Expand all
237 image_rect.Inset(-1, -1); 236 image_rect.Inset(-1, -1);
238 237
239 // The true target color space will be assigned when it is known, in 238 // The true target color space will be assigned when it is known, in
240 // GetDiscardableImagesInRect. 239 // GetDiscardableImagesInRect.
241 gfx::ColorSpace target_color_space; 240 gfx::ColorSpace target_color_space;
242 241
243 SkMatrix matrix = ctm; 242 SkMatrix matrix = ctm;
244 if (local_matrix) 243 if (local_matrix)
245 matrix.postConcat(*local_matrix); 244 matrix.postConcat(*local_matrix);
246 245
247 // TODO(khushalsagar): Keep PaintImage in DrawImage. 246 (*image_id_to_rect_)[paint_image.stable_id()].Union(image_rect);
248 (*image_id_to_rect_)[sk_image->uniqueID()].Union(image_rect);
249 image_set_->push_back( 247 image_set_->push_back(
250 std::make_pair(DrawImage(std::move(sk_image), src_irect, filter_quality, 248 std::make_pair(DrawImage(std::move(paint_image), src_irect,
251 matrix, target_color_space), 249 filter_quality, matrix, target_color_space),
252 image_rect)); 250 image_rect));
253 } 251 }
254 252
255 } // namespace cc 253 } // namespace cc
OLDNEW
« no previous file with comments | « cc/paint/discardable_image_store.h ('k') | cc/paint/draw_image.h » ('j') | cc/paint/image_id.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698