1ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org/*
2ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org * Copyright 2013 Google Inc.
3ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org *
4ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org * Use of this source code is governed by a BSD-style license that can be
5ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org * found in the LICENSE file.
6ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org */
7ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org
8ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org#ifndef GrTypesPriv_DEFINED
9ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org#define GrTypesPriv_DEFINED
10ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org
11054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com#include "GrTypes.h"
1231ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com#include "SkTArray.h"
1331ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com
14ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org/**
15054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com * Types of shader-language-specific boxed variables we can create. (Currently only GrGLShaderVars,
16054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com * but should be applicable to other shader languages.)
17ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org */
18ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.orgenum GrSLType {
19ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org    kVoid_GrSLType,
20ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org    kFloat_GrSLType,
21ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org    kVec2f_GrSLType,
22ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org    kVec3f_GrSLType,
23ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org    kVec4f_GrSLType,
24ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org    kMat33f_GrSLType,
25ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org    kMat44f_GrSLType,
26054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    kSampler2D_GrSLType,
27054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com
28054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    kLast_GrSLType = kSampler2D_GrSLType
29ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org};
30054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.comstatic const int kGrSLTypeCount = kLast_GrSLType + 1;
31054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com
32054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com/**
33054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com * Gets the vector size of the SLType. Returns -1 for void, matrices, and samplers.
34054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com */
35054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.comstatic inline int GrSLTypeVectorCount(GrSLType type) {
36f6de475e5cbd143f348ff7738919e397b7fe7f57tfarina@chromium.org    SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
37054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1 };
38054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    return kCounts[type];
39054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com
40054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(0 == kVoid_GrSLType);
41054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(1 == kFloat_GrSLType);
42054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(2 == kVec2f_GrSLType);
43054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(3 == kVec3f_GrSLType);
44054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(4 == kVec4f_GrSLType);
45054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(5 == kMat33f_GrSLType);
46054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(6 == kMat44f_GrSLType);
47054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
48972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org    GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrSLTypeCount);
49054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com}
50054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com
51018f179efb2413431bdb1a9e6701eb44ef36b792bsalomon@google.com/** Return the type enum for a vector of floats of length n (1..4),
52018f179efb2413431bdb1a9e6701eb44ef36b792bsalomon@google.com e.g. 1 -> kFloat_GrSLType, 2 -> kVec2_GrSLType, ... */
53054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.comstatic inline GrSLType GrSLFloatVectorType(int count) {
54f6de475e5cbd143f348ff7738919e397b7fe7f57tfarina@chromium.org    SkASSERT(count > 0 && count <= 4);
55054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    return (GrSLType)(count);
56054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com
57054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(kFloat_GrSLType == 1);
58054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(kVec2f_GrSLType == 2);
59054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(kVec3f_GrSLType == 3);
60054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(kVec4f_GrSLType == 4);
61054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com}
62ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org
63cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org//////////////////////////////////////////////////////////////////////////////
64cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org
6531ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com/**
66054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com * Types used to describe format of vertices in arrays.
6731ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com  */
6831ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.comenum GrVertexAttribType {
6931ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com    kFloat_GrVertexAttribType = 0,
7031ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com    kVec2f_GrVertexAttribType,
7131ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com    kVec3f_GrVertexAttribType,
7231ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com    kVec4f_GrVertexAttribType,
7331ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com    kVec4ub_GrVertexAttribType,   // vector of 4 unsigned bytes, e.g. colors
7431ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com
7531ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com    kLast_GrVertexAttribType = kVec4ub_GrVertexAttribType
7631ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com};
7731ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.comstatic const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1;
7831ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com
79054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com/**
80054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com * Returns the vector size of the type.
81054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com */
82054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.comstatic inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) {
83f6de475e5cbd143f348ff7738919e397b7fe7f57tfarina@chromium.org    SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount);
84054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    static const int kCounts[] = { 1, 2, 3, 4, 4 };
85054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    return kCounts[type];
86054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com
87054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType);
88054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType);
89054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType);
90054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType);
91054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(4 == kVec4ub_GrVertexAttribType);
92972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org    GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrVertexAttribTypeCount);
93054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com}
94054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com
95054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com/**
96054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com * Returns the size of the attrib type in bytes.
97054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com */
98054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.comstatic inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) {
99f6de475e5cbd143f348ff7738919e397b7fe7f57tfarina@chromium.org    SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount);
100054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    static const size_t kSizes[] = {
101054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com        sizeof(float),          // kFloat_GrVertexAttribType
102054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com        2*sizeof(float),        // kVec2f_GrVertexAttribType
103054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com        3*sizeof(float),        // kVec3f_GrVertexAttribType
104054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com        4*sizeof(float),        // kVec4f_GrVertexAttribType
105054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com        4*sizeof(char)          // kVec4ub_GrVertexAttribType
106054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    };
107054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    return kSizes[type];
108054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com
109054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType);
110054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType);
111054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType);
112054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType);
113054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(4 == kVec4ub_GrVertexAttribType);
114972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org    GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount);
115054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com}
116054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com
117054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com/**
118054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com * Semantic bindings for vertex attributes. kEffect means that the attribute is input to a GrEffect.
119054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com * Each binding other than kEffect may not appear more than once in the current set of attributes.
120054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com * kPosition must be appear for exactly one attribute.
121054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com */
122054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.comenum GrVertexAttribBinding {
123054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    kPosition_GrVertexAttribBinding,    // required, must have vector count of 2
124054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    kLocalCoord_GrVertexAttribBinding,  // must have vector count of 2
125054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    kColor_GrVertexAttribBinding,       // must have vector count of 4
126054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    kCoverage_GrVertexAttribBinding,    // must have vector count of 4
127054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com
128054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    kLastFixedFunction_GrVertexAttribBinding = kCoverage_GrVertexAttribBinding,
129054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com
130054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    kEffect_GrVertexAttribBinding,      // vector length must agree with
131054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com                                        // GrEffect::vertexAttribType() for each effect input to
132054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com                                        // which the attribute is mapped by GrDrawState::setEffect()
133054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    kLast_GrVertexAttribBinding = kEffect_GrVertexAttribBinding
134054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com};
135054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com
136054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.comstatic const int kGrVertexAttribBindingCnt = kLast_GrVertexAttribBinding + 1;
137054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.comstatic const int kGrFixedFunctionVertexAttribBindingCnt =
138054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    kLastFixedFunction_GrVertexAttribBinding + 1;
139054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com
14086b5e29f8044a28c19f7cbb2fe43882131922bb6jvanverth@google.comstatic inline int GrFixedFunctionVertexAttribVectorCount(GrVertexAttribBinding binding) {
141f6de475e5cbd143f348ff7738919e397b7fe7f57tfarina@chromium.org    SkASSERT(binding >= 0 && binding < kGrFixedFunctionVertexAttribBindingCnt);
142054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    static const int kVecCounts[] = { 2, 2, 4, 4 };
143054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com
144054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    return kVecCounts[binding];
145054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com
146054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(0 == kPosition_GrVertexAttribBinding);
147054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(1 == kLocalCoord_GrVertexAttribBinding);
148054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(2 == kColor_GrVertexAttribBinding);
149054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(3 == kCoverage_GrVertexAttribBinding);
150054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GR_STATIC_ASSERT(kGrFixedFunctionVertexAttribBindingCnt == SK_ARRAY_COUNT(kVecCounts));
151054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com}
152054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com
15331ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.comstruct GrVertexAttrib {
154054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    inline void set(GrVertexAttribType type, size_t offset, GrVertexAttribBinding binding) {
155054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com        fType = type;
156054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com        fOffset = offset;
157054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com        fBinding = binding;
15831ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com    }
15931ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com    bool operator==(const GrVertexAttrib& other) const {
160054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com        return fType == other.fType && fOffset == other.fOffset && fBinding == other.fBinding;
16131ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com    };
16231ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com    bool operator!=(const GrVertexAttrib& other) const { return !(*this == other); }
16331ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com
164054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GrVertexAttribType      fType;
165054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    size_t                  fOffset;
166054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.com    GrVertexAttribBinding   fBinding;
16731ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com};
16831ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com
169054ae99d93711c26e40682a0e3a03a47ea605c53jvanverth@google.comtemplate <int N> class GrVertexAttribArray : public SkSTArray<N, GrVertexAttrib, true> {};
17031ec7985f2b52a0cab4aa714a613b918cf663c08bsalomon@google.com
171cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org//////////////////////////////////////////////////////////////////////////////
172cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org
173cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org/**
174cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org* We have coverage effects that clip rendering to the edge of some geometric primitive.
17506acb58074778d8eb40f14ae72b000d5120a8111skia.committer@gmail.com* This enum specifies how that clipping is performed. Not all factories that take a
176cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org* GrEffectEdgeType will succeed with all values and it is up to the caller to check for
177cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org* a NULL return.
178cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org*/
179cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.orgenum GrEffectEdgeType {
180cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org    kFillBW_GrEffectEdgeType,
181cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org    kFillAA_GrEffectEdgeType,
182cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org    kInverseFillBW_GrEffectEdgeType,
183cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org    kInverseFillAA_GrEffectEdgeType,
184cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org    kHairlineAA_GrEffectEdgeType,
185cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org
186cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org    kLast_GrEffectEdgeType = kHairlineAA_GrEffectEdgeType
187cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org};
188cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org
189cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.orgstatic const int kGrEffectEdgeTypeCnt = kLast_GrEffectEdgeType + 1;
190cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org
191cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.orgstatic inline bool GrEffectEdgeTypeIsFill(const GrEffectEdgeType edgeType) {
192cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org    return (kFillAA_GrEffectEdgeType == edgeType || kFillBW_GrEffectEdgeType == edgeType);
193cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org}
194cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org
195cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.orgstatic inline bool GrEffectEdgeTypeIsInverseFill(const GrEffectEdgeType edgeType) {
196cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org    return (kInverseFillAA_GrEffectEdgeType == edgeType ||
197cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org            kInverseFillBW_GrEffectEdgeType == edgeType);
198cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org}
199cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org
200cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.orgstatic inline bool GrEffectEdgeTypeIsAA(const GrEffectEdgeType edgeType) {
201cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org    return (kFillBW_GrEffectEdgeType != edgeType && kInverseFillBW_GrEffectEdgeType != edgeType);
202cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org}
203cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org
204cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.orgstatic inline GrEffectEdgeType GrInvertEffectEdgeType(const GrEffectEdgeType edgeType) {
205cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org    switch (edgeType) {
206cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org        case kFillBW_GrEffectEdgeType:
207cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org            return kInverseFillBW_GrEffectEdgeType;
208cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org        case kFillAA_GrEffectEdgeType:
209cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org            return kInverseFillAA_GrEffectEdgeType;
210cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org        case kInverseFillBW_GrEffectEdgeType:
211cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org            return kFillBW_GrEffectEdgeType;
212cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org        case kInverseFillAA_GrEffectEdgeType:
213cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org            return kFillAA_GrEffectEdgeType;
214cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org        case kHairlineAA_GrEffectEdgeType:
21588cb22b6b4816c7a9ca6c5b795965b4606f9eb7bcommit-bot@chromium.org            SkFAIL("Hairline fill isn't invertible.");
216cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org    }
217cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org    return kFillAA_GrEffectEdgeType; // suppress warning.
218cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org}
219cabf4b2f3664b98c1084fbb94a999af15ddfb52dcommit-bot@chromium.org
220ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3commit-bot@chromium.org#endif
221