diff options
author | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-01-28 16:42:38 +0000 |
---|---|---|
committer | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-01-28 16:42:38 +0000 |
commit | ef5dbe1cd90fe586f165e54cb6f7608942610793 (patch) | |
tree | d3634e1c6676c96145f8047c17d94fb8b6e5f11f /src/gpu/gl | |
parent | 02ddc8b85ace91b15feb329a6a1d5d62b2b846c6 (diff) |
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
Diffstat (limited to 'src/gpu/gl')
-rw-r--r-- | src/gpu/gl/GrGLEffectMatrix.cpp | 8 | ||||
-rw-r--r-- | src/gpu/gl/GrGLRenderTarget.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLTexture.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLTexture.h | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL.cpp | 12 |
5 files changed, 17 insertions, 11 deletions
diff --git a/src/gpu/gl/GrGLEffectMatrix.cpp b/src/gpu/gl/GrGLEffectMatrix.cpp index 6dcb6e6096..5fdde2c394 100644 --- a/src/gpu/gl/GrGLEffectMatrix.cpp +++ b/src/gpu/gl/GrGLEffectMatrix.cpp @@ -19,7 +19,7 @@ GrGLEffect::EffectKey GrGLEffectMatrix::GenKey(const SkMatrix& effectMatrix, SkMatrix::kPerspective_Mask; int combinedTypes = type0 | type1; - bool reverseY = (NULL != texture) && GrSurface::kBottomLeft_Origin == texture->origin(); + bool reverseY = (NULL != texture) && kBottomLeft_GrSurfaceOrigin == texture->origin(); if (SkMatrix::kPerspective_Mask & combinedTypes) { return kGeneral_Key; @@ -173,11 +173,11 @@ void GrGLEffectMatrix::setData(const GrGLUniformManager& uniformManager, case kVoid_GrSLType: GrAssert(matrix.isIdentity()); GrAssert(coordChangeMatrix.isIdentity()); - GrAssert(NULL == texture || GrSurface::kTopLeft_Origin == texture->origin()); + GrAssert(NULL == texture || kTopLeft_GrSurfaceOrigin == texture->origin()); return; case kVec2f_GrSLType: { GrAssert(SkMatrix::kTranslate_Mask == (matrix.getType() | coordChangeMatrix.getType())); - GrAssert(NULL == texture || GrSurface::kTopLeft_Origin == texture->origin()); + GrAssert(NULL == texture || kTopLeft_GrSurfaceOrigin == texture->origin()); SkScalar tx = matrix[SkMatrix::kMTransX] + coordChangeMatrix[SkMatrix::kMTransX]; SkScalar ty = matrix[SkMatrix::kMTransY] + coordChangeMatrix[SkMatrix::kMTransY]; if (fPrevMatrix.get(SkMatrix::kMTransX) != tx || @@ -191,7 +191,7 @@ void GrGLEffectMatrix::setData(const GrGLUniformManager& uniformManager, case kMat33f_GrSLType: { SkMatrix combined; combined.setConcat(matrix, coordChangeMatrix); - if (NULL != texture && GrSurface::kBottomLeft_Origin == texture->origin()) { + if (NULL != texture && kBottomLeft_GrSurfaceOrigin == texture->origin()) { // combined.postScale(1,-1); // combined.postTranslate(0,1); combined.set(SkMatrix::kMSkewY, diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp index c68283e648..47128e7064 100644 --- a/src/gpu/gl/GrGLRenderTarget.cpp +++ b/src/gpu/gl/GrGLRenderTarget.cpp @@ -51,7 +51,7 @@ GrGLRenderTarget::GrGLRenderTarget(GrGpuGL* gpu, viewport.fWidth, viewport.fHeight, desc.fConfig, desc.fSampleCnt), texture->origin()) { - GrAssert(kBottomLeft_Origin == texture->origin()); + GrAssert(kBottomLeft_GrSurfaceOrigin == texture->origin()); GrAssert(NULL != texID); GrAssert(NULL != texture); // FBO 0 can't also be a texture, right? @@ -74,7 +74,7 @@ GrGLRenderTarget::GrGLRenderTarget(GrGpuGL* gpu, MakeDesc(kNone_GrTextureFlags, viewport.fWidth, viewport.fHeight, desc.fConfig, desc.fSampleCnt), - kBottomLeft_Origin) { + kBottomLeft_GrSurfaceOrigin) { this->init(desc, viewport, NULL); } diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp index 5c588e7f0d..3ec555a924 100644 --- a/src/gpu/gl/GrGLTexture.cpp +++ b/src/gpu/gl/GrGLTexture.cpp @@ -28,7 +28,7 @@ void GrGLTexture::init(GrGpuGL* gpu, textureDesc.fIsWrapped)); if (NULL != rtDesc) { - GrAssert(kBottomLeft_Origin == textureDesc.fOrigin); + GrAssert(kBottomLeft_GrSurfaceOrigin == textureDesc.fSurfaceOrigin); GrGLIRect vp; vp.fLeft = 0; vp.fWidth = textureDesc.fWidth; diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h index 527bab0e84..231482134b 100644 --- a/src/gpu/gl/GrGLTexture.h +++ b/src/gpu/gl/GrGLTexture.h @@ -59,7 +59,7 @@ public: struct Desc : public GrTextureDesc { GrGLuint fTextureID; bool fIsWrapped; - Origin fOrigin; + GrSurfaceOrigin fOrigin; }; // creates a texture that is also an RT diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index 670f6acfa4..a1a5bee5f2 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -485,6 +485,12 @@ GrTexture* GrGpuGL::onWrapBackendTexture(const GrBackendTextureDesc& desc) { 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 @@ GrTexture* GrGpuGL::onWrapBackendTexture(const GrBackendTextureDesc& desc) { 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 GrGpuGL::uploadTexData(const GrGLTexture::Desc& desc, 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 @@ GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc, // 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() && |