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 #include "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
11 #include "SkImageGenerator.h" | 11 #include "SkImageGenerator.h" |
12 #include "SkImagePriv.h" | 12 #include "SkImagePriv.h" |
13 #include "SkImage_Base.h" | 13 #include "SkImage_Base.h" |
14 #include "SkPixelRef.h" | 14 #include "SkPixelRef.h" |
15 #include "SkReadPixelsRec.h" | 15 #include "SkReadPixelsRec.h" |
16 #include "SkString.h" | 16 #include "SkString.h" |
17 #include "SkSurface.h" | 17 #include "SkSurface.h" |
18 | 18 |
19 #if SK_SUPPORT_GPU | 19 #if SK_SUPPORT_GPU |
20 #include "GrTexture.h" | 20 #include "GrTexture.h" |
21 #include "GrContext.h" | 21 #include "GrContext.h" |
22 #include "SkImage_Gpu.h" | 22 #include "SkImage_Gpu.h" |
23 #endif | 23 #endif |
24 | 24 |
25 #include "SkNextID.h" | |
25 uint32_t SkImage::NextUniqueID() { | 26 uint32_t SkImage::NextUniqueID() { |
f(malita)
2015/07/30 20:24:26
Nit: any reason to keep this wrapper around?
reed1
2015/07/30 21:17:08
Done.
| |
26 static int32_t gUniqueID; | 27 return SkNextID::ImageID(); |
27 | |
28 // never return 0; | |
29 uint32_t id; | |
30 do { | |
31 id = sk_atomic_inc(&gUniqueID) + 1; | |
32 } while (0 == id); | |
33 return id; | |
34 } | 28 } |
35 | 29 |
36 const void* SkImage::peekPixels(SkImageInfo* info, size_t* rowBytes) const { | 30 const void* SkImage::peekPixels(SkImageInfo* info, size_t* rowBytes) const { |
37 SkImageInfo infoStorage; | 31 SkImageInfo infoStorage; |
38 size_t rowBytesStorage; | 32 size_t rowBytesStorage; |
39 if (NULL == info) { | 33 if (NULL == info) { |
40 info = &infoStorage; | 34 info = &infoStorage; |
41 } | 35 } |
42 if (NULL == rowBytes) { | 36 if (NULL == rowBytes) { |
43 rowBytes = &rowBytesStorage; | 37 rowBytes = &rowBytesStorage; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 SkAutoTUnref<GrTexture> unrefCopy; | 235 SkAutoTUnref<GrTexture> unrefCopy; |
242 if (!bm.isImmutable()) { | 236 if (!bm.isImmutable()) { |
243 const bool notBudgeted = false; | 237 const bool notBudgeted = false; |
244 tex = GrDeepCopyTexture(tex, notBudgeted); | 238 tex = GrDeepCopyTexture(tex, notBudgeted); |
245 if (NULL == tex) { | 239 if (NULL == tex) { |
246 return NULL; | 240 return NULL; |
247 } | 241 } |
248 unrefCopy.reset(tex); | 242 unrefCopy.reset(tex); |
249 } | 243 } |
250 const SkImageInfo info = bm.info(); | 244 const SkImageInfo info = bm.info(); |
251 return SkNEW_ARGS(SkImage_Gpu, (info.width(), info.height(), info.alphaT ype(), | 245 return SkNEW_ARGS(SkImage_Gpu, (info.width(), info.height(), bm.getGener ationID(), |
252 tex, 0, SkSurface::kNo_Budgeted)); | 246 info.alphaType(), tex, 0, SkSurface::kNo _Budgeted)); |
253 } | 247 } |
254 #endif | 248 #endif |
255 | 249 |
256 // This will check for immutable (share or copy) | 250 // This will check for immutable (share or copy) |
257 return SkNewImageFromRasterBitmap(bm, nullptr, kUnlocked_SharedPixelRefMode) ; | 251 return SkNewImageFromRasterBitmap(bm, nullptr, kUnlocked_SharedPixelRefMode) ; |
258 } | 252 } |
259 | 253 |
260 bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const { | 254 bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const { |
261 return as_IB(this)->onAsLegacyBitmap(bitmap, mode); | 255 return as_IB(this)->onAsLegacyBitmap(bitmap, mode); |
262 } | 256 } |
(...skipping 28 matching lines...) Expand all Loading... | |
291 | 285 |
292 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType) { | 286 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType) { |
293 return NULL; | 287 return NULL; |
294 } | 288 } |
295 | 289 |
296 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk AlphaType) { | 290 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk AlphaType) { |
297 return NULL; | 291 return NULL; |
298 } | 292 } |
299 | 293 |
300 #endif | 294 #endif |
OLD | NEW |