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" |
tfarina@chromium.org | 4ee16bf | 2014-01-10 22:08:27 +0000 | [diff] [blame] | 14 | #include "SkTypes.h" |
| 15 | #include "Test.h" |
bsalomon@google.com | 686bcb8 | 2013-04-09 15:04:12 +0000 | [diff] [blame] | 16 | |
tfarina@chromium.org | 4ee16bf | 2014-01-10 22:08:27 +0000 | [diff] [blame] | 17 | DEF_GPUTEST(GrSurfaceTest, reporter, factory) { |
bsalomon@google.com | 686bcb8 | 2013-04-09 15:04:12 +0000 | [diff] [blame] | 18 | GrContext* context = factory->get(GrContextFactory::kNull_GLContextType); |
| 19 | if (NULL != context) { |
| 20 | GrTextureDesc desc; |
| 21 | desc.fConfig = kSkia8888_GrPixelConfig; |
| 22 | desc.fFlags = kRenderTarget_GrTextureFlagBit; |
| 23 | desc.fWidth = 256; |
| 24 | desc.fHeight = 256; |
| 25 | desc.fSampleCnt = 0; |
| 26 | GrSurface* texRT1 = context->createUncachedTexture(desc, NULL, 0); |
| 27 | GrSurface* texRT2 = context->createUncachedTexture(desc, NULL, 0); |
| 28 | desc.fFlags = kNone_GrTextureFlags; |
| 29 | GrSurface* tex1 = context->createUncachedTexture(desc, NULL, 0); |
| 30 | |
| 31 | REPORTER_ASSERT(reporter, texRT1->isSameAs(texRT1)); |
| 32 | REPORTER_ASSERT(reporter, texRT1->isSameAs(texRT1->asRenderTarget())); |
| 33 | REPORTER_ASSERT(reporter, texRT1->asRenderTarget()->isSameAs(texRT1)); |
| 34 | REPORTER_ASSERT(reporter, !texRT2->isSameAs(texRT1)); |
| 35 | REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->isSameAs(texRT1)); |
| 36 | REPORTER_ASSERT(reporter, !texRT2->isSameAs(texRT1->asRenderTarget())); |
| 37 | REPORTER_ASSERT(reporter, !texRT2->isSameAs(tex1)); |
| 38 | REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->isSameAs(tex1)); |
| 39 | |
| 40 | GrBackendTextureDesc backendDesc; |
| 41 | backendDesc.fConfig = kSkia8888_GrPixelConfig; |
| 42 | backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag; |
| 43 | backendDesc.fWidth = 256; |
| 44 | backendDesc.fHeight = 256; |
| 45 | backendDesc.fSampleCnt = 0; |
| 46 | backendDesc.fTextureHandle = 5; |
| 47 | GrSurface* externalTexRT = context->wrapBackendTexture(backendDesc); |
| 48 | REPORTER_ASSERT(reporter, externalTexRT->isSameAs(externalTexRT)); |
| 49 | REPORTER_ASSERT(reporter, externalTexRT->isSameAs(externalTexRT->asRenderTarget())); |
| 50 | REPORTER_ASSERT(reporter, externalTexRT->asRenderTarget()->isSameAs(externalTexRT)); |
| 51 | REPORTER_ASSERT(reporter, !externalTexRT->isSameAs(texRT1)); |
| 52 | REPORTER_ASSERT(reporter, !externalTexRT->asRenderTarget()->isSameAs(texRT1)); |
| 53 | |
| 54 | texRT1->unref(); |
| 55 | texRT2->unref(); |
| 56 | tex1->unref(); |
| 57 | externalTexRT->unref(); |
| 58 | } |
| 59 | } |
| 60 | |
bsalomon@google.com | 686bcb8 | 2013-04-09 15:04:12 +0000 | [diff] [blame] | 61 | #endif |