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" |
14 #include "SkTypes.h" | 15 #include "SkTypes.h" |
15 #include "Test.h" | 16 #include "Test.h" |
16 | 17 |
17 DEF_GPUTEST(GrSurface, reporter, factory) { | 18 DEF_GPUTEST(GrSurface, reporter, factory) { |
18 GrContext* context = factory->get(GrContextFactory::kNull_GLContextType); | 19 GrContext* context = factory->get(GrContextFactory::kNull_GLContextType); |
19 if (context) { | 20 if (context) { |
20 GrTextureDesc desc; | 21 GrTextureDesc desc; |
21 desc.fConfig = kSkia8888_GrPixelConfig; | 22 desc.fConfig = kSkia8888_GrPixelConfig; |
22 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 23 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
23 desc.fWidth = 256; | 24 desc.fWidth = 256; |
24 desc.fHeight = 256; | 25 desc.fHeight = 256; |
25 desc.fSampleCnt = 0; | 26 desc.fSampleCnt = 0; |
26 GrSurface* texRT1 = context->createUncachedTexture(desc, NULL, 0); | 27 GrSurface* texRT1 = context->createUncachedTexture(desc, NULL, 0); |
27 GrSurface* texRT2 = context->createUncachedTexture(desc, NULL, 0); | 28 GrSurface* texRT2 = context->createUncachedTexture(desc, NULL, 0); |
28 desc.fFlags = kNone_GrTextureFlags; | 29 desc.fFlags = kNone_GrTextureFlags; |
29 GrSurface* tex1 = context->createUncachedTexture(desc, NULL, 0); | 30 GrSurface* tex1 = context->createUncachedTexture(desc, NULL, 0); |
30 | 31 |
31 REPORTER_ASSERT(reporter, texRT1->isSameAs(texRT1)); | 32 REPORTER_ASSERT(reporter, texRT1->surfacePriv().isSameAs(texRT1)); |
32 REPORTER_ASSERT(reporter, texRT1->isSameAs(texRT1->asRenderTarget())); | 33 REPORTER_ASSERT(reporter, texRT1->surfacePriv().isSameAs(texRT1->asRende
rTarget())); |
33 REPORTER_ASSERT(reporter, texRT1->asRenderTarget()->isSameAs(texRT1)); | 34 REPORTER_ASSERT(reporter, texRT1->asRenderTarget()->surfacePriv().isSame
As(texRT1)); |
34 REPORTER_ASSERT(reporter, !texRT2->isSameAs(texRT1)); | 35 REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(texRT1)); |
35 REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->isSameAs(texRT1)); | 36 REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->surfacePriv().isSam
eAs(texRT1)); |
36 REPORTER_ASSERT(reporter, !texRT2->isSameAs(texRT1->asRenderTarget())); | 37 REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(texRT1->asRend
erTarget())); |
37 REPORTER_ASSERT(reporter, !texRT2->isSameAs(tex1)); | 38 REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(tex1)); |
38 REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->isSameAs(tex1)); | 39 REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->surfacePriv().isSam
eAs(tex1)); |
39 | 40 |
40 GrBackendTextureDesc backendDesc; | 41 GrBackendTextureDesc backendDesc; |
41 backendDesc.fConfig = kSkia8888_GrPixelConfig; | 42 backendDesc.fConfig = kSkia8888_GrPixelConfig; |
42 backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag; | 43 backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag; |
43 backendDesc.fWidth = 256; | 44 backendDesc.fWidth = 256; |
44 backendDesc.fHeight = 256; | 45 backendDesc.fHeight = 256; |
45 backendDesc.fSampleCnt = 0; | 46 backendDesc.fSampleCnt = 0; |
46 backendDesc.fTextureHandle = 5; | 47 backendDesc.fTextureHandle = 5; |
47 GrSurface* externalTexRT = context->wrapBackendTexture(backendDesc); | 48 GrSurface* externalTexRT = context->wrapBackendTexture(backendDesc); |
48 REPORTER_ASSERT(reporter, externalTexRT->isSameAs(externalTexRT)); | 49 REPORTER_ASSERT(reporter, externalTexRT->surfacePriv().isSameAs(external
TexRT)); |
49 REPORTER_ASSERT(reporter, externalTexRT->isSameAs(externalTexRT->asRende
rTarget())); | 50 REPORTER_ASSERT(reporter, |
50 REPORTER_ASSERT(reporter, externalTexRT->asRenderTarget()->isSameAs(exte
rnalTexRT)); | 51 externalTexRT->surfacePriv().isSameAs(externalTexRT->asR
enderTarget())); |
51 REPORTER_ASSERT(reporter, !externalTexRT->isSameAs(texRT1)); | 52 REPORTER_ASSERT(reporter, |
52 REPORTER_ASSERT(reporter, !externalTexRT->asRenderTarget()->isSameAs(tex
RT1)); | 53 externalTexRT->asRenderTarget()->surfacePriv().isSameAs(
externalTexRT)); |
| 54 REPORTER_ASSERT(reporter, !externalTexRT->surfacePriv().isSameAs(texRT1)
); |
| 55 REPORTER_ASSERT(reporter, !externalTexRT->asRenderTarget()->surfacePriv(
).isSameAs(texRT1)); |
53 | 56 |
54 texRT1->unref(); | 57 texRT1->unref(); |
55 texRT2->unref(); | 58 texRT2->unref(); |
56 tex1->unref(); | 59 tex1->unref(); |
57 externalTexRT->unref(); | 60 externalTexRT->unref(); |
58 } | 61 } |
59 } | 62 } |
60 | 63 |
61 #endif | 64 #endif |
OLD | NEW |