diff options
author | bsalomon <bsalomon@google.com> | 2016-01-14 09:24:09 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-14 09:24:09 -0800 |
commit | e5286e0b37abe4d0db67a6b3d87b2d5a12a70ab3 (patch) | |
tree | 506ce530275a41ca0561e0d00b3d535c58366b4e /include | |
parent | fe09119dd2acb43bb9986e6edeef3a480b539473 (diff) |
Beginning of support for texture rectangles.
Adds support for importing a RECTANGLE texture into Skia via GrTexureProvider::wrapBackendTexture().
Tests read/writing pixels, copySurface, and clear.
Does not add support for texturing from a RECTANGLE texture as the coords will be incorrectly normalized.
BUG=skia:3868
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1583863002
Review URL: https://codereview.chromium.org/1583863002
Diffstat (limited to 'include')
-rw-r--r-- | include/gpu/GrTypesPriv.h | 24 | ||||
-rw-r--r-- | include/gpu/gl/SkGLContext.h | 5 |
2 files changed, 24 insertions, 5 deletions
diff --git a/include/gpu/GrTypesPriv.h b/include/gpu/GrTypesPriv.h index 6a9c44ff9f..c46e25bd0d 100644 --- a/include/gpu/GrTypesPriv.h +++ b/include/gpu/GrTypesPriv.h @@ -26,8 +26,9 @@ enum GrSLType { kMat44f_GrSLType, kSampler2D_GrSLType, kSamplerExternal_GrSLType, + kSampler2DRect_GrSLType, - kLast_GrSLType = kSamplerExternal_GrSLType + kLast_GrSLType = kSampler2DRect_GrSLType }; static const int kGrSLTypeCount = kLast_GrSLType + 1; @@ -64,7 +65,7 @@ static const int kGrSLPrecisionCount = kLast_GrSLPrecision + 1; */ static inline int GrSLTypeVectorCount(GrSLType type) { SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); - static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1 }; + static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1 }; return kCounts[type]; GR_STATIC_ASSERT(0 == kVoid_GrSLType); @@ -76,6 +77,7 @@ static inline int GrSLTypeVectorCount(GrSLType type) { GR_STATIC_ASSERT(6 == kMat44f_GrSLType); GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); + GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrSLTypeCount); } @@ -105,7 +107,8 @@ static inline bool GrSLTypeIsFloatType(GrSLType type) { GR_STATIC_ASSERT(6 == kMat44f_GrSLType); GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); - GR_STATIC_ASSERT(9 == kGrSLTypeCount); + GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); + GR_STATIC_ASSERT(10 == kGrSLTypeCount); } /** Returns the size in bytes for floating point GrSLTypes. For non floating point type returns 0 */ @@ -120,7 +123,8 @@ static inline size_t GrSLTypeSize(GrSLType type) { 9 * sizeof(float), // kMat33f_GrSLType 16 * sizeof(float), // kMat44f_GrSLType 0, // kSampler2D_GrSLType - 0 // kSamplerExternal_GrSLType + 0, // kSamplerExternal_GrSLType + 0 // kSampler2DRect_GrSLType }; return kSizes[type]; @@ -133,7 +137,17 @@ static inline size_t GrSLTypeSize(GrSLType type) { GR_STATIC_ASSERT(6 == kMat44f_GrSLType); GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); - GR_STATIC_ASSERT(9 == kGrSLTypeCount); + GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); + GR_STATIC_ASSERT(10 == kGrSLTypeCount); +} + +static inline bool GrSLTypeIsSamplerType(GrSLType type) { + SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); + return type >= 7 && type <= 9; + + GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); + GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); + GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); } ////////////////////////////////////////////////////////////////////////////// diff --git a/include/gpu/gl/SkGLContext.h b/include/gpu/gl/SkGLContext.h index 7edfa730aa..77fd325dd8 100644 --- a/include/gpu/gl/SkGLContext.h +++ b/include/gpu/gl/SkGLContext.h @@ -41,6 +41,11 @@ public: virtual GrEGLImage texture2DToEGLImage(GrGLuint /*texID*/) const { return 0; } virtual void destroyEGLImage(GrEGLImage) const {} + /** Used for testing GL_TEXTURE_RECTANGLE integration. */ + GrGLint createTextureRectangle(int width, int height, GrGLenum internalFormat, + GrGLenum externalFormat, GrGLenum externalType, + GrGLvoid* data); + /** * Used for testing EGLImage integration. Takes a EGLImage and wraps it in a * GL_TEXTURE_EXTERNAL_OES. |