127847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com 2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/* 3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2011 Google Inc. 4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 727847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com */ 827847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com 9ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 1027847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com#ifndef GrPaint_DEFINED 1127847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com#define GrPaint_DEFINED 1227847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com 1327847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com#include "GrColor.h" 14b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt#include "GrProcessorStage.h" 1527847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com 1697c88c255cff3dbb8343c5d090526fdbedad6dd6Scroggo#include "SkXfermode.h" 1797c88c255cff3dbb8343c5d090526fdbedad6dd6Scroggo 1827847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com/** 19c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * The paint describes how color and coverage are computed at each pixel by GrContext draw 20c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * functions and the how color is blended with the destination pixel. 21c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * 22c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * The paint allows installation of custom color and coverage stages. New types of stages are 23b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt * created by subclassing GrProcessor. 24c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * 25c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * The primitive color computation starts with the color specified by setColor(). This color is the 26c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * input to the first color stage. Each color stage feeds its output to the next color stage. The 27c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * final color stage's output color is input to the color filter specified by 2867e78c9e47c38a51816412a24a10f4fe2db142a3bsalomon@google.com * setXfermodeColorFilter which produces the final source color, S. 29c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * 30c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * Fractional pixel coverage follows a similar flow. The coverage is initially the value specified 31c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * by setCoverage(). This is input to the first coverage stage. Coverage stages are chained 32c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * together in the same manner as color stages. The output of the last stage is modulated by any 33c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * fractional coverage produced by anti-aliasing. This last step produces the final coverage, C. 34c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * 35c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * setBlendFunc() specifies blending coefficients for S (described above) and D, the initial value 36c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * of the destination pixel, labeled Bs and Bd respectively. The final value of the destination 37c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * pixel is then D' = (1-C)*D + C*(Bd*D + Bs*S). 38c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * 39c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * Note that the coverage is applied after the blend. This is why they are computed as distinct 40c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * values. 41c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * 42b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt * TODO: Encapsulate setXfermodeColorFilter in a GrProcessor and remove from GrPaint. 4327847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com */ 4427847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.comclass GrPaint { 4527847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.compublic: 46c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com GrPaint() { this->reset(); } 4727847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com 48c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com GrPaint(const GrPaint& paint) { *this = paint; } 4927847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com 50c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com ~GrPaint() {} 51c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com 52c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com /** 53c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * Sets the blending coefficients to use to blend the final primitive color with the 54c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * destination color. Defaults to kOne for src and kZero for dst (i.e. src mode). 55c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com */ 56c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com void setBlendFunc(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) { 57c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com fSrcBlendCoeff = srcCoeff; 58c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com fDstBlendCoeff = dstCoeff; 59c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com } 60c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlendCoeff; } 61c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com GrBlendCoeff getDstBlendCoeff() const { return fDstBlendCoeff; } 62c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com 63c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com /** 64c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * The initial color of the drawn primitive. Defaults to solid white. 65c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com */ 66c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com void setColor(GrColor color) { fColor = color; } 67c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com GrColor getColor() const { return fColor; } 68c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com 69c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com /** 70c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * Applies fractional coverage to the entire drawn primitive. Defaults to 0xff. 71c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com */ 72c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com void setCoverage(uint8_t coverage) { fCoverage = coverage; } 73c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com uint8_t getCoverage() const { return fCoverage; } 74c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com 75c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com /** 76c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * Should primitives be anti-aliased or not. Defaults to false. 77c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com */ 78c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com void setAntiAlias(bool aa) { fAntiAlias = aa; } 79c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com bool isAntiAlias() const { return fAntiAlias; } 80c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com 81c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com /** 82c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * Should dithering be applied. Defaults to false. 83c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com */ 84c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com void setDither(bool dither) { fDither = dither; } 85c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com bool isDither() const { return fDither; } 86c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com 87c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com /** 88b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt * Appends an additional color processor to the color computation. 89c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com */ 90b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* fp) { 91b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt SkASSERT(fp); 92b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt if (!fp->willUseInputColor()) { 93a34995e18b1f0a7d8c9f23451718bb30ff0105b0commit-bot@chromium.org fColorStages.reset(); 94a34995e18b1f0a7d8c9f23451718bb30ff0105b0commit-bot@chromium.org } 95b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt SkNEW_APPEND_TO_TARRAY(&fColorStages, GrProcessorStage, (fp)); 96b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt return fp; 9726c2d0a69e66f1656d2dc23953a6f153e5d5009fbsalomon@google.com } 9826c2d0a69e66f1656d2dc23953a6f153e5d5009fbsalomon@google.com 99c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com /** 100b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt * Appends an additional coverage processor to the coverage computation. 101c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com */ 102b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* fp) { 103b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt SkASSERT(fp); 104b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt if (!fp->willUseInputColor()) { 105a34995e18b1f0a7d8c9f23451718bb30ff0105b0commit-bot@chromium.org fCoverageStages.reset(); 106a34995e18b1f0a7d8c9f23451718bb30ff0105b0commit-bot@chromium.org } 107b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrProcessorStage, (fp)); 108b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt return fp; 10927847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com } 11027847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com 11142dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org /** 11242dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org * Helpers for adding color or coverage effects that sample a texture. The matrix is applied 11342dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org * to the src space position to compute texture coordinates. 11442dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org */ 115b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt void addColorTextureProcessor(GrTexture*, const SkMatrix&); 116b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt void addCoverageTextureProcessor(GrTexture*, const SkMatrix&); 117b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt void addColorTextureProcessor(GrTexture*, const SkMatrix&, const GrTextureParams&); 118b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt void addCoverageTextureProcessor(GrTexture*, const SkMatrix&, const GrTextureParams&); 119e3d3216fe17b6afb2e613271b5246a2766e12df6bsalomon@google.com 12042dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org int numColorStages() const { return fColorStages.count(); } 12142dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org int numCoverageStages() const { return fCoverageStages.count(); } 12242dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org int numTotalStages() const { return this->numColorStages() + this->numCoverageStages(); } 123e3d3216fe17b6afb2e613271b5246a2766e12df6bsalomon@google.com 124b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt const GrFragmentStage& getColorStage(int s) const { return fColorStages[s]; } 125b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt const GrFragmentStage& getCoverageStage(int s) const { return fCoverageStages[s]; } 126e3d3216fe17b6afb2e613271b5246a2766e12df6bsalomon@google.com 12727c9b6d27681dd54b82137b1e67140470b868f07bsalomon@google.com GrPaint& operator=(const GrPaint& paint) { 12827847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com fSrcBlendCoeff = paint.fSrcBlendCoeff; 12927847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com fDstBlendCoeff = paint.fDstBlendCoeff; 13027847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com fAntiAlias = paint.fAntiAlias; 13127847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com fDither = paint.fDither; 13227847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com 13327847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com fColor = paint.fColor; 134dd1be60702b3622f49d97651e31d13eaf2175cf8bsalomon@google.com fCoverage = paint.fCoverage; 13527847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com 13642dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org fColorStages = paint.fColorStages; 13742dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org fCoverageStages = paint.fCoverageStages; 13842dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org 13927c9b6d27681dd54b82137b1e67140470b868f07bsalomon@google.com return *this; 14027847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com } 14127847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com 142c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com /** 143c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com * Resets the paint to the defaults. 144c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com */ 14527847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com void reset() { 14626c2d0a69e66f1656d2dc23953a6f153e5d5009fbsalomon@google.com this->resetBlend(); 14726c2d0a69e66f1656d2dc23953a6f153e5d5009fbsalomon@google.com this->resetOptions(); 14826c2d0a69e66f1656d2dc23953a6f153e5d5009fbsalomon@google.com this->resetColor(); 149dd1be60702b3622f49d97651e31d13eaf2175cf8bsalomon@google.com this->resetCoverage(); 15008283afc265f1153834256fc1012519813ba6b73bsalomon@google.com this->resetStages(); 15197c88c255cff3dbb8343c5d090526fdbedad6dd6Scroggo } 15297c88c255cff3dbb8343c5d090526fdbedad6dd6Scroggo 15324ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org /** 15424ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org * Determines whether the drawing with this paint is opaque with respect to both color blending 15524ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org * and fractional coverage. It does not consider whether AA has been enabled on the paint or 15624ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org * not. Depending upon whether multisampling or coverage-based AA is in use, AA may make the 15724ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org * result only apply to the interior of primitives. 15824ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org * 15924ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org */ 16024ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org bool isOpaque() const; 16124ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org 16224ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org /** 16324ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org * Returns true if isOpaque would return true and the paint represents a solid constant color 16424ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org * draw. If the result is true, constantColor will be updated to contain the constant color. 16524ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org */ 16624ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org bool isOpaqueAndConstantColor(GrColor* constantColor) const; 16724ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org 16827847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.comprivate: 16924ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org 17024ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org /** 17124ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org * Helper for isOpaque and isOpaqueAndConstantColor. 17224ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org */ 17324ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org bool getOpaqueAndKnownColor(GrColor* solidColor, uint32_t* solidColorKnownComponents) const; 17424ab3b0ce50b3428f063849b6160e468f047487ccommit-bot@chromium.org 175c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com /** 176c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com * Called when the source coord system from which geometry is rendered changes. It ensures that 177c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com * the local coordinates seen by effects remains unchanged. oldToNew gives the transformation 178c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com * from the previous coord system to the new coord system. 179c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com */ 180c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com void localCoordChange(const SkMatrix& oldToNew) { 18142dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org for (int i = 0; i < fColorStages.count(); ++i) { 18242dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org fColorStages[i].localCoordChange(oldToNew); 183c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com } 18442dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org for (int i = 0; i < fCoverageStages.count(); ++i) { 18542dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org fCoverageStages[i].localCoordChange(oldToNew); 186c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com } 187c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com } 188c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com 189c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com bool localCoordChangeInverse(const SkMatrix& newToOld) { 190c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com SkMatrix oldToNew; 191c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com bool computed = false; 19242dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org for (int i = 0; i < fColorStages.count(); ++i) { 19342dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org if (!computed && !newToOld.invert(&oldToNew)) { 19442dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org return false; 19542dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org } else { 19642dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org computed = true; 197c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com } 19842dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org fColorStages[i].localCoordChange(oldToNew); 199c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com } 20042dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org for (int i = 0; i < fCoverageStages.count(); ++i) { 20142dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org if (!computed && !newToOld.invert(&oldToNew)) { 20242dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org return false; 20342dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org } else { 20442dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org computed = true; 205c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com } 20642dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org fCoverageStages[i].localCoordChange(oldToNew); 207c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com } 208c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com return true; 209c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com } 210c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com 211c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com friend class GrContext; // To access above two functions 212c6cb56f36c4aad8ed45486a3bb4de614bb822f1bkkinnunen friend class GrStencilAndCoverTextContext; // To access above two functions 21326c2d0a69e66f1656d2dc23953a6f153e5d5009fbsalomon@google.com 214b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt SkSTArray<4, GrFragmentStage> fColorStages; 215b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt SkSTArray<2, GrFragmentStage> fCoverageStages; 21626c2d0a69e66f1656d2dc23953a6f153e5d5009fbsalomon@google.com 217c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com GrBlendCoeff fSrcBlendCoeff; 218c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com GrBlendCoeff fDstBlendCoeff; 219c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com bool fAntiAlias; 220c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com bool fDither; 221c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com 222c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com GrColor fColor; 223c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com uint8_t fCoverage; 224c7448cef098b835d6f9adf8a365fde9de076f178bsalomon@google.com 22527847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com void resetBlend() { 22647059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com fSrcBlendCoeff = kOne_GrBlendCoeff; 22747059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com fDstBlendCoeff = kZero_GrBlendCoeff; 22827847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com } 22927847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com 23027847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com void resetOptions() { 23127847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com fAntiAlias = false; 23227847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com fDither = false; 23327847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com } 23427847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com 23527847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com void resetColor() { 23627847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com fColor = GrColorPackRGBA(0xff, 0xff, 0xff, 0xff); 23727847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com } 23827847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com 239dd1be60702b3622f49d97651e31d13eaf2175cf8bsalomon@google.com void resetCoverage() { 240dd1be60702b3622f49d97651e31d13eaf2175cf8bsalomon@google.com fCoverage = 0xff; 241dd1be60702b3622f49d97651e31d13eaf2175cf8bsalomon@google.com } 242dd1be60702b3622f49d97651e31d13eaf2175cf8bsalomon@google.com 24308283afc265f1153834256fc1012519813ba6b73bsalomon@google.com void resetStages() { 24442dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org fColorStages.reset(); 24542dacab4e7366d9f53989558cc8d045c3d065bcdcommit-bot@chromium.org fCoverageStages.reset(); 24626c2d0a69e66f1656d2dc23953a6f153e5d5009fbsalomon@google.com } 24727847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com}; 24827847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com 24927847dedd9b5c1f48998c40842f3494c0746257fbsalomon@google.com#endif 250