| 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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 // TODO(vmpstr): Work towards removing "UNKNOWN" value. | 29 // TODO(vmpstr): Work towards removing "UNKNOWN" value. |
| 30 enum class AnimationType { UNKNOWN, ANIMATED, VIDEO, STATIC }; | 30 enum class AnimationType { UNKNOWN, ANIMATED, VIDEO, STATIC }; |
| 31 | 31 |
| 32 // TODO(vmpstr): Work towards removing "UNKNOWN" value. | 32 // TODO(vmpstr): Work towards removing "UNKNOWN" value. |
| 33 enum class CompletionState { UNKNOWN, DONE, PARTIALLY_DONE }; | 33 enum class CompletionState { UNKNOWN, DONE, PARTIALLY_DONE }; |
| 34 | 34 |
| 35 static Id GetNextId(); | 35 static Id GetNextId(); |
| 36 | 36 |
| 37 PaintImage(); | 37 PaintImage(); |
| 38 // - id: stable id for this image; can be generated using GetNextId(). |
| 39 // - sk_image: the underlying skia image that this represents. |
| 40 // - animation_type: the animation type of this paint image. |
| 41 // - completion_state: indicates whether the image is completed loading. |
| 42 // - frame_count: the known number of frames in this image. E.g. number of GIF |
| 43 // frames in an animated GIF. |
| 38 explicit PaintImage(Id id, | 44 explicit PaintImage(Id id, |
| 39 sk_sp<SkImage> sk_image, | 45 sk_sp<SkImage> sk_image, |
| 40 AnimationType animation_type = AnimationType::STATIC, | 46 AnimationType animation_type = AnimationType::STATIC, |
| 41 CompletionState completion_state = CompletionState::DONE); | 47 CompletionState completion_state = CompletionState::DONE, |
| 48 size_t frame_count = 0); |
| 42 PaintImage(const PaintImage& other); | 49 PaintImage(const PaintImage& other); |
| 43 PaintImage(PaintImage&& other); | 50 PaintImage(PaintImage&& other); |
| 44 ~PaintImage(); | 51 ~PaintImage(); |
| 45 | 52 |
| 46 PaintImage& operator=(const PaintImage& other); | 53 PaintImage& operator=(const PaintImage& other); |
| 47 PaintImage& operator=(PaintImage&& other); | 54 PaintImage& operator=(PaintImage&& other); |
| 48 | 55 |
| 49 bool operator==(const PaintImage& other) const; | 56 bool operator==(const PaintImage& other) const; |
| 50 explicit operator bool() const { return sk_image_; } | 57 explicit operator bool() const { return sk_image_; } |
| 51 | 58 |
| 52 Id stable_id() const { return id_; } | 59 Id stable_id() const { return id_; } |
| 53 const sk_sp<SkImage>& sk_image() const { return sk_image_; } | 60 const sk_sp<SkImage>& sk_image() const { return sk_image_; } |
| 54 AnimationType animation_type() const { return animation_type_; } | 61 AnimationType animation_type() const { return animation_type_; } |
| 55 CompletionState completion_state() const { return completion_state_; } | 62 CompletionState completion_state() const { return completion_state_; } |
| 63 size_t frame_count() const { return frame_count_; } |
| 56 | 64 |
| 57 private: | 65 private: |
| 58 Id id_ = kUnknownStableId; | 66 Id id_ = kUnknownStableId; |
| 59 sk_sp<SkImage> sk_image_; | 67 sk_sp<SkImage> sk_image_; |
| 60 AnimationType animation_type_ = AnimationType::UNKNOWN; | 68 AnimationType animation_type_ = AnimationType::UNKNOWN; |
| 61 CompletionState completion_state_ = CompletionState::UNKNOWN; | 69 CompletionState completion_state_ = CompletionState::UNKNOWN; |
| 70 // The number of frames known to exist in this image (eg number of GIF frames |
| 71 // loaded). 0 indicates either unknown or only a single frame, both of which |
| 72 // should be treated similarly. |
| 73 size_t frame_count_ = 0; |
| 62 }; | 74 }; |
| 63 | 75 |
| 64 } // namespace cc | 76 } // namespace cc |
| 65 | 77 |
| 66 #endif // CC_PAINT_PAINT_IMAGE_H_ | 78 #endif // CC_PAINT_PAINT_IMAGE_H_ |
| OLD | NEW |