OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkImage_Base_DEFINED | 8 #ifndef SkImage_Base_DEFINED |
9 #define SkImage_Base_DEFINED | 9 #define SkImage_Base_DEFINED |
10 | 10 |
11 #include "SkImage.h" | 11 #include "SkImage.h" |
12 #include "SkSurface.h" | 12 #include "SkSurface.h" |
13 | 13 |
| 14 enum { |
| 15 kNeedNewImageUniqueID = 0 |
| 16 }; |
| 17 |
14 static SkSurfaceProps copy_or_safe_defaults(const SkSurfaceProps* props) { | 18 static SkSurfaceProps copy_or_safe_defaults(const SkSurfaceProps* props) { |
15 return props ? *props : SkSurfaceProps(0, kUnknown_SkPixelGeometry); | 19 return props ? *props : SkSurfaceProps(0, kUnknown_SkPixelGeometry); |
16 } | 20 } |
17 | 21 |
18 class SkImage_Base : public SkImage { | 22 class SkImage_Base : public SkImage { |
19 public: | 23 public: |
20 SkImage_Base(int width, int height, const SkSurfaceProps* props) | 24 SkImage_Base(int width, int height, uint32_t uniqueID, const SkSurfaceProps*
props) |
21 : INHERITED(width, height) | 25 : INHERITED(width, height, uniqueID) |
22 , fProps(copy_or_safe_defaults(props)) | 26 , fProps(copy_or_safe_defaults(props)) |
23 {} | 27 {} |
24 | 28 |
25 /** | 29 /** |
26 * If the props weren't know at constructor time, call this but only before
the image is | 30 * If the props weren't know at constructor time, call this but only before
the image is |
27 * ever released into the wild (since the props field must appear to be imm
utable). | 31 * ever released into the wild (since the props field must appear to be imm
utable). |
28 */ | 32 */ |
29 void initWithProps(const SkSurfaceProps& props) { | 33 void initWithProps(const SkSurfaceProps& props) { |
30 SkASSERT(this->unique()); // only viewed by one thread | 34 SkASSERT(this->unique()); // only viewed by one thread |
31 SkSurfaceProps* mutableProps = const_cast<SkSurfaceProps*>(&fProps); | 35 SkSurfaceProps* mutableProps = const_cast<SkSurfaceProps*>(&fProps); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 75 |
72 static inline SkImage_Base* as_IB(SkImage* image) { | 76 static inline SkImage_Base* as_IB(SkImage* image) { |
73 return static_cast<SkImage_Base*>(image); | 77 return static_cast<SkImage_Base*>(image); |
74 } | 78 } |
75 | 79 |
76 static inline const SkImage_Base* as_IB(const SkImage* image) { | 80 static inline const SkImage_Base* as_IB(const SkImage* image) { |
77 return static_cast<const SkImage_Base*>(image); | 81 return static_cast<const SkImage_Base*>(image); |
78 } | 82 } |
79 | 83 |
80 #endif | 84 #endif |
OLD | NEW |