Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef CC_PAINT_PAINT_IMAGE_H_ | 5 #ifndef CC_PAINT_PAINT_IMAGE_H_ |
| 6 #define CC_PAINT_PAINT_IMAGE_H_ | 6 #define CC_PAINT_PAINT_IMAGE_H_ |
| 7 | 7 |
| 8 #include "base/atomic_sequence_num.h" | |
| 8 #include "base/logging.h" | 9 #include "base/logging.h" |
| 9 #include "cc/paint/paint_export.h" | 10 #include "cc/paint/paint_export.h" |
| 10 #include "third_party/skia/include/core/SkImage.h" | 11 #include "third_party/skia/include/core/SkImage.h" |
| 11 | 12 |
| 12 namespace cc { | 13 namespace cc { |
| 13 | 14 |
| 14 // TODO(vmpstr): Add a persistent id to the paint image. | 15 // TODO(vmpstr): Add a persistent id to the paint image. |
| 15 class CC_PAINT_EXPORT PaintImage { | 16 class CC_PAINT_EXPORT PaintImage { |
| 16 public: | 17 public: |
| 18 using Id = int; | |
| 19 | |
| 20 // An id that can be used for all non-lazy images. Note that if an image is | |
| 21 // not lazy, it does not mean that this id must be used; one can still use | |
| 22 // GetNextId to generate a stable id for such images. | |
| 23 static const Id kNonLazyStableId = -1; | |
| 24 | |
| 17 // TODO(vmpstr): Work towards removing "UNKNOWN" value. | 25 // TODO(vmpstr): Work towards removing "UNKNOWN" value. |
| 18 enum class AnimationType { UNKNOWN, ANIMATED, VIDEO, STATIC }; | 26 enum class AnimationType { UNKNOWN, ANIMATED, VIDEO, STATIC }; |
| 19 | 27 |
| 20 // TODO(vmpstr): Work towards removing "UNKNOWN" value. | 28 // TODO(vmpstr): Work towards removing "UNKNOWN" value. |
| 21 enum class CompletionState { UNKNOWN, DONE, PARTIALLY_DONE }; | 29 enum class CompletionState { UNKNOWN, DONE, PARTIALLY_DONE }; |
| 22 | 30 |
| 31 static Id GetNextId(); | |
| 32 | |
| 23 PaintImage(); | 33 PaintImage(); |
| 24 explicit PaintImage(sk_sp<SkImage> sk_image, | 34 explicit PaintImage(Id stable_id, |
| 35 sk_sp<SkImage> sk_image, | |
| 25 AnimationType animation_type = AnimationType::STATIC, | 36 AnimationType animation_type = AnimationType::STATIC, |
| 26 CompletionState completion_state = CompletionState::DONE); | 37 CompletionState completion_state = CompletionState::DONE); |
| 27 PaintImage(const PaintImage& other); | 38 PaintImage(const PaintImage& other); |
| 28 PaintImage(PaintImage&& other); | 39 PaintImage(PaintImage&& other); |
| 29 ~PaintImage(); | 40 ~PaintImage(); |
| 30 | 41 |
| 31 PaintImage& operator=(const PaintImage& other); | 42 PaintImage& operator=(const PaintImage& other); |
| 32 PaintImage& operator=(PaintImage&& other); | 43 PaintImage& operator=(PaintImage&& other); |
| 33 | 44 |
| 34 bool operator==(const PaintImage& other); | 45 bool operator==(const PaintImage& other); |
| 35 explicit operator bool() const { return sk_image_; } | 46 explicit operator bool() const { return sk_image_; } |
| 36 | 47 |
| 48 Id stable_id() const { return stable_id_; } | |
| 37 const sk_sp<SkImage>& sk_image() const { return sk_image_; } | 49 const sk_sp<SkImage>& sk_image() const { return sk_image_; } |
| 38 AnimationType animation_type() const { return animation_type_; } | 50 AnimationType animation_type() const { return animation_type_; } |
| 39 CompletionState completion_state() const { return completion_state_; } | 51 CompletionState completion_state() const { return completion_state_; } |
| 40 | 52 |
| 41 private: | 53 private: |
| 54 static base::AtomicSequenceNumber s_next_id_; | |
|
Khushal
2017/05/09 22:57:21
Do you need to declare this again in the .cc file?
| |
| 55 | |
| 56 Id stable_id_; | |
|
Khushal
2017/05/09 22:57:21
nit: Just id_ should be good enough.
| |
| 42 sk_sp<SkImage> sk_image_; | 57 sk_sp<SkImage> sk_image_; |
| 43 AnimationType animation_type_ = AnimationType::UNKNOWN; | 58 AnimationType animation_type_ = AnimationType::UNKNOWN; |
| 44 CompletionState completion_state_ = CompletionState::UNKNOWN; | 59 CompletionState completion_state_ = CompletionState::UNKNOWN; |
| 45 }; | 60 }; |
| 46 | 61 |
| 47 } // namespace cc | 62 } // namespace cc |
| 48 | 63 |
| 49 #endif // CC_PAINT_PAINT_IMAGE_H_ | 64 #endif // CC_PAINT_PAINT_IMAGE_H_ |
| OLD | NEW |