GrTypes.h revision b9014f4f2e6e2bb13f63006cecf34b848d95b0f3
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" 16ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 17fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com//////////////////////////////////////////////////////////////////////////////// 18fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com 19fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com/** 20fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * Defines overloaded bitwise operators to make it easier to use an enum as a 21fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * bitfield. 22fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com */ 23fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com#define GR_MAKE_BITFIELD_OPS(X) \ 2486c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com inline X operator | (X a, X b) { \ 25fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com return (X) (+a | +b); \ 26fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com } \ 27fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com \ 2886c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com inline X operator & (X a, X b) { \ 29fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com return (X) (+a & +b); \ 30fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com } \ 31fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com template <typename T> \ 3286c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com inline X operator & (T a, X b) { \ 33fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com return (X) (+a & +b); \ 34fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com } \ 35fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com template <typename T> \ 3686c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com inline X operator & (X a, T b) { \ 37fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com return (X) (+a & +b); \ 38fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com } \ 39fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com 4086c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com#define GR_DECL_BITFIELD_OPS_FRIENDS(X) \ 4186c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com friend X operator | (X a, X b); \ 4286c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com \ 4386c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com friend X operator & (X a, X b); \ 4486c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com \ 4586c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com template <typename T> \ 4686c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com friend X operator & (T a, X b); \ 4786c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com \ 4886c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com template <typename T> \ 4986c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com friend X operator & (X a, T b); \ 50fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com//////////////////////////////////////////////////////////////////////////////// 51fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com 52fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com 53ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/** 54ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Macro to round n up to the next multiple of 4, or return it unchanged if 55ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * n is already a multiple of 4 56ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 579b24d25c6b7ddde5788444f17fa3bfad19096f37reed@google.com#define GrALIGN4(n) SkAlign4(n) 5801224d5d0a3228fe47e63d8346e0e433a87563a8tomhudson@google.com#define GrIsALIGN4(n) SkIsAlign4(n) 59ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 60ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.comtemplate <typename T> const T& GrMin(const T& a, const T& b) { 61ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com return (a < b) ? a : b; 62ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com} 63ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 64ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.comtemplate <typename T> const T& GrMax(const T& a, const T& b) { 65ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com return (b < a) ? a : b; 66ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com} 67ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 68ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com// compile time versions of min/max 69ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#define GR_CT_MAX(a, b) (((b) < (a)) ? (a) : (b)) 70ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#define GR_CT_MIN(a, b) (((b) < (a)) ? (b) : (a)) 71ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 72ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/** 73ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * divide, rounding up 74ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 75919583674bd5daeb60327c0bc1ce8aaa80d54e13bsalomon@google.comstatic inline int32_t GrIDivRoundUp(int x, int y) { 76919583674bd5daeb60327c0bc1ce8aaa80d54e13bsalomon@google.com GrAssert(y > 0); 77919583674bd5daeb60327c0bc1ce8aaa80d54e13bsalomon@google.com return (x + (y-1)) / y; 78919583674bd5daeb60327c0bc1ce8aaa80d54e13bsalomon@google.com} 791c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.comstatic inline uint32_t GrUIDivRoundUp(uint32_t x, uint32_t y) { 801c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com return (x + (y-1)) / y; 811c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com} 821c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.comstatic inline size_t GrSizeDivRoundUp(size_t x, uint32_t y) { 83ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com return (x + (y-1)) / y; 84ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com} 85ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 86ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/** 87ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * align up 88ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 891c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.comstatic inline uint32_t GrUIAlignUp(uint32_t x, uint32_t alignment) { 90ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com return GrUIDivRoundUp(x, alignment) * alignment; 91ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com} 921c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.comstatic inline uint32_t GrSizeAlignUp(size_t x, uint32_t alignment) { 931c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com return GrSizeDivRoundUp(x, alignment) * alignment; 941c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com} 95ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 96ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/** 97ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * amount of pad needed to align up 98ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 991c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.comstatic inline uint32_t GrUIAlignUpPad(uint32_t x, uint32_t alignment) { 1001c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com return (alignment - x % alignment) % alignment; 1011c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com} 1021c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.comstatic inline size_t GrSizeAlignUpPad(size_t x, uint32_t alignment) { 103ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com return (alignment - x % alignment) % alignment; 104ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com} 105ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 106ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/** 107ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * align down 108ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 1091c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.comstatic inline uint32_t GrUIAlignDown(uint32_t x, uint32_t alignment) { 1101c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com return (x / alignment) * alignment; 1111c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.com} 1121c13c9668a889e56a0c85b51b9f28139c25b76ffbsalomon@google.comstatic inline uint32_t GrSizeAlignDown(size_t x, uint32_t alignment) { 113ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com return (x / alignment) * alignment; 114ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com} 115ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 116ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/** 117ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Count elements in an array 118ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 1199b24d25c6b7ddde5788444f17fa3bfad19096f37reed@google.com#define GR_ARRAY_COUNT(array) SK_ARRAY_COUNT(array) 120ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 121ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com//!< allocate a block of memory, will never return NULL 122ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.comextern void* GrMalloc(size_t bytes); 123ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 124ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com//!< free block allocated by GrMalloc. ptr may be NULL 125ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.comextern void GrFree(void* ptr); 126ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 127ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.comstatic inline void Gr_bzero(void* dst, size_t size) { 128ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com memset(dst, 0, size); 129ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com} 130ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 131ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/////////////////////////////////////////////////////////////////////////////// 132ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 133ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/** 134ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Return the number of leading zeros in n 135ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 136ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.comextern int Gr_clz(uint32_t n); 137ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 138ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/** 139ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Return true if n is a power of 2 140ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 141ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.comstatic inline bool GrIsPow2(unsigned n) { 142ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com return n && 0 == (n & (n - 1)); 143ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com} 144ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 145ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/** 146ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Return the next power of 2 >= n. 147ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 148ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.comstatic inline uint32_t GrNextPow2(uint32_t n) { 149ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com return n ? (1 << (32 - Gr_clz(n - 1))) : 1; 150ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com} 151ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 152b5b3168a645802f66233234a06dd5a3764f18018bsalomon@google.comstatic inline int GrNextPow2(int n) { 153b5b3168a645802f66233234a06dd5a3764f18018bsalomon@google.com GrAssert(n >= 0); // this impl only works for non-neg. 154b5b3168a645802f66233234a06dd5a3764f18018bsalomon@google.com return n ? (1 << (32 - Gr_clz(n - 1))) : 1; 155b5b3168a645802f66233234a06dd5a3764f18018bsalomon@google.com} 156b5b3168a645802f66233234a06dd5a3764f18018bsalomon@google.com 157ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/////////////////////////////////////////////////////////////////////////////// 158ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 159ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/** 160ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * 16.16 fixed point type 161ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 162ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.comtypedef int32_t GrFixed; 163ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 164ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#if GR_DEBUG 165ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 166ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.comstatic inline int16_t GrToS16(intptr_t x) { 167ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com GrAssert((int16_t)x == x); 168ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com return (int16_t)x; 169ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com} 170ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 171ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#else 172ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 173ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#define GrToS16(x) x 174ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 175ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#endif 176ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 1775877ffd5ea71a3ea70096d5c11c843798defa690bsalomon@google.com 1785877ffd5ea71a3ea70096d5c11c843798defa690bsalomon@google.com/////////////////////////////////////////////////////////////////////////////// 17905ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com 18005ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com/** 18105ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com * Possible 3D APIs that may be used by Ganesh. 18205ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com */ 18305ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.comenum GrEngine { 18405ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com kOpenGL_Shaders_GrEngine, 18505ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com kOpenGL_Fixed_GrEngine, 18605ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com}; 18705ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com 18805ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com/** 18905ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com * Engine-specific 3D context handle 1900b77d6892b067ad402c9678b0226bff70599fbe2bsalomon@google.com * GrGLInterface* for OpenGL. If NULL will use the default GL interface. 19105ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com */ 19205ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.comtypedef intptr_t GrPlatform3DContext; 19305ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com 19405ef510389950e1ae8dcba40e41e001db771b12dbsalomon@google.com/////////////////////////////////////////////////////////////////////////////// 1955877ffd5ea71a3ea70096d5c11c843798defa690bsalomon@google.com 196ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/** 197ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Type used to describe format of vertices in arrays 198ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com * Values are defined in GrDrawTarget 199ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com */ 2004be283f3a82895530d1b70372cd48ddb1c663fd8bsalomon@google.comtypedef int GrVertexLayout; 201ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 202ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com/** 203ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com* Geometric primitives used for drawing. 204ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com*/ 205ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.comenum GrPrimitiveType { 206ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com kTriangles_PrimitiveType, 207ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com kTriangleStrip_PrimitiveType, 208ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com kTriangleFan_PrimitiveType, 209ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com kPoints_PrimitiveType, 210471d471dcd7422e5dd9c822c1092b2ba4721dcfebsalomon@google.com kLines_PrimitiveType, // 1 pix wide only 211471d471dcd7422e5dd9c822c1092b2ba4721dcfebsalomon@google.com kLineStrip_PrimitiveType // 1 pix wide only 212ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com}; 213ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com 2140650e811b537f21a3a9d09a953960626cf5cfce4bsalomon@google.comstatic inline bool GrIsPrimTypeLines(GrPrimitiveType type) { 2150650e811b537f21a3a9d09a953960626cf5cfce4bsalomon@google.com return kLines_PrimitiveType == type || kLineStrip_PrimitiveType == type; 2160650e811b537f21a3a9d09a953960626cf5cfce4bsalomon@google.com} 2170650e811b537f21a3a9d09a953960626cf5cfce4bsalomon@google.com 2180650e811b537f21a3a9d09a953960626cf5cfce4bsalomon@google.comstatic inline bool GrIsPrimTypeTris(GrPrimitiveType type) { 2190650e811b537f21a3a9d09a953960626cf5cfce4bsalomon@google.com return kTriangles_PrimitiveType == type || 2200650e811b537f21a3a9d09a953960626cf5cfce4bsalomon@google.com kTriangleStrip_PrimitiveType == type || 2210650e811b537f21a3a9d09a953960626cf5cfce4bsalomon@google.com kTriangleFan_PrimitiveType == type; 2220650e811b537f21a3a9d09a953960626cf5cfce4bsalomon@google.com} 2230650e811b537f21a3a9d09a953960626cf5cfce4bsalomon@google.com 224ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com/** 225ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com * Coeffecients for alpha-blending. 226ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com */ 227ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.comenum GrBlendCoeff { 228ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com kZero_BlendCoeff, //<! 0 229ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com kOne_BlendCoeff, //<! 1 230ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com kSC_BlendCoeff, //<! src color 231ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com kISC_BlendCoeff, //<! one minus src color 232ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com kDC_BlendCoeff, //<! dst color 233ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com kIDC_BlendCoeff, //<! one minus dst color 234ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com kSA_BlendCoeff, //<! src alpha 235ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com kISA_BlendCoeff, //<! one minus src alpha 236ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com kDA_BlendCoeff, //<! dst alpha 237ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com kIDA_BlendCoeff, //<! one minus dst alpha 238080773ca79cbdc230730d295441255e9254d76a6bsalomon@google.com kConstC_BlendCoeff, //<! constant color 239080773ca79cbdc230730d295441255e9254d76a6bsalomon@google.com kIConstC_BlendCoeff, //<! one minus constant color 240080773ca79cbdc230730d295441255e9254d76a6bsalomon@google.com kConstA_BlendCoeff, //<! constant color alpha 241080773ca79cbdc230730d295441255e9254d76a6bsalomon@google.com kIConstA_BlendCoeff, //<! one minus constant color alpha 242080773ca79cbdc230730d295441255e9254d76a6bsalomon@google.com 243271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com kPublicBlendCoeffCount 244ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com}; 245ffca400ef6f96a280c3e2c09210f950af64a1f24bsalomon@google.com 246d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com/** 247759c16e20dc42577226c8805bfea92d8bacb14d8reed@google.com * Formats for masks, used by the font cache. 248759c16e20dc42577226c8805bfea92d8bacb14d8reed@google.com * Important that these are 0-based. 24998539c607b05f7e25406ae873bf1b24154a36a6freed@google.com */ 25098539c607b05f7e25406ae873bf1b24154a36a6freed@google.comenum GrMaskFormat { 2511eeaf0ba2381f84ffd889f56303cbe0d1886bb21caryclark@google.com kA8_GrMaskFormat, //!< 1-byte per pixel 2521eeaf0ba2381f84ffd889f56303cbe0d1886bb21caryclark@google.com kA565_GrMaskFormat, //!< 2-bytes per pixel 2531eeaf0ba2381f84ffd889f56303cbe0d1886bb21caryclark@google.com kA888_GrMaskFormat, //!< 4-bytes per pixel 2541eeaf0ba2381f84ffd889f56303cbe0d1886bb21caryclark@google.com 2551eeaf0ba2381f84ffd889f56303cbe0d1886bb21caryclark@google.com kCount_GrMaskFormats //!< used to allocate arrays sized for mask formats 25698539c607b05f7e25406ae873bf1b24154a36a6freed@google.com}; 25798539c607b05f7e25406ae873bf1b24154a36a6freed@google.com 25898539c607b05f7e25406ae873bf1b24154a36a6freed@google.com/** 25998539c607b05f7e25406ae873bf1b24154a36a6freed@google.com * Return the number of bytes-per-pixel for the specified mask format. 26098539c607b05f7e25406ae873bf1b24154a36a6freed@google.com */ 26198539c607b05f7e25406ae873bf1b24154a36a6freed@google.comstatic inline int GrMaskFormatBytesPerPixel(GrMaskFormat format) { 262bbf1226530d1a4e521e40c982f127fd49dbeb6a0reed@google.com GrAssert((unsigned)format <= 2); 263bbf1226530d1a4e521e40c982f127fd49dbeb6a0reed@google.com // kA8 (0) -> 1 264bbf1226530d1a4e521e40c982f127fd49dbeb6a0reed@google.com // kA565 (1) -> 2 265bbf1226530d1a4e521e40c982f127fd49dbeb6a0reed@google.com // kA888 (2) -> 4 266bbf1226530d1a4e521e40c982f127fd49dbeb6a0reed@google.com return 1 << (int)format; 26798539c607b05f7e25406ae873bf1b24154a36a6freed@google.com} 26898539c607b05f7e25406ae873bf1b24154a36a6freed@google.com 26998539c607b05f7e25406ae873bf1b24154a36a6freed@google.com/** 270669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com * Pixel configurations. 27174b98715a375e5e4863115d681386c9f5ec194f5bsalomon@google.com * 27274b98715a375e5e4863115d681386c9f5ec194f5bsalomon@google.com * Unpremultiplied configs are intended for converting pixel data in and out 27374b98715a375e5e4863115d681386c9f5ec194f5bsalomon@google.com * from skia. Surfaces with these configs have limited support. As an input 27474b98715a375e5e4863115d681386c9f5ec194f5bsalomon@google.com * (GrPaint texture) the corresponding GrSamplerState must have its filter set 27574b98715a375e5e4863115d681386c9f5ec194f5bsalomon@google.com * to kNearest_Filter. Otherwise, the draw will fail. When the render target 27674b98715a375e5e4863115d681386c9f5ec194f5bsalomon@google.com * has an unpremultiplied config draws must use blend coeffs 1,0 (AKA src-mode). 27774b98715a375e5e4863115d681386c9f5ec194f5bsalomon@google.com * Other coeffs will cause the draw to fail. 278669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com */ 279669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.comenum GrPixelConfig { 280669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com kUnknown_GrPixelConfig, 281669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com kAlpha_8_GrPixelConfig, 282669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com kIndex_8_GrPixelConfig, 283669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com kRGB_565_GrPixelConfig, 284c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com /** 285c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com * Premultiplied 286c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com */ 287c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com kRGBA_4444_GrPixelConfig, 288c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com /** 289c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com * Premultiplied. Byte order is r,g,b,a 290c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com */ 291c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com kRGBA_8888_PM_GrPixelConfig, 292c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com /** 293c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com * Unpremultiplied. Byte order is r,g,b,a 294c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com */ 295c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com kRGBA_8888_UPM_GrPixelConfig, 296c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com /** 297c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com * Premultiplied. Byte order is b,g,r,a 298c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com */ 299c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com kBGRA_8888_PM_GrPixelConfig, 300c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com /** 301c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com * Unpremultiplied. Byte order is b,g,r,a 302c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com */ 303c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com kBGRA_8888_UPM_GrPixelConfig, 3044bcb0c6e0377557d326344f4bd2bbab4e8b1bc3absalomon@google.com 3054bcb0c6e0377557d326344f4bd2bbab4e8b1bc3absalomon@google.com kGrPixelConfigCount 306669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com}; 307669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com 308c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com// Aliases for pixel configs that match skia's byte order 309c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com#ifndef SK_CPU_LENDIAN 310c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com #error "Skia gpu currently assumes little endian" 311c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com#endif 312c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com#if 24 == SK_A32_SHIFT && 16 == SK_R32_SHIFT && \ 313c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com 8 == SK_G32_SHIFT && 0 == SK_B32_SHIFT 314c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com static const GrPixelConfig kSkia8888_PM_GrPixelConfig = kBGRA_8888_PM_GrPixelConfig; 315c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com static const GrPixelConfig kSkia8888_UPM_GrPixelConfig = kBGRA_8888_UPM_GrPixelConfig; 316c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com#elif 24 == SK_A32_SHIFT && 16 == SK_B32_SHIFT && \ 317c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com 8 == SK_G32_SHIFT && 0 == SK_R32_SHIFT 318c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com static const GrPixelConfig kSkia8888_PM_GrPixelConfig = kRGBA_8888_PM_GrPixelConfig; 319c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com static const GrPixelConfig kSkia8888_UPM_GrPixelConfig = kRGBA_8888_UPM_GrPixelConfig; 320c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com#else 321c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com #error "SK_*32_SHIFT values must correspond to GL_BGRA or GL_RGBA format." 322c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com#endif 323c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com 3240a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com// Returns true if the pixel config has 8bit r,g,b,a components in that byte 3250a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com// order 3260a97be216df494291fe929b79d438809af7e9c83bsalomon@google.comstatic inline bool GrPixelConfigIsRGBA8888(GrPixelConfig config) { 3270a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com switch (config) { 3280a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com case kRGBA_8888_PM_GrPixelConfig: 3290a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com case kRGBA_8888_UPM_GrPixelConfig: 3300a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com return true; 3310a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com default: 3320a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com return false; 3330a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com } 3340a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com} 3350a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com 3360a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com// Returns true if the pixel config has 8bit b,g,r,a components in that byte 3370a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com// order 3380a97be216df494291fe929b79d438809af7e9c83bsalomon@google.comstatic inline bool GrPixelConfigIsBGRA8888(GrPixelConfig config) { 3390a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com switch (config) { 3400a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com case kBGRA_8888_PM_GrPixelConfig: 3410a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com case kBGRA_8888_UPM_GrPixelConfig: 3420a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com return true; 3430a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com default: 3440a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com return false; 3450a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com } 3460a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com} 3470a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com 3480a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com// Returns true if the pixel config is 32 bits per pixel 3490a97be216df494291fe929b79d438809af7e9c83bsalomon@google.comstatic inline bool GrPixelConfigIs32Bit(GrPixelConfig config) { 3500a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com switch (config) { 3510a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com case kRGBA_8888_PM_GrPixelConfig: 3520a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com case kRGBA_8888_UPM_GrPixelConfig: 3530a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com case kBGRA_8888_PM_GrPixelConfig: 3540a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com case kBGRA_8888_UPM_GrPixelConfig: 3550a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com return true; 3560a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com default: 3570a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com return false; 3580a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com } 3590a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com} 3600a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com 3610a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com// Takes a config and returns the equivalent config with the R and B order 3620a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com// swapped if such a config exists. Otherwise, kUnknown_GrPixelConfig 3630a97be216df494291fe929b79d438809af7e9c83bsalomon@google.comstatic inline GrPixelConfig GrPixelConfigSwapRAndB(GrPixelConfig config) { 3640a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com switch (config) { 3650a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com case kBGRA_8888_PM_GrPixelConfig: 3660a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com return kRGBA_8888_PM_GrPixelConfig; 3670a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com case kBGRA_8888_UPM_GrPixelConfig: 3680a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com return kRGBA_8888_UPM_GrPixelConfig; 3690a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com case kRGBA_8888_PM_GrPixelConfig: 3700a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com return kBGRA_8888_PM_GrPixelConfig; 3710a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com case kRGBA_8888_UPM_GrPixelConfig: 3720a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com return kBGRA_8888_UPM_GrPixelConfig; 3730a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com default: 3740a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com return kUnknown_GrPixelConfig; 3750a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com } 3760a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com} 3770a97be216df494291fe929b79d438809af7e9c83bsalomon@google.com 378669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.comstatic inline size_t GrBytesPerPixel(GrPixelConfig config) { 379669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com switch (config) { 380669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com case kAlpha_8_GrPixelConfig: 381669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com case kIndex_8_GrPixelConfig: 382669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com return 1; 383669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com case kRGB_565_GrPixelConfig: 384669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com case kRGBA_4444_GrPixelConfig: 385669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com return 2; 386c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com case kRGBA_8888_PM_GrPixelConfig: 387c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com case kRGBA_8888_UPM_GrPixelConfig: 388c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com case kBGRA_8888_PM_GrPixelConfig: 389c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com case kBGRA_8888_UPM_GrPixelConfig: 390669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com return 4; 391669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com default: 392669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com return 0; 393669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com } 394669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com} 395669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com 396669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.comstatic inline bool GrPixelConfigIsOpaque(GrPixelConfig config) { 397669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com switch (config) { 398669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com case kRGB_565_GrPixelConfig: 399c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com return true; 400c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com default: 401c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com return false; 402c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com } 403c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com} 404c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com 405c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com/** 406c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com * Premultiplied alpha is the usual for skia. Therefore, configs that are 407c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com * ambiguous (alpha-only or color-only) are considered premultiplied. 408c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com */ 409c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.comstatic inline bool GrPixelConfigIsUnpremultiplied(GrPixelConfig config) { 410c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com switch (config) { 411c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com case kRGBA_8888_UPM_GrPixelConfig: 412c43649962221c348d656d425a3fa9b29c78231d4bsalomon@google.com case kBGRA_8888_UPM_GrPixelConfig: 413669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com return true; 414669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com default: 415669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com return false; 416669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com } 417669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com} 418669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com 419669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.comstatic inline bool GrPixelConfigIsAlphaOnly(GrPixelConfig config) { 420669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com switch (config) { 421669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com case kAlpha_8_GrPixelConfig: 422669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com return true; 423669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com default: 424669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com return false; 425669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com } 426669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com} 427669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com 428669fdc4ed8ed461a141cb97d0afdd9ef72a82be1bsalomon@google.com/** 429fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * Optional bitfield flags that can be passed to createTexture. 430fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com */ 431fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.comenum GrTextureFlags { 432fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com kNone_GrTextureFlags = 0x0, 433fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com /** 434fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * Creates a texture that can be rendered to as a GrRenderTarget. Use 435fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * GrTexture::asRenderTarget() to access. 436fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com */ 437fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com kRenderTarget_GrTextureFlagBit = 0x1, 438fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com /** 439fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * By default all render targets have an associated stencil buffer that 440fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * may be required for path filling. This flag overrides stencil buffer 441fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * creation. 442fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * MAKE THIS PRIVATE? 443fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com */ 444fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com kNoStencil_GrTextureFlagBit = 0x2, 445fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com /** 446fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * Hint that the CPU may modify this texture after creation. 447fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com */ 448fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com kDynamicUpdate_GrTextureFlagBit = 0x4, 449fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com}; 450fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com 451fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.comGR_MAKE_BITFIELD_OPS(GrTextureFlags) 452fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com 453fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.comenum { 454fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com /** 455fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * For Index8 pixel config, the colortable must be 256 entries 456fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com */ 457fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com kGrColorTableSize = 256 * 4 //sizeof(GrColor) 458fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com}; 459fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com 460fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com/** 461fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * Describes a texture to be created. 462fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com */ 463fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.comstruct GrTextureDesc { 464fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com GrTextureFlags fFlags; //!< bitfield of TextureFlags 46579d2dbed5a08e0d3f65646d52b4bb884cd0af9b5bsalomon@google.com int fWidth; //!< Width of the texture 46679d2dbed5a08e0d3f65646d52b4bb884cd0af9b5bsalomon@google.com int fHeight; //!< Height of the texture 46778d6cf9f434d3351b19de14f1eab424c23f0ab6dbsalomon@google.com 468fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com /** 469fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * Format of source data of the texture. Not guaraunteed to be the same as 470fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com * internal format used by 3D API. 471fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com */ 4725bc34f04fe70cdde702ac3bff1fea0ccb275d4a5bsalomon@google.com GrPixelConfig fConfig; 473b9014f4f2e6e2bb13f63006cecf34b848d95b0f3bsalomon@google.com 47478d6cf9f434d3351b19de14f1eab424c23f0ab6dbsalomon@google.com /** 47578d6cf9f434d3351b19de14f1eab424c23f0ab6dbsalomon@google.com * The number of samples per pixel or 0 to disable full scene AA. This only 47678d6cf9f434d3351b19de14f1eab424c23f0ab6dbsalomon@google.com * applies if the kRenderTarget_GrTextureFlagBit is set. The actual number 47778d6cf9f434d3351b19de14f1eab424c23f0ab6dbsalomon@google.com * of samples may not exactly match the request. The request will be rounded 47878d6cf9f434d3351b19de14f1eab424c23f0ab6dbsalomon@google.com * up to the next supported sample count, or down if it is larger than the 47978d6cf9f434d3351b19de14f1eab424c23f0ab6dbsalomon@google.com * max supportex count. 48078d6cf9f434d3351b19de14f1eab424c23f0ab6dbsalomon@google.com */ 481b9014f4f2e6e2bb13f63006cecf34b848d95b0f3bsalomon@google.com int fSampleCnt; 482fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com}; 483fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com 484fea37b5e532dfe776269253afb9951e763c3b205bsalomon@google.com/** 485d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com * Set Operations used to construct clips. 486d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com */ 487d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.comenum GrSetOp { 488d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com kReplace_SetOp, 489d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com kIntersect_SetOp, 490d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com kUnion_SetOp, 491d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com kXor_SetOp, 492d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com kDifference_SetOp, 493d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com kReverseDifference_SetOp, 494d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com}; 495d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com 496d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com/** 497d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com * Clips are composed from these objects. 498d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com */ 499d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.comenum GrClipType { 500d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com kRect_ClipType, 501d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com kPath_ClipType 502d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com}; 503d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com 5045aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com/** 5055aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com * Commands used to describe a path. Each command 5065aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com * is accompanied by some number of points. 5075aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com */ 5085aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.comenum GrPathCmd { 5095aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com kMove_PathCmd, //!< Starts a new subpath at 5105aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com // at the returned point 5115aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com // 1 point 5125aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com kLine_PathCmd, //!< Adds a line segment 5135aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com // 2 points 5145aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com kQuadratic_PathCmd, //!< Adds a quadratic segment 5155aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com // 3 points 5165aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com kCubic_PathCmd, //!< Adds a cubic segment 5175aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com // 4 points 5185aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com kClose_PathCmd, //!< Closes the current subpath 5195aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com // by connecting a line to the 5205aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com // starting point. 5215aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com // 0 points 5225aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com kEnd_PathCmd //!< Indicates the end of the last subpath 5235aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com // when iterating 5245aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com // 0 points. 5255aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com}; 5265aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com 5275aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com/** 5285aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com * Gets the number of points associated with a path command. 5295aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com */ 5305aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.comstatic int inline NumPathCmdPoints(GrPathCmd cmd) { 5315aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com static const int gNumPoints[] = { 5325aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com 1, 2, 3, 4, 0, 0 5335aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com }; 5345aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com return gNumPoints[cmd]; 5355aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com} 5365aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com 5375aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com/** 5385aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com * Path filling rules 5395aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com */ 5405aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.comenum GrPathFill { 5415aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com kWinding_PathFill, 5425aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com kEvenOdd_PathFill, 5435aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com kInverseWinding_PathFill, 5445aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com kInverseEvenOdd_PathFill, 5455aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com kHairLine_PathFill, 5465aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com 5475aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com kPathFillCount 5485aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com}; 5495aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com 550fa6ac938e64fe11b442d05fe8a90ddac2d1951f9bsalomon@google.comstatic inline GrPathFill GrNonInvertedFill(GrPathFill fill) { 5515aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com static const GrPathFill gNonInvertedFills[] = { 5525aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com kWinding_PathFill, // kWinding_PathFill 5535aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com kEvenOdd_PathFill, // kEvenOdd_PathFill 5545aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com kWinding_PathFill, // kInverseWinding_PathFill 5555aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com kEvenOdd_PathFill, // kInverseEvenOdd_PathFill 5565aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com kHairLine_PathFill,// kHairLine_PathFill 5575aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com }; 5585aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com GR_STATIC_ASSERT(0 == kWinding_PathFill); 5595aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com GR_STATIC_ASSERT(1 == kEvenOdd_PathFill); 5605aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com GR_STATIC_ASSERT(2 == kInverseWinding_PathFill); 5615aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com GR_STATIC_ASSERT(3 == kInverseEvenOdd_PathFill); 5625aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com GR_STATIC_ASSERT(4 == kHairLine_PathFill); 5635aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com GR_STATIC_ASSERT(5 == kPathFillCount); 5645aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com return gNonInvertedFills[fill]; 5655aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com} 5665aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com 567fa6ac938e64fe11b442d05fe8a90ddac2d1951f9bsalomon@google.comstatic inline bool GrIsFillInverted(GrPathFill fill) { 5685aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com static const bool gIsFillInverted[] = { 5695aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com false, // kWinding_PathFill 5705aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com false, // kEvenOdd_PathFill 5715aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com true, // kInverseWinding_PathFill 5725aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com true, // kInverseEvenOdd_PathFill 5735aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com false, // kHairLine_PathFill 5745aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com }; 5755aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com GR_STATIC_ASSERT(0 == kWinding_PathFill); 5765aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com GR_STATIC_ASSERT(1 == kEvenOdd_PathFill); 5775aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com GR_STATIC_ASSERT(2 == kInverseWinding_PathFill); 5785aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com GR_STATIC_ASSERT(3 == kInverseEvenOdd_PathFill); 5795aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com GR_STATIC_ASSERT(4 == kHairLine_PathFill); 5805aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com GR_STATIC_ASSERT(5 == kPathFillCount); 5815aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com return gIsFillInverted[fill]; 5825aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com} 5835aaa69e4339e229adfb05e96084a8ec0a590238bbsalomon@google.com 584ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com/////////////////////////////////////////////////////////////////////////////// 585ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 586e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com// opaque type for 3D API object handles 587e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.comtypedef intptr_t GrPlatform3DObject; 588e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com 589e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com/** 590e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * Gr can wrap an existing texture created by the client with a GrTexture 591e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * object. The client is responsible for ensuring that the texture lives at 592e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * least as long as the GrTexture object wrapping it. We require the client to 593e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * explicitly provide information about the texture, such as width, height, 594e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * and pixel config, rather than querying the 3D APIfor these values. We expect 595e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * these to be immutable even if the 3D API doesn't require this (OpenGL). 596e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * 597e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * Textures that are also render targets are supported as well. Gr will manage 598e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * any ancillary 3D API (stencil buffer, FBO id, etc) objects necessary for 599e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * Gr to draw into the render target. To access the render target object 600e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * call GrTexture::asRenderTarget(). 601e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * 602e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * If in addition to the render target flag, the caller also specifies a sample 603e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * count Gr will create an MSAA buffer that resolves into the texture. Gr auto- 604e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * resolves when it reads from the texture. The client can explictly resolve 605e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * using the GrRenderTarget interface. 606e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com */ 607e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com 608e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.comenum GrPlatformTextureFlags { 609e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com /** 610e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * No flags enabled 611e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com */ 612e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com kNone_GrPlatformTextureFlag = 0x0, 613e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com /** 614e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * Indicates that the texture is also a render target, and thus should have 615e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * a GrRenderTarget object. 616e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * 617e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * D3D (future): client must have created the texture with flags that allow 618e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * it to be used as a render target. 619e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com */ 620e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com kRenderTarget_GrPlatformTextureFlag = 0x1, 621e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com}; 622e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.comGR_MAKE_BITFIELD_OPS(GrPlatformTextureFlags) 623e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com 624e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.comstruct GrPlatformTextureDesc { 625e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com GrPlatformTextureDesc() { memset(this, 0, sizeof(*this)); } 626e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com GrPlatformTextureFlags fFlags; 627e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com int fWidth; //<! width in pixels 628e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com int fHeight; //<! height in pixels 629e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com GrPixelConfig fConfig; //<! color format 630e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com /** 631e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * If the render target flag is set and sample count is greater than 0 632e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * then Gr will create an MSAA buffer that resolves to the texture. 633e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com */ 634e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com int fSampleCnt; 635e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com /** 636e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * Handle to the 3D API object. 637e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * OpenGL: Texture ID. 638e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com */ 639e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com GrPlatform3DObject fTextureHandle; 640e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com}; 641e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com 642e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com/////////////////////////////////////////////////////////////////////////////// 643e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com 644e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com/** 645e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * Gr can wrap an existing render target created by the client in the 3D API 646e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * with a GrRenderTarget object. The client is responsible for ensuring that the 647e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * underlying 3D API object lives at least as long as the GrRenderTarget object 648e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * wrapping it. We require the client to explicitly provide information about 649e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * the target, such as width, height, and pixel config rather than querying the 650e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * 3D API for these values. We expect these properties to be immutable even if 651e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * the 3D API doesn't require this (OpenGL). 652e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com */ 653e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com 654e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.comstruct GrPlatformRenderTargetDesc { 655e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com GrPlatformRenderTargetDesc() { memset(this, 0, sizeof(*this)); } 656e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com int fWidth; //<! width in pixels 657e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com int fHeight; //<! height in pixels 658e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com GrPixelConfig fConfig; //<! color format 659e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com /** 660e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * The number of samples per pixel. Gr uses this to influence decisions 661e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * about applying other forms of antialiasing. 662e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com */ 663e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com int fSampleCnt; 664e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com /** 665e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * Number of bits of stencil per-pixel. 666e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com */ 667e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com int fStencilBits; 668e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com /** 669e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * Handle to the 3D API object. 670e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com * OpenGL: FBO ID 671e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com */ 672e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com GrPlatform3DObject fRenderTargetHandle; 673e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com}; 674e269f210bdae0288643afaf8a579b22d3f6d5bebbsalomon@google.com 6755877ffd5ea71a3ea70096d5c11c843798defa690bsalomon@google.com 6765877ffd5ea71a3ea70096d5c11c843798defa690bsalomon@google.com/////////////////////////////////////////////////////////////////////////////// 6775877ffd5ea71a3ea70096d5c11c843798defa690bsalomon@google.com 678ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com// this is included only to make it easy to use this debugging facility 679ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#include "GrInstanceCounter.h" 680ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com 681ac10a2d039c5d52eed66e27cbbc503ab523c1cd5reed@google.com#endif 682