Add an origin flag for backend (external) textures. Some textures in WebKit have a topdown orientation, and skia needs to be notified of this, so that they are not drawn upside-down.
Review URL: https://codereview.appspot.com/7200048
git-svn-id: http://skia.googlecode.com/svn/trunk@7414 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 670f6ac..a1a5bee 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -485,6 +485,12 @@
return NULL;
}
+ // FIXME: add support for TopLeft RT's by flipping all draws.
+ if (desc.fFlags & kRenderTarget_GrBackendTextureFlag &&
+ kBottomLeft_GrSurfaceOrigin != desc.fOrigin) {
+ return NULL;
+ }
+
int maxSize = this->getCaps().maxTextureSize();
if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
return NULL;
@@ -499,7 +505,7 @@
glTexDesc.fSampleCnt = desc.fSampleCnt;
glTexDesc.fTextureID = static_cast<GrGLuint>(desc.fTextureHandle);
glTexDesc.fIsWrapped = true;
- glTexDesc.fOrigin = GrSurface::kBottomLeft_Origin;
+ glTexDesc.fOrigin = desc.fOrigin;
GrGLTexture* texture = NULL;
if (desc.fFlags & kRenderTarget_GrBackendTextureFlag) {
@@ -675,7 +681,7 @@
bool swFlipY = false;
bool glFlipY = false;
if (NULL != data) {
- if (GrSurface::kBottomLeft_Origin == desc.fOrigin) {
+ if (kBottomLeft_GrSurfaceOrigin == desc.fOrigin) {
if (this->glCaps().unpackFlipYSupport()) {
glFlipY = true;
} else {
@@ -957,7 +963,7 @@
// We keep GrRenderTargets in GL's normal orientation so that they
// can be drawn to by the outside world without the client having
// to render upside down.
- glTexDesc.fOrigin = renderTarget ? GrSurface::kBottomLeft_Origin : GrSurface::kTopLeft_Origin;
+ glTexDesc.fOrigin = renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin;
glRTDesc.fSampleCnt = desc.fSampleCnt;
if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() &&