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

Side by Side Diff: gm/beziereffects.cpp

Issue 979343002: handle null vertex or index buffers in batch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanup Created 5 years, 9 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
« no previous file with comments | « no previous file | gm/convexpolyeffect.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 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 // This test only works with the GPU backend. 9 // This test only works with the GPU backend.
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 size_t vertexStride = this->geometryProcessor()->getVertexStride(); 69 size_t vertexStride = this->geometryProcessor()->getVertexStride();
70 70
71 const GrVertexBuffer* vertexBuffer; 71 const GrVertexBuffer* vertexBuffer;
72 int firstVertex; 72 int firstVertex;
73 73
74 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, 74 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
75 kVertsPerCubic, 75 kVertsPerCubic,
76 &vertexBuffer, 76 &vertexBuffer,
77 &firstVertex); 77 &firstVertex);
78 78
79 if (!vertices || !batchTarget->quadIndexBuffer()) {
80 SkDebugf("Could not allocate buffers\n");
81 return;
82 }
83
79 SkASSERT(vertexStride == sizeof(Vertex)); 84 SkASSERT(vertexStride == sizeof(Vertex));
80 Vertex* verts = reinterpret_cast<Vertex*>(vertices); 85 Vertex* verts = reinterpret_cast<Vertex*>(vertices);
81 86
82 verts[0].fPosition.setRectFan(fGeometry.fBounds.fLeft, fGeometry.fBounds .fTop, 87 verts[0].fPosition.setRectFan(fGeometry.fBounds.fLeft, fGeometry.fBounds .fTop,
83 fGeometry.fBounds.fRight, fGeometry.fBound s.fBottom, 88 fGeometry.fBounds.fRight, fGeometry.fBound s.fBottom,
84 sizeof(Vertex)); 89 sizeof(Vertex));
85 for (int v = 0; v < 4; ++v) { 90 for (int v = 0; v < 4; ++v) {
86 verts[v].fKLM[0] = eval_line(verts[v].fPosition, fKlmEqs + 0, fSign) ; 91 verts[v].fKLM[0] = eval_line(verts[v].fPosition, fKlmEqs + 0, fSign) ;
87 verts[v].fKLM[1] = eval_line(verts[v].fPosition, fKlmEqs + 3, fSign) ; 92 verts[v].fKLM[1] = eval_line(verts[v].fPosition, fKlmEqs + 3, fSign) ;
88 verts[v].fKLM[2] = eval_line(verts[v].fPosition, fKlmEqs + 6, 1.f); 93 verts[v].fKLM[2] = eval_line(verts[v].fPosition, fKlmEqs + 6, 1.f);
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 size_t vertexStride = this->geometryProcessor()->getVertexStride(); 476 size_t vertexStride = this->geometryProcessor()->getVertexStride();
472 477
473 const GrVertexBuffer* vertexBuffer; 478 const GrVertexBuffer* vertexBuffer;
474 int firstVertex; 479 int firstVertex;
475 480
476 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, 481 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
477 kVertsPerCubic, 482 kVertsPerCubic,
478 &vertexBuffer, 483 &vertexBuffer,
479 &firstVertex); 484 &firstVertex);
480 485
486 if (!vertices || !batchTarget->quadIndexBuffer()) {
487 SkDebugf("Could not allocate buffers\n");
488 return;
489 }
490
481 SkASSERT(vertexStride == sizeof(Vertex)); 491 SkASSERT(vertexStride == sizeof(Vertex));
482 Vertex* verts = reinterpret_cast<Vertex*>(vertices); 492 Vertex* verts = reinterpret_cast<Vertex*>(vertices);
483 493
484 verts[0].fPosition.setRectFan(fGeometry.fBounds.fLeft, fGeometry.fBounds .fTop, 494 verts[0].fPosition.setRectFan(fGeometry.fBounds.fLeft, fGeometry.fBounds .fTop,
485 fGeometry.fBounds.fRight, fGeometry.fBound s.fBottom, 495 fGeometry.fBounds.fRight, fGeometry.fBound s.fBottom,
486 sizeof(Vertex)); 496 sizeof(Vertex));
487 497
488 fDevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts); 498 fDevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts);
489 499
490 500
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 typedef GM INHERITED; 656 typedef GM INHERITED;
647 }; 657 };
648 658
649 DEF_GM( return SkNEW(BezierCubicEffects); ) 659 DEF_GM( return SkNEW(BezierCubicEffects); )
650 DEF_GM( return SkNEW(BezierConicEffects); ) 660 DEF_GM( return SkNEW(BezierConicEffects); )
651 DEF_GM( return SkNEW(BezierQuadEffects); ) 661 DEF_GM( return SkNEW(BezierQuadEffects); )
652 662
653 } 663 }
654 664
655 #endif 665 #endif
OLDNEW
« no previous file with comments | « no previous file | gm/convexpolyeffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698