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

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

Issue 22043006: Separate quad UV calculation from bloat_quad (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 2011 Google Inc. 2 * Copyright 2011 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 "GrAAHairLinePathRenderer.h" 8 #include "GrAAHairLinePathRenderer.h"
9 9
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 SkScalarMul(normA.fY, normB.fX); 465 SkScalarMul(normA.fY, normB.fX);
466 wInv = SkScalarInvert(wInv); 466 wInv = SkScalarInvert(wInv);
467 467
468 result->fX = SkScalarMul(normA.fY, lineBW) - SkScalarMul(lineAW, normB.fY); 468 result->fX = SkScalarMul(normA.fY, lineBW) - SkScalarMul(lineAW, normB.fY);
469 result->fX = SkScalarMul(result->fX, wInv); 469 result->fX = SkScalarMul(result->fX, wInv);
470 470
471 result->fY = SkScalarMul(lineAW, normB.fX) - SkScalarMul(normA.fX, lineBW); 471 result->fY = SkScalarMul(lineAW, normB.fX) - SkScalarMul(normA.fX, lineBW);
472 result->fY = SkScalarMul(result->fY, wInv); 472 result->fY = SkScalarMul(result->fY, wInv);
473 } 473 }
474 474
475 void set_uv_quad(const SkPoint qpts[3], Vertex verts[kVertsPerQuad]) {
476 // this should be in the src space, not dev coords, when we have perspective
477 GrPathUtils::QuadUVMatrix DevToUV(qpts);
478 DevToUV.apply<kVertsPerQuad, sizeof(Vertex), sizeof(GrPoint)>(verts);
479 }
480
475 void bloat_quad(const SkPoint qpts[3], const SkMatrix* toDevice, 481 void bloat_quad(const SkPoint qpts[3], const SkMatrix* toDevice,
476 const SkMatrix* toSrc, Vertex verts[kVertsPerQuad], 482 const SkMatrix* toSrc, Vertex verts[kVertsPerQuad],
477 SkRect* devBounds) { 483 SkRect* devBounds) {
478 GrAssert(!toDevice == !toSrc); 484 GrAssert(!toDevice == !toSrc);
479 // original quad is specified by tri a,b,c 485 // original quad is specified by tri a,b,c
480 SkPoint a = qpts[0]; 486 SkPoint a = qpts[0];
481 SkPoint b = qpts[1]; 487 SkPoint b = qpts[1];
482 SkPoint c = qpts[2]; 488 SkPoint c = qpts[2];
483 489
484 // this should be in the src space, not dev coords, when we have perspective
485 GrPathUtils::QuadUVMatrix DevToUV(qpts);
486
487 if (toDevice) { 490 if (toDevice) {
488 toDevice->mapPoints(&a, 1); 491 toDevice->mapPoints(&a, 1);
489 toDevice->mapPoints(&b, 1); 492 toDevice->mapPoints(&b, 1);
490 toDevice->mapPoints(&c, 1); 493 toDevice->mapPoints(&c, 1);
491 } 494 }
492 // make a new poly where we replace a and c by a 1-pixel wide edges orthog 495 // make a new poly where we replace a and c by a 1-pixel wide edges orthog
493 // to edges ab and bc: 496 // to edges ab and bc:
494 // 497 //
495 // before | after 498 // before | after
496 // | b0 499 // | b0
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 c1.fPos -= cbN; 545 c1.fPos -= cbN;
543 546
544 // This point may not be within 1 pixel of a control point. We update the bo unding box to 547 // This point may not be within 1 pixel of a control point. We update the bo unding box to
545 // include it. 548 // include it.
546 intersect_lines(a0.fPos, abN, c0.fPos, cbN, &b0.fPos); 549 intersect_lines(a0.fPos, abN, c0.fPos, cbN, &b0.fPos);
547 devBounds->growToInclude(b0.fPos.fX, b0.fPos.fY); 550 devBounds->growToInclude(b0.fPos.fX, b0.fPos.fY);
548 551
549 if (toSrc) { 552 if (toSrc) {
550 toSrc->mapPointsWithStride(&verts[0].fPos, sizeof(Vertex), kVertsPerQuad ); 553 toSrc->mapPointsWithStride(&verts[0].fPos, sizeof(Vertex), kVertsPerQuad );
551 } 554 }
552 DevToUV.apply<kVertsPerQuad, sizeof(Vertex), sizeof(GrPoint)>(verts);
553 } 555 }
554 556
555 // Input: 557 // Input:
556 // Three control points: p[0], p[1], p[2] and weight: w 558 // Three control points: p[0], p[1], p[2] and weight: w
557 // Output: 559 // Output:
558 // Let: 560 // Let:
559 // l = (2*w * (y1 - y0), 2*w * (x0 - x1), 2*w * (x1*y0 - x0*y1)) 561 // l = (2*w * (y1 - y0), 2*w * (x0 - x1), 2*w * (x1*y0 - x0*y1))
560 // m = (2*w * (y2 - y1), 2*w * (x1 - x2), 2*w * (x2*y1 - x1*y2)) 562 // m = (2*w * (y2 - y1), 2*w * (x1 - x2), 2*w * (x2*y1 - x1*y2))
561 // k = (y2 - y0, x0 - x2, (x2 - x0)*y0 - (y2 - y0)*x0 ) 563 // k = (y2 - y0, x0 - x2, (x2 - x0)*y0 - (y2 - y0)*x0 )
562 void calc_conic_klm(const SkPoint p[3], const SkScalar weight, 564 void calc_conic_klm(const SkPoint p[3], const SkScalar weight,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 Vertex** vert, 636 Vertex** vert,
635 SkRect* devBounds) { 637 SkRect* devBounds) {
636 GrAssert(subdiv >= 0); 638 GrAssert(subdiv >= 0);
637 if (subdiv) { 639 if (subdiv) {
638 SkPoint newP[5]; 640 SkPoint newP[5];
639 SkChopQuadAtHalf(p, newP); 641 SkChopQuadAtHalf(p, newP);
640 add_quads(newP + 0, subdiv-1, toDevice, toSrc, vert, devBounds); 642 add_quads(newP + 0, subdiv-1, toDevice, toSrc, vert, devBounds);
641 add_quads(newP + 2, subdiv-1, toDevice, toSrc, vert, devBounds); 643 add_quads(newP + 2, subdiv-1, toDevice, toSrc, vert, devBounds);
642 } else { 644 } else {
643 bloat_quad(p, toDevice, toSrc, *vert, devBounds); 645 bloat_quad(p, toDevice, toSrc, *vert, devBounds);
646 set_uv_quad(p, *vert);
644 *vert += kVertsPerQuad; 647 *vert += kVertsPerQuad;
645 } 648 }
646 } 649 }
647 650
648 void add_line(const SkPoint p[2], 651 void add_line(const SkPoint p[2],
649 int rtHeight, 652 int rtHeight,
650 const SkMatrix* toSrc, 653 const SkMatrix* toSrc,
651 Vertex** vert) { 654 Vertex** vert) {
652 const SkPoint& a = p[0]; 655 const SkPoint& a = p[0];
653 const SkPoint& b = p[1]; 656 const SkPoint& b = p[1];
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 kVertsPerQuad*n, // vCount 1238 kVertsPerQuad*n, // vCount
1236 kIdxsPerQuad*n, // iCount 1239 kIdxsPerQuad*n, // iCount
1237 &devBounds); 1240 &devBounds);
1238 conics += n; 1241 conics += n;
1239 } 1242 }
1240 } 1243 }
1241 target->resetIndexSource(); 1244 target->resetIndexSource();
1242 1245
1243 return true; 1246 return true;
1244 } 1247 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698