From c49e8682ab0614e1b6816dadd00f65d770ab6999 Mon Sep 17 00:00:00 2001 From: bsalomon Date: Tue, 30 Jun 2015 11:37:35 -0700 Subject: [PATCH] Rename flushForExternalRead->flushForExternalIO and always call in SkSurface::getTextureHandle Review URL: https://codereview.chromium.org/1216243003 --- include/core/SkImage.h | 6 +++--- include/gpu/GrContext.h | 7 +++---- include/gpu/GrSurface.h | 4 ++-- src/gpu/GrContext.cpp | 2 +- src/gpu/GrSurface.cpp | 4 ++-- src/gpu/SkGpuDevice.cpp | 2 +- src/image/SkImage.cpp | 8 ++++---- src/image/SkSurface_Gpu.cpp | 3 +-- 8 files changed, 17 insertions(+), 19 deletions(-) diff --git a/include/core/SkImage.h b/include/core/SkImage.h index e0ea7217d0..28b1803629 100644 --- a/include/core/SkImage.h +++ b/include/core/SkImage.h @@ -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), diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 63f577fb15..1f1ebc2db2 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -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. diff --git a/include/gpu/GrSurface.h b/include/gpu/GrSurface.h index 543ccd134f..bdf48be0f9 100644 --- a/include/gpu/GrSurface.h +++ b/include/gpu/GrSurface.h @@ -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(); diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index ed588b6b51..5cb89345e4 100755 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -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); diff --git a/src/gpu/GrSurface.cpp b/src/gpu/GrSurface.cpp index b304ccb1dd..9685c56275 100644 --- a/src/gpu/GrSurface.cpp +++ b/src/gpu/GrSurface.cpp @@ -84,9 +84,9 @@ void GrSurface::flushWrites() { } } -void GrSurface::prepareForExternalRead() { +void GrSurface::prepareForExternalIO() { if (!this->wasDestroyed()) { - this->getContext()->prepareSurfaceForExternalRead(this); + this->getContext()->prepareSurfaceForExternalIO(this); } } diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 17d837be42..028ab561f4 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1737,7 +1737,7 @@ bool SkGpuDevice::onShouldDisableLCD(const SkPaint& paint) const { void SkGpuDevice::flush() { DO_DEFERRED_CLEAR(); - fRenderTarget->prepareForExternalRead(); + fRenderTarget->prepareForExternalIO(); } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index 5e7d1b9150..1d61438707 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -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 diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index 71bed3a9b9..d243b657b4 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -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(); }