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

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: 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
« cc/paint/paint_op_buffer.h ('K') | « cc/paint/paint_op_buffer.h ('k') | no next file » | 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 AnnotateOp::~AnnotateOp() = default; 409 AnnotateOp::~AnnotateOp() = default;
410 410
411 DrawDisplayItemListOp::DrawDisplayItemListOp( 411 DrawDisplayItemListOp::DrawDisplayItemListOp(
412 scoped_refptr<DisplayItemList> list) 412 scoped_refptr<DisplayItemList> list)
413 : list(list) {} 413 : list(list) {}
414 414
415 size_t DrawDisplayItemListOp::AdditionalBytesUsed() const { 415 size_t DrawDisplayItemListOp::AdditionalBytesUsed() const {
416 return list->ApproximateMemoryUsage(); 416 return list->ApproximateMemoryUsage();
417 } 417 }
418 418
419 bool DrawDisplayItemListOp::HasDiscardableImages() const {
420 return list->has_discardable_images();
421 }
422
419 DrawDisplayItemListOp::DrawDisplayItemListOp(const DrawDisplayItemListOp& op) = 423 DrawDisplayItemListOp::DrawDisplayItemListOp(const DrawDisplayItemListOp& op) =
420 default; 424 default;
421 425
422 DrawDisplayItemListOp& DrawDisplayItemListOp::operator=( 426 DrawDisplayItemListOp& DrawDisplayItemListOp::operator=(
423 const DrawDisplayItemListOp& op) = default; 427 const DrawDisplayItemListOp& op) = default;
424 428
425 DrawDisplayItemListOp::~DrawDisplayItemListOp() = default; 429 DrawDisplayItemListOp::~DrawDisplayItemListOp() = default;
426 430
427 DrawImageOp::DrawImageOp(const PaintImage& image, 431 DrawImageOp::DrawImageOp(const PaintImage& image,
428 SkScalar left, 432 SkScalar left,
429 SkScalar top, 433 SkScalar top,
430 const PaintFlags* flags) 434 const PaintFlags* flags)
431 : image(image), 435 : image(image),
432 left(left), 436 left(left),
433 top(top), 437 top(top),
434 flags(flags ? *flags : PaintFlags()) {} 438 flags(flags ? *flags : PaintFlags()) {}
435 439
440 bool DrawImageOp::HasDiscardableImages() const {
441 // TODO(khushalsagar): Callers should not be able to change the lazy generated
442 // state for a PaintImage.
443 return image.sk_image()->isLazyGenerated();
444 }
445
436 DrawImageOp::~DrawImageOp() = default; 446 DrawImageOp::~DrawImageOp() = default;
437 447
438 DrawImageRectOp::DrawImageRectOp(const PaintImage& image, 448 DrawImageRectOp::DrawImageRectOp(const PaintImage& image,
439 const SkRect& src, 449 const SkRect& src,
440 const SkRect& dst, 450 const SkRect& dst,
441 const PaintFlags* flags, 451 const PaintFlags* flags,
442 PaintCanvas::SrcRectConstraint constraint) 452 PaintCanvas::SrcRectConstraint constraint)
443 : image(image), 453 : image(image),
444 flags(flags ? *flags : PaintFlags()), 454 flags(flags ? *flags : PaintFlags()),
445 src(src), 455 src(src),
446 dst(dst), 456 dst(dst),
447 constraint(constraint) {} 457 constraint(constraint) {}
448 458
459 bool DrawImageRectOp::HasDiscardableImages() const {
460 return image.sk_image()->isLazyGenerated();
461 }
462
449 DrawImageRectOp::~DrawImageRectOp() = default; 463 DrawImageRectOp::~DrawImageRectOp() = default;
450 464
451 DrawPosTextOp::DrawPosTextOp(size_t bytes, 465 DrawPosTextOp::DrawPosTextOp(size_t bytes,
452 size_t count, 466 size_t count,
453 const PaintFlags& flags) 467 const PaintFlags& flags)
454 : PaintOpWithDataArray(bytes, count), flags(flags) {} 468 : PaintOpWithDataArray(bytes, count), flags(flags) {}
455 469
456 DrawPosTextOp::~DrawPosTextOp() = default; 470 DrawPosTextOp::~DrawPosTextOp() = default;
457 471
458 DrawRecordOp::DrawRecordOp(sk_sp<const PaintRecord> record) 472 DrawRecordOp::DrawRecordOp(sk_sp<const PaintRecord> record)
459 : record(std::move(record)) {} 473 : record(std::move(record)) {}
460 474
461 DrawRecordOp::~DrawRecordOp() = default; 475 DrawRecordOp::~DrawRecordOp() = default;
462 476
463 size_t DrawRecordOp::AdditionalBytesUsed() const { 477 size_t DrawRecordOp::AdditionalBytesUsed() const {
464 return record->approximateBytesUsed(); 478 return record->approximateBytesUsed();
465 } 479 }
466 480
481 bool DrawRecordOp::HasDiscardableImages() const {
482 return record->HasDiscardableImages();
483 }
484
467 DrawTextBlobOp::DrawTextBlobOp(sk_sp<SkTextBlob> blob, 485 DrawTextBlobOp::DrawTextBlobOp(sk_sp<SkTextBlob> blob,
468 SkScalar x, 486 SkScalar x,
469 SkScalar y, 487 SkScalar y,
470 const PaintFlags& flags) 488 const PaintFlags& flags)
471 : blob(std::move(blob)), x(x), y(y), flags(flags) {} 489 : blob(std::move(blob)), x(x), y(y), flags(flags) {}
472 490
473 DrawTextBlobOp::~DrawTextBlobOp() = default; 491 DrawTextBlobOp::~DrawTextBlobOp() = default;
474 492
475 PaintOpBuffer::PaintOpBuffer() : cull_rect_(SkRect::MakeEmpty()) {} 493 PaintOpBuffer::PaintOpBuffer() : cull_rect_(SkRect::MakeEmpty()) {}
476 494
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 575 }
558 576
559 void PaintOpBuffer::ShrinkToFit() { 577 void PaintOpBuffer::ShrinkToFit() {
560 if (!used_ || used_ == reserved_) 578 if (!used_ || used_ == reserved_)
561 return; 579 return;
562 data_.realloc(used_); 580 data_.realloc(used_);
563 reserved_ = used_; 581 reserved_ = used_;
564 } 582 }
565 583
566 } // namespace cc 584 } // namespace cc
OLDNEW
« cc/paint/paint_op_buffer.h ('K') | « cc/paint/paint_op_buffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698