2016-05-04 19:47:41 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GrRenderTargetProxy_DEFINED
|
|
|
|
#define GrRenderTargetProxy_DEFINED
|
|
|
|
|
|
|
|
#include "GrSurfaceProxy.h"
|
2017-06-13 12:11:36 +00:00
|
|
|
#include "GrTypesPriv.h"
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2017-03-04 13:12:46 +00:00
|
|
|
class GrResourceProvider;
|
2016-05-04 19:47:41 +00:00
|
|
|
|
|
|
|
// This class delays the acquisition of RenderTargets until they are actually
|
|
|
|
// required
|
|
|
|
// Beware: the uniqueID of the RenderTargetProxy will usually be different than
|
|
|
|
// the uniqueID of the RenderTarget it represents!
|
2016-11-04 15:59:10 +00:00
|
|
|
class GrRenderTargetProxy : virtual public GrSurfaceProxy {
|
2016-05-04 19:47:41 +00:00
|
|
|
public:
|
|
|
|
GrRenderTargetProxy* asRenderTargetProxy() override { return this; }
|
|
|
|
const GrRenderTargetProxy* asRenderTargetProxy() const override { return this; }
|
|
|
|
|
|
|
|
// Actually instantiate the backing rendertarget, if necessary.
|
2017-07-18 18:49:38 +00:00
|
|
|
bool instantiate(GrResourceProvider*) override;
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2017-05-12 15:36:10 +00:00
|
|
|
GrFSAAType fsaaType() const {
|
2017-05-17 17:49:59 +00:00
|
|
|
if (!fSampleCnt) {
|
2017-06-13 12:11:36 +00:00
|
|
|
SkASSERT(!(fRenderTargetFlags & GrRenderTargetFlags::kMixedSampled));
|
2017-05-12 15:36:10 +00:00
|
|
|
return GrFSAAType::kNone;
|
|
|
|
}
|
2017-06-13 12:11:36 +00:00
|
|
|
return (fRenderTargetFlags & GrRenderTargetFlags::kMixedSampled)
|
|
|
|
? GrFSAAType::kMixedSamples
|
|
|
|
: GrFSAAType::kUnifiedMSAA;
|
2017-05-12 15:36:10 +00:00
|
|
|
}
|
2017-05-17 17:49:59 +00:00
|
|
|
|
2017-08-10 12:44:49 +00:00
|
|
|
/*
|
|
|
|
* When instantiated does this proxy require a stencil buffer?
|
|
|
|
*/
|
|
|
|
void setNeedsStencil() { fNeedsStencil = true; }
|
|
|
|
bool needsStencil() const { return fNeedsStencil; }
|
|
|
|
|
2017-05-17 17:49:59 +00:00
|
|
|
/**
|
|
|
|
* Returns the number of samples/pixel in the stencil buffer (Zero if non-MSAA).
|
|
|
|
*/
|
|
|
|
int numStencilSamples() const { return fSampleCnt; }
|
|
|
|
|
2016-05-04 19:47:41 +00:00
|
|
|
/**
|
2016-08-10 18:09:07 +00:00
|
|
|
* Returns the number of samples/pixel in the color buffer (Zero if non-MSAA or mixed sampled).
|
2016-05-04 19:47:41 +00:00
|
|
|
*/
|
2017-05-12 15:36:10 +00:00
|
|
|
int numColorSamples() const {
|
2017-05-17 17:49:59 +00:00
|
|
|
return GrFSAAType::kMixedSamples == this->fsaaType() ? 0 : fSampleCnt;
|
2017-05-12 15:36:10 +00:00
|
|
|
}
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2016-11-09 13:54:35 +00:00
|
|
|
int maxWindowRectangles(const GrCaps& caps) const;
|
|
|
|
|
2017-06-13 12:11:36 +00:00
|
|
|
GrRenderTargetFlags testingOnly_getFlags() const;
|
2016-10-28 17:25:24 +00:00
|
|
|
|
2016-12-15 14:23:05 +00:00
|
|
|
// TODO: move this to a priv class!
|
|
|
|
bool refsWrappedObjects() const;
|
|
|
|
|
2016-11-04 15:59:10 +00:00
|
|
|
protected:
|
2016-11-09 11:50:43 +00:00
|
|
|
friend class GrSurfaceProxy; // for ctors
|
|
|
|
|
2016-08-10 18:09:07 +00:00
|
|
|
// Deferred version
|
2017-02-28 16:26:32 +00:00
|
|
|
GrRenderTargetProxy(const GrCaps&, const GrSurfaceDesc&,
|
|
|
|
SkBackingFit, SkBudgeted, uint32_t flags);
|
2016-05-04 19:47:41 +00:00
|
|
|
|
|
|
|
// Wrapped version
|
2017-07-25 14:16:35 +00:00
|
|
|
GrRenderTargetProxy(sk_sp<GrSurface>, GrSurfaceOrigin);
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2017-07-18 18:49:38 +00:00
|
|
|
sk_sp<GrSurface> createSurface(GrResourceProvider*) const override;
|
|
|
|
|
2016-11-04 15:59:10 +00:00
|
|
|
private:
|
2017-05-17 17:49:59 +00:00
|
|
|
size_t onUninstantiatedGpuMemorySize() const override;
|
2016-11-01 21:28:40 +00:00
|
|
|
|
2017-06-13 12:11:36 +00:00
|
|
|
int fSampleCnt;
|
2017-08-10 12:44:49 +00:00
|
|
|
bool fNeedsStencil;
|
|
|
|
|
2016-10-28 17:25:24 +00:00
|
|
|
// For wrapped render targets the actual GrRenderTarget is stored in the GrIORefProxy class.
|
|
|
|
// For deferred proxies that pointer is filled in when we need to instantiate the
|
|
|
|
// deferred resource.
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2016-08-10 18:09:07 +00:00
|
|
|
// These don't usually get computed until the render target is instantiated, but the render
|
|
|
|
// target proxy may need to answer queries about it before then. And since in the deferred case
|
|
|
|
// we know the newly created render target will be internal, we are able to precompute what the
|
|
|
|
// flags will ultimately end up being. In the wrapped case we just copy the wrapped
|
2016-05-04 19:47:41 +00:00
|
|
|
// rendertarget's info here.
|
2017-06-13 12:11:36 +00:00
|
|
|
GrRenderTargetFlags fRenderTargetFlags;
|
2016-05-04 19:47:41 +00:00
|
|
|
|
|
|
|
typedef GrSurfaceProxy INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|