bsalomon@google.com | 686bcb8 | 2013-04-09 15:04:12 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
bsalomon@google.com | 686bcb8 | 2013-04-09 15:04:12 +0000 | [diff] [blame] | 8 | #if SK_SUPPORT_GPU |
| 9 | |
bsalomon@google.com | 686bcb8 | 2013-04-09 15:04:12 +0000 | [diff] [blame] | 10 | #include "GrContext.h" |
| 11 | #include "GrContextFactory.h" |
| 12 | #include "GrRenderTarget.h" |
| 13 | #include "GrTexture.h" |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame^] | 14 | #include "GrSurfacePriv.h" |
tfarina@chromium.org | 4ee16bf | 2014-01-10 22:08:27 +0000 | [diff] [blame] | 15 | #include "SkTypes.h" |
| 16 | #include "Test.h" |
bsalomon@google.com | 686bcb8 | 2013-04-09 15:04:12 +0000 | [diff] [blame] | 17 | |
tfarina | 9ea53f9 | 2014-06-24 06:50:39 -0700 | [diff] [blame] | 18 | DEF_GPUTEST(GrSurface, reporter, factory) { |
bsalomon@google.com | 686bcb8 | 2013-04-09 15:04:12 +0000 | [diff] [blame] | 19 | GrContext* context = factory->get(GrContextFactory::kNull_GLContextType); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 20 | if (context) { |
bsalomon@google.com | 686bcb8 | 2013-04-09 15:04:12 +0000 | [diff] [blame] | 21 | GrTextureDesc desc; |
| 22 | desc.fConfig = kSkia8888_GrPixelConfig; |
| 23 | desc.fFlags = kRenderTarget_GrTextureFlagBit; |
| 24 | desc.fWidth = 256; |
| 25 | desc.fHeight = 256; |
| 26 | desc.fSampleCnt = 0; |
| 27 | GrSurface* texRT1 = context->createUncachedTexture(desc, NULL, 0); |
| 28 | GrSurface* texRT2 = context->createUncachedTexture(desc, NULL, 0); |
| 29 | desc.fFlags = kNone_GrTextureFlags; |
| 30 | GrSurface* tex1 = context->createUncachedTexture(desc, NULL, 0); |
| 31 | |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame^] | 32 | REPORTER_ASSERT(reporter, texRT1->surfacePriv().isSameAs(texRT1)); |
| 33 | REPORTER_ASSERT(reporter, texRT1->surfacePriv().isSameAs(texRT1->asRenderTarget())); |
| 34 | REPORTER_ASSERT(reporter, texRT1->asRenderTarget()->surfacePriv().isSameAs(texRT1)); |
| 35 | REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(texRT1)); |
| 36 | REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->surfacePriv().isSameAs(texRT1)); |
| 37 | REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(texRT1->asRenderTarget())); |
| 38 | REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(tex1)); |
| 39 | REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->surfacePriv().isSameAs(tex1)); |
bsalomon@google.com | 686bcb8 | 2013-04-09 15:04:12 +0000 | [diff] [blame] | 40 | |
| 41 | GrBackendTextureDesc backendDesc; |
| 42 | backendDesc.fConfig = kSkia8888_GrPixelConfig; |
| 43 | backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag; |
| 44 | backendDesc.fWidth = 256; |
| 45 | backendDesc.fHeight = 256; |
| 46 | backendDesc.fSampleCnt = 0; |
| 47 | backendDesc.fTextureHandle = 5; |
| 48 | GrSurface* externalTexRT = context->wrapBackendTexture(backendDesc); |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame^] | 49 | REPORTER_ASSERT(reporter, externalTexRT->surfacePriv().isSameAs(externalTexRT)); |
| 50 | REPORTER_ASSERT(reporter, |
| 51 | externalTexRT->surfacePriv().isSameAs(externalTexRT->asRenderTarget())); |
| 52 | REPORTER_ASSERT(reporter, |
| 53 | externalTexRT->asRenderTarget()->surfacePriv().isSameAs(externalTexRT)); |
| 54 | REPORTER_ASSERT(reporter, !externalTexRT->surfacePriv().isSameAs(texRT1)); |
| 55 | REPORTER_ASSERT(reporter, !externalTexRT->asRenderTarget()->surfacePriv().isSameAs(texRT1)); |
bsalomon@google.com | 686bcb8 | 2013-04-09 15:04:12 +0000 | [diff] [blame] | 56 | |
| 57 | texRT1->unref(); |
| 58 | texRT2->unref(); |
| 59 | tex1->unref(); |
| 60 | externalTexRT->unref(); |
| 61 | } |
| 62 | } |
| 63 | |
bsalomon@google.com | 686bcb8 | 2013-04-09 15:04:12 +0000 | [diff] [blame] | 64 | #endif |