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

Side by Side Diff: cc/paint/paint_image.h

Issue 2857923004: cc: Keep PaintImage in DrawImage. (Closed)
Patch Set: .. 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 unified diff | Download patch
« no previous file with comments | « cc/paint/image_id.h ('k') | cc/paint/paint_image.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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; 17 using Id = int;
18 18
19 // An id that can be used for all non-lazy images. Note that if an image is 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 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. 21 // GetNextId to generate a stable id for such images.
22 static const Id kNonLazyStableId = -1; 22 static const Id kNonLazyStableId = -1;
23 23
24 // This is the id used in places where we are currently not plumbing the
25 // correct image id from blink.
26 // TODO(khushalsagar): Eliminate these cases. See crbug.com/722559.
27 static const Id kUnknownStableId = -2;
28
24 // TODO(vmpstr): Work towards removing "UNKNOWN" value. 29 // TODO(vmpstr): Work towards removing "UNKNOWN" value.
25 enum class AnimationType { UNKNOWN, ANIMATED, VIDEO, STATIC }; 30 enum class AnimationType { UNKNOWN, ANIMATED, VIDEO, STATIC };
26 31
27 // TODO(vmpstr): Work towards removing "UNKNOWN" value. 32 // TODO(vmpstr): Work towards removing "UNKNOWN" value.
28 enum class CompletionState { UNKNOWN, DONE, PARTIALLY_DONE }; 33 enum class CompletionState { UNKNOWN, DONE, PARTIALLY_DONE };
29 34
30 static Id GetNextId(); 35 static Id GetNextId();
31 36
32 PaintImage(); 37 PaintImage();
33 explicit PaintImage(Id id, 38 explicit PaintImage(Id id,
34 sk_sp<SkImage> sk_image, 39 sk_sp<SkImage> sk_image,
35 AnimationType animation_type = AnimationType::STATIC, 40 AnimationType animation_type = AnimationType::STATIC,
36 CompletionState completion_state = CompletionState::DONE); 41 CompletionState completion_state = CompletionState::DONE);
37 PaintImage(const PaintImage& other); 42 PaintImage(const PaintImage& other);
38 PaintImage(PaintImage&& other); 43 PaintImage(PaintImage&& other);
39 ~PaintImage(); 44 ~PaintImage();
40 45
41 PaintImage& operator=(const PaintImage& other); 46 PaintImage& operator=(const PaintImage& other);
42 PaintImage& operator=(PaintImage&& other); 47 PaintImage& operator=(PaintImage&& other);
43 48
44 bool operator==(const PaintImage& other); 49 bool operator==(const PaintImage& other) const;
45 explicit operator bool() const { return sk_image_; } 50 explicit operator bool() const { return sk_image_; }
46 51
47 Id stable_id() const { return id_; } 52 Id stable_id() const { return id_; }
48 const sk_sp<SkImage>& sk_image() const { return sk_image_; } 53 const sk_sp<SkImage>& sk_image() const { return sk_image_; }
49 AnimationType animation_type() const { return animation_type_; } 54 AnimationType animation_type() const { return animation_type_; }
50 CompletionState completion_state() const { return completion_state_; } 55 CompletionState completion_state() const { return completion_state_; }
51 56
52 private: 57 private:
53 Id id_ = kNonLazyStableId; 58 Id id_ = kUnknownStableId;
54 sk_sp<SkImage> sk_image_; 59 sk_sp<SkImage> sk_image_;
55 AnimationType animation_type_ = AnimationType::UNKNOWN; 60 AnimationType animation_type_ = AnimationType::UNKNOWN;
56 CompletionState completion_state_ = CompletionState::UNKNOWN; 61 CompletionState completion_state_ = CompletionState::UNKNOWN;
57 }; 62 };
58 63
59 } // namespace cc 64 } // namespace cc
60 65
61 #endif // CC_PAINT_PAINT_IMAGE_H_ 66 #endif // CC_PAINT_PAINT_IMAGE_H_
OLDNEW
« no previous file with comments | « cc/paint/image_id.h ('k') | cc/paint/paint_image.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698