aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/GrSurfaceTest.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-11-25 07:41:12 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-25 07:41:12 -0800
commita2c2323005fb22e564426f4ed86adaa6d213aba1 (patch)
tree03872273e7a1eb533a311746a6dc43c928295009 /tests/GrSurfaceTest.cpp
parent821e3522380ee8995da15f9c9bec9e8b21f4a809 (diff)
Remove GrSurface::isSameAs
Diffstat (limited to 'tests/GrSurfaceTest.cpp')
-rw-r--r--tests/GrSurfaceTest.cpp46
1 files changed, 26 insertions, 20 deletions
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();
}
}