| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorTyp
e dstCT, | 56 static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorTyp
e dstCT, |
| 57 const SkIRect* subset) { | 57 const SkIRect* subset) { |
| 58 if (NULL == texture || kUnknown_SkColorType == dstCT) { | 58 if (NULL == texture || kUnknown_SkColorType == dstCT) { |
| 59 return NULL; | 59 return NULL; |
| 60 } | 60 } |
| 61 GrContext* context = texture->getContext(); | 61 GrContext* context = texture->getContext(); |
| 62 if (NULL == context) { | 62 if (NULL == context) { |
| 63 return NULL; | 63 return NULL; |
| 64 } | 64 } |
| 65 GrTextureDesc desc; | 65 GrSurfaceDesc desc; |
| 66 | 66 |
| 67 SkIRect srcRect; | 67 SkIRect srcRect; |
| 68 | 68 |
| 69 if (!subset) { | 69 if (!subset) { |
| 70 desc.fWidth = texture->width(); | 70 desc.fWidth = texture->width(); |
| 71 desc.fHeight = texture->height(); | 71 desc.fHeight = texture->height(); |
| 72 srcRect = SkIRect::MakeWH(texture->width(), texture->height()); | 72 srcRect = SkIRect::MakeWH(texture->width(), texture->height()); |
| 73 } else { | 73 } else { |
| 74 SkASSERT(SkIRect::MakeWH(texture->width(), texture->height()).contains(*
subset)); | 74 SkASSERT(SkIRect::MakeWH(texture->width(), texture->height()).contains(*
subset)); |
| 75 // Create a new texture that is the size of subset. | 75 // Create a new texture that is the size of subset. |
| 76 desc.fWidth = subset->width(); | 76 desc.fWidth = subset->width(); |
| 77 desc.fHeight = subset->height(); | 77 desc.fHeight = subset->height(); |
| 78 srcRect = *subset; | 78 srcRect = *subset; |
| 79 } | 79 } |
| 80 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; | 80 desc.fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFlag; |
| 81 desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType); | 81 desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType); |
| 82 | 82 |
| 83 GrTexture* dst = context->createUncachedTexture(desc, NULL, 0); | 83 GrTexture* dst = context->createUncachedTexture(desc, NULL, 0); |
| 84 if (NULL == dst) { | 84 if (NULL == dst) { |
| 85 return NULL; | 85 return NULL; |
| 86 } | 86 } |
| 87 | 87 |
| 88 // Blink is relying on the above copy being sent to GL immediately in the ca
se when the source | 88 // Blink is relying on the above copy being sent to GL immediately in the ca
se when the source |
| 89 // is a WebGL canvas backing store. We could have a TODO to remove this flus
h flag, but we have | 89 // is a WebGL canvas backing store. We could have a TODO to remove this flus
h flag, but we have |
| 90 // a larger TODO to remove SkGrPixelRef entirely. | 90 // a larger TODO to remove SkGrPixelRef entirely. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 cachedBitmap.setImmutable(); | 188 cachedBitmap.setImmutable(); |
| 189 //Add to the cache | 189 //Add to the cache |
| 190 SkBitmapCache::Add(this->getGenerationID(), bounds, cachedBitmap); | 190 SkBitmapCache::Add(this->getGenerationID(), bounds, cachedBitmap); |
| 191 | 191 |
| 192 dst->swap(cachedBitmap); | 192 dst->swap(cachedBitmap); |
| 193 } | 193 } |
| 194 | 194 |
| 195 return true; | 195 return true; |
| 196 | 196 |
| 197 } | 197 } |
| OLD | NEW |