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

Side by Side Diff: Source/core/html/canvas/WebGLTexture.cpp

Issue 16437002: Add check on Cube Completeness for Cube textures and improve the efficiency of checks associated wi… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 6 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 | « no previous file | 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 if (isNPOT()) 278 if (isNPOT())
279 return false; 279 return false;
280 const LevelInfo& first = m_info[0][0]; 280 const LevelInfo& first = m_info[0][0];
281 for (size_t ii = 0; ii < m_info.size(); ++ii) { 281 for (size_t ii = 0; ii < m_info.size(); ++ii) {
282 const LevelInfo& info = m_info[ii][0]; 282 const LevelInfo& info = m_info[ii][0];
283 if (!info.valid 283 if (!info.valid
284 || info.width != first.width || info.height != first.height 284 || info.width != first.width || info.height != first.height
285 || info.internalFormat != first.internalFormat || info.type != first .type) 285 || info.internalFormat != first.internalFormat || info.type != first .type)
286 return false; 286 return false;
287 } 287 }
288 return true; 288 return true;
Ken Russell (switch to Gerrit) 2013/06/06 23:16:43 This won't return the correct answer for a cube ma
Jun Jiang 2013/06/07 13:58:22 The code here is a little misleading but in my und
289 } 289 }
290 290
291 GC3Dint WebGLTexture::computeLevelCount(GC3Dsizei width, GC3Dsizei height) 291 GC3Dint WebGLTexture::computeLevelCount(GC3Dsizei width, GC3Dsizei height)
292 { 292 {
293 // return 1 + log2Floor(std::max(width, height)); 293 // return 1 + log2Floor(std::max(width, height));
294 GC3Dsizei n = std::max(width, height); 294 GC3Dsizei n = std::max(width, height);
295 if (n <= 0) 295 if (n <= 0)
296 return 0; 296 return 0;
297 GC3Dint log = 0; 297 GC3Dint log = 0;
298 GC3Dsizei value = n; 298 GC3Dsizei value = n;
(...skipping 12 matching lines...) Expand all
311 void WebGLTexture::update() 311 void WebGLTexture::update()
312 { 312 {
313 m_isNPOT = false; 313 m_isNPOT = false;
314 for (size_t ii = 0; ii < m_info.size(); ++ii) { 314 for (size_t ii = 0; ii < m_info.size(); ++ii) {
315 if (isNPOT(m_info[ii][0].width, m_info[ii][0].height)) { 315 if (isNPOT(m_info[ii][0].width, m_info[ii][0].height)) {
316 m_isNPOT = true; 316 m_isNPOT = true;
317 break; 317 break;
318 } 318 }
319 } 319 }
320 m_isComplete = true; 320 m_isComplete = true;
321 bool isCubeComplete = true;
Ken Russell (switch to Gerrit) 2013/06/06 23:16:43 Please make isCubeComplete a member of the WebGLTe
321 const LevelInfo& first = m_info[0][0]; 322 const LevelInfo& first = m_info[0][0];
322 GC3Dint levelCount = computeLevelCount(first.width, first.height); 323 GC3Dint levelCount = computeLevelCount(first.width, first.height);
323 if (levelCount < 1) 324 if (levelCount < 1)
324 m_isComplete = false; 325 m_isComplete = false;
325 else { 326 else {
326 for (size_t ii = 0; ii < m_info.size() && m_isComplete; ++ii) { 327 for (size_t ii = 0; ii < m_info.size() && m_isComplete; ++ii) {
327 const LevelInfo& info0 = m_info[ii][0]; 328 const LevelInfo& info0 = m_info[ii][0];
328 if (!info0.valid 329 if (!info0.valid
329 || info0.width != first.width || info0.height != first.height 330 || info0.width != first.width || info0.height != first.height
330 || info0.internalFormat != first.internalFormat || info0.type != first.type) { 331 || info0.internalFormat != first.internalFormat || info0.type != first.type
332 || (m_info.size() > 1 && info0.width != info0.height)) {
333 if (m_info.size() > 1)
334 isCubeComplete = false;
331 m_isComplete = false; 335 m_isComplete = false;
332 break; 336 break;
333 } 337 }
334 GC3Dsizei width = info0.width; 338 GC3Dsizei width = info0.width;
335 GC3Dsizei height = info0.height; 339 GC3Dsizei height = info0.height;
336 for (GC3Dint level = 1; level < levelCount; ++level) { 340 for (GC3Dint level = 1; level < levelCount; ++level) {
337 width = std::max(1, width >> 1); 341 width = std::max(1, width >> 1);
338 height = std::max(1, height >> 1); 342 height = std::max(1, height >> 1);
339 const LevelInfo& info = m_info[ii][level]; 343 const LevelInfo& info = m_info[ii][level];
340 if (!info.valid 344 if (!info.valid
341 || info.width != width || info.height != height 345 || info.width != width || info.height != height
342 || info.internalFormat != info0.internalFormat || info.type != info0.type) { 346 || info.internalFormat != info0.internalFormat || info.type != info0.type) {
343 m_isComplete = false; 347 m_isComplete = false;
344 break; 348 break;
345 } 349 }
346 350
347 } 351 }
348 } 352 }
349 } 353 }
350 m_isFloatType = false; 354 m_isFloatType = m_info[0][0].type == GraphicsContext3D::FLOAT;
351 if (m_isComplete) 355 m_isHalfFloatType = m_info[0][0].type == GraphicsContext3D::HALF_FLOAT_OES;
bajones 2013/06/05 17:29:00 This feels unrelated to the cubemap change. What's
Jun Jiang 2013/06/06 01:19:48 This change is to optimize the check on whether th
352 m_isFloatType = m_info[0][0].type == GraphicsContext3D::FLOAT;
353 else {
354 for (size_t ii = 0; ii < m_info.size(); ++ii) {
355 if (m_info[ii][0].type == GraphicsContext3D::FLOAT) {
356 m_isFloatType = true;
357 break;
358 }
359 }
360 }
361 m_isHalfFloatType = false;
362 if (m_isComplete)
363 m_isHalfFloatType = m_info[0][0].type == GraphicsContext3D::HALF_FLOAT_O ES;
364 else {
365 for (size_t ii = 0; ii < m_info.size(); ++ii) {
366 if (m_info[ii][0].type == GraphicsContext3D::HALF_FLOAT_OES) {
367 m_isHalfFloatType = true;
368 break;
369 }
370 }
371 }
372 356
373 m_needToUseBlackTexture = false; 357 m_needToUseBlackTexture = false;
374 // NPOT 358 // NPOT
375 if (m_isNPOT && ((m_minFilter != GraphicsContext3D::NEAREST && m_minFilter ! = GraphicsContext3D::LINEAR) 359 if (m_isNPOT && ((m_minFilter != GraphicsContext3D::NEAREST && m_minFilter ! = GraphicsContext3D::LINEAR)
376 || m_wrapS != GraphicsContext3D::CLAMP_TO_EDGE || m_wrapT ! = GraphicsContext3D::CLAMP_TO_EDGE)) 360 || m_wrapS != GraphicsContext3D::CLAMP_TO_EDGE || m_wrapT ! = GraphicsContext3D::CLAMP_TO_EDGE))
377 m_needToUseBlackTexture = true; 361 m_needToUseBlackTexture = true;
362 // If it is a Cube texture, check Cube Completeness first
363 if (m_info.size() > 1 && !isCubeComplete)
364 m_needToUseBlackTexture = true;
378 // Completeness 365 // Completeness
379 if (!m_isComplete && m_minFilter != GraphicsContext3D::NEAREST && m_minFilte r != GraphicsContext3D::LINEAR) 366 if (!m_isComplete && m_minFilter != GraphicsContext3D::NEAREST && m_minFilte r != GraphicsContext3D::LINEAR)
380 m_needToUseBlackTexture = true; 367 m_needToUseBlackTexture = true;
381 } 368 }
382 369
383 const WebGLTexture::LevelInfo* WebGLTexture::getLevelInfo(GC3Denum target, GC3Di nt level) const 370 const WebGLTexture::LevelInfo* WebGLTexture::getLevelInfo(GC3Denum target, GC3Di nt level) const
384 { 371 {
385 if (!object() || !m_target) 372 if (!object() || !m_target)
386 return 0; 373 return 0;
387 int targetIndex = mapTargetToIndex(target); 374 int targetIndex = mapTargetToIndex(target);
388 if (targetIndex < 0 || targetIndex >= static_cast<int>(m_info.size())) 375 if (targetIndex < 0 || targetIndex >= static_cast<int>(m_info.size()))
389 return 0; 376 return 0;
390 if (level < 0 || level >= static_cast<GC3Dint>(m_info[targetIndex].size())) 377 if (level < 0 || level >= static_cast<GC3Dint>(m_info[targetIndex].size()))
391 return 0; 378 return 0;
392 return &(m_info[targetIndex][level]); 379 return &(m_info[targetIndex][level]);
393 } 380 }
394 381
395 } 382 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698