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

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: confirmed weird matrix. 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/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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 AnnotateOp::~AnnotateOp() = default; 478 AnnotateOp::~AnnotateOp() = default;
479 479
480 DrawDisplayItemListOp::DrawDisplayItemListOp( 480 DrawDisplayItemListOp::DrawDisplayItemListOp(
481 scoped_refptr<DisplayItemList> list) 481 scoped_refptr<DisplayItemList> list)
482 : list(list) {} 482 : list(list) {}
483 483
484 size_t DrawDisplayItemListOp::AdditionalBytesUsed() const { 484 size_t DrawDisplayItemListOp::AdditionalBytesUsed() const {
485 return list->ApproximateMemoryUsage(); 485 return list->ApproximateMemoryUsage();
486 } 486 }
487 487
488 bool DrawDisplayItemListOp::HasDiscardableImages() const {
489 return list->has_discardable_images();
490 }
491
488 DrawDisplayItemListOp::DrawDisplayItemListOp(const DrawDisplayItemListOp& op) = 492 DrawDisplayItemListOp::DrawDisplayItemListOp(const DrawDisplayItemListOp& op) =
489 default; 493 default;
490 494
491 DrawDisplayItemListOp& DrawDisplayItemListOp::operator=( 495 DrawDisplayItemListOp& DrawDisplayItemListOp::operator=(
492 const DrawDisplayItemListOp& op) = default; 496 const DrawDisplayItemListOp& op) = default;
493 497
494 DrawDisplayItemListOp::~DrawDisplayItemListOp() = default; 498 DrawDisplayItemListOp::~DrawDisplayItemListOp() = default;
495 499
496 DrawImageOp::DrawImageOp(const PaintImage& image, 500 DrawImageOp::DrawImageOp(const PaintImage& image,
497 SkScalar left, 501 SkScalar left,
498 SkScalar top, 502 SkScalar top,
499 const PaintFlags* flags) 503 const PaintFlags* flags)
500 : PaintOpWithFlags(flags ? *flags : PaintFlags()), 504 : PaintOpWithFlags(flags ? *flags : PaintFlags()),
501 image(image), 505 image(image),
502 left(left), 506 left(left),
503 top(top) {} 507 top(top) {}
504 508
509 bool DrawImageOp::HasDiscardableImages() const {
510 // TODO(khushalsagar): Callers should not be able to change the lazy generated
511 // state for a PaintImage.
512 return image.sk_image()->isLazyGenerated();
513 }
514
505 DrawImageOp::~DrawImageOp() = default; 515 DrawImageOp::~DrawImageOp() = default;
506 516
507 DrawImageRectOp::DrawImageRectOp(const PaintImage& image, 517 DrawImageRectOp::DrawImageRectOp(const PaintImage& image,
508 const SkRect& src, 518 const SkRect& src,
509 const SkRect& dst, 519 const SkRect& dst,
510 const PaintFlags* flags, 520 const PaintFlags* flags,
511 PaintCanvas::SrcRectConstraint constraint) 521 PaintCanvas::SrcRectConstraint constraint)
512 : PaintOpWithFlags(flags ? *flags : PaintFlags()), 522 : PaintOpWithFlags(flags ? *flags : PaintFlags()),
513 image(image), 523 image(image),
514 src(src), 524 src(src),
515 dst(dst), 525 dst(dst),
516 constraint(constraint) {} 526 constraint(constraint) {}
517 527
528 bool DrawImageRectOp::HasDiscardableImages() const {
529 return image.sk_image()->isLazyGenerated();
530 }
531
518 DrawImageRectOp::~DrawImageRectOp() = default; 532 DrawImageRectOp::~DrawImageRectOp() = default;
519 533
520 DrawPosTextOp::DrawPosTextOp(size_t bytes, 534 DrawPosTextOp::DrawPosTextOp(size_t bytes,
521 size_t count, 535 size_t count,
522 const PaintFlags& flags) 536 const PaintFlags& flags)
523 : PaintOpWithArray(flags, bytes, count) {} 537 : PaintOpWithArray(flags, bytes, count) {}
524 538
525 DrawPosTextOp::~DrawPosTextOp() = default; 539 DrawPosTextOp::~DrawPosTextOp() = default;
526 540
527 DrawRecordOp::DrawRecordOp(sk_sp<const PaintRecord> record) 541 DrawRecordOp::DrawRecordOp(sk_sp<const PaintRecord> record)
528 : record(std::move(record)) {} 542 : record(std::move(record)) {}
529 543
530 DrawRecordOp::~DrawRecordOp() = default; 544 DrawRecordOp::~DrawRecordOp() = default;
531 545
532 size_t DrawRecordOp::AdditionalBytesUsed() const { 546 size_t DrawRecordOp::AdditionalBytesUsed() const {
533 return record->approximateBytesUsed(); 547 return record->approximateBytesUsed();
534 } 548 }
535 549
550 bool DrawRecordOp::HasDiscardableImages() const {
551 return record->HasDiscardableImages();
552 }
553
536 DrawTextBlobOp::DrawTextBlobOp(sk_sp<SkTextBlob> blob, 554 DrawTextBlobOp::DrawTextBlobOp(sk_sp<SkTextBlob> blob,
537 SkScalar x, 555 SkScalar x,
538 SkScalar y, 556 SkScalar y,
539 const PaintFlags& flags) 557 const PaintFlags& flags)
540 : PaintOpWithFlags(flags), blob(std::move(blob)), x(x), y(y) {} 558 : PaintOpWithFlags(flags), blob(std::move(blob)), x(x), y(y) {}
541 559
542 DrawTextBlobOp::~DrawTextBlobOp() = default; 560 DrawTextBlobOp::~DrawTextBlobOp() = default;
543 561
544 PaintOpBuffer::PaintOpBuffer() : cull_rect_(SkRect::MakeEmpty()) {} 562 PaintOpBuffer::PaintOpBuffer() : cull_rect_(SkRect::MakeEmpty()) {}
545 563
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 return std::make_pair(op, skip); 690 return std::make_pair(op, skip);
673 } 691 }
674 692
675 void PaintOpBuffer::ShrinkToFit() { 693 void PaintOpBuffer::ShrinkToFit() {
676 if (!used_ || used_ == reserved_) 694 if (!used_ || used_ == reserved_)
677 return; 695 return;
678 ReallocBuffer(used_); 696 ReallocBuffer(used_);
679 } 697 }
680 698
681 } // namespace cc 699 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698