Rename and clarify semantics of GrContext::resolveRenderTarget.

Review URL: https://codereview.chromium.org/696293004
This commit is contained in:
bsalomon 2014-11-03 14:28:32 -08:00 committed by Commit bot
parent a702415d9e
commit 87a94eb163
7 changed files with 30 additions and 33 deletions

View File

@ -659,17 +659,15 @@ public:
void flushSurfaceWrites(GrSurface* surface);
/**
* Resolves a render target that has MSAA. The intermediate MSAA buffer is
* down-sampled to the associated GrTexture (accessible via
* GrRenderTarget::asTexture()). Any pending draws to the render target will
* be executed before the resolve.
* Equivalent to flushSurfaceWrites but also performs MSAA resolve if necessary. This call is
* used to make the surface contents available to be read in the backend 3D API, usually for a
* compositing step external to Skia.
*
* This is only necessary when a client wants to access the object directly
* using the backend API directly. GrContext will detect when it must
* perform a resolve to a GrTexture used as the source of a draw or before
* reading pixels back from a GrTexture or GrRenderTarget.
* It is not necessary to call this before reading the render target via Skia/GrContext.
* GrContext will detect when it must perform a resolve before reading pixels back from the
* surface or using it as a texture.
*/
void resolveRenderTarget(GrRenderTarget*);
void prepareSurfaceForExternalRead(GrSurface*);
/**
* Provides a perfomance hint that the render target's contents are allowed

View File

@ -86,14 +86,6 @@ public:
*/
const SkIRect& getResolveRect() const { return fResolveRect; }
/**
* If the render target is multisampled this will perform a multisample
* resolve. Any pending draws to the target are first flushed. This only
* applies to render targets that are associated with GrTextures. After the
* function returns the GrTexture will contain the resolved pixels.
*/
void resolve();
/**
* Provide a performance hint that the render target's contents are allowed
* to become undefined.

View File

@ -116,6 +116,13 @@ public:
*/
void flushWrites();
/**
* After this returns any pending writes to the surface will be issued to the backend 3D API and
* if the surface has MSAA it will be resolved.
*/
void prepareForExternalRead();
/** Access methods that are only to be used within Skia code. */
inline GrSurfacePriv surfacePriv();
inline const GrSurfacePriv surfacePriv() const;

View File

@ -1534,12 +1534,15 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
return true;
}
void GrContext::resolveRenderTarget(GrRenderTarget* target) {
SkASSERT(target);
ASSERT_OWNED_RESOURCE(target);
this->flush();
if (fGpu) {
fGpu->resolveRenderTarget(target);
void GrContext::prepareSurfaceForExternalRead(GrSurface* surface) {
SkASSERT(surface);
ASSERT_OWNED_RESOURCE(surface);
if (surface->surfacePriv().hasPendingIO()) {
this->flush();
}
GrRenderTarget* rt = surface->asRenderTarget();
if (fGpu && rt) {
fGpu->resolveRenderTarget(rt);
}
}

View File

@ -13,15 +13,6 @@
#include "GrGpu.h"
#include "GrStencilBuffer.h"
void GrRenderTarget::resolve() {
// go through context so that all necessary flushing occurs
GrContext* context = this->getContext();
if (NULL == context) {
return;
}
context->resolveRenderTarget(this);
}
void GrRenderTarget::discard() {
// go through context so that all necessary flushing occurs
GrContext* context = this->getContext();

View File

@ -82,6 +82,12 @@ void GrSurface::flushWrites() {
}
}
void GrSurface::prepareForExternalRead() {
if (!this->wasDestroyed()) {
this->getContext()->prepareSurfaceForExternalRead(this);
}
}
bool GrSurface::hasPendingRead() const {
const GrTexture* thisTex = this->asTexture();
if (thisTex && thisTex->internalHasPendingRead()) {

View File

@ -1747,7 +1747,7 @@ bool SkGpuDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) {
void SkGpuDevice::flush() {
DO_DEFERRED_CLEAR();
fContext->resolveRenderTarget(fRenderTarget);
fRenderTarget->prepareForExternalRead();
}
///////////////////////////////////////////////////////////////////////////////