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

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

Issue 14860016: Implement OES_texture_float_linear and OES_texture_half_float_linear extensions in WebGL. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 7 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
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 30 matching lines...) Expand all
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
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;
239 if ((m_isFloatType && !(flag & TextureFloatLinearExtensionEnabled)) || (m_is HalfFloatType && !(flag && TextureHalfFloatLinearExtensionEnabled))) {
240 if (m_magFilter != GraphicsContext3D::NEAREST || (m_minFilter != Graphic sContext3D::NEAREST && m_minFilter != GraphicsContext3D::NEAREST_MIPMAP_NEAREST) )
241 return true;
242 }
Ken Russell (switch to Gerrit) 2013/05/15 23:25:10 Per the comment below, I would write this for clar
237 return m_needToUseBlackTexture; 243 return m_needToUseBlackTexture;
238 } 244 }
239 245
240 void WebGLTexture::deleteObjectImpl(GraphicsContext3D* context3d, Platform3DObje ct object) 246 void WebGLTexture::deleteObjectImpl(GraphicsContext3D* context3d, Platform3DObje ct object)
241 { 247 {
242 context3d->deleteTexture(object); 248 context3d->deleteTexture(object);
243 } 249 }
244 250
245 int WebGLTexture::mapTargetToIndex(GC3Denum target) const 251 int WebGLTexture::mapTargetToIndex(GC3Denum target) const
246 { 252 {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 309
304 void WebGLTexture::update() 310 void WebGLTexture::update()
305 { 311 {
306 m_isNPOT = false; 312 m_isNPOT = false;
307 for (size_t ii = 0; ii < m_info.size(); ++ii) { 313 for (size_t ii = 0; ii < m_info.size(); ++ii) {
308 if (isNPOT(m_info[ii][0].width, m_info[ii][0].height)) { 314 if (isNPOT(m_info[ii][0].width, m_info[ii][0].height)) {
309 m_isNPOT = true; 315 m_isNPOT = true;
310 break; 316 break;
311 } 317 }
312 } 318 }
319 m_isFloatType = false;
320 for (size_t ii = 0; ii < m_info.size(); ++ii) {
321 if (m_info[ii][0].type == GraphicsContext3D::FLOAT) {
322 m_isFloatType = true;
323 break;
324 }
325 }
326 m_isHalfFloatType = false;
327 for (size_t ii = 0; ii < m_info.size(); ++ii) {
328 if (m_info[ii][0].type == GraphicsContext3D::HALF_FLOAT_OES) {
329 m_isHalfFloatType = true;
330 break;
331 }
332 }
Ken Russell (switch to Gerrit) 2013/05/15 23:25:10 It isn't necessary to scan all the mip levels. If
Jun Jiang 2013/05/16 02:25:43 Here only mip level 0 is checked. The "for" loop h
313 m_isComplete = true; 333 m_isComplete = true;
314 const LevelInfo& first = m_info[0][0]; 334 const LevelInfo& first = m_info[0][0];
315 GC3Dint levelCount = computeLevelCount(first.width, first.height); 335 GC3Dint levelCount = computeLevelCount(first.width, first.height);
316 if (levelCount < 1) 336 if (levelCount < 1)
317 m_isComplete = false; 337 m_isComplete = false;
318 else { 338 else {
319 for (size_t ii = 0; ii < m_info.size() && m_isComplete; ++ii) { 339 for (size_t ii = 0; ii < m_info.size() && m_isComplete; ++ii) {
320 const LevelInfo& info0 = m_info[ii][0]; 340 const LevelInfo& info0 = m_info[ii][0];
321 if (!info0.valid 341 if (!info0.valid
322 || info0.width != first.width || info0.height != first.height 342 || info0.width != first.width || info0.height != first.height
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 return 0; 377 return 0;
358 int targetIndex = mapTargetToIndex(target); 378 int targetIndex = mapTargetToIndex(target);
359 if (targetIndex < 0 || targetIndex >= static_cast<int>(m_info.size())) 379 if (targetIndex < 0 || targetIndex >= static_cast<int>(m_info.size()))
360 return 0; 380 return 0;
361 if (level < 0 || level >= static_cast<GC3Dint>(m_info[targetIndex].size())) 381 if (level < 0 || level >= static_cast<GC3Dint>(m_info[targetIndex].size()))
362 return 0; 382 return 0;
363 return &(m_info[targetIndex][level]); 383 return &(m_info[targetIndex][level]);
364 } 384 }
365 385
366 } 386 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698