aboutsummaryrefslogtreecommitdiffhomepage
path: root/gpu/include
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-02-18 16:09:55 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-02-18 16:09:55 +0000
commit8895a7a0e222de4530e506e43eaa5e6030e8c5ed (patch)
tree1493fb4cf14a7cfaccf86a16302495d7c27d61f5 /gpu/include
parentce2b1afb582f0a2274f476c949cff8b0e1c72b36 (diff)
Reduce glGets for stencil bits.
Clean up GL vs Gr rect conventions for viewport and scissor. Review URL: http://codereview.appspot.com/4185056/ git-svn-id: http://skia.googlecode.com/svn/trunk@813 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gpu/include')
-rw-r--r--gpu/include/GrContext.h9
-rw-r--r--gpu/include/GrGLConfig.h36
-rw-r--r--gpu/include/GrGLTexture.h51
-rw-r--r--gpu/include/GrGpu.h8
-rw-r--r--gpu/include/GrTexture.h4
-rw-r--r--gpu/include/GrUserConfig.h2
6 files changed, 75 insertions, 35 deletions
diff --git a/gpu/include/GrContext.h b/gpu/include/GrContext.h
index 973198b135..93c012c33b 100644
--- a/gpu/include/GrContext.h
+++ b/gpu/include/GrContext.h
@@ -145,9 +145,16 @@ public:
/**
* Wraps an externally-created rendertarget in a GrRenderTarget.
- * e.g. in GL platforamRenderTarget is an FBO id.
+ * @param platformRenderTarget 3D API-specific render target identifier
+ * e.g. in GL platforamRenderTarget is an FBO
+ * id.
+ * @param stencilBits the number of stencil bits that the render
+ * target has.
+ * @param width width of the render target.
+ * @param height height of the render target.
*/
GrRenderTarget* createPlatformRenderTarget(intptr_t platformRenderTarget,
+ int stencilBits,
int width, int height);
/**
diff --git a/gpu/include/GrGLConfig.h b/gpu/include/GrGLConfig.h
index e20e3a5ffa..dcad9a144b 100644
--- a/gpu/include/GrGLConfig.h
+++ b/gpu/include/GrGLConfig.h
@@ -384,4 +384,40 @@ static inline void GrGLClearErr() {
#define GR_GLEXT(exts, X) exts. X; GR_GL_LOG_CALLS_IMPL(X); GR_GL_CHECK_ERROR_IMPL(X);
#define GR_GLEXT_NO_ERR(exts, X) GrGLClearErr(); exts. X; GR_GL_LOG_CALLS_IMPL(X); GR_GL_CHECK_ERROR_IMPL(X);
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Helpers for glGetString()
+ */
+bool has_gl_extension(const char* ext);
+void gl_version(int* major, int* minor);
+
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * GrGL_RestoreResetRowLength() will reset GL_UNPACK_ROW_LENGTH to 0. We write
+ * this wrapper, since GL_UNPACK_ROW_LENGTH is not available on all GL versions
+ */
+#if GR_SUPPORT_GLDESKTOP
+ static inline void GrGL_RestoreResetRowLength() {
+ GR_GL(PixelStorei(GL_UNPACK_ROW_LENGTH, 0));
+ }
+#else
+ #define GrGL_RestoreResetRowLength()
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Some drivers want the var-int arg to be zero-initialized on input.
+ */
+#define GR_GL_INIT_ZERO 0
+#define GR_GL_GetIntegerv(e, p) \
+ do { \
+ *(p) = GR_GL_INIT_ZERO; \
+ GR_GL(GetIntegerv(e, p)); \
+ } while (0)
+
+////////////////////////////////////////////////////////////////////////////////
+
#endif \ No newline at end of file
diff --git a/gpu/include/GrGLTexture.h b/gpu/include/GrGLTexture.h
index 6f1b9615bf..fc12ee0878 100644
--- a/gpu/include/GrGLTexture.h
+++ b/gpu/include/GrGLTexture.h
@@ -18,17 +18,31 @@
#ifndef GrGLTexture_DEFINED
#define GrGLTexture_DEFINED
-#include "GrGLConfig.h"
-#include "GrGpu.h"
#include "GrTexture.h"
-#include "GrRect.h"
+#include "GrScalar.h"
+#include "GrGLIRect.h"
class GrGpuGL;
class GrGLTexture;
class GrGLRenderTarget : public GrRenderTarget {
-protected:
+public:
+ virtual ~GrGLRenderTarget();
+
+ bool resolveable() const { return fRTFBOID != fTexFBOID; }
+ bool needsResolve() const { return fNeedsResolve; }
+ void setDirty(bool dirty) { fNeedsResolve = resolveable() && dirty; }
+ GLuint renderFBOID() const { return fRTFBOID; }
+ GLuint textureFBOID() const { return fTexFBOID; }
+
+ GLuint getStencilBits() const { return fStencilBits; }
+
+ const GrGLIRect& viewport() const { return fViewport; }
+ void abandon();
+
+protected:
+
struct GLRenderTargetIDs {
GLuint fRTFBOID;
GLuint fTexFBOID;
@@ -37,29 +51,16 @@ protected:
bool fOwnIDs;
};
- GrGLRenderTarget(const GLRenderTargetIDs& ids,
- const GrIRect& fViewport,
+ GrGLRenderTarget(const GLRenderTargetIDs& ids,
+ GLuint stencilBits,
+ const GrGLIRect& fViewport,
GrGLTexture* texture,
GrGpuGL* gl);
- void setViewport(const GrIRect& rect) { GrAssert(rect.height() <= 0);
- fViewport = rect;}
-
- virtual uint32_t width() const { return fViewport.width(); }
- virtual uint32_t height() const { return -fViewport.height(); }
+ void setViewport(const GrGLIRect& rect) { fViewport = rect; }
-public:
- virtual ~GrGLRenderTarget();
-
- bool resolveable() const { return fRTFBOID != fTexFBOID; }
- bool needsResolve() const { return fNeedsResolve; }
- void setDirty(bool dirty) { fNeedsResolve = resolveable() && dirty; }
-
- GLuint renderFBOID() const { return fRTFBOID; }
- GLuint textureFBOID() const { return fTexFBOID; }
-
- const GrIRect& viewport() const { return fViewport; }
- void abandon();
+ virtual int width() const { return fViewport.fWidth; }
+ virtual int height() const { return fViewport.fHeight; }
private:
GrGpuGL* fGL;
@@ -67,6 +68,7 @@ private:
GLuint fTexFBOID;
GLuint fStencilRenderbufferID;
GLuint fMSColorRenderbufferID;
+ GLuint fStencilBits;
// Should this object delete IDs when it is destroyed or does someone
// else own them.
@@ -79,7 +81,7 @@ private:
// when we switch to this rendertarget we want to set the viewport to
// only render to to content area (as opposed to the whole allocation) and
// we want the rendering to be at top left (GL has origin in bottom left)
- GrIRect fViewport;
+ GrGLIRect fViewport;
friend class GrGpuGL;
friend class GrGLTexture;
@@ -111,6 +113,7 @@ protected:
GLenum fUploadFormat;
GLenum fUploadByteCount;
GLenum fUploadType;
+ GLuint fStencilBits;
Orientation fOrientation;
};
typedef GrGLRenderTarget::GLRenderTargetIDs GLRenderTargetIDs;
diff --git a/gpu/include/GrGpu.h b/gpu/include/GrGpu.h
index a132e9f4cc..cfa1509211 100644
--- a/gpu/include/GrGpu.h
+++ b/gpu/include/GrGpu.h
@@ -170,11 +170,13 @@ public:
* @param platformRenderTarget handle to the the render target in the
* underlying 3D API. Interpretation depends on
* GrGpu subclass in use.
+ * @param stencilBits number of stencil bits the target has
* @param width width of the render target
* @param height height of the render target
*/
virtual GrRenderTarget* createPlatformRenderTarget(
intptr_t platformRenderTarget,
+ int stencilBits,
int width, int height) = 0;
/**
@@ -351,12 +353,6 @@ protected:
// prepares clip flushes gpu state before a draw
bool setupClipAndFlushState(PrimitiveType type);
- struct BoundsState {
- bool fScissorEnabled;
- GrIRect fScissorRect;
- GrIRect fViewportRect;
- };
-
// defaults to false, subclass can set true to support palleted textures
bool f8bitPaletteSupport;
diff --git a/gpu/include/GrTexture.h b/gpu/include/GrTexture.h
index 5b3ed09517..098ac595a2 100644
--- a/gpu/include/GrTexture.h
+++ b/gpu/include/GrTexture.h
@@ -34,11 +34,11 @@ public:
/**
* @return the width of the rendertarget
*/
- virtual uint32_t width() const = 0;
+ virtual int width() const = 0;
/**
* @return the height of the rendertarget
*/
- virtual uint32_t height() const = 0;
+ virtual int height() const = 0;
/**
* @return the texture associated with the rendertarget, may be NULL.
diff --git a/gpu/include/GrUserConfig.h b/gpu/include/GrUserConfig.h
index 819f09384e..201d8366ee 100644
--- a/gpu/include/GrUserConfig.h
+++ b/gpu/include/GrUserConfig.h
@@ -28,8 +28,6 @@
#define GR_DEBUG 1
#endif
-//#define GR_FORCE_GLCHECKERR 1
-
/*
* The default 32bit pixel config for texture upload is GL_RGBA on all
* platforms except on Windows where it is GL_BGRA. If your bitmaps map to a