| 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 "GrTextureParamsAdjuster.h" | 8 #include "GrTextureParamsAdjuster.h" |
| 9 | 9 |
| 10 #include "GrCaps.h" | 10 #include "GrCaps.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 typedef GrTextureProducer::CopyParams CopyParams; | 27 typedef GrTextureProducer::CopyParams CopyParams; |
| 28 | 28 |
| 29 ////////////////////////////////////////////////////////////////////////////// | 29 ////////////////////////////////////////////////////////////////////////////// |
| 30 | 30 |
| 31 static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset, | 31 static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset, |
| 32 const CopyParams& copyParams) { | 32 const CopyParams& copyParams) { |
| 33 SkASSERT(!subset || !subset->isEmpty()); | 33 SkASSERT(!subset || !subset->isEmpty()); |
| 34 GrContext* context = inputTexture->getContext(); | 34 GrContext* context = inputTexture->getContext(); |
| 35 SkASSERT(context); | 35 SkASSERT(context); |
| 36 const GrCaps* caps = context->caps(); | |
| 37 | 36 |
| 38 GrPixelConfig config = GrMakePixelConfigUncompressed(inputTexture->config())
; | 37 GrPixelConfig config = GrMakePixelConfigUncompressed(inputTexture->config())
; |
| 39 | 38 |
| 40 // If the config isn't renderable try converting to either A8 or an 32 bit c
onfig. Otherwise, | 39 sk_sp<GrDrawContext> copyDC = context->makeDrawContextWithFallback(SkBacking
Fit::kExact, |
| 41 // fail. | 40 copyParam
s.fWidth, |
| 42 if (!caps->isConfigRenderable(config, false)) { | 41 copyParam
s.fHeight, |
| 43 if (GrPixelConfigIsAlphaOnly(config)) { | 42 config, n
ullptr); |
| 44 if (caps->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { | |
| 45 config = kAlpha_8_GrPixelConfig; | |
| 46 } else if (caps->isConfigRenderable(kSkia8888_GrPixelConfig, false))
{ | |
| 47 config = kSkia8888_GrPixelConfig; | |
| 48 } else { | |
| 49 return nullptr; | |
| 50 } | |
| 51 } else if (kRGB_GrColorComponentFlags == | |
| 52 (kRGB_GrColorComponentFlags & GrPixelConfigComponentMask(config)
)) { | |
| 53 if (caps->isConfigRenderable(kSkia8888_GrPixelConfig, false)) { | |
| 54 config = kSkia8888_GrPixelConfig; | |
| 55 } else { | |
| 56 return nullptr; | |
| 57 } | |
| 58 } else { | |
| 59 return nullptr; | |
| 60 } | |
| 61 } | |
| 62 | |
| 63 sk_sp<GrDrawContext> copyDC = context->makeDrawContext(SkBackingFit::kExact,
copyParams.fWidth, | |
| 64 copyParams.fHeight, c
onfig, nullptr); | |
| 65 if (!copyDC) { | 43 if (!copyDC) { |
| 66 return nullptr; | 44 return nullptr; |
| 67 } | 45 } |
| 68 | 46 |
| 69 GrPaint paint; | 47 GrPaint paint; |
| 70 paint.setGammaCorrect(true); | 48 paint.setGammaCorrect(true); |
| 71 | 49 |
| 72 SkScalar sx SK_INIT_TO_AVOID_WARNING; | 50 SkScalar sx SK_INIT_TO_AVOID_WARNING; |
| 73 SkScalar sy SK_INIT_TO_AVOID_WARNING; | 51 SkScalar sy SK_INIT_TO_AVOID_WARNING; |
| 74 if (subset) { | 52 if (subset) { |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 } | 513 } |
| 536 | 514 |
| 537 GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams
, bool willBeMipped, | 515 GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams
, bool willBeMipped, |
| 538 SkSourceGammaTreatment gamma
Treatment) { | 516 SkSourceGammaTreatment gamma
Treatment) { |
| 539 SkAutoTUnref<GrTexture> original(this->refOriginalTexture(willBeMipped, gamm
aTreatment)); | 517 SkAutoTUnref<GrTexture> original(this->refOriginalTexture(willBeMipped, gamm
aTreatment)); |
| 540 if (!original) { | 518 if (!original) { |
| 541 return nullptr; | 519 return nullptr; |
| 542 } | 520 } |
| 543 return copy_on_gpu(original, nullptr, copyParams); | 521 return copy_on_gpu(original, nullptr, copyParams); |
| 544 } | 522 } |
| OLD | NEW |