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