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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 | 344 |
345 if (!result) { | 345 if (!result) { |
346 return nullptr; | 346 return nullptr; |
347 } | 347 } |
348 | 348 |
349 SkIRect fullSize = SkIRect::MakeWH(result->width(), result->height()); | 349 SkIRect fullSize = SkIRect::MakeWH(result->width(), result->height()); |
350 #if SK_SUPPORT_GPU | 350 #if SK_SUPPORT_GPU |
351 if (result->isTextureBacked()) { | 351 if (result->isTextureBacked()) { |
352 GrContext* context = result->getContext(); | 352 GrContext* context = result->getContext(); |
353 sk_sp<GrTexture> texture = result->asTextureRef(context); | 353 sk_sp<GrTexture> texture = result->asTextureRef(context); |
| 354 if (!texture) { |
| 355 return nullptr; |
| 356 } |
354 fullSize = SkIRect::MakeWH(texture->width(), texture->height()); | 357 fullSize = SkIRect::MakeWH(texture->width(), texture->height()); |
355 } | 358 } |
356 #endif | 359 #endif |
357 *outSubset = SkIRect::MakeWH(result->width(), result->height()); | 360 *outSubset = SkIRect::MakeWH(result->width(), result->height()); |
358 if (!outSubset->intersect(clipBounds.makeOffset(-offset->x(), -offset->y()))
) { | 361 if (!outSubset->intersect(clipBounds.makeOffset(-offset->x(), -offset->y()))
) { |
359 return nullptr; | 362 return nullptr; |
360 } | 363 } |
361 offset->fX += outSubset->x(); | 364 offset->fX += outSubset->x(); |
362 offset->fY += outSubset->y(); | 365 offset->fY += outSubset->y(); |
363 // This isn't really a "tight" subset, but includes any texture padding. | 366 // This isn't really a "tight" subset, but includes any texture padding. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 SkASSERT(image); | 452 SkASSERT(image); |
450 SkASSERT(ctx); | 453 SkASSERT(ctx); |
451 return as_IB(image)->onPinAsTexture(ctx); | 454 return as_IB(image)->onPinAsTexture(ctx); |
452 } | 455 } |
453 | 456 |
454 void SkImage_unpinAsTexture(const SkImage* image, GrContext* ctx) { | 457 void SkImage_unpinAsTexture(const SkImage* image, GrContext* ctx) { |
455 SkASSERT(image); | 458 SkASSERT(image); |
456 SkASSERT(ctx); | 459 SkASSERT(ctx); |
457 as_IB(image)->onUnpinAsTexture(ctx); | 460 as_IB(image)->onUnpinAsTexture(ctx); |
458 } | 461 } |
OLD | NEW |