diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-30 10:08:22 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-30 10:08:22 +0000 |
commit | 559a8833f0eae4af37dc0ffc3ee97e1fb14817b1 (patch) | |
tree | a386900cea6eec76e4f8b5d7133f8e14c3864887 /src/core/SkVertState.cpp | |
parent | 9681eebb0e441cee25b6faac82c3728512acda27 (diff) |
Fix the rendering error of SkDraw::drawVertices in gpu path for solid color.
If both textures and vertex-colors are NULL, drawVertices should stroke hairlines with the paint's color.
This behavior is a useful debugging mode to visualize the mesh.
BUG=skia:2266
R=bsalomon@google.com, reed@google.com
Author: yunchao.he@intel.com
Review URL: https://codereview.chromium.org/189963004
git-svn-id: http://skia.googlecode.com/svn/trunk@14985 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkVertState.cpp')
-rw-r--r-- | src/core/SkVertState.cpp | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/src/core/SkVertState.cpp b/src/core/SkVertState.cpp new file mode 100644 index 0000000000..f23b1083fe --- /dev/null +++ b/src/core/SkVertState.cpp @@ -0,0 +1,106 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkVertState.h" + +bool VertState::Triangles(VertState* state) { + int index = state->fCurrIndex; + if (index + 3 > state->fCount) { + return false; + } + state->f0 = index + 0; + state->f1 = index + 1; + state->f2 = index + 2; + state->fCurrIndex = index + 3; + return true; +} + +bool VertState::TrianglesX(VertState* state) { + const uint16_t* indices = state->fIndices; + int index = state->fCurrIndex; + if (index + 3 > state->fCount) { + return false; + } + state->f0 = indices[index + 0]; + state->f1 = indices[index + 1]; + state->f2 = indices[index + 2]; + state->fCurrIndex = index + 3; + return true; +} + +bool VertState::TriangleStrip(VertState* state) { + int index = state->fCurrIndex; + if (index + 3 > state->fCount) { + return false; + } + state->f2 = index + 2; + if (index & 1) { + state->f0 = index + 1; + state->f1 = index + 0; + } else { + state->f0 = index + 0; + state->f1 = index + 1; + } + state->fCurrIndex = index + 1; + return true; +} + +bool VertState::TriangleStripX(VertState* state) { + const uint16_t* indices = state->fIndices; + int index = state->fCurrIndex; + if (index + 3 > state->fCount) { + return false; + } + state->f2 = indices[index + 2]; + if (index & 1) { + state->f0 = indices[index + 1]; + state->f1 = indices[index + 0]; + } else { + state->f0 = indices[index + 0]; + state->f1 = indices[index + 1]; + } + state->fCurrIndex = index + 1; + return true; +} + +bool VertState::TriangleFan(VertState* state) { + int index = state->fCurrIndex; + if (index + 3 > state->fCount) { + return false; + } + state->f0 = 0; + state->f1 = index + 1; + state->f2 = index + 2; + state->fCurrIndex = index + 1; + return true; +} + +bool VertState::TriangleFanX(VertState* state) { + const uint16_t* indices = state->fIndices; + int index = state->fCurrIndex; + if (index + 3 > state->fCount) { + return false; + } + state->f0 = indices[0]; + state->f1 = indices[index + 1]; + state->f2 = indices[index + 2]; + state->fCurrIndex = index + 1; + return true; +} + +VertState::Proc VertState::chooseProc(SkCanvas::VertexMode mode) { + switch (mode) { + case SkCanvas::kTriangles_VertexMode: + return fIndices ? TrianglesX : Triangles; + case SkCanvas::kTriangleStrip_VertexMode: + return fIndices ? TriangleStripX : TriangleStrip; + case SkCanvas::kTriangleFan_VertexMode: + return fIndices ? TriangleFanX : TriangleFan; + default: + return NULL; + } +} |