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

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

Issue 682223002: rename GrTextureDesc->GrSurfaceDesc, GrTextureFlags->GrSurfaceFlags (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: const Created 6 years, 1 month 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/GrSWMaskHelper.h ('k') | src/gpu/GrTextStrike.cpp » ('j') | 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 fDraw.fClip = &fRasterClip.bwRgn(); 223 fDraw.fClip = &fRasterClip.bwRgn();
224 fDraw.fMatrix = &fMatrix; 224 fDraw.fMatrix = &fMatrix;
225 fDraw.fBitmap = &fBM; 225 fDraw.fBitmap = &fBM;
226 return true; 226 return true;
227 } 227 }
228 228
229 /** 229 /**
230 * Get a texture (from the texture cache) of the correct size & format. 230 * Get a texture (from the texture cache) of the correct size & format.
231 */ 231 */
232 GrTexture* GrSWMaskHelper::createTexture() { 232 GrTexture* GrSWMaskHelper::createTexture() {
233 GrTextureDesc desc; 233 GrSurfaceDesc desc;
234 desc.fWidth = fBM.width(); 234 desc.fWidth = fBM.width();
235 desc.fHeight = fBM.height(); 235 desc.fHeight = fBM.height();
236 desc.fConfig = kAlpha_8_GrPixelConfig; 236 desc.fConfig = kAlpha_8_GrPixelConfig;
237 237
238 if (kNone_CompressionMode != fCompressionMode) { 238 if (kNone_CompressionMode != fCompressionMode) {
239 239
240 #ifdef SK_DEBUG 240 #ifdef SK_DEBUG
241 int dimX, dimY; 241 int dimX, dimY;
242 SkTextureCompressor::GetBlockDimensions(fCompressedFormat, &dimX, &dimY) ; 242 SkTextureCompressor::GetBlockDimensions(fCompressedFormat, &dimX, &dimY) ;
243 SkASSERT((desc.fWidth % dimX) == 0); 243 SkASSERT((desc.fWidth % dimX) == 0);
244 SkASSERT((desc.fHeight % dimY) == 0); 244 SkASSERT((desc.fHeight % dimY) == 0);
245 #endif 245 #endif
246 246
247 desc.fConfig = fmt_to_config(fCompressedFormat); 247 desc.fConfig = fmt_to_config(fCompressedFormat);
248 SkASSERT(fContext->getGpu()->caps()->isConfigTexturable(desc.fConfig)); 248 SkASSERT(fContext->getGpu()->caps()->isConfigTexturable(desc.fConfig));
249 } 249 }
250 250
251 return fContext->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch) ; 251 return fContext->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch) ;
252 } 252 }
253 253
254 void GrSWMaskHelper::sendTextureData(GrTexture *texture, const GrTextureDesc& de sc, 254 void GrSWMaskHelper::sendTextureData(GrTexture *texture, const GrSurfaceDesc& de sc,
255 const void *data, int rowbytes) { 255 const void *data, int rowbytes) {
256 // If we aren't reusing scratch textures we don't need to flush before 256 // If we aren't reusing scratch textures we don't need to flush before
257 // writing since no one else will be using 'texture' 257 // writing since no one else will be using 'texture'
258 bool reuseScratch = fContext->getGpu()->caps()->reuseScratchTextures(); 258 bool reuseScratch = fContext->getGpu()->caps()->reuseScratchTextures();
259 259
260 // Since we're uploading to it, and it's compressed, 'texture' shouldn't 260 // Since we're uploading to it, and it's compressed, 'texture' shouldn't
261 // have a render target. 261 // have a render target.
262 SkASSERT(NULL == texture->asRenderTarget()); 262 SkASSERT(NULL == texture->asRenderTarget());
263 263
264 texture->writePixels(0, 0, desc.fWidth, desc.fHeight, 264 texture->writePixels(0, 0, desc.fWidth, desc.fHeight,
265 desc.fConfig, data, rowbytes, 265 desc.fConfig, data, rowbytes,
266 reuseScratch ? 0 : GrContext::kDontFlush_PixelOpsFlag); 266 reuseScratch ? 0 : GrContext::kDontFlush_PixelOpsFlag);
267 } 267 }
268 268
269 void GrSWMaskHelper::compressTextureData(GrTexture *texture, const GrTextureDesc & desc) { 269 void GrSWMaskHelper::compressTextureData(GrTexture *texture, const GrSurfaceDesc & desc) {
270 270
271 SkASSERT(GrPixelConfigIsCompressed(desc.fConfig)); 271 SkASSERT(GrPixelConfigIsCompressed(desc.fConfig));
272 SkASSERT(fmt_to_config(fCompressedFormat) == desc.fConfig); 272 SkASSERT(fmt_to_config(fCompressedFormat) == desc.fConfig);
273 273
274 SkAutoDataUnref cmpData(SkTextureCompressor::CompressBitmapToFormat(fBM, fCo mpressedFormat)); 274 SkAutoDataUnref cmpData(SkTextureCompressor::CompressBitmapToFormat(fBM, fCo mpressedFormat));
275 SkASSERT(cmpData); 275 SkASSERT(cmpData);
276 276
277 this->sendTextureData(texture, desc, cmpData->data(), 0); 277 this->sendTextureData(texture, desc, cmpData->data(), 0);
278 } 278 }
279 279
280 /** 280 /**
281 * Move the result of the software mask generation back to the gpu 281 * Move the result of the software mask generation back to the gpu
282 */ 282 */
283 void GrSWMaskHelper::toTexture(GrTexture *texture) { 283 void GrSWMaskHelper::toTexture(GrTexture *texture) {
284 SkAutoLockPixels alp(fBM); 284 SkAutoLockPixels alp(fBM);
285 285
286 GrTextureDesc desc; 286 GrSurfaceDesc desc;
287 desc.fWidth = fBM.width(); 287 desc.fWidth = fBM.width();
288 desc.fHeight = fBM.height(); 288 desc.fHeight = fBM.height();
289 desc.fConfig = texture->config(); 289 desc.fConfig = texture->config();
290 290
291 // First see if we should compress this texture before uploading. 291 // First see if we should compress this texture before uploading.
292 switch (fCompressionMode) { 292 switch (fCompressionMode) {
293 case kNone_CompressionMode: 293 case kNone_CompressionMode:
294 this->sendTextureData(texture, desc, fBM.getPixels(), fBM.rowBytes() ); 294 this->sendTextureData(texture, desc, fBM.getPixels(), fBM.rowBytes() );
295 break; 295 break;
296 296
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 maskMatrix.preConcat(drawState->getViewMatrix()); 371 maskMatrix.preConcat(drawState->getViewMatrix());
372 372
373 drawState->addCoverageProcessor( 373 drawState->addCoverageProcessor(
374 GrSimpleTextureEffect::Create(texture, 374 GrSimpleTextureEffect::Create(texture,
375 maskMatrix, 375 maskMatrix,
376 GrTextureParams::kNone_Fi lterMode, 376 GrTextureParams::kNone_Fi lterMode,
377 kPosition_GrCoordSet))->u nref(); 377 kPosition_GrCoordSet))->u nref();
378 378
379 target->drawSimpleRect(dstRect); 379 target->drawSimpleRect(dstRect);
380 } 380 }
OLDNEW
« no previous file with comments | « src/gpu/GrSWMaskHelper.h ('k') | src/gpu/GrTextStrike.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698