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

Side by Side Diff: src/gpu/gl/GrGpuGL.cpp

Issue 209413006: Make it possible to draw multiple paths at once to a draw target (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address review comment Created 6 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 | « src/gpu/gl/GrGpuGL.h ('k') | src/gpu/gl/GrGpuGL_program.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 8
9 #include "GrGpuGL.h" 9 #include "GrGpuGL.h"
10 #include "GrGLStencilBuffer.h" 10 #include "GrGLStencilBuffer.h"
(...skipping 1677 matching lines...) Expand 10 before | Expand all | Expand 10 after
1688 SkScalar bloat = drawState->getViewMatrix().getMaxStretch() * SK_Sca larHalf; 1688 SkScalar bloat = drawState->getViewMatrix().getMaxStretch() * SK_Sca larHalf;
1689 bounds.outset(bloat, bloat); 1689 bounds.outset(bloat, bloat);
1690 } else { 1690 } else {
1691 avmr.setIdentity(drawState); 1691 avmr.setIdentity(drawState);
1692 } 1692 }
1693 1693
1694 this->drawSimpleRect(bounds, NULL); 1694 this->drawSimpleRect(bounds, NULL);
1695 } 1695 }
1696 } 1696 }
1697 1697
1698 void GrGpuGL::onGpuDrawPaths(size_t pathCount, const GrPath** paths,
1699 const SkMatrix* transforms,
1700 SkPath::FillType fill,
1701 SkStrokeRec::Style stroke) {
1702 SkASSERT(this->caps()->pathRenderingSupport());
1703 SkASSERT(NULL != this->drawState()->getRenderTarget());
1704 SkASSERT(NULL != this->drawState()->getRenderTarget()->getStencilBuffer());
1705 SkASSERT(!fCurrentProgram->hasVertexShader());
1706 SkASSERT(stroke != SkStrokeRec::kHairline_Style);
1707
1708 SkAutoMalloc pathData(pathCount * sizeof(GrGLuint));
1709 SkAutoMalloc transformData(pathCount * sizeof(GrGLfloat) * 6);
1710 GrGLfloat* transformValues =
1711 reinterpret_cast<GrGLfloat*>(transformData.get());
1712 GrGLuint* pathIDs = reinterpret_cast<GrGLuint*>(pathData.get());
1713
1714 for (size_t i = 0; i < pathCount; ++i) {
1715 SkASSERT(transforms[i].asAffine(NULL));
1716 const SkMatrix& m = transforms[i];
1717 transformValues[i * 6] = m.getScaleX();
1718 transformValues[i * 6 + 1] = m.getSkewY();
1719 transformValues[i * 6 + 2] = m.getSkewX();
1720 transformValues[i * 6 + 3] = m.getScaleY();
1721 transformValues[i * 6 + 4] = m.getTranslateX();
1722 transformValues[i * 6 + 5] = m.getTranslateY();
1723 pathIDs[i] = static_cast<const GrGLPath*>(paths[i])->pathID();
1724 }
1725
1726 flushPathStencilSettings(fill);
1727
1728 SkPath::FillType nonInvertedFill =
1729 SkPath::ConvertToNonInverseFillType(fill);
1730
1731 SkASSERT(!fHWPathStencilSettings.isTwoSided());
1732 GrGLenum fillMode =
1733 gr_stencil_op_to_gl_path_rendering_fill_mode(
1734 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face));
1735 GrGLint writeMask =
1736 fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face);
1737
1738 bool doFill = stroke == SkStrokeRec::kFill_Style
1739 || stroke == SkStrokeRec::kStrokeAndFill_Style;
1740 bool doStroke = stroke == SkStrokeRec::kStroke_Style
1741 || stroke == SkStrokeRec::kStrokeAndFill_Style;
1742
1743 if (doFill) {
1744 GL_CALL(StencilFillPathInstanced(pathCount, GR_GL_UNSIGNED_INT,
1745 pathIDs, 0,
1746 fillMode, writeMask,
1747 GR_GL_AFFINE_2D, transformValues));
1748 }
1749 if (doStroke) {
1750 GL_CALL(StencilStrokePathInstanced(pathCount, GR_GL_UNSIGNED_INT,
1751 pathIDs, 0,
1752 0xffff, writeMask,
1753 GR_GL_AFFINE_2D, transformValues));
1754 }
1755
1756 if (nonInvertedFill == fill) {
1757 if (doStroke) {
1758 GL_CALL(CoverStrokePathInstanced(
1759 pathCount, GR_GL_UNSIGNED_INT, pathIDs, 0,
1760 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES,
1761 GR_GL_AFFINE_2D, transformValues));
1762 } else {
1763 GL_CALL(CoverFillPathInstanced(
1764 pathCount, GR_GL_UNSIGNED_INT, pathIDs, 0,
1765 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES,
1766 GR_GL_AFFINE_2D, transformValues));
1767
1768 }
1769 } else {
1770 GrDrawState* drawState = this->drawState();
1771 GrDrawState::AutoViewMatrixRestore avmr;
1772 SkRect bounds = SkRect::MakeLTRB(0, 0,
1773 SkIntToScalar(drawState->getRenderTarge t()->width()),
1774 SkIntToScalar(drawState->getRenderTarge t()->height()));
1775 SkMatrix vmi;
1776 // mapRect through persp matrix may not be correct
1777 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn verse(&vmi)) {
1778 vmi.mapRect(&bounds);
1779 // theoretically could set bloat = 0, instead leave it because of ma trix inversion
1780 // precision.
1781 SkScalar bloat = drawState->getViewMatrix().getMaxStretch() * SK_Sca larHalf;
1782 bounds.outset(bloat, bloat);
1783 } else {
1784 avmr.setIdentity(drawState);
1785 }
1786
1787 this->drawSimpleRect(bounds, NULL);
1788 }
1789 }
1790
1698 void GrGpuGL::onResolveRenderTarget(GrRenderTarget* target) { 1791 void GrGpuGL::onResolveRenderTarget(GrRenderTarget* target) {
1699 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target); 1792 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target);
1700 if (rt->needsResolve()) { 1793 if (rt->needsResolve()) {
1701 // Some extensions automatically resolves the texture when it is read. 1794 // Some extensions automatically resolves the texture when it is read.
1702 if (this->glCaps().usesMSAARenderBuffers()) { 1795 if (this->glCaps().usesMSAARenderBuffers()) {
1703 SkASSERT(rt->textureFBOID() != rt->renderFBOID()); 1796 SkASSERT(rt->textureFBOID() != rt->renderFBOID());
1704 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID())); 1797 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID()));
1705 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID())) ; 1798 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID())) ;
1706 // make sure we go through flushRenderTarget() since we've modified 1799 // make sure we go through flushRenderTarget() since we've modified
1707 // the bound DRAW FBO ID. 1800 // the bound DRAW FBO ID.
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
2705 this->setVertexArrayID(gpu, 0); 2798 this->setVertexArrayID(gpu, 0);
2706 } 2799 }
2707 int attrCount = gpu->glCaps().maxVertexAttributes(); 2800 int attrCount = gpu->glCaps().maxVertexAttributes();
2708 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2801 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2709 fDefaultVertexArrayAttribState.resize(attrCount); 2802 fDefaultVertexArrayAttribState.resize(attrCount);
2710 } 2803 }
2711 attribState = &fDefaultVertexArrayAttribState; 2804 attribState = &fDefaultVertexArrayAttribState;
2712 } 2805 }
2713 return attribState; 2806 return attribState;
2714 } 2807 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | src/gpu/gl/GrGpuGL_program.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698