| 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 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 DEF_GPUTEST(HalfFloatTextureTest, reporter, factory) { | 84 DEF_GPUTEST(HalfFloatTextureTest, reporter, factory) { |
| 85 SkHalf controlPixelData[HALF_CONTROL_ARRAY_SIZE]; | 85 SkHalf controlPixelData[HALF_CONTROL_ARRAY_SIZE]; |
| 86 SkHalf readBuffer[HALF_CONTROL_ARRAY_SIZE]; | 86 SkHalf readBuffer[HALF_CONTROL_ARRAY_SIZE]; |
| 87 for (int i = 0; i < HALF_CONTROL_ARRAY_SIZE; i += 4) { | 87 for (int i = 0; i < HALF_CONTROL_ARRAY_SIZE; i += 4) { |
| 88 controlPixelData[i] = SK_HalfMin; | 88 controlPixelData[i] = SK_HalfMin; |
| 89 controlPixelData[i + 1] = SK_HalfMax; | 89 controlPixelData[i + 1] = SK_HalfMax; |
| 90 controlPixelData[i + 2] = SK_HalfEpsilon; | 90 controlPixelData[i + 2] = SK_HalfEpsilon; |
| 91 controlPixelData[i + 3] = 0x6800; // 2^11 | 91 controlPixelData[i + 3] = 0x6800; // 2^11 |
| 92 } | 92 } |
| 93 | 93 |
| 94 for (int origin = 0; origin < 2; ++origin) { | 94 for (int origin = 0; origin < 2; ++origin) { |
| 95 int glCtxTypeCnt = 1; | 95 int glCtxTypeCnt = 1; |
| 96 glCtxTypeCnt = GrContextFactory::kGLContextTypeCnt; | 96 glCtxTypeCnt = GrContextFactory::kGLContextTypeCnt; |
| 97 for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) { | 97 for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) { |
| 98 GrSurfaceDesc desc; | 98 GrSurfaceDesc desc; |
| 99 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 99 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 100 desc.fWidth = DEV_W; | 100 desc.fWidth = DEV_W; |
| 101 desc.fHeight = DEV_H; | 101 desc.fHeight = DEV_H; |
| 102 desc.fConfig = kAlpha_half_GrPixelConfig; | 102 desc.fConfig = kAlpha_half_GrPixelConfig; |
| 103 desc.fOrigin = 0 == origin ? | 103 desc.fOrigin = 0 == origin ? |
| 104 kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin; | 104 kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin; |
| 105 | 105 |
| 106 GrContext* context = NULL; | 106 GrContext* context = NULL; |
| 107 GrContextFactory::GLContextType type = | 107 GrContextFactory::GLContextType type = |
| 108 static_cast<GrContextFactory::GLContextType>(glCtxType); | 108 static_cast<GrContextFactory::GLContextType>(glCtxType); |
| 109 if (!GrContextFactory::IsRenderingGLContext(type)) { | 109 if (!GrContextFactory::IsRenderingGLContext(type)) { |
| 110 continue; | 110 continue; |
| 111 } | 111 } |
| 112 context = factory->get(type); | 112 context = factory->get(type); |
| 113 if (NULL == context){ | 113 if (NULL == context){ |
| 114 continue; | 114 continue; |
| 115 } | 115 } |
| 116 | 116 |
| 117 SkAutoTUnref<GrTexture> fpTexture(context->createUncachedTexture(des
c, | 117 SkAutoTUnref<GrTexture> fpTexture(context->createUncachedTexture(des
c, |
| 118 NUL
L, | 118 NUL
L, |
| 119 0))
; | 119 0))
; |
| 120 | 120 |
| 121 // 16-bit floating point textures are NOT supported everywhere | 121 // 16-bit floating point textures are NOT supported everywhere |
| 122 if (NULL == fpTexture) { | 122 if (NULL == fpTexture) { |
| 123 continue; | 123 continue; |
| 124 } | 124 } |
| 125 | 125 |
| 126 // write square | 126 // write square |
| 127 fpTexture->writePixels(0, 0, DEV_W, DEV_H, desc.fConfig, controlPixe
lData, 0); | 127 fpTexture->writePixels(0, 0, DEV_W, DEV_H, desc.fConfig, controlPixe
lData, 0); |
| 128 fpTexture->readPixels(0, 0, DEV_W, DEV_H, desc.fConfig, readBuffer,
0); | 128 fpTexture->readPixels(0, 0, DEV_W, DEV_H, desc.fConfig, readBuffer,
0); |
| 129 for (int j = 0; j < HALF_CONTROL_ARRAY_SIZE; ++j) { | 129 for (int j = 0; j < HALF_CONTROL_ARRAY_SIZE; ++j) { |
| 130 REPORTER_ASSERT(reporter, readBuffer[j] == controlPixelData[j]); | 130 REPORTER_ASSERT(reporter, readBuffer[j] == controlPixelData[j]); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 | 135 |
| 136 #endif | 136 #endif |
| OLD | NEW |