diff options
author | 2014-11-25 07:41:12 -0800 | |
---|---|---|
committer | 2014-11-25 07:41:12 -0800 | |
commit | a2c2323005fb22e564426f4ed86adaa6d213aba1 (patch) | |
tree | 03872273e7a1eb533a311746a6dc43c928295009 | |
parent | 821e3522380ee8995da15f9c9bec9e8b21f4a809 (diff) |
Remove GrSurface::isSameAs
Review URL: https://codereview.chromium.org/753783003
-rw-r--r-- | include/gpu/GrSurface.h | 1 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrSurface.cpp | 11 | ||||
-rw-r--r-- | src/gpu/GrSurfacePriv.h | 7 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL.cpp | 4 | ||||
-rw-r--r-- | tests/GrSurfaceTest.cpp | 46 |
6 files changed, 29 insertions, 42 deletions
diff --git a/include/gpu/GrSurface.h b/include/gpu/GrSurface.h index 0de626d16e..8f772b3d5a 100644 --- a/include/gpu/GrSurface.h +++ b/include/gpu/GrSurface.h @@ -134,7 +134,6 @@ protected: bool hasPendingRead() const; bool hasPendingWrite() const; bool hasPendingIO() const; - bool isSameAs(const GrSurface* other) const; // Provides access to methods that should be public within Skia code. friend class GrSurfacePriv; diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index 2f395e666d..688a7445a1 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -971,7 +971,7 @@ bool GrDrawTarget::canCopySurface(const GrSurface* dst, SkASSERT(clippedDstPoint.fX + clippedSrcRect.width() <= dst->width() && clippedDstPoint.fY + clippedSrcRect.height() <= dst->height()); - return !dst->surfacePriv().isSameAs(src) && dst->asRenderTarget() && src->asTexture(); + return (dst != src) && dst->asRenderTarget() && src->asTexture(); } void GrDrawTarget::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) { diff --git a/src/gpu/GrSurface.cpp b/src/gpu/GrSurface.cpp index 1779f2441b..1ca305b5a1 100644 --- a/src/gpu/GrSurface.cpp +++ b/src/gpu/GrSurface.cpp @@ -123,14 +123,3 @@ bool GrSurface::hasPendingIO() const { } return false; } - -bool GrSurface::isSameAs(const GrSurface* other) const { - const GrRenderTarget* thisRT = this->asRenderTarget(); - if (thisRT) { - return thisRT == other->asRenderTarget(); - } else { - const GrTexture* thisTex = this->asTexture(); - SkASSERT(thisTex); // We must be one or the other - return thisTex == other->asTexture(); - } -} diff --git a/src/gpu/GrSurfacePriv.h b/src/gpu/GrSurfacePriv.h index 3203671fad..3c1e9c1e95 100644 --- a/src/gpu/GrSurfacePriv.h +++ b/src/gpu/GrSurfacePriv.h @@ -24,13 +24,6 @@ public: SkImageInfo info() const { return fSurface->info(); } /** - * Checks whether this GrSurface refers to the same GPU object as other. This - * catches the case where a GrTexture and GrRenderTarget refer to the same - * GPU memory. - */ - bool isSameAs(const GrSurface* other) const { return fSurface->isSameAs(other); } - - /** * Write the contents of the surface to a PNG. Returns true if successful. * @param filename Full path to desired file */ diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index bb40839f48..8bf35c1690 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -2429,7 +2429,7 @@ bool GrGpuGL::copySurface(GrSurface* dst, SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, srcRect.width(), srcRect.height()); bool selfOverlap = false; - if (dst->surfacePriv().isSameAs(src)) { + if (dst == src) { selfOverlap = SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect); } @@ -2503,7 +2503,7 @@ bool GrGpuGL::canCopySurface(const GrSurface* dst, return true; } if (can_blit_framebuffer(dst, src, this, &wouldNeedTempFBO) && !wouldNeedTempFBO) { - if (dst->surfacePriv().isSameAs(src)) { + if (dst == src) { SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, srcRect.width(), srcRect.height()); if(!SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect)) { diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index 0b3948f118..1e21df1972 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -5,6 +5,8 @@ * found in the LICENSE file. */ +#include "SkTypes.h" + #if SK_SUPPORT_GPU #include "GrContext.h" @@ -12,9 +14,10 @@ #include "GrRenderTarget.h" #include "GrTexture.h" #include "GrSurfacePriv.h" -#include "SkTypes.h" #include "Test.h" +// Tests that GrSurface::asTexture(), GrSurface::asRenderTarget(), and static upcasting of texture +// and render targets to GrSurface all work as expected. DEF_GPUTEST(GrSurface, reporter, factory) { GrContext* context = factory->get(GrContextFactory::kNull_GLContextType); if (context) { @@ -25,18 +28,21 @@ DEF_GPUTEST(GrSurface, reporter, factory) { desc.fHeight = 256; desc.fSampleCnt = 0; GrSurface* texRT1 = context->createUncachedTexture(desc, NULL, 0); - GrSurface* texRT2 = context->createUncachedTexture(desc, NULL, 0); + + REPORTER_ASSERT(reporter, texRT1 == texRT1->asRenderTarget()); + REPORTER_ASSERT(reporter, texRT1 == texRT1->asTexture()); + REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT1->asRenderTarget()) == + texRT1->asTexture()); + REPORTER_ASSERT(reporter, texRT1->asRenderTarget() == + static_cast<GrSurface*>(texRT1->asTexture())); + REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT1->asRenderTarget()) == + static_cast<GrSurface*>(texRT1->asTexture())); + desc.fFlags = kNone_GrSurfaceFlags; GrSurface* tex1 = context->createUncachedTexture(desc, NULL, 0); - - REPORTER_ASSERT(reporter, texRT1->surfacePriv().isSameAs(texRT1)); - REPORTER_ASSERT(reporter, texRT1->surfacePriv().isSameAs(texRT1->asRenderTarget())); - REPORTER_ASSERT(reporter, texRT1->asRenderTarget()->surfacePriv().isSameAs(texRT1)); - REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(texRT1)); - REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->surfacePriv().isSameAs(texRT1)); - REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(texRT1->asRenderTarget())); - REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(tex1)); - REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->surfacePriv().isSameAs(tex1)); + REPORTER_ASSERT(reporter, NULL == tex1->asRenderTarget()); + REPORTER_ASSERT(reporter, tex1 == tex1->asTexture()); + REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1) == tex1->asTexture()); GrBackendTextureDesc backendDesc; backendDesc.fConfig = kSkia8888_GrPixelConfig; @@ -45,19 +51,19 @@ DEF_GPUTEST(GrSurface, reporter, factory) { backendDesc.fHeight = 256; backendDesc.fSampleCnt = 0; backendDesc.fTextureHandle = 5; - GrSurface* externalTexRT = context->wrapBackendTexture(backendDesc); - REPORTER_ASSERT(reporter, externalTexRT->surfacePriv().isSameAs(externalTexRT)); - REPORTER_ASSERT(reporter, - externalTexRT->surfacePriv().isSameAs(externalTexRT->asRenderTarget())); - REPORTER_ASSERT(reporter, - externalTexRT->asRenderTarget()->surfacePriv().isSameAs(externalTexRT)); - REPORTER_ASSERT(reporter, !externalTexRT->surfacePriv().isSameAs(texRT1)); - REPORTER_ASSERT(reporter, !externalTexRT->asRenderTarget()->surfacePriv().isSameAs(texRT1)); + GrSurface* texRT2 = context->wrapBackendTexture(backendDesc); + REPORTER_ASSERT(reporter, texRT2 == texRT2->asRenderTarget()); + REPORTER_ASSERT(reporter, texRT2 == texRT2->asTexture()); + REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget()) == + texRT2->asTexture()); + REPORTER_ASSERT(reporter, texRT2->asRenderTarget() == + static_cast<GrSurface*>(texRT2->asTexture())); + REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget()) == + static_cast<GrSurface*>(texRT2->asTexture())); texRT1->unref(); texRT2->unref(); tex1->unref(); - externalTexRT->unref(); } } |