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/atomic_sequence_num.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "cc/paint/paint_export.h" | 10 #include "cc/paint/paint_export.h" |
11 #include "third_party/skia/include/core/SkImage.h" | 11 #include "third_party/skia/include/core/SkImage.h" |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 | 14 |
15 // TODO(vmpstr): Add a persistent id to the paint image. | 15 // TODO(vmpstr): Add a persistent id to the paint image. |
16 class CC_PAINT_EXPORT PaintImage { | 16 class CC_PAINT_EXPORT PaintImage { |
17 public: | 17 public: |
18 using Id = int; | 18 using Id = int; |
19 | 19 |
20 // An id that can be used for all non-lazy images. Note that if an image is | 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 | 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. | 22 // GetNextId to generate a stable id for such images. |
23 static const Id kNonLazyStableId = -1; | 23 static const Id kNonLazyStableId = -1; |
24 | 24 |
25 // This is the id used in places where we are currently not plumbing the | |
26 // correct image id from blink. | |
27 // TODO(khushalsagar): Eliminate these cases. See crbug.com/722559. | |
28 static const Id kWrongStableId = -2; | |
vmpstr
2017/05/16 17:43:27
s/Wrong/Unknown/ and also maybe initialize id_ to
Khushal
2017/05/16 21:29:12
Done.
| |
29 | |
25 // TODO(vmpstr): Work towards removing "UNKNOWN" value. | 30 // TODO(vmpstr): Work towards removing "UNKNOWN" value. |
26 enum class AnimationType { UNKNOWN, ANIMATED, VIDEO, STATIC }; | 31 enum class AnimationType { UNKNOWN, ANIMATED, VIDEO, STATIC }; |
27 | 32 |
28 // TODO(vmpstr): Work towards removing "UNKNOWN" value. | 33 // TODO(vmpstr): Work towards removing "UNKNOWN" value. |
29 enum class CompletionState { UNKNOWN, DONE, PARTIALLY_DONE }; | 34 enum class CompletionState { UNKNOWN, DONE, PARTIALLY_DONE }; |
30 | 35 |
31 static Id GetNextId(); | 36 static Id GetNextId(); |
32 | 37 |
33 PaintImage(); | 38 PaintImage(); |
34 explicit PaintImage(Id id, | 39 explicit PaintImage(Id id, |
35 sk_sp<SkImage> sk_image, | 40 sk_sp<SkImage> sk_image, |
36 AnimationType animation_type = AnimationType::STATIC, | 41 AnimationType animation_type = AnimationType::STATIC, |
37 CompletionState completion_state = CompletionState::DONE); | 42 CompletionState completion_state = CompletionState::DONE); |
38 PaintImage(const PaintImage& other); | 43 PaintImage(const PaintImage& other); |
39 PaintImage(PaintImage&& other); | 44 PaintImage(PaintImage&& other); |
40 ~PaintImage(); | 45 ~PaintImage(); |
41 | 46 |
42 PaintImage& operator=(const PaintImage& other); | 47 PaintImage& operator=(const PaintImage& other); |
43 PaintImage& operator=(PaintImage&& other); | 48 PaintImage& operator=(PaintImage&& other); |
44 | 49 |
45 bool operator==(const PaintImage& other); | 50 bool operator==(const PaintImage& other) const; |
46 explicit operator bool() const { return sk_image_; } | 51 explicit operator bool() const { return sk_image_; } |
47 | 52 |
48 Id stable_id() const { return id_; } | 53 Id stable_id() const { return id_; } |
49 const sk_sp<SkImage>& sk_image() const { return sk_image_; } | 54 const sk_sp<SkImage>& sk_image() const { return sk_image_; } |
50 AnimationType animation_type() const { return animation_type_; } | 55 AnimationType animation_type() const { return animation_type_; } |
51 CompletionState completion_state() const { return completion_state_; } | 56 CompletionState completion_state() const { return completion_state_; } |
52 | 57 |
53 private: | 58 private: |
54 static base::AtomicSequenceNumber s_next_id_; | 59 static base::AtomicSequenceNumber s_next_id_; |
55 | 60 |
56 Id id_; | 61 Id id_; |
57 sk_sp<SkImage> sk_image_; | 62 sk_sp<SkImage> sk_image_; |
58 AnimationType animation_type_ = AnimationType::UNKNOWN; | 63 AnimationType animation_type_ = AnimationType::UNKNOWN; |
59 CompletionState completion_state_ = CompletionState::UNKNOWN; | 64 CompletionState completion_state_ = CompletionState::UNKNOWN; |
60 }; | 65 }; |
61 | 66 |
62 } // namespace cc | 67 } // namespace cc |
63 | 68 |
64 #endif // CC_PAINT_PAINT_IMAGE_H_ | 69 #endif // CC_PAINT_PAINT_IMAGE_H_ |
OLD | NEW |