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

Unified Diff: cc/paint/paint_op_buffer.h

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 side-by-side diff with in-line comments
Download patch
Index: cc/paint/paint_op_buffer.h
diff --git a/cc/paint/paint_op_buffer.h b/cc/paint/paint_op_buffer.h
index d4d69387d21c4e61cef501707f9cef65324a5205..69a8f59679a5ff7845cd956d818eb936bd8ee977 100644
--- a/cc/paint/paint_op_buffer.h
+++ b/cc/paint/paint_op_buffer.h
@@ -88,6 +88,9 @@ struct CC_PAINT_EXPORT PaintOp {
int CountSlowPaths() const { return 0; }
int CountSlowPathsFromFlags() const { return 0; }
+ bool HasDiscardableImages() const { return false; }
+ bool HasDiscardableImagesFromFlags() const { return false; }
+
// Returns the number of bytes used by this op in referenced sub records
// and display lists. This doesn't count other objects like paths or blobs.
size_t AdditionalBytesUsed() const { return 0; }
@@ -103,6 +106,14 @@ struct CC_PAINT_EXPORT PaintOpWithFlags : PaintOp {
explicit PaintOpWithFlags(const PaintFlags& flags) : flags(flags) {}
int CountSlowPathsFromFlags() const { return flags.getPathEffect() ? 1 : 0; }
+ bool HasDiscardableImagesFromFlags() const {
+ if (!IsDrawOp())
+ return false;
+
+ SkShader* shader = flags.getShader();
+ SkImage* image = shader ? shader->isAImage(nullptr, nullptr) : nullptr;
+ return image && image->isLazyGenerated();
+ }
PaintFlags flags;
};
@@ -340,6 +351,7 @@ struct CC_PAINT_EXPORT DrawDisplayItemListOp final : PaintOp {
SkCanvas* canvas,
const SkMatrix& original_ctm);
size_t AdditionalBytesUsed() const;
+ bool HasDiscardableImages() const;
// TODO(enne): DisplayItemList should know number of slow paths.
scoped_refptr<DisplayItemList> list;
@@ -371,6 +383,7 @@ struct CC_PAINT_EXPORT DrawImageOp final : PaintOpWithFlags {
static void Raster(const PaintOp* op,
SkCanvas* canvas,
const SkMatrix& original_ctm);
+ bool HasDiscardableImages() const;
PaintImage image;
SkScalar left;
@@ -389,6 +402,7 @@ struct CC_PAINT_EXPORT DrawImageRectOp final : PaintOpWithFlags {
static void Raster(const PaintOp* op,
SkCanvas* canvas,
const SkMatrix& original_ctm);
+ bool HasDiscardableImages() const;
PaintImage image;
SkRect src;
@@ -476,6 +490,7 @@ struct CC_PAINT_EXPORT DrawRecordOp final : PaintOp {
SkCanvas* canvas,
const SkMatrix& original_ctm);
size_t AdditionalBytesUsed() const;
+ bool HasDiscardableImages() const;
sk_sp<const PaintRecord> record;
};
@@ -654,6 +669,7 @@ class CC_PAINT_EXPORT PaintOpBuffer : public SkRefCnt {
return sizeof(*this) + reserved_ + subrecord_bytes_used_;
}
int numSlowPaths() const { return num_slow_paths_; }
+ bool HasDiscardableImages() const { return has_discardable_images_; }
// Resize the PaintOpBuffer to exactly fit the current amount of used space.
void ShrinkToFit();
@@ -816,6 +832,9 @@ class CC_PAINT_EXPORT PaintOpBuffer : public SkRefCnt {
num_slow_paths_ += op->CountSlowPathsFromFlags();
num_slow_paths_ += op->CountSlowPaths();
+ has_discardable_images_ |= op->HasDiscardableImages();
+ has_discardable_images_ |= op->HasDiscardableImagesFromFlags();
+
subrecord_bytes_used_ += op->AdditionalBytesUsed();
}
@@ -831,6 +850,7 @@ class CC_PAINT_EXPORT PaintOpBuffer : public SkRefCnt {
int num_slow_paths_ = 0;
// Record additional bytes used by referenced sub-records and display lists.
size_t subrecord_bytes_used_ = 0;
+ bool has_discardable_images_ = false;
SkRect cull_rect_;
DISALLOW_COPY_AND_ASSIGN(PaintOpBuffer);

Powered by Google App Engine
This is Rietveld 408576698