| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #if SK_SUPPORT_GPU | 8 #if SK_SUPPORT_GPU |
| 9 | 9 |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| 11 #include "GrContextFactory.h" | 11 #include "GrContextFactory.h" |
| 12 #include "GrRenderTarget.h" | 12 #include "GrRenderTarget.h" |
| 13 #include "GrTexture.h" | 13 #include "GrTexture.h" |
| 14 #include "GrSurfacePriv.h" | |
| 15 #include "SkTypes.h" | 14 #include "SkTypes.h" |
| 16 #include "Test.h" | 15 #include "Test.h" |
| 17 | 16 |
| 18 DEF_GPUTEST(GrSurface, reporter, factory) { | 17 DEF_GPUTEST(GrSurface, reporter, factory) { |
| 19 GrContext* context = factory->get(GrContextFactory::kNull_GLContextType); | 18 GrContext* context = factory->get(GrContextFactory::kNull_GLContextType); |
| 20 if (context) { | 19 if (context) { |
| 21 GrTextureDesc desc; | 20 GrTextureDesc desc; |
| 22 desc.fConfig = kSkia8888_GrPixelConfig; | 21 desc.fConfig = kSkia8888_GrPixelConfig; |
| 23 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 22 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
| 24 desc.fWidth = 256; | 23 desc.fWidth = 256; |
| 25 desc.fHeight = 256; | 24 desc.fHeight = 256; |
| 26 desc.fSampleCnt = 0; | 25 desc.fSampleCnt = 0; |
| 27 GrSurface* texRT1 = context->createUncachedTexture(desc, NULL, 0); | 26 GrSurface* texRT1 = context->createUncachedTexture(desc, NULL, 0); |
| 28 GrSurface* texRT2 = context->createUncachedTexture(desc, NULL, 0); | 27 GrSurface* texRT2 = context->createUncachedTexture(desc, NULL, 0); |
| 29 desc.fFlags = kNone_GrTextureFlags; | 28 desc.fFlags = kNone_GrTextureFlags; |
| 30 GrSurface* tex1 = context->createUncachedTexture(desc, NULL, 0); | 29 GrSurface* tex1 = context->createUncachedTexture(desc, NULL, 0); |
| 31 | 30 |
| 32 REPORTER_ASSERT(reporter, texRT1->surfacePriv().isSameAs(texRT1)); | 31 REPORTER_ASSERT(reporter, texRT1->isSameAs(texRT1)); |
| 33 REPORTER_ASSERT(reporter, texRT1->surfacePriv().isSameAs(texRT1->asRende
rTarget())); | 32 REPORTER_ASSERT(reporter, texRT1->isSameAs(texRT1->asRenderTarget())); |
| 34 REPORTER_ASSERT(reporter, texRT1->asRenderTarget()->surfacePriv().isSame
As(texRT1)); | 33 REPORTER_ASSERT(reporter, texRT1->asRenderTarget()->isSameAs(texRT1)); |
| 35 REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(texRT1)); | 34 REPORTER_ASSERT(reporter, !texRT2->isSameAs(texRT1)); |
| 36 REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->surfacePriv().isSam
eAs(texRT1)); | 35 REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->isSameAs(texRT1)); |
| 37 REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(texRT1->asRend
erTarget())); | 36 REPORTER_ASSERT(reporter, !texRT2->isSameAs(texRT1->asRenderTarget())); |
| 38 REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(tex1)); | 37 REPORTER_ASSERT(reporter, !texRT2->isSameAs(tex1)); |
| 39 REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->surfacePriv().isSam
eAs(tex1)); | 38 REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->isSameAs(tex1)); |
| 40 | 39 |
| 41 GrBackendTextureDesc backendDesc; | 40 GrBackendTextureDesc backendDesc; |
| 42 backendDesc.fConfig = kSkia8888_GrPixelConfig; | 41 backendDesc.fConfig = kSkia8888_GrPixelConfig; |
| 43 backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag; | 42 backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag; |
| 44 backendDesc.fWidth = 256; | 43 backendDesc.fWidth = 256; |
| 45 backendDesc.fHeight = 256; | 44 backendDesc.fHeight = 256; |
| 46 backendDesc.fSampleCnt = 0; | 45 backendDesc.fSampleCnt = 0; |
| 47 backendDesc.fTextureHandle = 5; | 46 backendDesc.fTextureHandle = 5; |
| 48 GrSurface* externalTexRT = context->wrapBackendTexture(backendDesc); | 47 GrSurface* externalTexRT = context->wrapBackendTexture(backendDesc); |
| 49 REPORTER_ASSERT(reporter, externalTexRT->surfacePriv().isSameAs(external
TexRT)); | 48 REPORTER_ASSERT(reporter, externalTexRT->isSameAs(externalTexRT)); |
| 50 REPORTER_ASSERT(reporter, | 49 REPORTER_ASSERT(reporter, externalTexRT->isSameAs(externalTexRT->asRende
rTarget())); |
| 51 externalTexRT->surfacePriv().isSameAs(externalTexRT->asR
enderTarget())); | 50 REPORTER_ASSERT(reporter, externalTexRT->asRenderTarget()->isSameAs(exte
rnalTexRT)); |
| 52 REPORTER_ASSERT(reporter, | 51 REPORTER_ASSERT(reporter, !externalTexRT->isSameAs(texRT1)); |
| 53 externalTexRT->asRenderTarget()->surfacePriv().isSameAs(
externalTexRT)); | 52 REPORTER_ASSERT(reporter, !externalTexRT->asRenderTarget()->isSameAs(tex
RT1)); |
| 54 REPORTER_ASSERT(reporter, !externalTexRT->surfacePriv().isSameAs(texRT1)
); | |
| 55 REPORTER_ASSERT(reporter, !externalTexRT->asRenderTarget()->surfacePriv(
).isSameAs(texRT1)); | |
| 56 | 53 |
| 57 texRT1->unref(); | 54 texRT1->unref(); |
| 58 texRT2->unref(); | 55 texRT2->unref(); |
| 59 tex1->unref(); | 56 tex1->unref(); |
| 60 externalTexRT->unref(); | 57 externalTexRT->unref(); |
| 61 } | 58 } |
| 62 } | 59 } |
| 63 | 60 |
| 64 #endif | 61 #endif |
| OLD | NEW |