OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 30 matching lines...) Expand all Loading... | |
41 WebGLTexture::WebGLTexture(WebGLRenderingContext* ctx) | 41 WebGLTexture::WebGLTexture(WebGLRenderingContext* ctx) |
42 : WebGLSharedObject(ctx) | 42 : WebGLSharedObject(ctx) |
43 , m_target(0) | 43 , m_target(0) |
44 , m_minFilter(GraphicsContext3D::NEAREST_MIPMAP_LINEAR) | 44 , m_minFilter(GraphicsContext3D::NEAREST_MIPMAP_LINEAR) |
45 , m_magFilter(GraphicsContext3D::LINEAR) | 45 , m_magFilter(GraphicsContext3D::LINEAR) |
46 , m_wrapS(GraphicsContext3D::REPEAT) | 46 , m_wrapS(GraphicsContext3D::REPEAT) |
47 , m_wrapT(GraphicsContext3D::REPEAT) | 47 , m_wrapT(GraphicsContext3D::REPEAT) |
48 , m_isNPOT(false) | 48 , m_isNPOT(false) |
49 , m_isComplete(false) | 49 , m_isComplete(false) |
50 , m_needToUseBlackTexture(false) | 50 , m_needToUseBlackTexture(false) |
51 , m_isFloatType(false) | |
52 , m_isHalfFloatType(false) | |
51 { | 53 { |
52 setObject(ctx->graphicsContext3D()->createTexture()); | 54 setObject(ctx->graphicsContext3D()->createTexture()); |
53 } | 55 } |
54 | 56 |
55 WebGLTexture::~WebGLTexture() | 57 WebGLTexture::~WebGLTexture() |
56 { | 58 { |
57 deleteObject(0); | 59 deleteObject(0); |
58 } | 60 } |
59 | 61 |
60 void WebGLTexture::setTarget(GC3Denum target, GC3Dint maxLevel) | 62 void WebGLTexture::setTarget(GC3Denum target, GC3Dint maxLevel) |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 return false; | 225 return false; |
224 } | 226 } |
225 | 227 |
226 bool WebGLTexture::isNPOT() const | 228 bool WebGLTexture::isNPOT() const |
227 { | 229 { |
228 if (!object()) | 230 if (!object()) |
229 return false; | 231 return false; |
230 return m_isNPOT; | 232 return m_isNPOT; |
231 } | 233 } |
232 | 234 |
233 bool WebGLTexture::needToUseBlackTexture() const | 235 bool WebGLTexture::needToUseBlackTexture(TextureExtensionFlag flag) const |
234 { | 236 { |
235 if (!object()) | 237 if (!object()) |
236 return false; | 238 return false; |
237 return m_needToUseBlackTexture; | 239 if (m_needToUseBlackTexture) |
240 return true; | |
241 if ((m_isFloatType && !(flag & TextureFloatLinearExtensionEnabled)) || (m_is HalfFloatType && !(flag && TextureHalfFloatLinearExtensionEnabled))) { | |
242 if (m_magFilter != GraphicsContext3D::NEAREST || (m_minFilter != Graphic sContext3D::NEAREST && m_minFilter != GraphicsContext3D::NEAREST_MIPMAP_NEAREST) ) | |
243 return true; | |
244 } | |
245 return false; | |
238 } | 246 } |
239 | 247 |
240 void WebGLTexture::deleteObjectImpl(GraphicsContext3D* context3d, Platform3DObje ct object) | 248 void WebGLTexture::deleteObjectImpl(GraphicsContext3D* context3d, Platform3DObje ct object) |
241 { | 249 { |
242 context3d->deleteTexture(object); | 250 context3d->deleteTexture(object); |
243 } | 251 } |
244 | 252 |
245 int WebGLTexture::mapTargetToIndex(GC3Denum target) const | 253 int WebGLTexture::mapTargetToIndex(GC3Denum target) const |
246 { | 254 { |
247 if (m_target == GraphicsContext3D::TEXTURE_2D) { | 255 if (m_target == GraphicsContext3D::TEXTURE_2D) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
333 if (!info.valid | 341 if (!info.valid |
334 || info.width != width || info.height != height | 342 || info.width != width || info.height != height |
335 || info.internalFormat != info0.internalFormat || info.type != info0.type) { | 343 || info.internalFormat != info0.internalFormat || info.type != info0.type) { |
336 m_isComplete = false; | 344 m_isComplete = false; |
337 break; | 345 break; |
338 } | 346 } |
339 | 347 |
340 } | 348 } |
341 } | 349 } |
342 } | 350 } |
351 m_isFloatType = false; | |
352 if (m_isComplete) | |
353 m_isFloatType = m_info[0][0].type == GraphicsContext3D::FLOAT; | |
354 else { | |
355 for (size_t ii = 0; ii < m_info.size(); ++ii) { | |
356 if (m_info[ii][0].type == GraphicsContext3D::FLOAT) { | |
357 m_isFloatType = true; | |
358 break; | |
359 } | |
360 } | |
361 } | |
Ken Russell (switch to Gerrit)
2013/05/20 19:46:45
OK. It still isn't clear to me that scanning throu
| |
362 m_isHalfFloatType = false; | |
363 if (m_isComplete) | |
364 m_isHalfFloatType = m_info[0][0].type == GraphicsContext3D::HALF_FLOAT_O ES; | |
365 else { | |
366 for (size_t ii = 0; ii < m_info.size(); ++ii) { | |
367 if (m_info[ii][0].type == GraphicsContext3D::HALF_FLOAT_OES) { | |
368 m_isHalfFloatType = true; | |
369 break; | |
370 } | |
371 } | |
372 } | |
343 | 373 |
344 m_needToUseBlackTexture = false; | 374 m_needToUseBlackTexture = false; |
345 // NPOT | 375 // NPOT |
346 if (m_isNPOT && ((m_minFilter != GraphicsContext3D::NEAREST && m_minFilter ! = GraphicsContext3D::LINEAR) | 376 if (m_isNPOT && ((m_minFilter != GraphicsContext3D::NEAREST && m_minFilter ! = GraphicsContext3D::LINEAR) |
347 || m_wrapS != GraphicsContext3D::CLAMP_TO_EDGE || m_wrapT ! = GraphicsContext3D::CLAMP_TO_EDGE)) | 377 || m_wrapS != GraphicsContext3D::CLAMP_TO_EDGE || m_wrapT ! = GraphicsContext3D::CLAMP_TO_EDGE)) |
348 m_needToUseBlackTexture = true; | 378 m_needToUseBlackTexture = true; |
349 // Completeness | 379 // Completeness |
350 if (!m_isComplete && m_minFilter != GraphicsContext3D::NEAREST && m_minFilte r != GraphicsContext3D::LINEAR) | 380 if (!m_isComplete && m_minFilter != GraphicsContext3D::NEAREST && m_minFilte r != GraphicsContext3D::LINEAR) |
351 m_needToUseBlackTexture = true; | 381 m_needToUseBlackTexture = true; |
352 } | 382 } |
353 | 383 |
354 const WebGLTexture::LevelInfo* WebGLTexture::getLevelInfo(GC3Denum target, GC3Di nt level) const | 384 const WebGLTexture::LevelInfo* WebGLTexture::getLevelInfo(GC3Denum target, GC3Di nt level) const |
355 { | 385 { |
356 if (!object() || !m_target) | 386 if (!object() || !m_target) |
357 return 0; | 387 return 0; |
358 int targetIndex = mapTargetToIndex(target); | 388 int targetIndex = mapTargetToIndex(target); |
359 if (targetIndex < 0 || targetIndex >= static_cast<int>(m_info.size())) | 389 if (targetIndex < 0 || targetIndex >= static_cast<int>(m_info.size())) |
360 return 0; | 390 return 0; |
361 if (level < 0 || level >= static_cast<GC3Dint>(m_info[targetIndex].size())) | 391 if (level < 0 || level >= static_cast<GC3Dint>(m_info[targetIndex].size())) |
362 return 0; | 392 return 0; |
363 return &(m_info[targetIndex][level]); | 393 return &(m_info[targetIndex][level]); |
364 } | 394 } |
365 | 395 |
366 } | 396 } |
OLD | NEW |