Remove GrSurface::isSameAs

Review URL: https://codereview.chromium.org/753783003
This commit is contained in:
bsalomon 2014-11-25 07:41:12 -08:00 committed by Commit bot
parent 821e352238
commit a2c2323005
6 changed files with 29 additions and 42 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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();
}
}

View File

@ -23,13 +23,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

View File

@ -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)) {

View File

@ -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();
}
}