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

Side by Side Diff: tests/GrSurfaceTest.cpp

Issue 753783003: Remove GrSurface::isSameAs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more Created 6 years 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
« no previous file with comments | « src/gpu/gl/GrGpuGL.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
9
8 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
9 11
10 #include "GrContext.h" 12 #include "GrContext.h"
11 #include "GrContextFactory.h" 13 #include "GrContextFactory.h"
12 #include "GrRenderTarget.h" 14 #include "GrRenderTarget.h"
13 #include "GrTexture.h" 15 #include "GrTexture.h"
14 #include "GrSurfacePriv.h" 16 #include "GrSurfacePriv.h"
15 #include "SkTypes.h"
16 #include "Test.h" 17 #include "Test.h"
17 18
19 // Tests that GrSurface::asTexture(), GrSurface::asRenderTarget(), and static up casting of texture
20 // and render targets to GrSurface all work as expected.
18 DEF_GPUTEST(GrSurface, reporter, factory) { 21 DEF_GPUTEST(GrSurface, reporter, factory) {
19 GrContext* context = factory->get(GrContextFactory::kNull_GLContextType); 22 GrContext* context = factory->get(GrContextFactory::kNull_GLContextType);
20 if (context) { 23 if (context) {
21 GrSurfaceDesc desc; 24 GrSurfaceDesc desc;
22 desc.fConfig = kSkia8888_GrPixelConfig; 25 desc.fConfig = kSkia8888_GrPixelConfig;
23 desc.fFlags = kRenderTarget_GrSurfaceFlag; 26 desc.fFlags = kRenderTarget_GrSurfaceFlag;
24 desc.fWidth = 256; 27 desc.fWidth = 256;
25 desc.fHeight = 256; 28 desc.fHeight = 256;
26 desc.fSampleCnt = 0; 29 desc.fSampleCnt = 0;
27 GrSurface* texRT1 = context->createUncachedTexture(desc, NULL, 0); 30 GrSurface* texRT1 = context->createUncachedTexture(desc, NULL, 0);
28 GrSurface* texRT2 = context->createUncachedTexture(desc, NULL, 0); 31
32 REPORTER_ASSERT(reporter, texRT1 == texRT1->asRenderTarget());
33 REPORTER_ASSERT(reporter, texRT1 == texRT1->asTexture());
34 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT1->asRenderTarget ()) ==
35 texRT1->asTexture());
36 REPORTER_ASSERT(reporter, texRT1->asRenderTarget() ==
37 static_cast<GrSurface*>(texRT1->asTexture()));
38 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT1->asRenderTarget ()) ==
39 static_cast<GrSurface*>(texRT1->asTexture()));
40
29 desc.fFlags = kNone_GrSurfaceFlags; 41 desc.fFlags = kNone_GrSurfaceFlags;
30 GrSurface* tex1 = context->createUncachedTexture(desc, NULL, 0); 42 GrSurface* tex1 = context->createUncachedTexture(desc, NULL, 0);
31 43 REPORTER_ASSERT(reporter, NULL == tex1->asRenderTarget());
32 REPORTER_ASSERT(reporter, texRT1->surfacePriv().isSameAs(texRT1)); 44 REPORTER_ASSERT(reporter, tex1 == tex1->asTexture());
33 REPORTER_ASSERT(reporter, texRT1->surfacePriv().isSameAs(texRT1->asRende rTarget())); 45 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1) == tex1->asTextu re());
34 REPORTER_ASSERT(reporter, texRT1->asRenderTarget()->surfacePriv().isSame As(texRT1));
35 REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(texRT1));
36 REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->surfacePriv().isSam eAs(texRT1));
37 REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(texRT1->asRend erTarget()));
38 REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(tex1));
39 REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->surfacePriv().isSam eAs(tex1));
40 46
41 GrBackendTextureDesc backendDesc; 47 GrBackendTextureDesc backendDesc;
42 backendDesc.fConfig = kSkia8888_GrPixelConfig; 48 backendDesc.fConfig = kSkia8888_GrPixelConfig;
43 backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag; 49 backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag;
44 backendDesc.fWidth = 256; 50 backendDesc.fWidth = 256;
45 backendDesc.fHeight = 256; 51 backendDesc.fHeight = 256;
46 backendDesc.fSampleCnt = 0; 52 backendDesc.fSampleCnt = 0;
47 backendDesc.fTextureHandle = 5; 53 backendDesc.fTextureHandle = 5;
48 GrSurface* externalTexRT = context->wrapBackendTexture(backendDesc); 54 GrSurface* texRT2 = context->wrapBackendTexture(backendDesc);
49 REPORTER_ASSERT(reporter, externalTexRT->surfacePriv().isSameAs(external TexRT)); 55 REPORTER_ASSERT(reporter, texRT2 == texRT2->asRenderTarget());
50 REPORTER_ASSERT(reporter, 56 REPORTER_ASSERT(reporter, texRT2 == texRT2->asTexture());
51 externalTexRT->surfacePriv().isSameAs(externalTexRT->asR enderTarget())); 57 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget ()) ==
52 REPORTER_ASSERT(reporter, 58 texRT2->asTexture());
53 externalTexRT->asRenderTarget()->surfacePriv().isSameAs( externalTexRT)); 59 REPORTER_ASSERT(reporter, texRT2->asRenderTarget() ==
54 REPORTER_ASSERT(reporter, !externalTexRT->surfacePriv().isSameAs(texRT1) ); 60 static_cast<GrSurface*>(texRT2->asTexture()));
55 REPORTER_ASSERT(reporter, !externalTexRT->asRenderTarget()->surfacePriv( ).isSameAs(texRT1)); 61 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget ()) ==
robertphillips 2014/11/25 15:34:59 extra space ?
62 static_cast<GrSurface*>(texRT2->asTexture())) ;
56 63
57 texRT1->unref(); 64 texRT1->unref();
58 texRT2->unref(); 65 texRT2->unref();
59 tex1->unref(); 66 tex1->unref();
60 externalTexRT->unref();
61 } 67 }
62 } 68 }
63 69
64 #endif 70 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGpuGL.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698