Rename flushForExternalRead->flushForExternalIO and always call in SkSurface::getTextureHandle
Review URL: https://codereview.chromium.org/1216243003
This commit is contained in:
parent
37cc0b2e31
commit
c49e8682ab
@ -171,11 +171,11 @@ public:
|
||||
bool isTextureBacked() const;
|
||||
|
||||
/**
|
||||
* Retrieves the backend API handle of the texture. If flushPendingGrContextReads then the
|
||||
* GrContext will issue to the backend API any deferred read operations on the texture before
|
||||
* Retrieves the backend API handle of the texture. If flushPendingGrContextIO then the
|
||||
* GrContext will issue to the backend API any deferred IO operations on the texture before
|
||||
* returning.
|
||||
*/
|
||||
GrBackendObject getTextureHandle(bool flushPendingGrContextReads) const;
|
||||
GrBackendObject getTextureHandle(bool flushPendingGrContextIO) const;
|
||||
|
||||
/**
|
||||
* Copy the pixels from the image into the specified buffer (pixels + rowBytes),
|
||||
|
@ -304,15 +304,14 @@ public:
|
||||
void flushSurfaceWrites(GrSurface* surface);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Finalizes all pending reads and writes to the surface and also performs an MSAA resolve
|
||||
* if necessary.
|
||||
*
|
||||
* 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 prepareSurfaceForExternalRead(GrSurface*);
|
||||
void prepareSurfaceForExternalIO(GrSurface*);
|
||||
|
||||
/**
|
||||
* An ID associated with this context, guaranteed to be unique.
|
||||
|
@ -116,10 +116,10 @@ public:
|
||||
|
||||
|
||||
/**
|
||||
* After this returns any pending writes to the surface will be issued to the backend 3D API and
|
||||
* After this returns any pending surface IO will be issued to the backend 3D API and
|
||||
* if the surface has MSAA it will be resolved.
|
||||
*/
|
||||
void prepareForExternalRead();
|
||||
void prepareForExternalIO();
|
||||
|
||||
/** Access methods that are only to be used within Skia code. */
|
||||
inline GrSurfacePriv surfacePriv();
|
||||
|
@ -593,7 +593,7 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
|
||||
return true;
|
||||
}
|
||||
|
||||
void GrContext::prepareSurfaceForExternalRead(GrSurface* surface) {
|
||||
void GrContext::prepareSurfaceForExternalIO(GrSurface* surface) {
|
||||
RETURN_IF_ABANDONED
|
||||
SkASSERT(surface);
|
||||
ASSERT_OWNED_RESOURCE(surface);
|
||||
|
@ -84,9 +84,9 @@ void GrSurface::flushWrites() {
|
||||
}
|
||||
}
|
||||
|
||||
void GrSurface::prepareForExternalRead() {
|
||||
void GrSurface::prepareForExternalIO() {
|
||||
if (!this->wasDestroyed()) {
|
||||
this->getContext()->prepareSurfaceForExternalRead(this);
|
||||
this->getContext()->prepareSurfaceForExternalIO(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1737,7 +1737,7 @@ bool SkGpuDevice::onShouldDisableLCD(const SkPaint& paint) const {
|
||||
|
||||
void SkGpuDevice::flush() {
|
||||
DO_DEFERRED_CLEAR();
|
||||
fRenderTarget->prepareForExternalRead();
|
||||
fRenderTarget->prepareForExternalIO();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -122,13 +122,13 @@ GrTexture* SkImage::getTexture() const {
|
||||
|
||||
bool SkImage::isTextureBacked() const { return SkToBool(as_IB(this)->getTexture()); }
|
||||
|
||||
GrBackendObject SkImage::getTextureHandle(bool flushPendingGrContextReads) const {
|
||||
GrBackendObject SkImage::getTextureHandle(bool flushPendingGrContextIO) const {
|
||||
GrTexture* texture = as_IB(this)->getTexture();
|
||||
if (texture) {
|
||||
GrContext* context = texture->getContext();
|
||||
if (context) {
|
||||
if (flushPendingGrContextReads) {
|
||||
context->prepareSurfaceForExternalRead(texture);
|
||||
if (flushPendingGrContextIO) {
|
||||
context->prepareSurfaceForExternalIO(texture);
|
||||
}
|
||||
}
|
||||
return texture->getTextureHandle();
|
||||
@ -142,7 +142,7 @@ GrTexture* SkImage::getTexture() const { return NULL; }
|
||||
|
||||
bool SkImage::isTextureBacked() const { return false; }
|
||||
|
||||
GrBackendObject SkImage::getTextureHandle(bool flushPendingGrContextReads) const { return 0; }
|
||||
GrBackendObject SkImage::getTextureHandle(bool) const { return 0; }
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -30,15 +30,14 @@ GrBackendObject SkSurface_Gpu::onGetTextureHandle(TextureHandleAccess access) {
|
||||
GrRenderTarget* rt = fDevice->accessRenderTarget();
|
||||
switch (access) {
|
||||
case kFlushRead_TextureHandleAccess:
|
||||
rt->prepareForExternalRead(); // todo: rename to prepareForExternalAccess()
|
||||
break;
|
||||
case kFlushWrite_TextureHandleAccess:
|
||||
case kDiscardWrite_TextureHandleAccess:
|
||||
// for now we don't special-case on Discard, but we may in the future.
|
||||
this->notifyContentWillChange(kRetain_ContentChangeMode);
|
||||
rt->flushWrites();
|
||||
break;
|
||||
}
|
||||
rt->prepareForExternalIO();
|
||||
return rt->asTexture()->getTextureHandle();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user