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

Unified Diff: cc/paint/paint_image.h

Issue 2873003002: Add stable id to PaintImage. (Closed)
Patch Set: update 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_image.h
diff --git a/cc/paint/paint_image.h b/cc/paint/paint_image.h
index a79bcf02ca3e71085c7cfc57084eb186a3d84443..1dc39ae5551da64cb75a7acb57335a921bc211e2 100644
--- a/cc/paint/paint_image.h
+++ b/cc/paint/paint_image.h
@@ -5,6 +5,7 @@
#ifndef CC_PAINT_PAINT_IMAGE_H_
#define CC_PAINT_PAINT_IMAGE_H_
+#include "base/atomic_sequence_num.h"
#include "base/logging.h"
#include "cc/paint/paint_export.h"
#include "third_party/skia/include/core/SkImage.h"
@@ -14,14 +15,24 @@ namespace cc {
// TODO(vmpstr): Add a persistent id to the paint image.
class CC_PAINT_EXPORT PaintImage {
public:
+ using Id = int;
+
+ // An id that can be used for all non-lazy images. Note that if an image is
+ // not lazy, it does not mean that this id must be used; one can still use
+ // GetNextId to generate a stable id for such images.
+ static const Id kNonLazyStableId = -1;
+
// TODO(vmpstr): Work towards removing "UNKNOWN" value.
enum class AnimationType { UNKNOWN, ANIMATED, VIDEO, STATIC };
// TODO(vmpstr): Work towards removing "UNKNOWN" value.
enum class CompletionState { UNKNOWN, DONE, PARTIALLY_DONE };
+ static Id GetNextId();
+
PaintImage();
- explicit PaintImage(sk_sp<SkImage> sk_image,
+ explicit PaintImage(Id id,
+ sk_sp<SkImage> sk_image,
AnimationType animation_type = AnimationType::STATIC,
CompletionState completion_state = CompletionState::DONE);
PaintImage(const PaintImage& other);
@@ -34,11 +45,15 @@ class CC_PAINT_EXPORT PaintImage {
bool operator==(const PaintImage& other);
explicit operator bool() const { return sk_image_; }
+ Id stable_id() const { return id_; }
const sk_sp<SkImage>& sk_image() const { return sk_image_; }
AnimationType animation_type() const { return animation_type_; }
CompletionState completion_state() const { return completion_state_; }
private:
+ static base::AtomicSequenceNumber s_next_id_;
piman 2017/05/12 19:02:58 Use base::StaticAtomicSequenceNumber instead
+
+ Id id_;
sk_sp<SkImage> sk_image_;
AnimationType animation_type_ = AnimationType::UNKNOWN;
CompletionState completion_state_ = CompletionState::UNKNOWN;

Powered by Google App Engine
This is Rietveld 408576698