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

Side by Side Diff: src/gpu/SkGpuDevice.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: drawVertices should stroke hairlines if both textures and colors are NULL Created 6 years, 7 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
« include/core/SkVertState.h ('K') | « src/core/SkVertState.cpp ('k') | no next file » | 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 2011 Google Inc. 2 * Copyright 2011 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 "SkGpuDevice.h" 8 #include "SkGpuDevice.h"
9 9
10 #include "effects/GrBicubicEffect.h" 10 #include "effects/GrBicubicEffect.h"
11 #include "effects/GrTextureDomain.h" 11 #include "effects/GrTextureDomain.h"
12 #include "effects/GrSimpleTextureEffect.h" 12 #include "effects/GrSimpleTextureEffect.h"
13 13
14 #include "GrContext.h" 14 #include "GrContext.h"
15 #include "GrBitmapTextContext.h" 15 #include "GrBitmapTextContext.h"
16 #include "GrDistanceFieldTextContext.h" 16 #include "GrDistanceFieldTextContext.h"
17 #include "GrLayerCache.h" 17 #include "GrLayerCache.h"
18 #include "GrPictureUtils.h" 18 #include "GrPictureUtils.h"
19 19
20 #include "SkGrTexturePixelRef.h" 20 #include "SkGrTexturePixelRef.h"
21 21
22 #include "SkBounder.h" 22 #include "SkBounder.h"
23 #include "SkColorFilter.h" 23 #include "SkColorFilter.h"
24 #include "SkDeviceImageFilterProxy.h" 24 #include "SkDeviceImageFilterProxy.h"
25 #include "SkDrawProcs.h" 25 #include "SkDrawProcs.h"
26 #include "SkVertState.h"
26 #include "SkGlyphCache.h" 27 #include "SkGlyphCache.h"
27 #include "SkImageFilter.h" 28 #include "SkImageFilter.h"
28 #include "SkMaskFilter.h" 29 #include "SkMaskFilter.h"
29 #include "SkPathEffect.h" 30 #include "SkPathEffect.h"
30 #include "SkPicture.h" 31 #include "SkPicture.h"
31 #include "SkRRect.h" 32 #include "SkRRect.h"
32 #include "SkStroke.h" 33 #include "SkStroke.h"
33 #include "SkSurface.h" 34 #include "SkSurface.h"
34 #include "SkTLazy.h" 35 #include "SkTLazy.h"
35 #include "SkUtils.h" 36 #include "SkUtils.h"
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 }; 1724 };
1724 1725
1725 void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, 1726 void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
1726 int vertexCount, const SkPoint vertices[], 1727 int vertexCount, const SkPoint vertices[],
1727 const SkPoint texs[], const SkColor colors[], 1728 const SkPoint texs[], const SkColor colors[],
1728 SkXfermode* xmode, 1729 SkXfermode* xmode,
1729 const uint16_t indices[], int indexCount, 1730 const uint16_t indices[], int indexCount,
1730 const SkPaint& paint) { 1731 const SkPaint& paint) {
1731 CHECK_SHOULD_DRAW(draw, false); 1732 CHECK_SHOULD_DRAW(draw, false);
1732 1733
1734 // If both textures and vertex-colors are NULL, strokes hairlines with the p aint's color.
1735 if ((NULL == texs || NULL == paint.getShader()) && NULL == colors) {
1736 texs = NULL;
1737 SkPaint copy(paint);
1738 copy.setStyle(SkPaint::kStroke_Style);
1739 copy.setStrokeWidth(0);
1740
1741 VertState state(vertexCount, indices, indexCount);
1742 VertState::Proc vertProc = state.chooseProc(vmode);
1743
1744 SkPoint* pts = new SkPoint[vertexCount * 6];
1745 int i = 0;
1746 while (vertProc(&state)) {
1747 pts[i] = vertices[state.f0];
1748 pts[i + 1] = vertices[state.f1];
1749 pts[i + 2] = vertices[state.f1];
1750 pts[i + 3] = vertices[state.f2];
1751 pts[i + 4] = vertices[state.f2];
1752 pts[i + 5] = vertices[state.f0];
1753 i += 6;
1754 }
1755 draw.drawPoints(SkCanvas::kLines_PointMode, vertexCount * 6, pts, copy, true);
1756 return;
1757 }
1758
1733 GrPaint grPaint; 1759 GrPaint grPaint;
1734 // we ignore the shader if texs is null. 1760 // we ignore the shader if texs is null.
1735 if (NULL == texs) { 1761 if (NULL == texs) {
1736 if (!skPaint2GrPaintNoShader(this, paint, false, NULL == colors, &grPain t)) { 1762 if (!skPaint2GrPaintNoShader(this, paint, false, NULL == colors, &grPain t)) {
1737 return; 1763 return;
1738 } 1764 }
1739 } else { 1765 } else {
1740 if (!skPaint2GrPaintShader(this, paint, NULL == colors, &grPaint)) { 1766 if (!skPaint2GrPaintShader(this, paint, NULL == colors, &grPaint)) {
1741 return; 1767 return;
1742 } 1768 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 const GPUAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(j); 1986 const GPUAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(j);
1961 1987
1962 if (ops.offset(i) > info.fSaveLayerOpID && ops.offset(i) < info.fRes toreOpID) { 1988 if (ops.offset(i) > info.fSaveLayerOpID && ops.offset(i) < info.fRes toreOpID) {
1963 pullForward[j] = true; 1989 pullForward[j] = true;
1964 } 1990 }
1965 } 1991 }
1966 } 1992 }
1967 1993
1968 return false; 1994 return false;
1969 } 1995 }
OLDNEW
« include/core/SkVertState.h ('K') | « src/core/SkVertState.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698