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 #include "SkTypes.h" | 8 #include "SkTypes.h" |
9 | 9 |
10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
11 | 11 |
12 #include "GrContext.h" | 12 #include "GrContext.h" |
13 #include "GrGpu.h" | 13 #include "GrGpu.h" |
14 #include "GrRenderTarget.h" | 14 #include "GrRenderTarget.h" |
15 #include "GrTexture.h" | 15 #include "GrTexture.h" |
16 #include "GrSurfacePriv.h" | 16 #include "GrSurfacePriv.h" |
17 #include "Test.h" | 17 #include "Test.h" |
18 | 18 |
19 // Tests that GrSurface::asTexture(), GrSurface::asRenderTarget(), and static up
casting of texture | 19 // Tests that GrSurface::asTexture(), GrSurface::asRenderTarget(), and static up
casting of texture |
20 // and render targets to GrSurface all work as expected. | 20 // and render targets to GrSurface all work as expected. |
21 DEF_GPUTEST_FOR_NULL_CONTEXT(GrSurface, reporter, context) { | 21 DEF_GPUTEST_FOR_NULL_CONTEXT(GrSurface, reporter, context) { |
22 GrSurfaceDesc desc; | 22 GrSurfaceDesc desc; |
23 desc.fConfig = kSkia8888_GrPixelConfig; | 23 desc.fConfig = kSkia8888_GrPixelConfig; |
24 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 24 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
25 desc.fWidth = 256; | 25 desc.fWidth = 256; |
26 desc.fHeight = 256; | 26 desc.fHeight = 256; |
27 desc.fSampleCnt = 0; | 27 desc.fSampleCnt = 0; |
28 GrSurface* texRT1 = context->textureProvider()->createTexture(desc, false, n
ullptr, 0); | 28 GrSurface* texRT1 = context->textureProvider()->createTexture( |
| 29 desc, SkBudgeted::kNo, nullptr, 0); |
29 | 30 |
30 REPORTER_ASSERT(reporter, texRT1 == texRT1->asRenderTarget()); | 31 REPORTER_ASSERT(reporter, texRT1 == texRT1->asRenderTarget()); |
31 REPORTER_ASSERT(reporter, texRT1 == texRT1->asTexture()); | 32 REPORTER_ASSERT(reporter, texRT1 == texRT1->asTexture()); |
32 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT1->asRenderTarget())
== | 33 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT1->asRenderTarget())
== |
33 texRT1->asTexture()); | 34 texRT1->asTexture()); |
34 REPORTER_ASSERT(reporter, texRT1->asRenderTarget() == | 35 REPORTER_ASSERT(reporter, texRT1->asRenderTarget() == |
35 static_cast<GrSurface*>(texRT1->asTexture())); | 36 static_cast<GrSurface*>(texRT1->asTexture())); |
36 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT1->asRenderTarget())
== | 37 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT1->asRenderTarget())
== |
37 static_cast<GrSurface*>(texRT1->asTexture())); | 38 static_cast<GrSurface*>(texRT1->asTexture())); |
38 | 39 |
39 desc.fFlags = kNone_GrSurfaceFlags; | 40 desc.fFlags = kNone_GrSurfaceFlags; |
40 GrSurface* tex1 = context->textureProvider()->createTexture(desc, false, nul
lptr, 0); | 41 GrSurface* tex1 = context->textureProvider()->createTexture(desc, SkBudgeted
::kNo, nullptr, 0); |
41 REPORTER_ASSERT(reporter, nullptr == tex1->asRenderTarget()); | 42 REPORTER_ASSERT(reporter, nullptr == tex1->asRenderTarget()); |
42 REPORTER_ASSERT(reporter, tex1 == tex1->asTexture()); | 43 REPORTER_ASSERT(reporter, tex1 == tex1->asTexture()); |
43 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1) == tex1->asTexture()
); | 44 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1) == tex1->asTexture()
); |
44 | 45 |
45 GrBackendObject backendTex = context->getGpu()->createTestingOnlyBackendText
ure( | 46 GrBackendObject backendTex = context->getGpu()->createTestingOnlyBackendText
ure( |
46 nullptr, 256, 256, kSkia8888_GrPixelConfig); | 47 nullptr, 256, 256, kSkia8888_GrPixelConfig); |
47 | 48 |
48 GrBackendTextureDesc backendDesc; | 49 GrBackendTextureDesc backendDesc; |
49 backendDesc.fConfig = kSkia8888_GrPixelConfig; | 50 backendDesc.fConfig = kSkia8888_GrPixelConfig; |
50 backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag; | 51 backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag; |
(...skipping 12 matching lines...) Expand all Loading... |
63 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget())
== | 64 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget())
== |
64 static_cast<GrSurface*>(texRT2->asTexture())); | 65 static_cast<GrSurface*>(texRT2->asTexture())); |
65 | 66 |
66 texRT1->unref(); | 67 texRT1->unref(); |
67 texRT2->unref(); | 68 texRT2->unref(); |
68 tex1->unref(); | 69 tex1->unref(); |
69 context->getGpu()->deleteTestingOnlyBackendTexture(backendTex); | 70 context->getGpu()->deleteTestingOnlyBackendTexture(backendTex); |
70 } | 71 } |
71 | 72 |
72 #endif | 73 #endif |
OLD | NEW |