Implement support for origin-TopLeft render targets in GL backend.
Review URL: https://codereview.appspot.com/7230049
git-svn-id: http://skia.googlecode.com/svn/trunk/include@7545 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/GrRenderTarget.h b/gpu/GrRenderTarget.h
index 19a37a5..fcb4c3d 100644
--- a/gpu/GrRenderTarget.h
+++ b/gpu/GrRenderTarget.h
@@ -141,9 +141,8 @@
GrRenderTarget(GrGpu* gpu,
bool isWrapped,
GrTexture* texture,
- const GrTextureDesc& desc,
- GrSurfaceOrigin origin)
- : INHERITED(gpu, isWrapped, desc, origin)
+ const GrTextureDesc& desc)
+ : INHERITED(gpu, isWrapped, desc)
, fStencilBuffer(NULL)
, fTexture(texture) {
fResolveRect.setLargestInverted();
diff --git a/gpu/GrSurface.h b/gpu/GrSurface.h
index 3429cc6..02fc0d5 100644
--- a/gpu/GrSurface.h
+++ b/gpu/GrSurface.h
@@ -34,8 +34,8 @@
int height() const { return fDesc.fHeight; }
GrSurfaceOrigin origin() const {
- GrAssert(kTopLeft_GrSurfaceOrigin == fOrigin || kBottomLeft_GrSurfaceOrigin == fOrigin);
- return fOrigin;
+ GrAssert(kTopLeft_GrSurfaceOrigin == fDesc.fOrigin || kBottomLeft_GrSurfaceOrigin == fDesc.fOrigin);
+ return fDesc.fOrigin;
}
/**
@@ -104,17 +104,14 @@
uint32_t pixelOpsFlags = 0) = 0;
protected:
- GrSurface(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc, GrSurfaceOrigin origin)
+ GrSurface(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc)
: INHERITED(gpu, isWrapped)
- , fDesc(desc)
- , fOrigin(origin) {
+ , fDesc(desc) {
}
GrTextureDesc fDesc;
private:
- GrSurfaceOrigin fOrigin;
-
typedef GrResource INHERITED;
};
diff --git a/gpu/GrTexture.h b/gpu/GrTexture.h
index 94d5788..c088bdd 100644
--- a/gpu/GrTexture.h
+++ b/gpu/GrTexture.h
@@ -140,8 +140,8 @@
// base class cons sets to NULL
// subclass cons can create and set
- GrTexture(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc, GrSurfaceOrigin origin)
- : INHERITED(gpu, isWrapped, desc, origin)
+ GrTexture(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc)
+ : INHERITED(gpu, isWrapped, desc)
, fRenderTarget(NULL) {
// only make sense if alloc size is pow2
diff --git a/gpu/GrTypes.h b/gpu/GrTypes.h
index 055750d..88c5771 100644
--- a/gpu/GrTypes.h
+++ b/gpu/GrTypes.h
@@ -428,13 +428,14 @@
/**
* Some textures will be stored such that the upper and left edges of the content meet at the
* the origin (in texture coord space) and for other textures the lower and left edges meet at
- * the origin. Render-targets are always consistent with the convention of the underlying
- * backend API to make it easier to mix native backend rendering with Skia rendering.
+ * the origin. kDefault_GrSurfaceOrigin sets textures to TopLeft, and render targets
+ * to BottomLeft.
*/
enum GrSurfaceOrigin {
- kBottomLeft_GrSurfaceOrigin,
+ kDefault_GrSurfaceOrigin,
kTopLeft_GrSurfaceOrigin,
+ kBottomLeft_GrSurfaceOrigin,
};
/**
@@ -443,6 +444,7 @@
struct GrTextureDesc {
GrTextureDesc()
: fFlags(kNone_GrTextureFlags)
+ , fOrigin(kDefault_GrSurfaceOrigin)
, fWidth(0)
, fHeight(0)
, fConfig(kUnknown_GrPixelConfig)
@@ -450,6 +452,7 @@
}
GrTextureFlags fFlags; //!< bitfield of TextureFlags
+ GrSurfaceOrigin fOrigin; //!< origin of the texture
int fWidth; //!< Width of the texture
int fHeight; //!< Height of the texture
@@ -640,6 +643,7 @@
int fWidth; //<! width in pixels
int fHeight; //<! height in pixels
GrPixelConfig fConfig; //<! color format
+ GrSurfaceOrigin fOrigin; //<! pixel origin
/**
* The number of samples per pixel. Gr uses this to influence decisions
* about applying other forms of anti-aliasing.