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

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

Issue 14890021: Remove isIRect "optimization" & defer computation of device Rect in AA rect rendering (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « include/gpu/GrAARectRenderer.h ('k') | src/gpu/GrClipMaskManager.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 "GrAARectRenderer.h" 8 #include "GrAARectRenderer.h"
9 #include "GrRefCnt.h" 9 #include "GrRefCnt.h"
10 #include "GrGpu.h" 10 #include "GrGpu.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 GR_DEBUGASSERT(updated); 357 GR_DEBUGASSERT(updated);
358 } 358 }
359 } 359 }
360 return fAAStrokeRectIndexBuffer; 360 return fAAStrokeRectIndexBuffer;
361 } 361 }
362 362
363 void GrAARectRenderer::geometryFillAARect(GrGpu* gpu, 363 void GrAARectRenderer::geometryFillAARect(GrGpu* gpu,
364 GrDrawTarget* target, 364 GrDrawTarget* target,
365 const GrRect& rect, 365 const GrRect& rect,
366 const SkMatrix& combinedMatrix, 366 const SkMatrix& combinedMatrix,
367 const GrRect& devRect,
368 bool useVertexCoverage) { 367 bool useVertexCoverage) {
369 GrDrawState* drawState = target->drawState(); 368 GrDrawState* drawState = target->drawState();
370 369
371 set_aa_rect_vertex_attributes(drawState, useVertexCoverage); 370 set_aa_rect_vertex_attributes(drawState, useVertexCoverage);
372 371
373 GrDrawTarget::AutoReleaseGeometry geo(target, 8, 0); 372 GrDrawTarget::AutoReleaseGeometry geo(target, 8, 0);
374 if (!geo.succeeded()) { 373 if (!geo.succeeded()) {
375 GrPrintf("Failed to get space for vertices!\n"); 374 GrPrintf("Failed to get space for vertices!\n");
376 return; 375 return;
377 } 376 }
378 377
379 GrIndexBuffer* indexBuffer = this->aaFillRectIndexBuffer(gpu); 378 GrIndexBuffer* indexBuffer = this->aaFillRectIndexBuffer(gpu);
380 if (NULL == indexBuffer) { 379 if (NULL == indexBuffer) {
381 GrPrintf("Failed to create index buffer!\n"); 380 GrPrintf("Failed to create index buffer!\n");
382 return; 381 return;
383 } 382 }
384 383
385 intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices()); 384 intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices());
386 size_t vsize = drawState->getVertexSize(); 385 size_t vsize = drawState->getVertexSize();
387 GrAssert(sizeof(GrPoint) + sizeof(GrColor) == vsize); 386 GrAssert(sizeof(GrPoint) + sizeof(GrColor) == vsize);
388 387
389 GrPoint* fan0Pos = reinterpret_cast<GrPoint*>(verts); 388 GrPoint* fan0Pos = reinterpret_cast<GrPoint*>(verts);
390 GrPoint* fan1Pos = reinterpret_cast<GrPoint*>(verts + 4 * vsize); 389 GrPoint* fan1Pos = reinterpret_cast<GrPoint*>(verts + 4 * vsize);
391 390
391 SkRect devRect;
392 combinedMatrix.mapRect(&devRect, rect);
393
392 if (combinedMatrix.rectStaysRect()) { 394 if (combinedMatrix.rectStaysRect()) {
393 set_inset_fan(fan0Pos, vsize, devRect, -SK_ScalarHalf, -SK_ScalarHalf); 395 set_inset_fan(fan0Pos, vsize, devRect, -SK_ScalarHalf, -SK_ScalarHalf);
394 set_inset_fan(fan1Pos, vsize, devRect, SK_ScalarHalf, SK_ScalarHalf); 396 set_inset_fan(fan1Pos, vsize, devRect, SK_ScalarHalf, SK_ScalarHalf);
395 } else { 397 } else {
396 // compute transformed (1, 0) and (0, 1) vectors 398 // compute transformed (1, 0) and (0, 1) vectors
397 SkVector vec[2] = { 399 SkVector vec[2] = {
398 { combinedMatrix[SkMatrix::kMScaleX], combinedMatrix[SkMatrix::kMSkewY ] }, 400 { combinedMatrix[SkMatrix::kMScaleX], combinedMatrix[SkMatrix::kMSkewY ] },
399 { combinedMatrix[SkMatrix::kMSkewX], combinedMatrix[SkMatrix::kMScale Y] } 401 { combinedMatrix[SkMatrix::kMSkewX], combinedMatrix[SkMatrix::kMScale Y] }
400 }; 402 };
401 403
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 verts[3].fOffset = SkPoint::Make(widthHeight.fX, -widthHeight.fY); 611 verts[3].fOffset = SkPoint::Make(widthHeight.fX, -widthHeight.fY);
610 verts[3].fWidthHeight = widthHeight; 612 verts[3].fWidthHeight = widthHeight;
611 613
612 target->setIndexSourceToBuffer(gpu->getContext()->getQuadIndexBuffer()); 614 target->setIndexSourceToBuffer(gpu->getContext()->getQuadIndexBuffer());
613 target->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, 4, 6); 615 target->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, 4, 6);
614 target->resetIndexSource(); 616 target->resetIndexSource();
615 } 617 }
616 618
617 void GrAARectRenderer::strokeAARect(GrGpu* gpu, 619 void GrAARectRenderer::strokeAARect(GrGpu* gpu,
618 GrDrawTarget* target, 620 GrDrawTarget* target,
619 const GrRect& devRect, 621 const GrRect& rect,
622 const SkMatrix& combinedMatrix,
620 const GrVec& devStrokeSize, 623 const GrVec& devStrokeSize,
621 bool useVertexCoverage) { 624 bool useVertexCoverage) {
622 GrDrawState* drawState = target->drawState(); 625 GrDrawState* drawState = target->drawState();
623 626
624 const SkScalar& dx = devStrokeSize.fX; 627 const SkScalar dx = devStrokeSize.fX;
625 const SkScalar& dy = devStrokeSize.fY; 628 const SkScalar dy = devStrokeSize.fY;
626 const SkScalar rx = SkScalarMul(dx, SK_ScalarHalf); 629 const SkScalar rx = SkScalarMul(dx, SK_ScalarHalf);
627 const SkScalar ry = SkScalarMul(dy, SK_ScalarHalf); 630 const SkScalar ry = SkScalarMul(dy, SK_ScalarHalf);
628 631
632 SkRect devRect;
633 combinedMatrix.mapRect(&devRect, rect);
634
629 SkScalar spare; 635 SkScalar spare;
630 { 636 {
631 SkScalar w = devRect.width() - dx; 637 SkScalar w = devRect.width() - dx;
632 SkScalar h = devRect.height() - dy; 638 SkScalar h = devRect.height() - dy;
633 spare = GrMin(w, h); 639 spare = GrMin(w, h);
634 } 640 }
635 641
636 if (spare <= 0) { 642 if (spare <= 0) {
637 GrRect r(devRect); 643 devRect.inset(-rx, -ry);
638 r.inset(-rx, -ry); 644 this->fillAARect(gpu, target, devRect, SkMatrix::I(), useVertexCoverage) ;
639 this->fillAARect(gpu, target, r, SkMatrix::I(), r, useVertexCoverage);
640 return; 645 return;
641 } 646 }
642 647
643 set_aa_rect_vertex_attributes(drawState, useVertexCoverage); 648 set_aa_rect_vertex_attributes(drawState, useVertexCoverage);
644 649
645 GrDrawTarget::AutoReleaseGeometry geo(target, 16, 0); 650 GrDrawTarget::AutoReleaseGeometry geo(target, 16, 0);
646 if (!geo.succeeded()) { 651 if (!geo.succeeded()) {
647 GrPrintf("Failed to get space for vertices!\n"); 652 GrPrintf("Failed to get space for vertices!\n");
648 return; 653 return;
649 } 654 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 // The innermost rect has full coverage 700 // The innermost rect has full coverage
696 verts += 8 * vsize; 701 verts += 8 * vsize;
697 for (int i = 0; i < 4; ++i) { 702 for (int i = 0; i < 4; ++i) {
698 *reinterpret_cast<GrColor*>(verts + i * vsize) = 0; 703 *reinterpret_cast<GrColor*>(verts + i * vsize) = 0;
699 } 704 }
700 705
701 target->setIndexSourceToBuffer(indexBuffer); 706 target->setIndexSourceToBuffer(indexBuffer);
702 target->drawIndexed(kTriangles_GrPrimitiveType, 707 target->drawIndexed(kTriangles_GrPrimitiveType,
703 0, 0, 16, aaStrokeRectIndexCount()); 708 0, 0, 16, aaStrokeRectIndexCount());
704 } 709 }
OLDNEW
« no previous file with comments | « include/gpu/GrAARectRenderer.h ('k') | src/gpu/GrClipMaskManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698