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

Side by Side Diff: src/gpu/SkGpuDevice.cpp

Issue 1382753002: Fix drawVertices when there is a paint alpha (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comment Created 5 years, 2 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 | src/gpu/SkGr.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 * 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 "GrBlurUtils.h" 10 #include "GrBlurUtils.h"
(...skipping 1724 matching lines...) Expand 10 before | Expand all | Expand 10 after
1735 colors, 1735 colors,
1736 lineIndices.get(), 1736 lineIndices.get(),
1737 indexCount); 1737 indexCount);
1738 return; 1738 return;
1739 } 1739 }
1740 1740
1741 GrPrimitiveType primType = gVertexMode2PrimitiveType[vmode]; 1741 GrPrimitiveType primType = gVertexMode2PrimitiveType[vmode];
1742 1742
1743 SkAutoSTMalloc<128, GrColor> convertedColors(0); 1743 SkAutoSTMalloc<128, GrColor> convertedColors(0);
1744 if (colors) { 1744 if (colors) {
1745 // need to convert byte order and from non-PM to PM 1745 // need to convert byte order and from non-PM to PM. TODO: Keep unpremul until after
1746 // interpolation.
1746 convertedColors.reset(vertexCount); 1747 convertedColors.reset(vertexCount);
1747 SkColor color;
1748 for (int i = 0; i < vertexCount; ++i) { 1748 for (int i = 0; i < vertexCount; ++i) {
1749 color = colors[i]; 1749 convertedColors[i] = SkColorToPremulGrColor(colors[i]);
1750 if (paint.getAlpha() != 255) {
1751 color = SkColorSetA(color, SkMulDiv255Round(SkColorGetA(color), paint.getAlpha()));
1752 }
1753 /// TODO: Perform the premul after interpolating
1754 convertedColors[i] = SkColorToPremulGrColor(color);
1755 } 1750 }
1756 colors = convertedColors.get(); 1751 colors = convertedColors.get();
1757 } 1752 }
1758 GrPaint grPaint; 1753 GrPaint grPaint;
1759 if (texs && colors && paint.getShader()) { 1754 if (texs && paint.getShader()) {
1760 // When there are texs and colors the shader and colors are combined usi ng xmode. A null 1755 if (colors) {
1761 // xmode is defined to mean modulate. 1756 // When there are texs and colors the shader and colors are combined using xmode. A null
1762 SkXfermode::Mode colorMode; 1757 // xmode is defined to mean modulate.
1763 if (xmode) { 1758 SkXfermode::Mode colorMode;
1764 if (!xmode->asMode(&colorMode)) { 1759 if (xmode) {
1760 if (!xmode->asMode(&colorMode)) {
1761 return;
1762 }
1763 } else {
1764 colorMode = SkXfermode::kModulate_Mode;
1765 }
1766 if (!SkPaintToGrPaintWithXfermode(this->context(), paint, *draw.fMat rix, colorMode,
1767 false, &grPaint)) {
1765 return; 1768 return;
1766 } 1769 }
1767 } else { 1770 } else {
1768 colorMode = SkXfermode::kModulate_Mode; 1771 // We have a shader, but no colors to blend it against.
1772 if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPain t)) {
1773 return;
1774 }
1769 } 1775 }
1770 if (!SkPaintToGrPaintWithXfermode(this->context(), paint, *draw.fMatrix, colorMode, false, 1776 } else {
1771 &grPaint)) { 1777 if (colors) {
1772 return; 1778 // We have colors, but either have no shader or no texture coords (w hich implies that
1779 // we should ignore the shader).
1780 if (!SkPaintToGrPaintWithPrimitiveColor(this->context(), paint, &grP aint)) {
1781 return;
1782 }
1783 } else {
1784 // No colors and no shaders. Just draw with the paint color.
1785 if (!SkPaintToGrPaintNoShader(this->context(), paint, &grPaint)) {
1786 return;
1787 }
1773 } 1788 }
1774 } else if (!texs) {
1775 // Defined to ignore the shader unless texs is provided.
1776 if (!SkPaintToGrPaintNoShader(this->context(), paint, &grPaint)) {
1777 return;
1778 }
1779 } else if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint )) {
1780 return;
1781 } 1789 }
1782 1790
1783 fDrawContext->drawVertices(fRenderTarget, 1791 fDrawContext->drawVertices(fRenderTarget,
1784 fClip, 1792 fClip,
1785 grPaint, 1793 grPaint,
1786 *draw.fMatrix, 1794 *draw.fMatrix,
1787 primType, 1795 primType,
1788 vertexCount, 1796 vertexCount,
1789 vertices, 1797 vertices,
1790 texs, 1798 texs,
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1993 #endif 2001 #endif
1994 } 2002 }
1995 2003
1996 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 2004 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1997 // We always return a transient cache, so it is freed after each 2005 // We always return a transient cache, so it is freed after each
1998 // filter traversal. 2006 // filter traversal.
1999 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 2007 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
2000 } 2008 }
2001 2009
2002 #endif 2010 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/SkGr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698