gfx/skia/trunk/src/gpu/gl/GrGLRenderTarget.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /*
michael@0 2 * Copyright 2011 Google Inc.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8
michael@0 9 #ifndef GrGLRenderTarget_DEFINED
michael@0 10 #define GrGLRenderTarget_DEFINED
michael@0 11
michael@0 12 #include "GrGLIRect.h"
michael@0 13 #include "GrRenderTarget.h"
michael@0 14 #include "SkScalar.h"
michael@0 15
michael@0 16 class GrGpuGL;
michael@0 17 class GrGLTexture;
michael@0 18 class GrGLTexID;
michael@0 19
michael@0 20 class GrGLRenderTarget : public GrRenderTarget {
michael@0 21
michael@0 22 public:
michael@0 23 // set fTexFBOID to this value to indicate that it is multisampled but
michael@0 24 // Gr doesn't know how to resolve it.
michael@0 25 enum { kUnresolvableFBOID = 0 };
michael@0 26
michael@0 27 struct Desc {
michael@0 28 GrGLuint fRTFBOID;
michael@0 29 GrGLuint fTexFBOID;
michael@0 30 GrGLuint fMSColorRenderbufferID;
michael@0 31 bool fIsWrapped;
michael@0 32 GrPixelConfig fConfig;
michael@0 33 int fSampleCnt;
michael@0 34 GrSurfaceOrigin fOrigin;
michael@0 35 bool fCheckAllocation;
michael@0 36 };
michael@0 37
michael@0 38 // creates a GrGLRenderTarget associated with a texture
michael@0 39 GrGLRenderTarget(GrGpuGL* gpu,
michael@0 40 const Desc& desc,
michael@0 41 const GrGLIRect& viewport,
michael@0 42 GrGLTexID* texID,
michael@0 43 GrGLTexture* texture);
michael@0 44
michael@0 45 // creates an independent GrGLRenderTarget
michael@0 46 GrGLRenderTarget(GrGpuGL* gpu,
michael@0 47 const Desc& desc,
michael@0 48 const GrGLIRect& viewport);
michael@0 49
michael@0 50 virtual ~GrGLRenderTarget() { this->release(); }
michael@0 51
michael@0 52 void setViewport(const GrGLIRect& rect) { fViewport = rect; }
michael@0 53 const GrGLIRect& getViewport() const { return fViewport; }
michael@0 54
michael@0 55 // The following two functions return the same ID when a
michael@0 56 // texture/render target is multisampled, and different IDs when
michael@0 57 // it is.
michael@0 58 // FBO ID used to render into
michael@0 59 GrGLuint renderFBOID() const { return fRTFBOID; }
michael@0 60 // FBO ID that has texture ID attached.
michael@0 61 GrGLuint textureFBOID() const { return fTexFBOID; }
michael@0 62
michael@0 63 // override of GrRenderTarget
michael@0 64 virtual GrBackendObject getRenderTargetHandle() const {
michael@0 65 return this->renderFBOID();
michael@0 66 }
michael@0 67 virtual GrBackendObject getRenderTargetResolvedHandle() const {
michael@0 68 return this->textureFBOID();
michael@0 69 }
michael@0 70 virtual ResolveType getResolveType() const {
michael@0 71
michael@0 72 if (!this->isMultisampled() ||
michael@0 73 fRTFBOID == fTexFBOID) {
michael@0 74 // catches FBO 0 and non MSAA case
michael@0 75 return kAutoResolves_ResolveType;
michael@0 76 } else if (kUnresolvableFBOID == fTexFBOID) {
michael@0 77 return kCantResolve_ResolveType;
michael@0 78 } else {
michael@0 79 return kCanResolve_ResolveType;
michael@0 80 }
michael@0 81 }
michael@0 82
michael@0 83 protected:
michael@0 84 // override of GrResource
michael@0 85 virtual void onAbandon() SK_OVERRIDE;
michael@0 86 virtual void onRelease() SK_OVERRIDE;
michael@0 87
michael@0 88 private:
michael@0 89 GrGLuint fRTFBOID;
michael@0 90 GrGLuint fTexFBOID;
michael@0 91
michael@0 92 GrGLuint fMSColorRenderbufferID;
michael@0 93
michael@0 94 // when we switch to this render target we want to set the viewport to
michael@0 95 // only render to to content area (as opposed to the whole allocation) and
michael@0 96 // we want the rendering to be at top left (GL has origin in bottom left)
michael@0 97 GrGLIRect fViewport;
michael@0 98
michael@0 99 // non-NULL if this RT was created by Gr with an associated GrGLTexture.
michael@0 100 SkAutoTUnref<GrGLTexID> fTexIDObj;
michael@0 101
michael@0 102 void init(const Desc& desc, const GrGLIRect& viewport, GrGLTexID* texID);
michael@0 103
michael@0 104 typedef GrRenderTarget INHERITED;
michael@0 105 };
michael@0 106
michael@0 107 #endif

mercurial