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

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

Issue 2880813002: Revert of Add stable id to PaintImage. (Closed)
Patch Set: 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/paint_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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 std::vector<SkPaint> saved_paints_; 68 std::vector<SkPaint> saved_paints_;
69 }; 69 };
70 70
71 DiscardableImageStore::DiscardableImageStore( 71 DiscardableImageStore::DiscardableImageStore(
72 int width, 72 int width,
73 int height, 73 int height,
74 std::vector<std::pair<DrawImage, gfx::Rect>>* image_set, 74 std::vector<std::pair<DrawImage, gfx::Rect>>* image_set,
75 base::flat_map<ImageId, gfx::Rect>* image_id_to_rect) 75 base::flat_map<ImageId, gfx::Rect>* image_id_to_rect)
76 : canvas_(base::MakeUnique<PaintTrackingCanvas>(width, height)), 76 : canvas_(base::MakeUnique<PaintTrackingCanvas>(width, height)),
77 image_set_(image_set), 77 image_set_(image_set),
78 image_id_to_rect_(image_id_to_rect), 78 image_id_to_rect_(image_id_to_rect) {}
79 unknown_stable_id_(PaintImage::GetNextId()) {}
80 79
81 DiscardableImageStore::~DiscardableImageStore() = default; 80 DiscardableImageStore::~DiscardableImageStore() = default;
82 81
83 SkNoDrawCanvas* DiscardableImageStore::GetNoDrawCanvas() { 82 SkNoDrawCanvas* DiscardableImageStore::GetNoDrawCanvas() {
84 return canvas_.get(); 83 return canvas_.get();
85 } 84 }
86 85
87 void DiscardableImageStore::GatherDiscardableImages( 86 void DiscardableImageStore::GatherDiscardableImages(
88 const PaintOpBuffer* buffer) { 87 const PaintOpBuffer* buffer) {
89 if (!buffer->HasDiscardableImages()) 88 if (!buffer->HasDiscardableImages())
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // embedded in SkPaints. Other embedded image cases, such as SkPictures, 175 // embedded in SkPaints. Other embedded image cases, such as SkPictures,
177 // are not yet handled. 176 // are not yet handled.
178 void DiscardableImageStore::AddImageFromFlags(const SkRect& rect, 177 void DiscardableImageStore::AddImageFromFlags(const SkRect& rect,
179 const PaintFlags& flags) { 178 const PaintFlags& flags) {
180 SkShader* shader = flags.getShader(); 179 SkShader* shader = flags.getShader();
181 if (shader) { 180 if (shader) {
182 SkMatrix matrix; 181 SkMatrix matrix;
183 SkShader::TileMode xy[2]; 182 SkShader::TileMode xy[2];
184 SkImage* image = shader->isAImage(&matrix, xy); 183 SkImage* image = shader->isAImage(&matrix, xy);
185 if (image) { 184 if (image) {
186 PaintImage paint_image(unknown_stable_id_, sk_ref_sp(image), 185 PaintImage paint_image(sk_ref_sp(image),
187 PaintImage::AnimationType::UNKNOWN, 186 PaintImage::AnimationType::UNKNOWN,
188 PaintImage::CompletionState::UNKNOWN); 187 PaintImage::CompletionState::UNKNOWN);
189 // 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
190 // image. crbug.com/671821 189 // image. crbug.com/671821
191 AddImage(paint_image, SkRect::MakeFromIRect(image->bounds()), rect, 190 AddImage(paint_image, SkRect::MakeFromIRect(image->bounds()), rect,
192 &matrix, flags); 191 &matrix, flags);
193 } 192 }
194 } 193 }
195 } 194 }
196 195
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 245
247 // TODO(khushalsagar): Keep PaintImage in DrawImage. 246 // TODO(khushalsagar): Keep PaintImage in DrawImage.
248 (*image_id_to_rect_)[sk_image->uniqueID()].Union(image_rect); 247 (*image_id_to_rect_)[sk_image->uniqueID()].Union(image_rect);
249 image_set_->push_back( 248 image_set_->push_back(
250 std::make_pair(DrawImage(std::move(sk_image), src_irect, filter_quality, 249 std::make_pair(DrawImage(std::move(sk_image), src_irect, filter_quality,
251 matrix, target_color_space), 250 matrix, target_color_space),
252 image_rect)); 251 image_rect));
253 } 252 }
254 253
255 } // namespace cc 254 } // namespace cc
OLDNEW
« no previous file with comments | « cc/paint/discardable_image_store.h ('k') | cc/paint/paint_image.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698