OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 /* | 8 /* |
9 * This is a straightforward test of floating point textures, which are | 9 * This is a straightforward test of floating point textures, which are |
10 * supported on some platforms. As of right now, this test only supports | 10 * supported on some platforms. As of right now, this test only supports |
11 * 32 bit floating point textures, and indeed floating point test values | 11 * 32 bit floating point textures, and indeed floating point test values |
12 * have been selected to require 32 bits of precision and full IEEE conformance | 12 * have been selected to require 32 bits of precision and full IEEE conformance |
13 */ | 13 */ |
14 #if SK_SUPPORT_GPU | 14 |
15 #include <float.h> | 15 #include <float.h> |
16 #include "Test.h" | 16 #include "Test.h" |
| 17 #if SK_SUPPORT_GPU |
17 #include "GrContext.h" | 18 #include "GrContext.h" |
18 #include "GrTexture.h" | 19 #include "GrTexture.h" |
19 #include "GrContextFactory.h" | 20 #include "GrContextFactory.h" |
20 | 21 |
21 #include "SkGpuDevice.h" | 22 #include "SkGpuDevice.h" |
22 #include "SkHalf.h" | 23 #include "SkHalf.h" |
23 | 24 |
24 static const int DEV_W = 100, DEV_H = 100; | 25 static const int DEV_W = 100, DEV_H = 100; |
25 static const int FP_CONTROL_ARRAY_SIZE = DEV_W * DEV_H * 4/*RGBA*/; | 26 static const int FP_CONTROL_ARRAY_SIZE = DEV_W * DEV_H * 4/*RGBA*/; |
26 static const float kMaxIntegerRepresentableInSPFloatingPoint = 16777216; // 2 ^
24 | 27 static const float kMaxIntegerRepresentableInSPFloatingPoint = 16777216; // 2 ^
24 |
(...skipping 25 matching lines...) Expand all Loading... |
52 GrContextFactory::GLContextType type = | 53 GrContextFactory::GLContextType type = |
53 static_cast<GrContextFactory::GLContextType>(glCtxType); | 54 static_cast<GrContextFactory::GLContextType>(glCtxType); |
54 if (!GrContextFactory::IsRenderingGLContext(type)) { | 55 if (!GrContextFactory::IsRenderingGLContext(type)) { |
55 continue; | 56 continue; |
56 } | 57 } |
57 GrContext* context = factory->get(type); | 58 GrContext* context = factory->get(type); |
58 if (NULL == context){ | 59 if (NULL == context){ |
59 continue; | 60 continue; |
60 } | 61 } |
61 | 62 |
62 SkAutoTUnref<GrTexture> fpTexture(context->createTexture(desc, false
, | 63 SkAutoTUnref<GrTexture> fpTexture(context->textureProvider()->create
Texture( |
63 controlPixe
lData.begin(), 0)); | 64 desc, false, controlPixelData.begin(), 0)); |
64 // Floating point textures are NOT supported everywhere | 65 // Floating point textures are NOT supported everywhere |
65 if (NULL == fpTexture) { | 66 if (NULL == fpTexture) { |
66 continue; | 67 continue; |
67 } | 68 } |
68 fpTexture->readPixels(0, 0, DEV_W, DEV_H, desc.fConfig, readBuffer.b
egin(), 0); | 69 fpTexture->readPixels(0, 0, DEV_W, DEV_H, desc.fConfig, readBuffer.b
egin(), 0); |
69 REPORTER_ASSERT(reporter, | 70 REPORTER_ASSERT(reporter, |
70 0 == memcmp(readBuffer.begin(), controlPixelData.begin(), re
adBuffer.bytes())); | 71 0 == memcmp(readBuffer.begin(), controlPixelData.begin(), re
adBuffer.bytes())); |
71 } | 72 } |
72 } | 73 } |
73 } | 74 } |
(...skipping 25 matching lines...) Expand all Loading... |
99 GrContextFactory::GLContextType type = | 100 GrContextFactory::GLContextType type = |
100 static_cast<GrContextFactory::GLContextType>(glCtxType); | 101 static_cast<GrContextFactory::GLContextType>(glCtxType); |
101 if (!GrContextFactory::IsRenderingGLContext(type)) { | 102 if (!GrContextFactory::IsRenderingGLContext(type)) { |
102 continue; | 103 continue; |
103 } | 104 } |
104 GrContext* context = factory->get(type); | 105 GrContext* context = factory->get(type); |
105 if (NULL == context){ | 106 if (NULL == context){ |
106 continue; | 107 continue; |
107 } | 108 } |
108 | 109 |
109 SkAutoTUnref<GrTexture> fpTexture(context->createTexture(desc, false
, | 110 SkAutoTUnref<GrTexture> fpTexture(context->textureProvider()->create
Texture( |
110 controlPixe
lData.begin(), 0)); | 111 desc, false, controlPixelData.begin(), 0)); |
111 // 16-bit floating point textures are NOT supported everywhere | 112 // 16-bit floating point textures are NOT supported everywhere |
112 if (NULL == fpTexture) { | 113 if (NULL == fpTexture) { |
113 continue; | 114 continue; |
114 } | 115 } |
115 fpTexture->readPixels(0, 0, DEV_W, DEV_H, desc.fConfig, readBuffer.b
egin(), 0); | 116 fpTexture->readPixels(0, 0, DEV_W, DEV_H, desc.fConfig, readBuffer.b
egin(), 0); |
116 REPORTER_ASSERT(reporter, | 117 REPORTER_ASSERT(reporter, |
117 0 == memcmp(readBuffer.begin(), controlPixelData.begin(), re
adBuffer.bytes())); | 118 0 == memcmp(readBuffer.begin(), controlPixelData.begin(), re
adBuffer.bytes())); |
118 } | 119 } |
119 } | 120 } |
120 } | 121 } |
121 | 122 |
122 #endif | 123 #endif |
OLD | NEW |