Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: tests/GrSurfaceTest.cpp

Issue 1429863009: Use a struct for client GL texture handles (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "GrContextFactory.h" 13 #include "GrContextFactory.h"
14 #include "GrGpu.h"
14 #include "GrRenderTarget.h" 15 #include "GrRenderTarget.h"
15 #include "GrTexture.h" 16 #include "GrTexture.h"
16 #include "GrSurfacePriv.h" 17 #include "GrSurfacePriv.h"
17 #include "Test.h" 18 #include "Test.h"
18 19
19 // Tests that GrSurface::asTexture(), GrSurface::asRenderTarget(), and static up casting of texture 20 // Tests that GrSurface::asTexture(), GrSurface::asRenderTarget(), and static up casting of texture
20 // and render targets to GrSurface all work as expected. 21 // and render targets to GrSurface all work as expected.
21 DEF_GPUTEST(GrSurface, reporter, factory) { 22 DEF_GPUTEST(GrSurface, reporter, factory) {
22 GrContext* context = factory->get(GrContextFactory::kNull_GLContextType); 23 GrContext* context = factory->get(GrContextFactory::kNull_GLContextType);
23 if (context) { 24 if (context) {
(...skipping 13 matching lines...) Expand all
37 static_cast<GrSurface*>(texRT1->asTexture())); 38 static_cast<GrSurface*>(texRT1->asTexture()));
38 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT1->asRenderTarget ()) == 39 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT1->asRenderTarget ()) ==
39 static_cast<GrSurface*>(texRT1->asTexture())); 40 static_cast<GrSurface*>(texRT1->asTexture()));
40 41
41 desc.fFlags = kNone_GrSurfaceFlags; 42 desc.fFlags = kNone_GrSurfaceFlags;
42 GrSurface* tex1 = context->textureProvider()->createTexture(desc, false, nullptr, 0); 43 GrSurface* tex1 = context->textureProvider()->createTexture(desc, false, nullptr, 0);
43 REPORTER_ASSERT(reporter, nullptr == tex1->asRenderTarget()); 44 REPORTER_ASSERT(reporter, nullptr == tex1->asRenderTarget());
44 REPORTER_ASSERT(reporter, tex1 == tex1->asTexture()); 45 REPORTER_ASSERT(reporter, tex1 == tex1->asTexture());
45 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1) == tex1->asTextu re()); 46 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1) == tex1->asTextu re());
46 47
48 GrBackendObject backendTex = context->getGpu()->createTestingOnlyBackend Texture(
49 nullptr, 256, 256, kSkia8888_GrPixelConfig);
50
47 GrBackendTextureDesc backendDesc; 51 GrBackendTextureDesc backendDesc;
48 backendDesc.fConfig = kSkia8888_GrPixelConfig; 52 backendDesc.fConfig = kSkia8888_GrPixelConfig;
49 backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag; 53 backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag;
50 backendDesc.fWidth = 256; 54 backendDesc.fWidth = 256;
51 backendDesc.fHeight = 256; 55 backendDesc.fHeight = 256;
52 backendDesc.fSampleCnt = 0; 56 backendDesc.fSampleCnt = 0;
53 backendDesc.fTextureHandle = 5; 57 backendDesc.fTextureHandle = backendTex;
54 GrSurface* texRT2 = context->textureProvider()->wrapBackendTexture( 58 GrSurface* texRT2 = context->textureProvider()->wrapBackendTexture(
55 backendDesc, kBorrow_GrWrapOwnership); 59 backendDesc, kBorrow_GrWrapOwnership);
56 REPORTER_ASSERT(reporter, texRT2 == texRT2->asRenderTarget()); 60 REPORTER_ASSERT(reporter, texRT2 == texRT2->asRenderTarget());
57 REPORTER_ASSERT(reporter, texRT2 == texRT2->asTexture()); 61 REPORTER_ASSERT(reporter, texRT2 == texRT2->asTexture());
58 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget ()) == 62 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget ()) ==
59 texRT2->asTexture()); 63 texRT2->asTexture());
60 REPORTER_ASSERT(reporter, texRT2->asRenderTarget() == 64 REPORTER_ASSERT(reporter, texRT2->asRenderTarget() ==
61 static_cast<GrSurface*>(texRT2->asTexture())); 65 static_cast<GrSurface*>(texRT2->asTexture()));
62 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget ()) == 66 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget ()) ==
63 static_cast<GrSurface*>(texRT2->asTexture())) ; 67 static_cast<GrSurface*>(texRT2->asTexture()));
64 68
65 texRT1->unref(); 69 texRT1->unref();
66 texRT2->unref(); 70 texRT2->unref();
67 tex1->unref(); 71 tex1->unref();
72 context->getGpu()->deleteTestingOnlyBackendTexture(backendTex);
68 } 73 }
69 } 74 }
70 75
71 #endif 76 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698