GrTypes.h revision 6e7ddaae0a077a777b8b8872ec27f8faab275536
1ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/*
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2010 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.
7ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */
8ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
9ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
10ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
11ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#ifndef GrTypes_DEFINED
12ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#define GrTypes_DEFINED
13ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
149b24d25c6b7ddde5788444f17fa3bfad19096f37reed@google.com#include "SkTypes.h"
15ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#include "GrConfig.h"
16b9086a026844e4cfd08b219e49ce3f12294cba98bsalomon@google.com#include "SkMath.h"
17ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
18972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org//#define SK_SUPPORT_LEGACY_GRTYPES
19972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org
20fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com////////////////////////////////////////////////////////////////////////////////
21fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com
22fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com/**
23fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * Defines overloaded bitwise operators to make it easier to use an enum as a
24fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * bitfield.
25fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com */
26fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com#define GR_MAKE_BITFIELD_OPS(X) \
2786c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com    inline X operator | (X a, X b) { \
28fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com        return (X) (+a | +b); \
29fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    } \
30fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    \
3186c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com    inline X operator & (X a, X b) { \
32fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com        return (X) (+a & +b); \
33fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    } \
34fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    template <typename T> \
3586c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com    inline X operator & (T a, X b) { \
36fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com        return (X) (+a & +b); \
37fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    } \
38fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    template <typename T> \
3986c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com    inline X operator & (X a, T b) { \
40fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com        return (X) (+a & +b); \
41fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    } \
42fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com
4386c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com#define GR_DECL_BITFIELD_OPS_FRIENDS(X) \
4486c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com    friend X operator | (X a, X b); \
4586c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com    \
4686c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com    friend X operator & (X a, X b); \
4786c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com    \
4886c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com    template <typename T> \
4986c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com    friend X operator & (T a, X b); \
5086c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com    \
5186c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com    template <typename T> \
5286c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com    friend X operator & (X a, T b); \
53fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com////////////////////////////////////////////////////////////////////////////////
54fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com
55972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org#ifdef SK_SUPPORT_LEGACY_GRTYPES
56fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com
57ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/**
58ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com *  Macro to round n up to the next multiple of 4, or return it unchanged if
59ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com *  n is already a multiple of 4
60ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */
619b24d25c6b7ddde5788444f17fa3bfad19096f37reed@google.com#define GrALIGN4(n)     SkAlign4(n)
6201224d5d0a3228fe47e63d8346e0e433a87563a8tomhudson@google.com#define GrIsALIGN4(n)   SkIsAlign4(n)
63ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
64ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.comtemplate <typename T> const T& GrMin(const T& a, const T& b) {
6507ef911f18e30566d8a9d790e0bd69a836fd9d24robertphillips@google.com    return (a < b) ? a : b;
66ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com}
67ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
68ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.comtemplate <typename T> const T& GrMax(const T& a, const T& b) {
6907ef911f18e30566d8a9d790e0bd69a836fd9d24robertphillips@google.com    return (b < a) ? a : b;
70ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com}
71ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
72972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org/**
73972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org *  Count elements in an array
74972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org */
75972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org#define GR_ARRAY_COUNT(array)  SK_ARRAY_COUNT(array)
76972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org
77972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org/**
78972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org *  16.16 fixed point type
79972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org */
80972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.orgtypedef int32_t GrFixed;
81972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org
82972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org#ifdef SK_DEBUG
83972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org
84972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.orgstatic inline int16_t GrToS16(intptr_t x) {
85972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org    SkASSERT((int16_t)x == x);
86972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org    return (int16_t)x;
87972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org}
88972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org
89972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org#else
90972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org
91972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org#define GrToS16(x)  x
92972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org
93972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org#endif
94972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org
95972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org#endif
96972f9cd7a063d0544f8c919fd12b9a3adbd12b24commit-bot@chromium.org
97ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com// compile time versions of min/max
98ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#define GR_CT_MAX(a, b) (((b) < (a)) ? (a) : (b))
99ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#define GR_CT_MIN(a, b) (((b) < (a)) ? (b) : (a))
100ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
101ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/**
102ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com *  divide, rounding up
103ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */
104919583674bd5daeb60327c0bc1ce8aaa80d54e13bsalomon@google.comstatic inline int32_t GrIDivRoundUp(int x, int y) {
105f6de475e5cbd143f348ff7738919e397b7fe7f57tfarina@chromium.org    SkASSERT(y > 0);
106919583674bd5daeb60327c0bc1ce8aaa80d54e13bsalomon@google.com    return (x + (y-1)) / y;
107919583674bd5daeb60327c0bc1ce8aaa80d54e13bsalomon@google.com}
1081c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.comstatic inline uint32_t GrUIDivRoundUp(uint32_t x, uint32_t y) {
1091c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com    return (x + (y-1)) / y;
1101c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com}
1114da34e36cb7a07c3a28ae2a135b1837c26fc7aeabsalomon@google.comstatic inline size_t GrSizeDivRoundUp(size_t x, size_t y) {
112ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com    return (x + (y-1)) / y;
113ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com}
114ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
1154da34e36cb7a07c3a28ae2a135b1837c26fc7aeabsalomon@google.com// compile time, evaluates Y multiple times
1164da34e36cb7a07c3a28ae2a135b1837c26fc7aeabsalomon@google.com#define GR_CT_DIV_ROUND_UP(X, Y) (((X) + ((Y)-1)) / (Y))
1174da34e36cb7a07c3a28ae2a135b1837c26fc7aeabsalomon@google.com
118ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/**
119ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com *  align up
120ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */
1211c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.comstatic inline uint32_t GrUIAlignUp(uint32_t x, uint32_t alignment) {
122ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com    return GrUIDivRoundUp(x, alignment) * alignment;
123ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com}
1244da34e36cb7a07c3a28ae2a135b1837c26fc7aeabsalomon@google.comstatic inline size_t GrSizeAlignUp(size_t x, size_t alignment) {
1251c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com    return GrSizeDivRoundUp(x, alignment) * alignment;
1261c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com}
127ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
1284da34e36cb7a07c3a28ae2a135b1837c26fc7aeabsalomon@google.com// compile time, evaluates A multiple times
1294da34e36cb7a07c3a28ae2a135b1837c26fc7aeabsalomon@google.com#define GR_CT_ALIGN_UP(X, A) (GR_CT_DIV_ROUND_UP((X),(A)) * (A))
1304da34e36cb7a07c3a28ae2a135b1837c26fc7aeabsalomon@google.com
131ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/**
132ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * amount of pad needed to align up
133ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */
1341c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.comstatic inline uint32_t GrUIAlignUpPad(uint32_t x, uint32_t alignment) {
1351c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com    return (alignment - x % alignment) % alignment;
1361c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com}
1374da34e36cb7a07c3a28ae2a135b1837c26fc7aeabsalomon@google.comstatic inline size_t GrSizeAlignUpPad(size_t x, size_t alignment) {
138ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com    return (alignment - x % alignment) % alignment;
139ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com}
140ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
141ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/**
142ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com *  align down
143ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */
1441c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.comstatic inline uint32_t GrUIAlignDown(uint32_t x, uint32_t alignment) {
1451c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com    return (x / alignment) * alignment;
1461c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com}
1475e497329bb40704c468627a4d37148ea4fae4da3bsalomon@google.comstatic inline size_t GrSizeAlignDown(size_t x, uint32_t alignment) {
148ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com    return (x / alignment) * alignment;
149ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com}
150ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
151ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com///////////////////////////////////////////////////////////////////////////////
152ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
153ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/**
154ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com *  Return true if n is a power of 2
155ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */
156ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.comstatic inline bool GrIsPow2(unsigned n) {
157ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com    return n && 0 == (n & (n - 1));
158ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com}
159ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
160ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/**
161ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com *  Return the next power of 2 >= n.
162ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */
163ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.comstatic inline uint32_t GrNextPow2(uint32_t n) {
164b9086a026844e4cfd08b219e49ce3f12294cba98bsalomon@google.com    return n ? (1 << (32 - SkCLZ(n - 1))) : 1;
165ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com}
166ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
167b5b3168a645802f66233234a06dd5a3764f18018bsalomon@google.comstatic inline int GrNextPow2(int n) {
168f6de475e5cbd143f348ff7738919e397b7fe7f57tfarina@chromium.org    SkASSERT(n >= 0); // this impl only works for non-neg.
169b9086a026844e4cfd08b219e49ce3f12294cba98bsalomon@google.com    return n ? (1 << (32 - SkCLZ(n - 1))) : 1;
170b5b3168a645802f66233234a06dd5a3764f18018bsalomon@google.com}
171b5b3168a645802f66233234a06dd5a3764f18018bsalomon@google.com
172ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com///////////////////////////////////////////////////////////////////////////////
173ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
174ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/**
17505ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com * Possible 3D APIs that may be used by Ganesh.
17605ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com */
17716e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.comenum GrBackend {
17816e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.com    kOpenGL_GrBackend,
17905ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com};
18005ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com
18105ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com/**
18216e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.com * Backend-specific 3D context handle
1830b77d6892b067ad402c9678b0226bff70599fbe2bsalomon@google.com *      GrGLInterface* for OpenGL. If NULL will use the default GL interface.
18405ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com */
18516e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.comtypedef intptr_t GrBackendContext;
18605ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com
18705ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com///////////////////////////////////////////////////////////////////////////////
1885877ffd5ea71a3ea70096d5c11c843798defa690bsalomon@google.com
189ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/**
190ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com* Geometric primitives used for drawing.
191ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com*/
192ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.comenum GrPrimitiveType {
19347059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kTriangles_GrPrimitiveType,
19447059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kTriangleStrip_GrPrimitiveType,
19547059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kTriangleFan_GrPrimitiveType,
19647059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kPoints_GrPrimitiveType,
19747059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kLines_GrPrimitiveType,     // 1 pix wide only
19847059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kLineStrip_GrPrimitiveType  // 1 pix wide only
199ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com};
200ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com
2010650e811b537f21a3a9d09a953960626cf5cfce4bsalomon@google.comstatic inline bool GrIsPrimTypeLines(GrPrimitiveType type) {
20247059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    return kLines_GrPrimitiveType == type || kLineStrip_GrPrimitiveType == type;
2030650e811b537f21a3a9d09a953960626cf5cfce4bsalomon@google.com}
2040650e811b537f21a3a9d09a953960626cf5cfce4bsalomon@google.com
2050650e811b537f21a3a9d09a953960626cf5cfce4bsalomon@google.comstatic inline bool GrIsPrimTypeTris(GrPrimitiveType type) {
20647059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    return kTriangles_GrPrimitiveType == type     ||
20747059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com           kTriangleStrip_GrPrimitiveType == type ||
20847059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com           kTriangleFan_GrPrimitiveType == type;
2090650e811b537f21a3a9d09a953960626cf5cfce4bsalomon@google.com}
2100650e811b537f21a3a9d09a953960626cf5cfce4bsalomon@google.com
211ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com/**
212ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com * Coeffecients for alpha-blending.
213ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com */
214ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.comenum GrBlendCoeff {
21547059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kInvalid_GrBlendCoeff = -1,
21647059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com
21747059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kZero_GrBlendCoeff,    //<! 0
21847059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kOne_GrBlendCoeff,     //<! 1
21947059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kSC_GrBlendCoeff,      //<! src color
22047059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kISC_GrBlendCoeff,     //<! one minus src color
22147059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kDC_GrBlendCoeff,      //<! dst color
22247059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kIDC_GrBlendCoeff,     //<! one minus dst color
22347059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kSA_GrBlendCoeff,      //<! src alpha
22447059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kISA_GrBlendCoeff,     //<! one minus src alpha
22547059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kDA_GrBlendCoeff,      //<! dst alpha
22647059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kIDA_GrBlendCoeff,     //<! one minus dst alpha
22747059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kConstC_GrBlendCoeff,  //<! constant color
22847059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kIConstC_GrBlendCoeff, //<! one minus constant color
22947059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kConstA_GrBlendCoeff,  //<! constant color alpha
23047059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kIConstA_GrBlendCoeff, //<! one minus constant color alpha
23147059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com
23247059542e7aa153926377456a6c611e55c8e428cbsalomon@google.com    kPublicGrBlendCoeffCount
233ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com};
234ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com
235d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com/**
236759c16e20dc42577226c8805bfea92d8bacb14d8reed@google.com *  Formats for masks, used by the font cache.
237759c16e20dc42577226c8805bfea92d8bacb14d8reed@google.com *  Important that these are 0-based.
23898539c607b05f7e25406ae873bf1b24154a36a6freed@google.com */
23998539c607b05f7e25406ae873bf1b24154a36a6freed@google.comenum GrMaskFormat {
2401eeaf0ba2381f84ffd889f56303cbe0d1886bb21caryclark@google.com    kA8_GrMaskFormat,    //!< 1-byte per pixel
2411eeaf0ba2381f84ffd889f56303cbe0d1886bb21caryclark@google.com    kA565_GrMaskFormat,  //!< 2-bytes per pixel
2421eeaf0ba2381f84ffd889f56303cbe0d1886bb21caryclark@google.com    kA888_GrMaskFormat,  //!< 4-bytes per pixel
243f8cb184095946ebf8f183d253e27bd544a19f23ccommit-bot@chromium.org    kARGB_GrMaskFormat,  //!< 4-bytes per pixel, color format
24465caeaf32d09f5886f3c740cfef2f1c26ef9cb50skia.committer@gmail.com
245f8cb184095946ebf8f183d253e27bd544a19f23ccommit-bot@chromium.org    kLast_GrMaskFormat = kARGB_GrMaskFormat
24698539c607b05f7e25406ae873bf1b24154a36a6freed@google.com};
2473fddf0eed6dc2873bcc8e584f435c6cd34964518commit-bot@chromium.orgstatic const int kMaskFormatCount = kLast_GrMaskFormat + 1;
24898539c607b05f7e25406ae873bf1b24154a36a6freed@google.com
24998539c607b05f7e25406ae873bf1b24154a36a6freed@google.com/**
25098539c607b05f7e25406ae873bf1b24154a36a6freed@google.com *  Return the number of bytes-per-pixel for the specified mask format.
25198539c607b05f7e25406ae873bf1b24154a36a6freed@google.com */
25298539c607b05f7e25406ae873bf1b24154a36a6freed@google.comstatic inline int GrMaskFormatBytesPerPixel(GrMaskFormat format) {
253f8cb184095946ebf8f183d253e27bd544a19f23ccommit-bot@chromium.org    SkASSERT((unsigned)format <= 3);
254bbf1226530d1a4e521e40c982f127fd49dbeb6a0reed@google.com    // kA8   (0) -> 1
255bbf1226530d1a4e521e40c982f127fd49dbeb6a0reed@google.com    // kA565 (1) -> 2
256bbf1226530d1a4e521e40c982f127fd49dbeb6a0reed@google.com    // kA888 (2) -> 4
2576e515d67d2365ecd05fb80762eeb76c55e81368cskia.committer@gmail.com    // kARGB (3) -> 4
258f8cb184095946ebf8f183d253e27bd544a19f23ccommit-bot@chromium.org    static const int sBytesPerPixel[] = { 1, 2, 4, 4 };
259f8cb184095946ebf8f183d253e27bd544a19f23ccommit-bot@chromium.org    SK_COMPILE_ASSERT(SK_ARRAY_COUNT(sBytesPerPixel) == kMaskFormatCount, array_size_mismatch);
260f8cb184095946ebf8f183d253e27bd544a19f23ccommit-bot@chromium.org
261f8cb184095946ebf8f183d253e27bd544a19f23ccommit-bot@chromium.org    return sBytesPerPixel[(int) format];
26298539c607b05f7e25406ae873bf1b24154a36a6freed@google.com}
26398539c607b05f7e25406ae873bf1b24154a36a6freed@google.com
26498539c607b05f7e25406ae873bf1b24154a36a6freed@google.com/**
265669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com * Pixel configurations.
266669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com */
267669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.comenum GrPixelConfig {
268669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com    kUnknown_GrPixelConfig,
269669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com    kAlpha_8_GrPixelConfig,
270669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com    kIndex_8_GrPixelConfig,
271669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com    kRGB_565_GrPixelConfig,
272c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com    /**
273c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com     * Premultiplied
274c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com     */
275c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com    kRGBA_4444_GrPixelConfig,
276c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com    /**
2770342a85091fd430c90a142d155dc9642aa729d9ebsalomon@google.com     * Premultiplied. Byte order is r,g,b,a.
278c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com     */
2790342a85091fd430c90a142d155dc9642aa729d9ebsalomon@google.com    kRGBA_8888_GrPixelConfig,
280c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com    /**
2810342a85091fd430c90a142d155dc9642aa729d9ebsalomon@google.com     * Premultiplied. Byte order is b,g,r,a.
282c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com     */
2830342a85091fd430c90a142d155dc9642aa729d9ebsalomon@google.com    kBGRA_8888_GrPixelConfig,
2846e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org    /**
2856e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org     * ETC1 Compressed Data
2866e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org     */
2876e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org    kETC1_GrPixelConfig,
2886e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org    /**
2896e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org     * LATC/RGTC/3Dc/BC4 Compressed Data
2906e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org     */
2916e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org    kLATC_GrPixelConfig,
2924bcb0c6e0377557d326344f4bd2bbab4e8b1bc3absalomon@google.com
2936e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org    kLast_GrPixelConfig = kLATC_GrPixelConfig
294669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com};
295b8eb2e89edf914caf5479baeffcb670d3e93f496bsalomon@google.comstatic const int kGrPixelConfigCnt = kLast_GrPixelConfig + 1;
296669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com
297fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com// Aliases for pixel configs that match skia's byte order.
298c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com#ifndef SK_CPU_LENDIAN
299c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com    #error "Skia gpu currently assumes little endian"
300c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com#endif
301e4657ed7e1f4ae5b1834b398724c718f21589ca3commit-bot@chromium.org#if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
3020342a85091fd430c90a142d155dc9642aa729d9ebsalomon@google.com    static const GrPixelConfig kSkia8888_GrPixelConfig = kBGRA_8888_GrPixelConfig;
303e4657ed7e1f4ae5b1834b398724c718f21589ca3commit-bot@chromium.org#elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
3040342a85091fd430c90a142d155dc9642aa729d9ebsalomon@google.com    static const GrPixelConfig kSkia8888_GrPixelConfig = kRGBA_8888_GrPixelConfig;
305c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com#else
306c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com    #error "SK_*32_SHIFT values must correspond to GL_BGRA or GL_RGBA format."
307c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com#endif
308c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com
3096e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org// Returns true if the pixel config is a GPU-specific compressed format
3106e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org// representation.
3116e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.orgstatic inline bool GrPixelConfigIsCompressed(GrPixelConfig config) {
3126e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org    switch (config) {
3136e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org        case kETC1_GrPixelConfig:
3146e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org        case kLATC_GrPixelConfig:
3156e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org            return true;
3166e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org        default:
3176e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org            return false;
3186e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org    }
3196e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org}
3206e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org
3210a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com// Returns true if the pixel config is 32 bits per pixel
3229c68058b679aee81e6e0158e7fcbfb5d8479c91absalomon@google.comstatic inline bool GrPixelConfigIs8888(GrPixelConfig config) {
3230a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com    switch (config) {
3240342a85091fd430c90a142d155dc9642aa729d9ebsalomon@google.com        case kRGBA_8888_GrPixelConfig:
3250342a85091fd430c90a142d155dc9642aa729d9ebsalomon@google.com        case kBGRA_8888_GrPixelConfig:
3260a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com            return true;
3270a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com        default:
3280a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com            return false;
3290a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com    }
3300a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com}
3310a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com
3320a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com// Takes a config and returns the equivalent config with the R and B order
3330a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com// swapped if such a config exists. Otherwise, kUnknown_GrPixelConfig
3340a97be216df494291fe929b79d438809af7e9c83bsalomon@google.comstatic inline GrPixelConfig GrPixelConfigSwapRAndB(GrPixelConfig config) {
3350a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com    switch (config) {
3360342a85091fd430c90a142d155dc9642aa729d9ebsalomon@google.com        case kBGRA_8888_GrPixelConfig:
3370342a85091fd430c90a142d155dc9642aa729d9ebsalomon@google.com            return kRGBA_8888_GrPixelConfig;
3380342a85091fd430c90a142d155dc9642aa729d9ebsalomon@google.com        case kRGBA_8888_GrPixelConfig:
3390342a85091fd430c90a142d155dc9642aa729d9ebsalomon@google.com            return kBGRA_8888_GrPixelConfig;
3400a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com        default:
3410a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com            return kUnknown_GrPixelConfig;
3420a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com    }
3430a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com}
3440a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com
345669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.comstatic inline size_t GrBytesPerPixel(GrPixelConfig config) {
346669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com    switch (config) {
347669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com        case kAlpha_8_GrPixelConfig:
348669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com        case kIndex_8_GrPixelConfig:
349669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com            return 1;
350669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com        case kRGB_565_GrPixelConfig:
351669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com        case kRGBA_4444_GrPixelConfig:
352669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com            return 2;
3530342a85091fd430c90a142d155dc9642aa729d9ebsalomon@google.com        case kRGBA_8888_GrPixelConfig:
3540342a85091fd430c90a142d155dc9642aa729d9ebsalomon@google.com        case kBGRA_8888_GrPixelConfig:
355669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com            return 4;
356669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com        default:
357669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com            return 0;
358669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com    }
359669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com}
360669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com
361669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.comstatic inline bool GrPixelConfigIsOpaque(GrPixelConfig config) {
362669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com    switch (config) {
3636e7ddaae0a077a777b8b8872ec27f8faab275536commit-bot@chromium.org        case kETC1_GrPixelConfig:
364669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com        case kRGB_565_GrPixelConfig:
365c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com            return true;
366c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com        default:
367c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com            return false;
368c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com    }
369c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com}
370c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com
371669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.comstatic inline bool GrPixelConfigIsAlphaOnly(GrPixelConfig config) {
372669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com    switch (config) {
373669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com        case kAlpha_8_GrPixelConfig:
374669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com            return true;
375669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com        default:
376669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com            return false;
377669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com    }
378669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com}
379669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com
380669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com/**
381fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * Optional bitfield flags that can be passed to createTexture.
382fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com */
383fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.comenum GrTextureFlags {
384fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    kNone_GrTextureFlags            = 0x0,
385fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    /**
386fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com     * Creates a texture that can be rendered to as a GrRenderTarget. Use
387fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com     * GrTexture::asRenderTarget() to access.
388fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com     */
389fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    kRenderTarget_GrTextureFlagBit  = 0x1,
390fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    /**
391fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com     * By default all render targets have an associated stencil buffer that
392fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com     * may be required for path filling. This flag overrides stencil buffer
393fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com     * creation.
394fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com     * MAKE THIS PRIVATE?
395fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com     */
396fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    kNoStencil_GrTextureFlagBit     = 0x2,
397fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    /**
398fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com     * Hint that the CPU may modify this texture after creation.
399fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com     */
400fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    kDynamicUpdate_GrTextureFlagBit = 0x4,
401d0925240efb3732475e62966896716c28e9902b2senorblanco@chromium.org    /**
402d0925240efb3732475e62966896716c28e9902b2senorblanco@chromium.org     * Indicates that all allocations (color buffer, FBO completeness, etc)
403d0925240efb3732475e62966896716c28e9902b2senorblanco@chromium.org     * should be verified.
404d0925240efb3732475e62966896716c28e9902b2senorblanco@chromium.org     */
405d0925240efb3732475e62966896716c28e9902b2senorblanco@chromium.org    kCheckAllocation_GrTextureFlagBit  = 0x8,
40615c0fea699b25343fe6f49668a5632866e1a0306robertphillips@google.com
40715c0fea699b25343fe6f49668a5632866e1a0306robertphillips@google.com    kDummy_GrTextureFlagBit,
40815c0fea699b25343fe6f49668a5632866e1a0306robertphillips@google.com    kLastPublic_GrTextureFlagBit = kDummy_GrTextureFlagBit-1,
409fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com};
410fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com
411fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.comGR_MAKE_BITFIELD_OPS(GrTextureFlags)
412fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com
413fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.comenum {
414fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com   /**
415fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    *  For Index8 pixel config, the colortable must be 256 entries
416fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    */
417fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    kGrColorTableSize = 256 * 4 //sizeof(GrColor)
418fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com};
419fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com
420ef5dbe1cd90fe586f165e54cb6f7608942610793senorblanco@chromium.org/**
421ef5dbe1cd90fe586f165e54cb6f7608942610793senorblanco@chromium.org * Some textures will be stored such that the upper and left edges of the content meet at the
422ef5dbe1cd90fe586f165e54cb6f7608942610793senorblanco@chromium.org * the origin (in texture coord space) and for other textures the lower and left edges meet at
4233cb406bb88f5aa09cf9f5a9554b4b1314cf1a2eesenorblanco@chromium.org * the origin. kDefault_GrSurfaceOrigin sets textures to TopLeft, and render targets
4243cb406bb88f5aa09cf9f5a9554b4b1314cf1a2eesenorblanco@chromium.org * to BottomLeft.
425ef5dbe1cd90fe586f165e54cb6f7608942610793senorblanco@chromium.org */
426ef5dbe1cd90fe586f165e54cb6f7608942610793senorblanco@chromium.org
427ef5dbe1cd90fe586f165e54cb6f7608942610793senorblanco@chromium.orgenum GrSurfaceOrigin {
4283cb406bb88f5aa09cf9f5a9554b4b1314cf1a2eesenorblanco@chromium.org    kDefault_GrSurfaceOrigin,         // DEPRECATED; to be removed
429cf9faf6ce9e3351b4d4030753eb43c8cd2010e0crobertphillips@google.com    kTopLeft_GrSurfaceOrigin,
4303cb406bb88f5aa09cf9f5a9554b4b1314cf1a2eesenorblanco@chromium.org    kBottomLeft_GrSurfaceOrigin,
431ef5dbe1cd90fe586f165e54cb6f7608942610793senorblanco@chromium.org};
4325091b7094ba4708451ea73b4fdd8020d8aaa7d23robertphillips@google.com
4335091b7094ba4708451ea73b4fdd8020d8aaa7d23robertphillips@google.com/**
434fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * Describes a texture to be created.
435fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com */
436fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.comstruct GrTextureDesc {
437fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    GrTextureDesc()
43875b3c9633cb9a594dab0ccf51dab1e694c149a18robertphillips@google.com    : fFlags(kNone_GrTextureFlags)
4393cb406bb88f5aa09cf9f5a9554b4b1314cf1a2eesenorblanco@chromium.org    , fOrigin(kDefault_GrSurfaceOrigin)
44075b3c9633cb9a594dab0ccf51dab1e694c149a18robertphillips@google.com    , fWidth(0)
44175b3c9633cb9a594dab0ccf51dab1e694c149a18robertphillips@google.com    , fHeight(0)
44275b3c9633cb9a594dab0ccf51dab1e694c149a18robertphillips@google.com    , fConfig(kUnknown_GrPixelConfig)
4439c2ea846351a29208cb4a36301ee611e7fb384earobertphillips@google.com    , fSampleCnt(0) {
44475b3c9633cb9a594dab0ccf51dab1e694c149a18robertphillips@google.com    }
44575b3c9633cb9a594dab0ccf51dab1e694c149a18robertphillips@google.com
446fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    GrTextureFlags         fFlags;  //!< bitfield of TextureFlags
4473cb406bb88f5aa09cf9f5a9554b4b1314cf1a2eesenorblanco@chromium.org    GrSurfaceOrigin        fOrigin; //!< origin of the texture
44879d2dbed5a08e0d3f65646d52b4bb884cd0af9b5bsalomon@google.com    int                    fWidth;  //!< Width of the texture
44979d2dbed5a08e0d3f65646d52b4bb884cd0af9b5bsalomon@google.com    int                    fHeight; //!< Height of the texture
45078d6cf9f434d3351b19de14f1eab424c23f0ab6dbsalomon@google.com
451fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com    /**
45207ef911f18e30566d8a9d790e0bd69a836fd9d24robertphillips@google.com     * Format of source data of the texture. Not guaranteed to be the same as
453fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com     * internal format used by 3D API.
454fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com     */
4555bc34f04fe70cdde702ac3bff1fea0ccb275d4a5bsalomon@google.com    GrPixelConfig          fConfig;
456b9014f4f2e6e2bb13f63006cecf34b848d95b0f3bsalomon@google.com
45778d6cf9f434d3351b19de14f1eab424c23f0ab6dbsalomon@google.com    /**
45878d6cf9f434d3351b19de14f1eab424c23f0ab6dbsalomon@google.com     * The number of samples per pixel or 0 to disable full scene AA. This only
45978d6cf9f434d3351b19de14f1eab424c23f0ab6dbsalomon@google.com     * applies if the kRenderTarget_GrTextureFlagBit is set. The actual number
46078d6cf9f434d3351b19de14f1eab424c23f0ab6dbsalomon@google.com     * of samples may not exactly match the request. The request will be rounded
46178d6cf9f434d3351b19de14f1eab424c23f0ab6dbsalomon@google.com     * up to the next supported sample count, or down if it is larger than the
4622d0baded0f45dfde9dc8c25313ff14ea18c0c915bsalomon@google.com     * max supported count.
46378d6cf9f434d3351b19de14f1eab424c23f0ab6dbsalomon@google.com     */
46475b3c9633cb9a594dab0ccf51dab1e694c149a18robertphillips@google.com    int                    fSampleCnt;
4659c2ea846351a29208cb4a36301ee611e7fb384earobertphillips@google.com};
4669c2ea846351a29208cb4a36301ee611e7fb384earobertphillips@google.com
4679c2ea846351a29208cb4a36301ee611e7fb384earobertphillips@google.com/**
4680797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com * GrCacheID is used create and find cached GrResources (e.g. GrTextures). The ID has two parts:
4690797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com * the domain and the key. Domains simply allow multiple clients to use 0-based indices as their
4700797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com * cache key without colliding. The key uniquely identifies a GrResource within the domain.
4710797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com * Users of the cache must obtain a domain via GenerateDomain().
4729c2ea846351a29208cb4a36301ee611e7fb384earobertphillips@google.com */
4730797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.comstruct GrCacheID {
4740797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.compublic:
4750797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    typedef uint8_t  Domain;
4760797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com
4770797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    struct Key {
4780797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com        union {
4790797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com            uint8_t  fData8[16];
4800797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com            uint32_t fData32[4];
4810797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com            uint64_t fData64[2];
4820797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com        };
4830797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    };
4844b86e3428b115202e82d49a0914ea8ab6dc25940bsalomon@google.com
4850b6ad2297fbf43466950690102c1c9c150f2a972bsalomon@google.com    /**
4860797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com     * A default cache ID is invalid; a set method must be called before the object is used.
4870b6ad2297fbf43466950690102c1c9c150f2a972bsalomon@google.com     */
4880797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    GrCacheID() { fDomain = kInvalid_Domain; }
4894b86e3428b115202e82d49a0914ea8ab6dc25940bsalomon@google.com
4900b6ad2297fbf43466950690102c1c9c150f2a972bsalomon@google.com    /**
4910797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com     * Initialize the cache ID to a domain and key.
4920b6ad2297fbf43466950690102c1c9c150f2a972bsalomon@google.com     */
4930797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    GrCacheID(Domain domain, const Key& key) {
494f6de475e5cbd143f348ff7738919e397b7fe7f57tfarina@chromium.org        SkASSERT(kInvalid_Domain != domain);
4950797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com        this->reset(domain, key);
4960797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    }
4970797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com
4980797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    void reset(Domain domain, const Key& key) {
4990797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com        fDomain = domain;
5000797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com        memcpy(&fKey, &key, sizeof(Key));
5010797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    }
5020797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com
5030797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    /** Has this been initialized to a valid domain */
5040797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    bool isValid() const { return kInvalid_Domain != fDomain; }
5050797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com
506f6de475e5cbd143f348ff7738919e397b7fe7f57tfarina@chromium.org    const Key& getKey() const { SkASSERT(this->isValid()); return fKey; }
507f6de475e5cbd143f348ff7738919e397b7fe7f57tfarina@chromium.org    Domain getDomain() const { SkASSERT(this->isValid()); return fDomain; }
5082859eb74f9c87471b2429cd12b84144b97157efbskia.committer@gmail.com
5090797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    /** Creates a new unique ID domain. */
5100797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    static Domain GenerateDomain();
5110797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com
5120797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.comprivate:
5130797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    Key             fKey;
5140797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    Domain          fDomain;
5150797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com
5160797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    static const Domain kInvalid_Domain = 0;
517fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com};
518fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com
519fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com/**
520d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com * Clips are composed from these objects.
521d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com */
522d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.comenum GrClipType {
523d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com    kRect_ClipType,
524d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com    kPath_ClipType
525d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com};
526d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com
527ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com///////////////////////////////////////////////////////////////////////////////
528ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com
529e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com// opaque type for 3D API object handles
53016e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.comtypedef intptr_t GrBackendObject;
531e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com
532e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com/**
533e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * Gr can wrap an existing texture created by the client with a GrTexture
534e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * object. The client is responsible for ensuring that the texture lives at
535fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com * least as long as the GrTexture object wrapping it. We require the client to
536fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com * explicitly provide information about the texture, such as width, height,
537e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * and pixel config, rather than querying the 3D APIfor these values. We expect
538e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * these to be immutable even if the 3D API doesn't require this (OpenGL).
539e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com *
540e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * Textures that are also render targets are supported as well. Gr will manage
541e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * any ancillary 3D API (stencil buffer, FBO id, etc) objects necessary for
542e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * Gr to draw into the render target. To access the render target object
543e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * call GrTexture::asRenderTarget().
544e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com *
545e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * If in addition to the render target flag, the caller also specifies a sample
546e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * count Gr will create an MSAA buffer that resolves into the texture. Gr auto-
547e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * resolves when it reads from the texture. The client can explictly resolve
548e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * using the GrRenderTarget interface.
54932716283420df90644c8b8114308f7967aa91d9frobertphillips@google.com *
55032716283420df90644c8b8114308f7967aa91d9frobertphillips@google.com * Note: These flags currently form a subset of GrTexture's flags.
551e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com */
552e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com
55316e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.comenum GrBackendTextureFlags {
554e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com    /**
555e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     * No flags enabled
556e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     */
55716e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.com    kNone_GrBackendTextureFlag             = kNone_GrTextureFlags,
558e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com    /**
559e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     * Indicates that the texture is also a render target, and thus should have
560e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     * a GrRenderTarget object.
561e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     *
562e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     * D3D (future): client must have created the texture with flags that allow
563e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     * it to be used as a render target.
564e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     */
56516e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.com    kRenderTarget_GrBackendTextureFlag     = kRenderTarget_GrTextureFlagBit,
566e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com};
56716e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.comGR_MAKE_BITFIELD_OPS(GrBackendTextureFlags)
568e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com
56916e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.comstruct GrBackendTextureDesc {
57016e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.com    GrBackendTextureDesc() { memset(this, 0, sizeof(*this)); }
57116e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.com    GrBackendTextureFlags           fFlags;
572ef5dbe1cd90fe586f165e54cb6f7608942610793senorblanco@chromium.org    GrSurfaceOrigin                 fOrigin;
573e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com    int                             fWidth;         //<! width in pixels
574e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com    int                             fHeight;        //<! height in pixels
575e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com    GrPixelConfig                   fConfig;        //<! color format
576e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com    /**
577e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     * If the render target flag is set and sample count is greater than 0
578e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     * then Gr will create an MSAA buffer that resolves to the texture.
579e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     */
580e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com    int                             fSampleCnt;
581e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com    /**
582e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     * Handle to the 3D API object.
583e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     * OpenGL: Texture ID.
584e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     */
58516e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.com    GrBackendObject                 fTextureHandle;
586e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com};
587e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com
588e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com///////////////////////////////////////////////////////////////////////////////
589e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com
590e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com/**
591e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * Gr can wrap an existing render target created by the client in the 3D API
592e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * with a GrRenderTarget object. The client is responsible for ensuring that the
593e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * underlying 3D API object lives at least as long as the GrRenderTarget object
594fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com * wrapping it. We require the client to explicitly provide information about
595e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * the target, such as width, height, and pixel config rather than querying the
596e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * 3D API for these values. We expect these properties to be immutable even if
597e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * the 3D API doesn't require this (OpenGL).
598e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com */
599e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com
60016e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.comstruct GrBackendRenderTargetDesc {
60116e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.com    GrBackendRenderTargetDesc() { memset(this, 0, sizeof(*this)); }
602e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com    int                             fWidth;         //<! width in pixels
603e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com    int                             fHeight;        //<! height in pixels
604e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com    GrPixelConfig                   fConfig;        //<! color format
6053cb406bb88f5aa09cf9f5a9554b4b1314cf1a2eesenorblanco@chromium.org    GrSurfaceOrigin                 fOrigin;        //<! pixel origin
606e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com    /**
607e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     * The number of samples per pixel. Gr uses this to influence decisions
60816e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.com     * about applying other forms of anti-aliasing.
609e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     */
610e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com    int                             fSampleCnt;
611e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com    /**
612e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     * Number of bits of stencil per-pixel.
613e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     */
614e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com    int                             fStencilBits;
615e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com    /**
616e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     * Handle to the 3D API object.
617e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     * OpenGL: FBO ID
618e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com     */
61916e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.com    GrBackendObject                 fRenderTargetHandle;
620e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com};
621e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com
6220a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com/**
6230a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com * The GrContext's cache of backend context state can be partially invalidated.
6240a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com * These enums are specific to the GL backend and we'd add a new set for an alternative backend.
6250a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com */
6260a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.comenum GrGLBackendState {
6270a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com    kRenderTarget_GrGLBackendState     = 1 << 0,
6280a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com    kTextureBinding_GrGLBackendState   = 1 << 1,
6290a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com    // View state stands for scissor and viewport
6300a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com    kView_GrGLBackendState             = 1 << 2,
6310a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com    kBlend_GrGLBackendState            = 1 << 3,
6320a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com    kAA_GrGLBackendState               = 1 << 4,
6330a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com    kVertex_GrGLBackendState           = 1 << 5,
6340a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com    kStencil_GrGLBackendState          = 1 << 6,
6350a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com    kPixelStore_GrGLBackendState       = 1 << 7,
6360a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com    kProgram_GrGLBackendState          = 1 << 8,
63746fbfe0cd1bbe60fd15ce52e784f5d51450ff5fdcommit-bot@chromium.org    kFixedFunction_GrGLBackendState    = 1 << 9,
6380a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com    kMisc_GrGLBackendState             = 1 << 10,
639c4dc0ad8e252a7e30d19b47d3d0d9f2c69faf854commit-bot@chromium.org    kPathRendering_GrGLBackendState    = 1 << 11,
6400a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com    kALL_GrGLBackendState              = 0xffff
6410a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com};
6420a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com
6430a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com/**
6440a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com * This value translates to reseting all the context state for any backend.
6450a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com */
6460a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.comstatic const uint32_t kAll_GrBackendState = 0xffffffff;
6470a208a117b2d7f2c2231aa357f1db4864dbdcba3bsalomon@google.com
64816e3ddea6a80972aced04b21b1d66377fa95e7c7bsalomon@google.com///////////////////////////////////////////////////////////////////////////////
6495877ffd5ea71a3ea70096d5c11c843798defa690bsalomon@google.com
650ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#endif
651