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

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: Removed tabs 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
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 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 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 10 matching lines...) Expand all
429 SkScalar yRadius = SkScalarHalf(xformedRect.height()); 445 SkScalar yRadius = SkScalarHalf(xformedRect.height());
430 if (SkScalarDiv(xRadius, yRadius) > 2 || SkScalarDiv(yRadius, xRadius) > 2) { 446 if (SkScalarDiv(xRadius, yRadius) > 2 || SkScalarDiv(yRadius, xRadius) > 2) {
431 return false; 447 return false;
432 } 448 }
433 449
434 GrDrawState::AutoDeviceCoordDraw adcd(drawState); 450 GrDrawState::AutoDeviceCoordDraw adcd(drawState);
435 if (!adcd.succeeded()) { 451 if (!adcd.succeeded()) {
436 return false; 452 return false;
437 } 453 }
438 454
439 // position + edge 455 drawState->setVertexAttribs<gEllipseVertexAttribs>(SK_ARRAY_COUNT(gEllipseVe rtexAttribs));
440 static const GrVertexAttrib kVertexAttribs[] = {
441 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
442 {kVec2f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBindi ng},
443 {kVec4f_GrVertexAttribType, 2*sizeof(GrPoint), kEffect_GrVertexAttribBin ding}
444 };
445 drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs));
446 GrAssert(sizeof(EllipseVertex) == drawState->getVertexSize()); 456 GrAssert(sizeof(EllipseVertex) == drawState->getVertexSize());
447 457
448 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); 458 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0);
449 if (!geo.succeeded()) { 459 if (!geo.succeeded()) {
450 GrPrintf("Failed to get space for vertices!\n"); 460 GrPrintf("Failed to get space for vertices!\n");
451 return false; 461 return false;
452 } 462 }
453 463
454 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices()); 464 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices());
455 465
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom); 547 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom);
538 verts[3].fOuterXRadius = xRadius; 548 verts[3].fOuterXRadius = xRadius;
539 verts[3].fInnerXRadius = innerXRadius; 549 verts[3].fInnerXRadius = innerXRadius;
540 verts[3].fOuterOffset = SkPoint::Make(xRadius, outerRatio*yRadius); 550 verts[3].fOuterOffset = SkPoint::Make(xRadius, outerRatio*yRadius);
541 verts[3].fInnerOffset = SkPoint::Make(xRadius, innerRatio*yRadius); 551 verts[3].fInnerOffset = SkPoint::Make(xRadius, innerRatio*yRadius);
542 552
543 target->drawNonIndexed(kTriangleStrip_GrPrimitiveType, 0, 4, &bounds); 553 target->drawNonIndexed(kTriangleStrip_GrPrimitiveType, 0, 4, &bounds);
544 554
545 return true; 555 return true;
546 } 556 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698