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 "SkBitmapCache.h" | 9 #include "SkBitmapCache.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 SkImage* SkImage::NewFromBitmap(const SkBitmap& bm) { | 281 SkImage* SkImage::NewFromBitmap(const SkBitmap& bm) { |
282 SkPixelRef* pr = bm.pixelRef(); | 282 SkPixelRef* pr = bm.pixelRef(); |
283 if (nullptr == pr) { | 283 if (nullptr == pr) { |
284 return nullptr; | 284 return nullptr; |
285 } | 285 } |
286 | 286 |
287 #if SK_SUPPORT_GPU | 287 #if SK_SUPPORT_GPU |
288 if (GrTexture* tex = pr->getTexture()) { | 288 if (GrTexture* tex = pr->getTexture()) { |
289 SkAutoTUnref<GrTexture> unrefCopy; | 289 SkAutoTUnref<GrTexture> unrefCopy; |
290 if (!bm.isImmutable()) { | 290 if (!bm.isImmutable()) { |
291 const bool notBudgeted = false; | 291 tex = GrDeepCopyTexture(tex, SkBudgeted::kNo); |
292 tex = GrDeepCopyTexture(tex, notBudgeted); | |
293 if (nullptr == tex) { | 292 if (nullptr == tex) { |
294 return nullptr; | 293 return nullptr; |
295 } | 294 } |
296 unrefCopy.reset(tex); | 295 unrefCopy.reset(tex); |
297 } | 296 } |
298 const SkImageInfo info = bm.info(); | 297 const SkImageInfo info = bm.info(); |
299 return new SkImage_Gpu(info.width(), info.height(), bm.getGenerationID()
, info.alphaType(), | 298 return new SkImage_Gpu(info.width(), info.height(), bm.getGenerationID()
, info.alphaType(), |
300 tex, SkSurface::kNo_Budgeted); | 299 tex, SkBudgeted::kNo); |
301 } | 300 } |
302 #endif | 301 #endif |
303 | 302 |
304 // This will check for immutable (share or copy) | 303 // This will check for immutable (share or copy) |
305 return SkNewImageFromRasterBitmap(bm); | 304 return SkNewImageFromRasterBitmap(bm); |
306 } | 305 } |
307 | 306 |
308 bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const { | 307 bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const { |
309 return as_IB(this)->onAsLegacyBitmap(bitmap, mode); | 308 return as_IB(this)->onAsLegacyBitmap(bitmap, mode); |
310 } | 309 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 354 |
356 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk
AlphaType) { | 355 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk
AlphaType) { |
357 return nullptr; | 356 return nullptr; |
358 } | 357 } |
359 | 358 |
360 SkImage* SkImage::newTextureImage(GrContext*) const { | 359 SkImage* SkImage::newTextureImage(GrContext*) const { |
361 return nullptr; | 360 return nullptr; |
362 } | 361 } |
363 | 362 |
364 #endif | 363 #endif |
OLD | NEW |