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

Side by Side Diff: src/image/SkImage.cpp

Issue 1266883002: unify pixelref and image ID space, so we can share IDs when we share pixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 | « src/core/SkPixelRef.cpp ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkNextID.h"
14 #include "SkPixelRef.h" 15 #include "SkPixelRef.h"
15 #include "SkReadPixelsRec.h" 16 #include "SkReadPixelsRec.h"
16 #include "SkString.h" 17 #include "SkString.h"
17 #include "SkSurface.h" 18 #include "SkSurface.h"
18 19
19 #if SK_SUPPORT_GPU 20 #if SK_SUPPORT_GPU
20 #include "GrTexture.h" 21 #include "GrTexture.h"
21 #include "GrContext.h" 22 #include "GrContext.h"
22 #include "SkImage_Gpu.h" 23 #include "SkImage_Gpu.h"
23 #endif 24 #endif
24 25
25 uint32_t SkImage::NextUniqueID() { 26 SkImage::SkImage(int width, int height, uint32_t uniqueID)
26 static int32_t gUniqueID; 27 : fWidth(width)
27 28 , fHeight(height)
28 // never return 0; 29 , fUniqueID(kNeedNewImageUniqueID == uniqueID ? SkNextID::ImageID() : unique ID)
29 uint32_t id; 30 {
30 do { 31 SkASSERT(width > 0);
31 id = sk_atomic_inc(&gUniqueID) + 1; 32 SkASSERT(height > 0);
32 } while (0 == id);
33 return id;
34 } 33 }
35 34
36 const void* SkImage::peekPixels(SkImageInfo* info, size_t* rowBytes) const { 35 const void* SkImage::peekPixels(SkImageInfo* info, size_t* rowBytes) const {
37 SkImageInfo infoStorage; 36 SkImageInfo infoStorage;
38 size_t rowBytesStorage; 37 size_t rowBytesStorage;
39 if (NULL == info) { 38 if (NULL == info) {
40 info = &infoStorage; 39 info = &infoStorage;
41 } 40 }
42 if (NULL == rowBytes) { 41 if (NULL == rowBytes) {
43 rowBytes = &rowBytesStorage; 42 rowBytes = &rowBytesStorage;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 SkAutoTUnref<GrTexture> unrefCopy; 240 SkAutoTUnref<GrTexture> unrefCopy;
242 if (!bm.isImmutable()) { 241 if (!bm.isImmutable()) {
243 const bool notBudgeted = false; 242 const bool notBudgeted = false;
244 tex = GrDeepCopyTexture(tex, notBudgeted); 243 tex = GrDeepCopyTexture(tex, notBudgeted);
245 if (NULL == tex) { 244 if (NULL == tex) {
246 return NULL; 245 return NULL;
247 } 246 }
248 unrefCopy.reset(tex); 247 unrefCopy.reset(tex);
249 } 248 }
250 const SkImageInfo info = bm.info(); 249 const SkImageInfo info = bm.info();
251 return SkNEW_ARGS(SkImage_Gpu, (info.width(), info.height(), info.alphaT ype(), 250 return SkNEW_ARGS(SkImage_Gpu, (info.width(), info.height(), bm.getGener ationID(),
252 tex, 0, SkSurface::kNo_Budgeted)); 251 info.alphaType(), tex, 0, SkSurface::kNo _Budgeted));
253 } 252 }
254 #endif 253 #endif
255 254
256 // This will check for immutable (share or copy) 255 // This will check for immutable (share or copy)
257 return SkNewImageFromRasterBitmap(bm, nullptr, kUnlocked_SharedPixelRefMode) ; 256 return SkNewImageFromRasterBitmap(bm, nullptr, kUnlocked_SharedPixelRefMode) ;
258 } 257 }
259 258
260 bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const { 259 bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const {
261 return as_IB(this)->onAsLegacyBitmap(bitmap, mode); 260 return as_IB(this)->onAsLegacyBitmap(bitmap, mode);
262 } 261 }
(...skipping 28 matching lines...) Expand all
291 290
292 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType) { 291 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType) {
293 return NULL; 292 return NULL;
294 } 293 }
295 294
296 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk AlphaType) { 295 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk AlphaType) {
297 return NULL; 296 return NULL;
298 } 297 }
299 298
300 #endif 299 #endif
OLDNEW
« no previous file with comments | « src/core/SkPixelRef.cpp ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698