OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "Test.h" | 8 #include "Test.h" |
9 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
10 #include "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 glCtx0->makeCurrent(); | 166 glCtx0->makeCurrent(); |
167 externalTexture.fTarget = GR_GL_TEXTURE_EXTERNAL; | 167 externalTexture.fTarget = GR_GL_TEXTURE_EXTERNAL; |
168 externalTexture.fID = glCtx0->eglImageToExternalTexture(image); | 168 externalTexture.fID = glCtx0->eglImageToExternalTexture(image); |
169 | 169 |
170 // Wrap this texture ID in a GrTexture | 170 // Wrap this texture ID in a GrTexture |
171 GrBackendTextureDesc externalDesc; | 171 GrBackendTextureDesc externalDesc; |
172 externalDesc.fConfig = kRGBA_8888_GrPixelConfig; | 172 externalDesc.fConfig = kRGBA_8888_GrPixelConfig; |
173 externalDesc.fWidth = kSize; | 173 externalDesc.fWidth = kSize; |
174 externalDesc.fHeight = kSize; | 174 externalDesc.fHeight = kSize; |
175 externalDesc.fTextureHandle = reinterpret_cast<GrBackendObject>(&externalTex
ture); | 175 externalDesc.fTextureHandle = reinterpret_cast<GrBackendObject>(&externalTex
ture); |
176 SkAutoTUnref<GrTexture> externalTextureObj( | 176 sk_sp<GrTexture> externalTextureObj( |
177 context0->textureProvider()->wrapBackendTexture(externalDesc)); | 177 context0->textureProvider()->wrapBackendTexture(externalDesc)); |
178 if (!externalTextureObj) { | 178 if (!externalTextureObj) { |
179 ERRORF(reporter, "Error wrapping external texture in GrTexture."); | 179 ERRORF(reporter, "Error wrapping external texture in GrTexture."); |
180 cleanup(glCtx0, externalTexture.fID, glCtx1, context1, backendTexture1,
image); | 180 cleanup(glCtx0, externalTexture.fID, glCtx1, context1, backendTexture1,
image); |
181 return; | 181 return; |
182 } | 182 } |
183 | 183 |
184 // Should not be able to wrap as a RT | 184 // Should not be able to wrap as a RT |
185 externalDesc.fFlags = kRenderTarget_GrBackendTextureFlag; | 185 externalDesc.fFlags = kRenderTarget_GrBackendTextureFlag; |
186 SkAutoTUnref<GrTexture> externalTextureRTObj( | 186 sk_sp<GrTexture> externalTextureRTObj( |
187 context0->textureProvider()->wrapBackendTexture(externalDesc)); | 187 context0->textureProvider()->wrapBackendTexture(externalDesc)); |
188 if (externalTextureRTObj) { | 188 if (externalTextureRTObj) { |
189 ERRORF(reporter, "Should not be able to wrap an EXTERNAL texture as a RT
."); | 189 ERRORF(reporter, "Should not be able to wrap an EXTERNAL texture as a RT
."); |
190 } | 190 } |
191 externalDesc.fFlags = kNone_GrBackendTextureFlag; | 191 externalDesc.fFlags = kNone_GrBackendTextureFlag; |
192 | 192 |
193 // Should not be able to wrap with a sample count | 193 // Should not be able to wrap with a sample count |
194 externalDesc.fSampleCnt = 4; | 194 externalDesc.fSampleCnt = 4; |
195 SkAutoTUnref<GrTexture> externalTextureMSAAObj( | 195 sk_sp<GrTexture> externalTextureMSAAObj( |
196 context0->textureProvider()->wrapBackendTexture(externalDesc)); | 196 context0->textureProvider()->wrapBackendTexture(externalDesc)); |
197 if (externalTextureMSAAObj) { | 197 if (externalTextureMSAAObj) { |
198 ERRORF(reporter, "Should not be able to wrap an EXTERNAL texture with MS
AA."); | 198 ERRORF(reporter, "Should not be able to wrap an EXTERNAL texture with MS
AA."); |
199 } | 199 } |
200 externalDesc.fSampleCnt = 0; | 200 externalDesc.fSampleCnt = 0; |
201 | 201 |
202 test_read_pixels(reporter, context0, externalTextureObj, pixels.get()); | 202 test_read_pixels(reporter, context0, externalTextureObj.get(), pixels.get())
; |
203 | 203 |
204 test_write_pixels(reporter, context0, externalTextureObj); | 204 test_write_pixels(reporter, context0, externalTextureObj.get()); |
205 | 205 |
206 test_copy_surface(reporter, context0, externalTextureObj, pixels.get()); | 206 test_copy_surface(reporter, context0, externalTextureObj.get(), pixels.get()
); |
207 | 207 |
208 cleanup(glCtx0, externalTexture.fID, glCtx1, context1, backendTexture1, imag
e); | 208 cleanup(glCtx0, externalTexture.fID, glCtx1, context1, backendTexture1, imag
e); |
209 } | 209 } |
210 | 210 |
211 #endif | 211 #endif |
OLD | NEW |