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

Side by Side Diff: src/core/SkVertState.cpp

Issue 189963004: Fix the rendering error of SkDraw::drawVertices in gpu path for solid color (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: code rebase + update comments according to Brian's suggestions Created 6 years, 6 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 | « src/core/SkDraw.cpp ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkVertState.h"
9
10 bool VertState::Triangles(VertState* state) {
11 int index = state->fCurrIndex;
12 if (index + 3 > state->fCount) {
13 return false;
14 }
15 state->f0 = index + 0;
16 state->f1 = index + 1;
17 state->f2 = index + 2;
18 state->fCurrIndex = index + 3;
19 return true;
20 }
21
22 bool VertState::TrianglesX(VertState* state) {
23 const uint16_t* indices = state->fIndices;
24 int index = state->fCurrIndex;
25 if (index + 3 > state->fCount) {
26 return false;
27 }
28 state->f0 = indices[index + 0];
29 state->f1 = indices[index + 1];
30 state->f2 = indices[index + 2];
31 state->fCurrIndex = index + 3;
32 return true;
33 }
34
35 bool VertState::TriangleStrip(VertState* state) {
36 int index = state->fCurrIndex;
37 if (index + 3 > state->fCount) {
38 return false;
39 }
40 state->f2 = index + 2;
41 if (index & 1) {
42 state->f0 = index + 1;
43 state->f1 = index + 0;
44 } else {
45 state->f0 = index + 0;
46 state->f1 = index + 1;
47 }
48 state->fCurrIndex = index + 1;
49 return true;
50 }
51
52 bool VertState::TriangleStripX(VertState* state) {
53 const uint16_t* indices = state->fIndices;
54 int index = state->fCurrIndex;
55 if (index + 3 > state->fCount) {
56 return false;
57 }
58 state->f2 = indices[index + 2];
59 if (index & 1) {
60 state->f0 = indices[index + 1];
61 state->f1 = indices[index + 0];
62 } else {
63 state->f0 = indices[index + 0];
64 state->f1 = indices[index + 1];
65 }
66 state->fCurrIndex = index + 1;
67 return true;
68 }
69
70 bool VertState::TriangleFan(VertState* state) {
71 int index = state->fCurrIndex;
72 if (index + 3 > state->fCount) {
73 return false;
74 }
75 state->f0 = 0;
76 state->f1 = index + 1;
77 state->f2 = index + 2;
78 state->fCurrIndex = index + 1;
79 return true;
80 }
81
82 bool VertState::TriangleFanX(VertState* state) {
83 const uint16_t* indices = state->fIndices;
84 int index = state->fCurrIndex;
85 if (index + 3 > state->fCount) {
86 return false;
87 }
88 state->f0 = indices[0];
89 state->f1 = indices[index + 1];
90 state->f2 = indices[index + 2];
91 state->fCurrIndex = index + 1;
92 return true;
93 }
94
95 VertState::Proc VertState::chooseProc(SkCanvas::VertexMode mode) {
96 switch (mode) {
97 case SkCanvas::kTriangles_VertexMode:
98 return fIndices ? TrianglesX : Triangles;
99 case SkCanvas::kTriangleStrip_VertexMode:
100 return fIndices ? TriangleStripX : TriangleStrip;
101 case SkCanvas::kTriangleFan_VertexMode:
102 return fIndices ? TriangleFanX : TriangleFan;
103 default:
104 return NULL;
105 }
106 }
OLDNEW
« no previous file with comments | « src/core/SkDraw.cpp ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698