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

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

Issue 2830243002: cc: Don't perform image analysis if the DisplayItemList has no images. (Closed)
Patch Set: for-draw-ops-only Created 3 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/display_item_list.h" 5 #include "cc/paint/display_item_list.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 TRACE_EVENT0("cc", "DisplayItemList::Finalize"); 255 TRACE_EVENT0("cc", "DisplayItemList::Finalize");
256 DCHECK(items_.size() == visual_rects_.size()) 256 DCHECK(items_.size() == visual_rects_.size())
257 << "items.size() " << items_.size() << " visual_rects.size() " 257 << "items.size() " << items_.size() << " visual_rects.size() "
258 << visual_rects_.size(); 258 << visual_rects_.size();
259 rtree_.Build(visual_rects_); 259 rtree_.Build(visual_rects_);
260 260
261 if (!retain_visual_rects_) 261 if (!retain_visual_rects_)
262 // This clears both the vector and the vector's capacity, since 262 // This clears both the vector and the vector's capacity, since
263 // visual_rects won't be used anymore. 263 // visual_rects won't be used anymore.
264 std::vector<gfx::Rect>().swap(visual_rects_); 264 std::vector<gfx::Rect>().swap(visual_rects_);
265
266 GenerateDiscardableImagesMetadata();
265 } 267 }
266 268
267 bool DisplayItemList::IsSuitableForGpuRasterization() const { 269 bool DisplayItemList::IsSuitableForGpuRasterization() const {
268 // TODO(wkorman): This is more permissive than Picture's implementation, since 270 // TODO(wkorman): This is more permissive than Picture's implementation, since
269 // none of the items might individually trigger a veto even though they 271 // none of the items might individually trigger a veto even though they
270 // collectively have enough "bad" operations that a corresponding Picture 272 // collectively have enough "bad" operations that a corresponding Picture
271 // would get vetoed. See crbug.com/513016. 273 // would get vetoed. See crbug.com/513016.
272 return all_items_are_suitable_for_gpu_rasterization_; 274 return all_items_are_suitable_for_gpu_rasterization_;
273 } 275 }
274 276
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 PictureDebugUtil::SerializeAsBase64(picture.get(), &b64_picture); 521 PictureDebugUtil::SerializeAsBase64(picture.get(), &b64_picture);
520 state->SetString("skp64", b64_picture); 522 state->SetString("skp64", b64_picture);
521 } 523 }
522 524
523 return state; 525 return state;
524 } 526 }
525 527
526 void DisplayItemList::GenerateDiscardableImagesMetadata() { 528 void DisplayItemList::GenerateDiscardableImagesMetadata() {
527 // This should be only called once. 529 // This should be only called once.
528 DCHECK(image_map_.empty()); 530 DCHECK(image_map_.empty());
531 if (!has_discardable_images_)
532 return;
529 533
530 gfx::Rect bounds = rtree_.GetBounds(); 534 gfx::Rect bounds = rtree_.GetBounds();
531 DiscardableImageMap::ScopedMetadataGenerator generator( 535 DiscardableImageMap::ScopedMetadataGenerator generator(
532 &image_map_, gfx::Size(bounds.right(), bounds.bottom())); 536 &image_map_, gfx::Size(bounds.right(), bounds.bottom()));
533 auto* canvas = generator.canvas(); 537 auto* canvas = generator.canvas();
534 for (const auto& item : items_) 538 for (const auto& item : items_)
535 RasterItem(item, canvas, nullptr); 539 RasterItem(item, canvas, nullptr);
536 } 540 }
537 541
538 void DisplayItemList::GetDiscardableImagesInRect( 542 void DisplayItemList::GetDiscardableImagesInRect(
539 const gfx::Rect& rect, 543 const gfx::Rect& rect,
540 float contents_scale, 544 float contents_scale,
541 const gfx::ColorSpace& target_color_space, 545 const gfx::ColorSpace& target_color_space,
542 std::vector<DrawImage>* images) { 546 std::vector<DrawImage>* images) {
543 image_map_.GetDiscardableImagesInRect(rect, contents_scale, 547 image_map_.GetDiscardableImagesInRect(rect, contents_scale,
544 target_color_space, images); 548 target_color_space, images);
545 } 549 }
546 550
547 gfx::Rect DisplayItemList::GetRectForImage(ImageId image_id) const { 551 gfx::Rect DisplayItemList::GetRectForImage(ImageId image_id) const {
548 return image_map_.GetRectForImage(image_id); 552 return image_map_.GetRectForImage(image_id);
549 } 553 }
550 554
551 } // namespace cc 555 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698