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

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

Issue 638403003: Remove uses of GrAutoScratchTexture. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 2 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/GrSWMaskHelper.h ('k') | src/gpu/GrSoftwarePathRenderer.h » ('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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 fRasterClip.setRect(bounds); 221 fRasterClip.setRect(bounds);
222 fDraw.fRC = &fRasterClip; 222 fDraw.fRC = &fRasterClip;
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 * Return true on success; false on failure.
232 */ 231 */
233 bool GrSWMaskHelper::getTexture(GrAutoScratchTexture* texture) { 232 GrTexture* GrSWMaskHelper::createTexture() {
234 GrTextureDesc desc; 233 GrTextureDesc desc;
235 desc.fWidth = fBM.width(); 234 desc.fWidth = fBM.width();
236 desc.fHeight = fBM.height(); 235 desc.fHeight = fBM.height();
237 desc.fConfig = kAlpha_8_GrPixelConfig; 236 desc.fConfig = kAlpha_8_GrPixelConfig;
238 237
239 if (kNone_CompressionMode != fCompressionMode) { 238 if (kNone_CompressionMode != fCompressionMode) {
240 239
241 #ifdef SK_DEBUG 240 #ifdef SK_DEBUG
242 int dimX, dimY; 241 int dimX, dimY;
243 SkTextureCompressor::GetBlockDimensions(fCompressedFormat, &dimX, &dimY) ; 242 SkTextureCompressor::GetBlockDimensions(fCompressedFormat, &dimX, &dimY) ;
244 SkASSERT((desc.fWidth % dimX) == 0); 243 SkASSERT((desc.fWidth % dimX) == 0);
245 SkASSERT((desc.fHeight % dimY) == 0); 244 SkASSERT((desc.fHeight % dimY) == 0);
246 #endif 245 #endif
247 246
248 desc.fConfig = fmt_to_config(fCompressedFormat); 247 desc.fConfig = fmt_to_config(fCompressedFormat);
249 SkASSERT(fContext->getGpu()->caps()->isConfigTexturable(desc.fConfig)); 248 SkASSERT(fContext->getGpu()->caps()->isConfigTexturable(desc.fConfig));
250 } 249 }
251 250
252 texture->set(fContext, desc); 251 return fContext->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch) ;
253 return SkToBool(texture->texture());
254 } 252 }
255 253
256 void GrSWMaskHelper::sendTextureData(GrTexture *texture, const GrTextureDesc& de sc, 254 void GrSWMaskHelper::sendTextureData(GrTexture *texture, const GrTextureDesc& de sc,
257 const void *data, int rowbytes) { 255 const void *data, int rowbytes) {
258 // 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
259 // writing since no one else will be using 'texture' 257 // writing since no one else will be using 'texture'
260 bool reuseScratch = fContext->getGpu()->caps()->reuseScratchTextures(); 258 bool reuseScratch = fContext->getGpu()->caps()->reuseScratchTextures();
261 259
262 // 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
263 // have a render target. 261 // have a render target.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 bool antiAlias, 328 bool antiAlias,
331 SkMatrix* matrix) { 329 SkMatrix* matrix) {
332 GrSWMaskHelper helper(context); 330 GrSWMaskHelper helper(context);
333 331
334 if (!helper.init(resultBounds, matrix)) { 332 if (!helper.init(resultBounds, matrix)) {
335 return NULL; 333 return NULL;
336 } 334 }
337 335
338 helper.draw(path, stroke, SkRegion::kReplace_Op, antiAlias, 0xFF); 336 helper.draw(path, stroke, SkRegion::kReplace_Op, antiAlias, 0xFF);
339 337
340 GrAutoScratchTexture ast; 338 GrTexture* texture(helper.createTexture());
341 if (!helper.getTexture(&ast)) { 339 if (!texture) {
342 return NULL; 340 return NULL;
343 } 341 }
344 342
345 helper.toTexture(ast.texture()); 343 helper.toTexture(texture);
346 344
347 return ast.detach(); 345 return texture;
348 } 346 }
349 347
350 void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture, 348 void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture,
351 GrDrawTarget* target, 349 GrDrawTarget* target,
352 const SkIRect& rect) { 350 const SkIRect& rect) {
353 GrDrawState* drawState = target->drawState(); 351 GrDrawState* drawState = target->drawState();
354 352
355 GrDrawState::AutoViewMatrixRestore avmr; 353 GrDrawState::AutoViewMatrixRestore avmr;
356 if (!avmr.setIdentity(drawState)) { 354 if (!avmr.setIdentity(drawState)) {
357 return; 355 return;
(...skipping 15 matching lines...) Expand all
373 maskMatrix.preConcat(drawState->getViewMatrix()); 371 maskMatrix.preConcat(drawState->getViewMatrix());
374 372
375 drawState->addCoverageProcessor( 373 drawState->addCoverageProcessor(
376 GrSimpleTextureEffect::Create(texture, 374 GrSimpleTextureEffect::Create(texture,
377 maskMatrix, 375 maskMatrix,
378 GrTextureParams::kNone_Fi lterMode, 376 GrTextureParams::kNone_Fi lterMode,
379 kPosition_GrCoordSet))->u nref(); 377 kPosition_GrCoordSet))->u nref();
380 378
381 target->drawSimpleRect(dstRect); 379 target->drawSimpleRect(dstRect);
382 } 380 }
OLDNEW
« no previous file with comments | « src/gpu/GrSWMaskHelper.h ('k') | src/gpu/GrSoftwarePathRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698