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

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

Issue 14328009: Vertex Attrib configurations now handled as pointers vs. SkSTArrays (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Added "extern const" & removed comment Created 7 years, 8 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 | « src/gpu/GrInOrderDrawBuffer.cpp ('k') | src/gpu/GrTextContext.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 2013 Google Inc. 2 * Copyright 2013 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 "GrOvalRenderer.h" 8 #include "GrOvalRenderer.h"
9 9
10 #include "GrEffect.h" 10 #include "GrEffect.h"
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } else if (vm.rectStaysRect()) { 299 } else if (vm.rectStaysRect()) {
300 return drawEllipse(target, paint, oval, stroke); 300 return drawEllipse(target, paint, oval, stroke);
301 301
302 } else { 302 } else {
303 return false; 303 return false;
304 } 304 }
305 305
306 return true; 306 return true;
307 } 307 }
308 308
309 namespace {
310
311 // position + edge
312 extern const GrVertexAttrib gCircleVertexAttribs[] = {
313 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding },
314 {kVec4f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding}
315 };
316
317 };
318
309 void GrOvalRenderer::drawCircle(GrDrawTarget* target, 319 void GrOvalRenderer::drawCircle(GrDrawTarget* target,
310 const GrPaint& paint, 320 const GrPaint& paint,
311 const GrRect& circle, 321 const GrRect& circle,
312 const SkStrokeRec& stroke) 322 const SkStrokeRec& stroke)
313 { 323 {
314 GrDrawState* drawState = target->drawState(); 324 GrDrawState* drawState = target->drawState();
315 325
316 const SkMatrix& vm = drawState->getViewMatrix(); 326 const SkMatrix& vm = drawState->getViewMatrix();
317 GrPoint center = GrPoint::Make(circle.centerX(), circle.centerY()); 327 GrPoint center = GrPoint::Make(circle.centerX(), circle.centerY());
318 vm.mapPoints(&center, 1); 328 vm.mapPoints(&center, 1);
319 SkScalar radius = vm.mapRadius(SkScalarHalf(circle.width())); 329 SkScalar radius = vm.mapRadius(SkScalarHalf(circle.width()));
320 SkScalar strokeWidth = vm.mapRadius(stroke.getWidth()); 330 SkScalar strokeWidth = vm.mapRadius(stroke.getWidth());
321 331
322 GrDrawState::AutoDeviceCoordDraw adcd(drawState); 332 GrDrawState::AutoDeviceCoordDraw adcd(drawState);
323 if (!adcd.succeeded()) { 333 if (!adcd.succeeded()) {
324 return; 334 return;
325 } 335 }
326 336
327 // position + edge 337 drawState->setVertexAttribs<gCircleVertexAttribs>(SK_ARRAY_COUNT(gCircleVert exAttribs));
328 static const GrVertexAttrib kVertexAttribs[] = {
329 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
330 {kVec4f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBindi ng}
331 };
332 drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs));
333 GrAssert(sizeof(CircleVertex) == drawState->getVertexSize()); 338 GrAssert(sizeof(CircleVertex) == drawState->getVertexSize());
334 339
335 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); 340 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0);
336 if (!geo.succeeded()) { 341 if (!geo.succeeded()) {
337 GrPrintf("Failed to get space for vertices!\n"); 342 GrPrintf("Failed to get space for vertices!\n");
338 return; 343 return;
339 } 344 }
340 345
341 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices()); 346 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices());
342 347
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 verts[2].fInnerRadius = innerRadius; 404 verts[2].fInnerRadius = innerRadius;
400 405
401 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom); 406 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom);
402 verts[3].fOffset = SkPoint::Make(outerRadius, outerRadius); 407 verts[3].fOffset = SkPoint::Make(outerRadius, outerRadius);
403 verts[3].fOuterRadius = outerRadius; 408 verts[3].fOuterRadius = outerRadius;
404 verts[3].fInnerRadius = innerRadius; 409 verts[3].fInnerRadius = innerRadius;
405 410
406 target->drawNonIndexed(kTriangleStrip_GrPrimitiveType, 0, 4, &bounds); 411 target->drawNonIndexed(kTriangleStrip_GrPrimitiveType, 0, 4, &bounds);
407 } 412 }
408 413
414 namespace {
415
416 // position + edge
417 extern const GrVertexAttrib gEllipseVertexAttribs[] = {
418 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBindi ng},
419 {kVec2f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding },
420 {kVec4f_GrVertexAttribType, 2*sizeof(GrPoint), kEffect_GrVertexAttribBinding }
421 };
422
423 };
424
409 bool GrOvalRenderer::drawEllipse(GrDrawTarget* target, 425 bool GrOvalRenderer::drawEllipse(GrDrawTarget* target,
410 const GrPaint& paint, 426 const GrPaint& paint,
411 const GrRect& ellipse, 427 const GrRect& ellipse,
412 const SkStrokeRec& stroke) 428 const SkStrokeRec& stroke)
413 { 429 {
414 GrDrawState* drawState = target->drawState(); 430 GrDrawState* drawState = target->drawState();
415 #ifdef SK_DEBUG 431 #ifdef SK_DEBUG
416 { 432 {
417 // we should have checked for this previously 433 // we should have checked for this previously
418 bool isAxisAlignedEllipse = drawState->getViewMatrix().rectStaysRect(); 434 bool isAxisAlignedEllipse = drawState->getViewMatrix().rectStaysRect();
(...skipping 19 matching lines...) Expand all
438 SkVector scaledStroke; 454 SkVector scaledStroke;
439 SkScalar strokeWidth = stroke.getWidth(); 455 SkScalar strokeWidth = stroke.getWidth();
440 scaledStroke.fX = SkScalarAbs(strokeWidth*(vm[SkMatrix::kMScaleX] + vm[SkMat rix::kMSkewY])); 456 scaledStroke.fX = SkScalarAbs(strokeWidth*(vm[SkMatrix::kMScaleX] + vm[SkMat rix::kMSkewY]));
441 scaledStroke.fY = SkScalarAbs(strokeWidth*(vm[SkMatrix::kMSkewX] + vm[SkMatr ix::kMScaleY])); 457 scaledStroke.fY = SkScalarAbs(strokeWidth*(vm[SkMatrix::kMSkewX] + vm[SkMatr ix::kMScaleY]));
442 458
443 GrDrawState::AutoDeviceCoordDraw adcd(drawState); 459 GrDrawState::AutoDeviceCoordDraw adcd(drawState);
444 if (!adcd.succeeded()) { 460 if (!adcd.succeeded()) {
445 return false; 461 return false;
446 } 462 }
447 463
448 // position + edge 464 drawState->setVertexAttribs<gEllipseVertexAttribs>(SK_ARRAY_COUNT(gEllipseVe rtexAttribs));
449 static const GrVertexAttrib kVertexAttribs[] = {
450 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
451 {kVec2f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBindi ng},
452 {kVec4f_GrVertexAttribType, 2*sizeof(GrPoint), kEffect_GrVertexAttribBin ding}
453 };
454 drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs));
455 GrAssert(sizeof(EllipseVertex) == drawState->getVertexSize()); 465 GrAssert(sizeof(EllipseVertex) == drawState->getVertexSize());
456 466
457 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); 467 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0);
458 if (!geo.succeeded()) { 468 if (!geo.succeeded()) {
459 GrPrintf("Failed to get space for vertices!\n"); 469 GrPrintf("Failed to get space for vertices!\n");
460 return false; 470 return false;
461 } 471 }
462 472
463 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices()); 473 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices());
464 474
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom); 551 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom);
542 verts[3].fOuterXRadius = xRadius; 552 verts[3].fOuterXRadius = xRadius;
543 verts[3].fInnerXRadius = innerXRadius; 553 verts[3].fInnerXRadius = innerXRadius;
544 verts[3].fOuterOffset = SkPoint::Make(xRadius, outerRatio*yRadius); 554 verts[3].fOuterOffset = SkPoint::Make(xRadius, outerRatio*yRadius);
545 verts[3].fInnerOffset = SkPoint::Make(xRadius, innerRatio*yRadius); 555 verts[3].fInnerOffset = SkPoint::Make(xRadius, innerRatio*yRadius);
546 556
547 target->drawNonIndexed(kTriangleStrip_GrPrimitiveType, 0, 4, &bounds); 557 target->drawNonIndexed(kTriangleStrip_GrPrimitiveType, 0, 4, &bounds);
548 558
549 return true; 559 return true;
550 } 560 }
OLDNEW
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.cpp ('k') | src/gpu/GrTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698