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

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

Issue 732693002: Drawstate on stack (Closed) Base URL: https://skia.googlesource.com/skia.git@real_def_gp
Patch Set: tiny fix 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/GrStencilAndCoverTextContext.h ('k') | src/gpu/GrTest.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 2014 Google Inc. 2 * Copyright 2014 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 "GrStencilAndCoverTextContext.h" 8 #include "GrStencilAndCoverTextContext.h"
9 #include "GrBitmapTextContext.h" 9 #include "GrBitmapTextContext.h"
10 #include "GrDrawTarget.h" 10 #include "GrDrawTarget.h"
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 fPaint.localCoordChange(textMatrix); 326 fPaint.localCoordChange(textMatrix);
327 fContext->concatMatrix(textMatrix); 327 fContext->concatMatrix(textMatrix);
328 328
329 fGlyphCache = fSkPaint.detachCache(&fDeviceProperties, NULL, false); 329 fGlyphCache = fSkPaint.detachCache(&fDeviceProperties, NULL, false);
330 fGlyphs = canUseRawPaths ? 330 fGlyphs = canUseRawPaths ?
331 get_gr_glyphs(fContext, fSkPaint.getTypeface(), NULL, gpuS troke) : 331 get_gr_glyphs(fContext, fSkPaint.getTypeface(), NULL, gpuS troke) :
332 get_gr_glyphs(fContext, fGlyphCache->getScalerContext()->g etTypeface(), 332 get_gr_glyphs(fContext, fGlyphCache->getScalerContext()->g etTypeface(),
333 &fGlyphCache->getDescriptor(), gpuStroke); 333 &fGlyphCache->getDescriptor(), gpuStroke);
334 } 334 }
335 335
336 fStateRestore.set(fDrawTarget->drawState()); 336 fStateRestore.set(&fDrawState);
337 337
338 fDrawTarget->drawState()->setFromPaint(fPaint, fContext->getMatrix(), 338 fDrawState.setFromPaint(fPaint, fContext->getMatrix(), fContext->getRenderTa rget());
339 fContext->getRenderTarget());
340 339
341 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, 340 GR_STATIC_CONST_SAME_STENCIL(kStencilPass,
342 kZero_StencilOp, 341 kZero_StencilOp,
343 kZero_StencilOp, 342 kZero_StencilOp,
344 kNotEqual_StencilFunc, 343 kNotEqual_StencilFunc,
345 0xffff, 344 0xffff,
346 0x0000, 345 0x0000,
347 0xffff); 346 0xffff);
348 347
349 *fDrawTarget->drawState()->stencil() = kStencilPass; 348 *fDrawState.stencil() = kStencilPass;
350 349
351 SkASSERT(0 == fPendingGlyphCount); 350 SkASSERT(0 == fPendingGlyphCount);
352 } 351 }
353 352
354 inline void GrStencilAndCoverTextContext::appendGlyph(uint16_t glyphID, float x, float y) { 353 inline void GrStencilAndCoverTextContext::appendGlyph(uint16_t glyphID, float x, float y) {
355 if (fPendingGlyphCount >= kGlyphBufferSize) { 354 if (fPendingGlyphCount >= kGlyphBufferSize) {
356 this->flush(); 355 this->flush();
357 } 356 }
358 357
359 fIndexBuffer[fPendingGlyphCount] = glyphID; 358 fIndexBuffer[fPendingGlyphCount] = glyphID;
360 fTransformBuffer[2 * fPendingGlyphCount] = fTextInverseRatio * x; 359 fTransformBuffer[2 * fPendingGlyphCount] = fTextInverseRatio * x;
361 fTransformBuffer[2 * fPendingGlyphCount + 1] = -fTextInverseRatio * y; 360 fTransformBuffer[2 * fPendingGlyphCount + 1] = -fTextInverseRatio * y;
362 361
363 ++fPendingGlyphCount; 362 ++fPendingGlyphCount;
364 } 363 }
365 364
366 void GrStencilAndCoverTextContext::flush() { 365 void GrStencilAndCoverTextContext::flush() {
367 if (0 == fPendingGlyphCount) { 366 if (0 == fPendingGlyphCount) {
368 return; 367 return;
369 } 368 }
370 369
371 fDrawTarget->drawPaths(fGlyphs, fIndexBuffer, fPendingGlyphCount, fTransform Buffer, 370 fDrawTarget->drawPaths(&fDrawState, fGlyphs, fIndexBuffer, fPendingGlyphCoun t, fTransformBuffer,
372 GrPathRendering::kTranslate_PathTransformType, 371 GrPathRendering::kTranslate_PathTransformType,
373 GrPathRendering::kWinding_FillType); 372 GrPathRendering::kWinding_FillType);
374 373
375 fPendingGlyphCount = 0; 374 fPendingGlyphCount = 0;
376 } 375 }
377 376
378 void GrStencilAndCoverTextContext::finish() { 377 void GrStencilAndCoverTextContext::finish() {
379 this->flush(); 378 this->flush();
380 379
381 fGlyphs->unref(); 380 fGlyphs->unref();
382 fGlyphs = NULL; 381 fGlyphs = NULL;
383 382
384 SkGlyphCache::AttachCache(fGlyphCache); 383 SkGlyphCache::AttachCache(fGlyphCache);
385 fGlyphCache = NULL; 384 fGlyphCache = NULL;
386 385
387 fDrawTarget->drawState()->stencil()->setDisabled(); 386 fDrawState.stencil()->setDisabled();
388 fStateRestore.set(NULL); 387 fStateRestore.set(NULL);
389 fContext->setMatrix(fContextInitialMatrix); 388 fContext->setMatrix(fContextInitialMatrix);
390 GrTextContext::finish(); 389 GrTextContext::finish();
391 } 390 }
392 391
OLDNEW
« no previous file with comments | « src/gpu/GrStencilAndCoverTextContext.h ('k') | src/gpu/GrTest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698