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

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

Issue 459033002: Change GR_COMPRESS_ALPHA_MASK from compile-time flag to run-time flag (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Code cleanup Created 6 years, 4 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
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "GrSWMaskHelper.h" 8 #include "GrSWMaskHelper.h"
9 9
10 #include "GrDrawState.h" 10 #include "GrDrawState.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 default: 59 default:
60 SkDEBUGFAIL("No GrPixelConfig for compression format!"); 60 SkDEBUGFAIL("No GrPixelConfig for compression format!");
61 // Best guess 61 // Best guess
62 config = kAlpha_8_GrPixelConfig; 62 config = kAlpha_8_GrPixelConfig;
63 break; 63 break;
64 } 64 }
65 65
66 return config; 66 return config;
67 } 67 }
68 68
69 #if GR_COMPRESS_ALPHA_MASK
70 static bool choose_compressed_fmt(const GrDrawTargetCaps* caps, 69 static bool choose_compressed_fmt(const GrDrawTargetCaps* caps,
71 SkTextureCompressor::Format *fmt) { 70 SkTextureCompressor::Format *fmt) {
72 if (NULL == fmt) { 71 if (NULL == fmt) {
73 return false; 72 return false;
74 } 73 }
75 74
76 // We can't use scratch textures without the ability to update 75 // We can't use scratch textures without the ability to update
77 // compressed textures... 76 // compressed textures...
78 if (!(caps->compressedTexSubImageSupport())) { 77 if (!(caps->compressedTexSubImageSupport())) {
79 return false; 78 return false;
80 } 79 }
81 80
82 // Figure out what our preferred texture type is. If ASTC is available, that always 81 // Figure out what our preferred texture type is. If ASTC is available, that always
83 // gives the biggest win. Otherwise, in terms of compression speed and accur acy, 82 // gives the biggest win. Otherwise, in terms of compression speed and accur acy,
84 // LATC has a slight edge over R11 EAC. 83 // LATC has a slight edge over R11 EAC.
85 if (caps->isConfigTexturable(kASTC_12x12_GrPixelConfig)) { 84 if (caps->isConfigTexturable(kASTC_12x12_GrPixelConfig)) {
86 *fmt = SkTextureCompressor::kASTC_12x12_Format; 85 *fmt = SkTextureCompressor::kASTC_12x12_Format;
87 return true; 86 return true;
88 } else if (caps->isConfigTexturable(kLATC_GrPixelConfig)) { 87 } else if (caps->isConfigTexturable(kLATC_GrPixelConfig)) {
89 *fmt = SkTextureCompressor::kLATC_Format; 88 *fmt = SkTextureCompressor::kLATC_Format;
90 return true; 89 return true;
91 } else if (caps->isConfigTexturable(kR11_EAC_GrPixelConfig)) { 90 } else if (caps->isConfigTexturable(kR11_EAC_GrPixelConfig)) {
92 *fmt = SkTextureCompressor::kR11_EAC_Format; 91 *fmt = SkTextureCompressor::kR11_EAC_Format;
93 return true; 92 return true;
94 } 93 }
95 94
96 return false; 95 return false;
97 } 96 }
98 #endif
99 97
100 } 98 }
101 99
102 /** 100 /**
103 * Draw a single rect element of the clip stack into the accumulation bitmap 101 * Draw a single rect element of the clip stack into the accumulation bitmap
104 */ 102 */
105 void GrSWMaskHelper::draw(const SkRect& rect, SkRegion::Op op, 103 void GrSWMaskHelper::draw(const SkRect& rect, SkRegion::Op op,
106 bool antiAlias, uint8_t alpha) { 104 bool antiAlias, uint8_t alpha) {
107 SkPaint paint; 105 SkPaint paint;
108 106
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } else { 162 } else {
165 fMatrix.setIdentity(); 163 fMatrix.setIdentity();
166 } 164 }
167 165
168 // Now translate so the bound's UL corner is at the origin 166 // Now translate so the bound's UL corner is at the origin
169 fMatrix.postTranslate(-resultBounds.fLeft * SK_Scalar1, 167 fMatrix.postTranslate(-resultBounds.fLeft * SK_Scalar1,
170 -resultBounds.fTop * SK_Scalar1); 168 -resultBounds.fTop * SK_Scalar1);
171 SkIRect bounds = SkIRect::MakeWH(resultBounds.width(), 169 SkIRect bounds = SkIRect::MakeWH(resultBounds.width(),
172 resultBounds.height()); 170 resultBounds.height());
173 171
174 #if GR_COMPRESS_ALPHA_MASK 172 if (fContext->getOptions().fDrawPathToCompressedTexture &&
175 if (choose_compressed_fmt(fContext->getGpu()->caps(), &fCompressedFormat)) { 173 choose_compressed_fmt(fContext->getGpu()->caps(), &fCompressedFormat)) {
176 fCompressionMode = kCompress_CompressionMode; 174 fCompressionMode = kCompress_CompressionMode;
177 } 175 }
178 #endif
179 176
180 // Make sure that the width is a multiple of the desired block dimensions 177 // Make sure that the width is a multiple of the desired block dimensions
181 // to allow for specialized SIMD instructions that compress multiple blocks at a time. 178 // to allow for specialized SIMD instructions that compress multiple blocks at a time.
182 int cmpWidth = bounds.fRight; 179 int cmpWidth = bounds.fRight;
183 int cmpHeight = bounds.fBottom; 180 int cmpHeight = bounds.fBottom;
184 if (kCompress_CompressionMode == fCompressionMode) { 181 if (kCompress_CompressionMode == fCompressionMode) {
185 int dimX, dimY; 182 int dimX, dimY;
186 SkTextureCompressor::GetBlockDimensions(fCompressedFormat, &dimX, &dimY) ; 183 SkTextureCompressor::GetBlockDimensions(fCompressedFormat, &dimX, &dimY) ;
187 cmpWidth = dimX * ((cmpWidth + (dimX - 1)) / dimX); 184 cmpWidth = dimX * ((cmpWidth + (dimX - 1)) / dimX);
188 cmpHeight = dimY * ((cmpHeight + (dimY - 1)) / dimY); 185 cmpHeight = dimY * ((cmpHeight + (dimY - 1)) / dimY);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 maskMatrix.preConcat(drawState->getViewMatrix()); 358 maskMatrix.preConcat(drawState->getViewMatrix());
362 359
363 drawState->addCoverageEffect( 360 drawState->addCoverageEffect(
364 GrSimpleTextureEffect::Create(texture, 361 GrSimpleTextureEffect::Create(texture,
365 maskMatrix, 362 maskMatrix,
366 GrTextureParams::kNone_Fi lterMode, 363 GrTextureParams::kNone_Fi lterMode,
367 kPosition_GrCoordSet))->u nref(); 364 kPosition_GrCoordSet))->u nref();
368 365
369 target->drawSimpleRect(dstRect); 366 target->drawSimpleRect(dstRect);
370 } 367 }
OLDNEW
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698