cleanup GrGLTexture / GrGLRenderTarget cons. Make GrRenderTarget aware of its msaa sample count.
Review URL: http://codereview.appspot.com/4833045/
git-svn-id: http://skia.googlecode.com/svn/trunk@1996 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/include/GrRenderTarget.h b/gpu/include/GrRenderTarget.h
index b6f4b62..a5616b9 100644
--- a/gpu/include/GrRenderTarget.h
+++ b/gpu/include/GrRenderTarget.h
@@ -77,7 +77,12 @@
/**
* @return true if the render target is multisampled, false otherwise
*/
- bool isMultisampled() { return fIsMultisampled; }
+ bool isMultisampled() const { return 0 != fSampleCnt; }
+
+ /**
+ * @return the number of samples-per-pixel or zero if non-MSAA.
+ */
+ int numSamples() const { return fSampleCnt; }
/**
* Call to indicate the multisample contents were modified such that the
@@ -147,14 +152,14 @@
int height,
GrPixelConfig config,
int stencilBits,
- bool isMultisampled)
+ int sampleCnt)
: INHERITED(gpu)
, fTexture(texture)
, fWidth(width)
, fHeight(height)
, fConfig(config)
, fStencilBits(stencilBits)
- , fIsMultisampled(isMultisampled)
+ , fSampleCnt(sampleCnt)
{
fResolveRect.setLargestInverted();
}
@@ -176,7 +181,7 @@
int fHeight;
GrPixelConfig fConfig;
int fStencilBits;
- bool fIsMultisampled;
+ int fSampleCnt;
GrIRect fResolveRect;
// GrGpu keeps a cached clip in the render target to avoid redundantly
diff --git a/gpu/include/GrTypes.h b/gpu/include/GrTypes.h
index a59a9ad..96dece0 100644
--- a/gpu/include/GrTypes.h
+++ b/gpu/include/GrTypes.h
@@ -506,10 +506,14 @@
enum GrPlatformRenderTargetFlags {
kNone_GrPlatformRenderTargetFlagBit = 0x0,
+
/**
* Specifies that the object being created is multisampled.
+ * WILL BE REMOVED ONCE WEBKIT STOPS USING THIS. INSTEAD
+ * SPECIFY # OF SAMPLES IN GrPlatformSurfaceDesc::fSampleCnt
*/
kIsMultisampled_GrPlatformRenderTargetFlagBit = 0x1,
+
/**
* Gives permission to Gr to perform the downsample-resolve of a
* multisampled render target. If this is not set then read pixel
@@ -545,6 +549,13 @@
* set in fFlags.
*/
int fStencilBits;
+
+ /**
+ * Number of samples per-pixel. Only relevant if kIsRenderTarget is set in
+ * fFlags.
+ */
+ int fSampleCnt;
+
/**
* Texture object in 3D API. Only relevant if fSurfaceType is kTexture or
* kTextureRenderTarget.
@@ -600,11 +611,12 @@
*
* GrPlatformSurfaceDesc renderTargetTextureDesc;
* renderTargetTextureDesc.fSurfaceType = kTextureRenderTarget_GrPlatformSurfaceType;
- * renderTargetTextureDesc.fRenderTargetFlags = (kIsMultisampled_GrPlatformRenderTargetFlagBit | kGrCanResolve_GrPlatformRenderTargetFlagBit);
+ * renderTargetTextureDesc.fRenderTargetFlags = kGrCanResolve_GrPlatformRenderTargetFlagBit;
* renderTargetTextureDesc.fWidth = W;
* renderTargetTextureDesc.fHeight = H;
* renderTargetTextureDesc.fConfig = kRGBA_8888_GrPixelConfig
* renderTargetTextureDesc.fStencilBits = 8;
+ * renderTargetTextureDesc.fSampleCnt = S;
* renderTargetTextureDesc.fPlatformTexture = textureID;
* renderTargetTextureDesc.fPlatformRenderTarget = drawFBOID;
* renderTargetTextureDesc.fPlatformResolveDestination = readFBOID;