Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/gpu/GrTextureParamsAdjuster.cpp

Issue 2296193005: Add a makeDrawContextWithFallback that handles config fallback (Closed)
Patch Set: update Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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,
41 // fail.
42 if (!caps->isConfigRenderable(config, false)) {
43 if (GrPixelConfigIsAlphaOnly(config)) {
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, 39 sk_sp<GrDrawContext> copyDC = context->makeDrawContext(SkBackingFit::kExact, copyParams.fWidth,
64 copyParams.fHeight, c onfig, nullptr); 40 copyParams.fHeight, c onfig, nullptr);
65 if (!copyDC) { 41 if (!copyDC) {
66 return nullptr; 42 return nullptr;
67 } 43 }
68 44
69 GrPaint paint; 45 GrPaint paint;
70 paint.setGammaCorrect(true); 46 paint.setGammaCorrect(true);
71 47
72 SkScalar sx SK_INIT_TO_AVOID_WARNING; 48 SkScalar sx SK_INIT_TO_AVOID_WARNING;
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 } 511 }
536 512
537 GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams , bool willBeMipped, 513 GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams , bool willBeMipped,
538 SkSourceGammaTreatment gamma Treatment) { 514 SkSourceGammaTreatment gamma Treatment) {
539 SkAutoTUnref<GrTexture> original(this->refOriginalTexture(willBeMipped, gamm aTreatment)); 515 SkAutoTUnref<GrTexture> original(this->refOriginalTexture(willBeMipped, gamm aTreatment));
540 if (!original) { 516 if (!original) {
541 return nullptr; 517 return nullptr;
542 } 518 }
543 return copy_on_gpu(original, nullptr, copyParams); 519 return copy_on_gpu(original, nullptr, copyParams);
544 } 520 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698