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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLTexture.cpp

Issue 1639103002: Remove blink side NPOT/incomplete texture handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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 | « third_party/WebKit/Source/modules/webgl/WebGLTexture.h ('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 (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 22 matching lines...) Expand all
33 { 33 {
34 return new WebGLTexture(ctx); 34 return new WebGLTexture(ctx);
35 } 35 }
36 36
37 WebGLTexture::WebGLTexture(WebGLRenderingContextBase* ctx) 37 WebGLTexture::WebGLTexture(WebGLRenderingContextBase* ctx)
38 : WebGLSharedPlatform3DObject(ctx) 38 : WebGLSharedPlatform3DObject(ctx)
39 , m_target(0) 39 , m_target(0)
40 , m_isNPOT(false) 40 , m_isNPOT(false)
41 , m_isCubeComplete(false) 41 , m_isCubeComplete(false)
42 , m_isComplete(false) 42 , m_isComplete(false)
43 , m_needToUseBlackTexture(false)
44 , m_isFloatType(false) 43 , m_isFloatType(false)
45 , m_isHalfFloatType(false) 44 , m_isHalfFloatType(false)
46 , m_isWebGL2OrHigher(ctx->isWebGL2OrHigher()) 45 , m_isWebGL2OrHigher(ctx->isWebGL2OrHigher())
47 , m_immutable(false) 46 , m_immutable(false)
48 , m_baseLevel(0) 47 , m_baseLevel(0)
49 , m_maxLevel(1000) 48 , m_maxLevel(1000)
50 { 49 {
51 setObject(ctx->webContext()->createTexture()); 50 setObject(ctx->webContext()->createTexture());
52 } 51 }
53 52
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 for (size_t level = m_baseLevel + 1; level <= maxLevel; ++level) { 220 for (size_t level = m_baseLevel + 1; level <= maxLevel; ++level) {
222 width = std::max(1, width >> 1); 221 width = std::max(1, width >> 1);
223 height = std::max(1, height >> 1); 222 height = std::max(1, height >> 1);
224 depth = std::max(1, depth >> 1); 223 depth = std::max(1, depth >> 1);
225 LevelInfo& info = m_info[ii][level]; 224 LevelInfo& info = m_info[ii][level];
226 info.setInfo(info0.internalFormat, width, height, depth, info0.t ype); 225 info.setInfo(info0.internalFormat, width, height, depth, info0.t ype);
227 } 226 }
228 } 227 }
229 m_isComplete = true; 228 m_isComplete = true;
230 } 229 }
231 m_needToUseBlackTexture = false;
232 } 230 }
233 231
234 GLenum WebGLTexture::getInternalFormat(GLenum target, GLint level) const 232 GLenum WebGLTexture::getInternalFormat(GLenum target, GLint level) const
235 { 233 {
236 const LevelInfo* info = getLevelInfo(target, level); 234 const LevelInfo* info = getLevelInfo(target, level);
237 if (!info) 235 if (!info)
238 return 0; 236 return 0;
239 return info->internalFormat; 237 return info->internalFormat;
240 } 238 }
241 239
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 if (!object()) 292 if (!object())
295 return false; 293 return false;
296 return m_isNPOT; 294 return m_isNPOT;
297 } 295 }
298 296
299 bool WebGLTexture::needToUseBlackTexture(TextureExtensionFlag flag, const WebGLS amplerState* samplerState) const 297 bool WebGLTexture::needToUseBlackTexture(TextureExtensionFlag flag, const WebGLS amplerState* samplerState) const
300 { 298 {
301 ASSERT(samplerState); 299 ASSERT(samplerState);
302 if (!object()) 300 if (!object())
303 return false; 301 return false;
304 if (m_needToUseBlackTexture)
305 return true;
306 if ((m_isFloatType && !(flag & TextureFloatLinearExtensionEnabled)) || (m_is HalfFloatType && !(flag && TextureHalfFloatLinearExtensionEnabled))) { 302 if ((m_isFloatType && !(flag & TextureFloatLinearExtensionEnabled)) || (m_is HalfFloatType && !(flag && TextureHalfFloatLinearExtensionEnabled))) {
307 if (samplerState->magFilter != GL_NEAREST || (samplerState->minFilter != GL_NEAREST && samplerState->minFilter != GL_NEAREST_MIPMAP_NEAREST)) 303 if (samplerState->magFilter != GL_NEAREST || (samplerState->minFilter != GL_NEAREST && samplerState->minFilter != GL_NEAREST_MIPMAP_NEAREST))
308 return true; 304 return true;
309 } 305 }
310 return false; 306 return false;
311 } 307 }
312 308
313 void WebGLTexture::deleteObjectImpl(WebGraphicsContext3D* context3d) 309 void WebGLTexture::deleteObjectImpl(WebGraphicsContext3D* context3d)
314 { 310 {
315 context3d->deleteTexture(m_object); 311 context3d->deleteTexture(m_object);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 || info.internalFormat != info0.internalFormat || info.type != info0.type) { 426 || info.internalFormat != info0.internalFormat || info.type != info0.type) {
431 m_isComplete = false; 427 m_isComplete = false;
432 break; 428 break;
433 } 429 }
434 430
435 } 431 }
436 } 432 }
437 } 433 }
438 m_isFloatType = m_info[0][0].type == GL_FLOAT; 434 m_isFloatType = m_info[0][0].type == GL_FLOAT;
439 m_isHalfFloatType = m_info[0][0].type == GL_HALF_FLOAT_OES; 435 m_isHalfFloatType = m_info[0][0].type == GL_HALF_FLOAT_OES;
440
441 m_needToUseBlackTexture = false;
442 // If it is a Cube texture, check Cube Completeness first
443 if (m_info.size() > 1 && !m_isCubeComplete)
444 m_needToUseBlackTexture = true;
445 if (!m_isWebGL2OrHigher) {
446 // We can do these checks up front in WebGL 1 because there's no separat e samplers.
447 // NPOT
448 if (m_isNPOT && ((m_samplerState.minFilter != GL_NEAREST && m_samplerSta te.minFilter != GL_LINEAR)
449 || m_samplerState.wrapS != GL_CLAMP_TO_EDGE || m_samplerState.wrapT != GL_CLAMP_TO_EDGE))
450 m_needToUseBlackTexture = true;
451 // Completeness
452 if (!m_isComplete && m_samplerState.minFilter != GL_NEAREST && m_sampler State.minFilter != GL_LINEAR)
453 m_needToUseBlackTexture = true;
454 }
455 } 436 }
456 437
457 const WebGLTexture::LevelInfo* WebGLTexture::getLevelInfo(GLenum target, GLint l evel) const 438 const WebGLTexture::LevelInfo* WebGLTexture::getLevelInfo(GLenum target, GLint l evel) const
458 { 439 {
459 if (!object() || !m_target) 440 if (!object() || !m_target)
460 return nullptr; 441 return nullptr;
461 int targetIndex = mapTargetToIndex(target); 442 int targetIndex = mapTargetToIndex(target);
462 if (targetIndex < 0 || targetIndex >= static_cast<int>(m_info.size())) 443 if (targetIndex < 0 || targetIndex >= static_cast<int>(m_info.size()))
463 return nullptr; 444 return nullptr;
464 if (level < 0 || level >= static_cast<GLint>(m_info[targetIndex].size())) 445 if (level < 0 || level >= static_cast<GLint>(m_info[targetIndex].size()))
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: 572 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
592 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: 573 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
593 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: 574 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
594 return GL_UNSIGNED_BYTE; 575 return GL_UNSIGNED_BYTE;
595 default: 576 default:
596 return GL_NONE; 577 return GL_NONE;
597 } 578 }
598 } 579 }
599 580
600 } // namespace blink 581 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLTexture.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698