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

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

Issue 2830243002: cc: Don't perform image analysis if the DisplayItemList has no images. (Closed)
Patch Set: rebase 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/paint_op_buffer.h ('k') | cc/paint/paint_op_buffer_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 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/paint_op_buffer.h" 5 #include "cc/paint/paint_op_buffer.h"
6 6
7 #include "cc/paint/display_item_list.h" 7 #include "cc/paint/display_item_list.h"
8 #include "cc/paint/paint_record.h" 8 #include "cc/paint/paint_record.h"
9 #include "third_party/skia/include/core/SkAnnotation.h" 9 #include "third_party/skia/include/core/SkAnnotation.h"
10 10
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 AnnotateOp::~AnnotateOp() = default; 495 AnnotateOp::~AnnotateOp() = default;
496 496
497 DrawDisplayItemListOp::DrawDisplayItemListOp( 497 DrawDisplayItemListOp::DrawDisplayItemListOp(
498 scoped_refptr<DisplayItemList> list) 498 scoped_refptr<DisplayItemList> list)
499 : list(list) {} 499 : list(list) {}
500 500
501 size_t DrawDisplayItemListOp::AdditionalBytesUsed() const { 501 size_t DrawDisplayItemListOp::AdditionalBytesUsed() const {
502 return list->ApproximateMemoryUsage(); 502 return list->ApproximateMemoryUsage();
503 } 503 }
504 504
505 bool DrawDisplayItemListOp::HasDiscardableImages() const {
506 return list->has_discardable_images();
507 }
508
505 DrawDisplayItemListOp::DrawDisplayItemListOp(const DrawDisplayItemListOp& op) = 509 DrawDisplayItemListOp::DrawDisplayItemListOp(const DrawDisplayItemListOp& op) =
506 default; 510 default;
507 511
508 DrawDisplayItemListOp& DrawDisplayItemListOp::operator=( 512 DrawDisplayItemListOp& DrawDisplayItemListOp::operator=(
509 const DrawDisplayItemListOp& op) = default; 513 const DrawDisplayItemListOp& op) = default;
510 514
511 DrawDisplayItemListOp::~DrawDisplayItemListOp() = default; 515 DrawDisplayItemListOp::~DrawDisplayItemListOp() = default;
512 516
513 DrawImageOp::DrawImageOp(const PaintImage& image, 517 DrawImageOp::DrawImageOp(const PaintImage& image,
514 SkScalar left, 518 SkScalar left,
515 SkScalar top, 519 SkScalar top,
516 const PaintFlags* flags) 520 const PaintFlags* flags)
517 : PaintOpWithFlags(flags ? *flags : PaintFlags()), 521 : PaintOpWithFlags(flags ? *flags : PaintFlags()),
518 image(image), 522 image(image),
519 left(left), 523 left(left),
520 top(top) {} 524 top(top) {}
521 525
526 bool DrawImageOp::HasDiscardableImages() const {
527 // TODO(khushalsagar): Callers should not be able to change the lazy generated
528 // state for a PaintImage.
529 return image.sk_image()->isLazyGenerated();
530 }
531
522 DrawImageOp::~DrawImageOp() = default; 532 DrawImageOp::~DrawImageOp() = default;
523 533
524 DrawImageRectOp::DrawImageRectOp(const PaintImage& image, 534 DrawImageRectOp::DrawImageRectOp(const PaintImage& image,
525 const SkRect& src, 535 const SkRect& src,
526 const SkRect& dst, 536 const SkRect& dst,
527 const PaintFlags* flags, 537 const PaintFlags* flags,
528 PaintCanvas::SrcRectConstraint constraint) 538 PaintCanvas::SrcRectConstraint constraint)
529 : PaintOpWithFlags(flags ? *flags : PaintFlags()), 539 : PaintOpWithFlags(flags ? *flags : PaintFlags()),
530 image(image), 540 image(image),
531 src(src), 541 src(src),
532 dst(dst), 542 dst(dst),
533 constraint(constraint) {} 543 constraint(constraint) {}
534 544
545 bool DrawImageRectOp::HasDiscardableImages() const {
546 return image.sk_image()->isLazyGenerated();
547 }
548
535 DrawImageRectOp::~DrawImageRectOp() = default; 549 DrawImageRectOp::~DrawImageRectOp() = default;
536 550
537 DrawPosTextOp::DrawPosTextOp(size_t bytes, 551 DrawPosTextOp::DrawPosTextOp(size_t bytes,
538 size_t count, 552 size_t count,
539 const PaintFlags& flags) 553 const PaintFlags& flags)
540 : PaintOpWithArray(flags, bytes, count) {} 554 : PaintOpWithArray(flags, bytes, count) {}
541 555
542 DrawPosTextOp::~DrawPosTextOp() = default; 556 DrawPosTextOp::~DrawPosTextOp() = default;
543 557
544 DrawRecordOp::DrawRecordOp(sk_sp<const PaintRecord> record) 558 DrawRecordOp::DrawRecordOp(sk_sp<const PaintRecord> record)
545 : record(std::move(record)) {} 559 : record(std::move(record)) {}
546 560
547 DrawRecordOp::~DrawRecordOp() = default; 561 DrawRecordOp::~DrawRecordOp() = default;
548 562
549 size_t DrawRecordOp::AdditionalBytesUsed() const { 563 size_t DrawRecordOp::AdditionalBytesUsed() const {
550 return record->approximateBytesUsed(); 564 return record->approximateBytesUsed();
551 } 565 }
552 566
567 bool DrawRecordOp::HasDiscardableImages() const {
568 return record->HasDiscardableImages();
569 }
570
553 DrawTextBlobOp::DrawTextBlobOp(sk_sp<SkTextBlob> blob, 571 DrawTextBlobOp::DrawTextBlobOp(sk_sp<SkTextBlob> blob,
554 SkScalar x, 572 SkScalar x,
555 SkScalar y, 573 SkScalar y,
556 const PaintFlags& flags) 574 const PaintFlags& flags)
557 : PaintOpWithFlags(flags), blob(std::move(blob)), x(x), y(y) {} 575 : PaintOpWithFlags(flags), blob(std::move(blob)), x(x), y(y) {}
558 576
559 DrawTextBlobOp::~DrawTextBlobOp() = default; 577 DrawTextBlobOp::~DrawTextBlobOp() = default;
560 578
561 PaintOpBuffer::PaintOpBuffer() : cull_rect_(SkRect::MakeEmpty()) {} 579 PaintOpBuffer::PaintOpBuffer() : cull_rect_(SkRect::MakeEmpty()) {}
562 580
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 return std::make_pair(op, skip); 707 return std::make_pair(op, skip);
690 } 708 }
691 709
692 void PaintOpBuffer::ShrinkToFit() { 710 void PaintOpBuffer::ShrinkToFit() {
693 if (!used_ || used_ == reserved_) 711 if (!used_ || used_ == reserved_)
694 return; 712 return;
695 ReallocBuffer(used_); 713 ReallocBuffer(used_);
696 } 714 }
697 715
698 } // namespace cc 716 } // namespace cc
OLDNEW
« no previous file with comments | « cc/paint/paint_op_buffer.h ('k') | cc/paint/paint_op_buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698