| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkImageGeneratorUtils.h" | 8 #include "SkImageGeneratorUtils.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 | 63 |
| 64 if (!subset) { | 64 if (!subset) { |
| 65 return SkRef(fTexture.get()); | 65 return SkRef(fTexture.get()); |
| 66 } | 66 } |
| 67 // need to copy the subset into a new texture | 67 // need to copy the subset into a new texture |
| 68 GrSurfaceDesc desc = fTexture->desc(); | 68 GrSurfaceDesc desc = fTexture->desc(); |
| 69 desc.fWidth = subset->width(); | 69 desc.fWidth = subset->width(); |
| 70 desc.fHeight = subset->height(); | 70 desc.fHeight = subset->height(); |
| 71 | 71 |
| 72 GrTexture* dst = fCtx->textureProvider()->createTexture(desc, false); | 72 GrTexture* dst = fCtx->textureProvider()->createTexture(desc, SkBudgeted
::kNo); |
| 73 fCtx->copySurface(dst, fTexture, *subset, SkIPoint::Make(0, 0)); | 73 fCtx->copySurface(dst, fTexture, *subset, SkIPoint::Make(0, 0)); |
| 74 return dst; | 74 return dst; |
| 75 } | 75 } |
| 76 private: | 76 private: |
| 77 SkAutoTUnref<GrContext> fCtx; | 77 SkAutoTUnref<GrContext> fCtx; |
| 78 SkAutoTUnref<GrTexture> fTexture; | 78 SkAutoTUnref<GrTexture> fTexture; |
| 79 }; | 79 }; |
| 80 #endif | 80 #endif |
| 81 | 81 |
| 82 SkImageGenerator* SkImageGeneratorUtils::NewFromTexture(GrContext* ctx, GrTextur
e* tex) { | 82 SkImageGenerator* SkImageGeneratorUtils::NewFromTexture(GrContext* ctx, GrTextur
e* tex) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 if (image) { | 125 if (image) { |
| 126 const SkColorType ct = kN32_SkColorType; | 126 const SkColorType ct = kN32_SkColorType; |
| 127 const SkAlphaType at = image->isOpaque() ? kOpaque_SkAlphaType : kPremul
_SkAlphaType; | 127 const SkAlphaType at = image->isOpaque() ? kOpaque_SkAlphaType : kPremul
_SkAlphaType; |
| 128 const SkImageInfo info = SkImageInfo::Make(image->width(), image->height
(), ct, at); | 128 const SkImageInfo info = SkImageInfo::Make(image->width(), image->height
(), ct, at); |
| 129 return new GeneratorFromImage(image, info); | 129 return new GeneratorFromImage(image, info); |
| 130 } | 130 } |
| 131 return nullptr; | 131 return nullptr; |
| 132 } | 132 } |
| 133 | 133 |
| 134 | 134 |
| OLD | NEW |