Implement support for origin-TopLeft render targets. Note that the default behaviour remains the same: textures default to origin-TopLeft, render targets default to origin-BottomLeft, and backend textures default to origin-BottomLeft. However, the caller can override the default by setting fOrigin in GrTextureDesc, GrBackendTextureDesc or GrBackendRenderTargetDesc.
Review URL: https://codereview.appspot.com/7230049
git-svn-id: http://skia.googlecode.com/svn/trunk@7594 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGLIRect.h b/src/gpu/gl/GrGLIRect.h
index 038520d..cbc4cb8 100644
--- a/src/gpu/gl/GrGLIRect.h
+++ b/src/gpu/gl/GrGLIRect.h
@@ -38,15 +38,20 @@
// sometimes we have a GrIRect from the client that we
// want to simultaneously make relative to GL's viewport
- // and convert from top-down to bottom-up.
+ // and (optionally) convert from top-down to bottom-up.
void setRelativeTo(const GrGLIRect& glRect,
int leftOffset,
int topOffset,
int width,
- int height) {
+ int height,
+ GrSurfaceOrigin origin) {
fLeft = glRect.fLeft + leftOffset;
fWidth = width;
- fBottom = glRect.fBottom + (glRect.fHeight - topOffset - height);
+ if (kBottomLeft_GrSurfaceOrigin == origin) {
+ fBottom = glRect.fBottom + (glRect.fHeight - topOffset - height);
+ } else {
+ fBottom = glRect.fBottom + topOffset;
+ }
fHeight = height;
GrAssert(fLeft >= 0);