| 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 29 matching lines...) Expand all Loading... |
| 40 SkImageGenerator* SkImageGeneratorUtils::NewFromBitmap(const SkBitmap& bm) { | 40 SkImageGenerator* SkImageGeneratorUtils::NewFromBitmap(const SkBitmap& bm) { |
| 41 return new GeneratorFromBitmap(bm); | 41 return new GeneratorFromBitmap(bm); |
| 42 } | 42 } |
| 43 | 43 |
| 44 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 44 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 45 | 45 |
| 46 #if SK_SUPPORT_GPU | 46 #if SK_SUPPORT_GPU |
| 47 | 47 |
| 48 #include "GrContext.h" | 48 #include "GrContext.h" |
| 49 #include "GrTexture.h" | 49 #include "GrTexture.h" |
| 50 #include "SkGr.h" | 50 #include "SkGrPriv.h" |
| 51 | 51 |
| 52 class GeneratorFromTexture : public SkImageGenerator { | 52 class GeneratorFromTexture : public SkImageGenerator { |
| 53 public: | 53 public: |
| 54 GeneratorFromTexture(GrContext* ctx, GrTexture* tex, const SkImageInfo& info
) | 54 GeneratorFromTexture(GrContext* ctx, GrTexture* tex, const SkImageInfo& info
) |
| 55 : SkImageGenerator(info), fCtx(ctx), fTexture(tex) | 55 : SkImageGenerator(info), fCtx(ctx), fTexture(tex) |
| 56 {} | 56 {} |
| 57 | 57 |
| 58 protected: | 58 protected: |
| 59 GrTexture* onGenerateTexture(GrContext* ctx, SkImageUsageType, const SkIRect
* subset) override { | 59 GrTexture* onGenerateTexture(GrContext* ctx, SkImageUsageType, const SkIRect
* subset) override { |
| 60 if (ctx) { | 60 if (ctx) { |
| (...skipping 64 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 |