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

Side by Side Diff: Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 1234883002: [Oilpan] Migrate classes under module/webgl onto oilpan heap (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Work for comments Created 5 years, 4 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 if (!desiredSize.isEmpty()) { 215 if (!desiredSize.isEmpty()) {
216 forciblyEvictedContexts().remove(0); 216 forciblyEvictedContexts().remove(0);
217 evictedContext->forceRestoreContext(); 217 evictedContext->forceRestoreContext();
218 } 218 }
219 break; 219 break;
220 } 220 }
221 } 221 }
222 222
223 namespace { 223 namespace {
224 224
225 // ScopedDrawingBufferBinder is used for ReadPixels/CopyTexImage2D/CopySubIm age2D to read from 225 // ScopedDrawingBufferBinder is used for ReadPixels/CopyTexImage2D/CopySubImage2 D to read from
226 // a multisampled DrawingBuffer. In this situation, we need to blit to a sin gle sampled buffer 226 // a multisampled DrawingBuffer. In this situation, we need to blit to a single sampled buffer
227 // for reading, during which the bindings could be changed and need to be re covered. 227 // for reading, during which the bindings could be changed and need to be recove red.
228 class ScopedDrawingBufferBinder { 228 class ScopedDrawingBufferBinder {
229 STACK_ALLOCATED(); 229 STACK_ALLOCATED();
230 public: 230 public:
231 ScopedDrawingBufferBinder(DrawingBuffer* drawingBuffer, WebGLFramebuffer * framebufferBinding) 231 ScopedDrawingBufferBinder(DrawingBuffer* drawingBuffer, WebGLFramebuffer* fr amebufferBinding)
232 : m_drawingBuffer(drawingBuffer) 232 : m_drawingBuffer(drawingBuffer)
233 , m_readFramebufferBinding(framebufferBinding) 233 , m_readFramebufferBinding(framebufferBinding)
234 { 234 {
235 // Commit DrawingBuffer if needed (e.g., for multisampling) 235 // Commit DrawingBuffer if needed (e.g., for multisampling)
236 if (!m_readFramebufferBinding && m_drawingBuffer) 236 if (!m_readFramebufferBinding && m_drawingBuffer)
237 m_drawingBuffer->commit(); 237 m_drawingBuffer->commit();
238 } 238 }
239 239
240 ~ScopedDrawingBufferBinder() 240 ~ScopedDrawingBufferBinder()
241 { 241 {
242 // Restore DrawingBuffer if needed 242 // Restore DrawingBuffer if needed
243 if (!m_readFramebufferBinding && m_drawingBuffer) 243 if (!m_readFramebufferBinding && m_drawingBuffer)
244 m_drawingBuffer->restoreFramebufferBindings(); 244 m_drawingBuffer->restoreFramebufferBindings();
245 } 245 }
246 246
247 private: 247 private:
248 DrawingBuffer* m_drawingBuffer; 248 DrawingBuffer* m_drawingBuffer;
249 RawPtrWillBeMember<WebGLFramebuffer> m_readFramebufferBinding; 249 Member<WebGLFramebuffer> m_readFramebufferBinding;
250 };
251
252 GLint clamp(GLint value, GLint min, GLint max)
253 {
254 if (value < min)
255 value = min;
256 if (value > max)
257 value = max;
258 return value;
259 }
260
261 // Return true if a character belongs to the ASCII subset as defined in
262 // GLSL ES 1.0 spec section 3.1.
263 bool validateCharacter(unsigned char c)
264 {
265 // Printing characters are valid except " $ ` @ \ ' DEL.
266 if (c >= 32 && c <= 126
267 && c != '"' && c != '$' && c != '`' && c != '@' && c != '\\' && c != '\' ')
268 return true;
269 // Horizontal tab, line feed, vertical tab, form feed, carriage return
270 // are also valid.
271 if (c >= 9 && c <= 13)
272 return true;
273 return false;
274 }
275
276 bool isPrefixReserved(const String& name)
277 {
278 if (name.startsWith("gl_") || name.startsWith("webgl_") || name.startsWith(" _webgl_"))
279 return true;
280 return false;
281 }
282
283 // Strips comments from shader text. This allows non-ASCII characters
284 // to be used in comments without potentially breaking OpenGL
285 // implementations not expecting characters outside the GLSL ES set.
286 class StripComments {
287 public:
288 StripComments(const String& str)
289 : m_parseState(BeginningOfLine)
290 , m_sourceString(str)
291 , m_length(str.length())
292 , m_position(0)
293 {
294 parse();
295 }
296
297 String result()
298 {
299 return m_builder.toString();
300 }
301
302 private:
303 bool hasMoreCharacters() const
304 {
305 return (m_position < m_length);
306 }
307
308 void parse()
309 {
310 while (hasMoreCharacters()) {
311 process(current());
312 // process() might advance the position.
313 if (hasMoreCharacters())
314 advance();
315 }
316 }
317
318 void process(UChar);
319
320 bool peek(UChar& character) const
321 {
322 if (m_position + 1 >= m_length)
323 return false;
324 character = m_sourceString[m_position + 1];
325 return true;
326 }
327
328 UChar current()
329 {
330 ASSERT_WITH_SECURITY_IMPLICATION(m_position < m_length);
331 return m_sourceString[m_position];
332 }
333
334 void advance()
335 {
336 ++m_position;
337 }
338
339 static bool isNewline(UChar character)
340 {
341 // Don't attempt to canonicalize newline related characters.
342 return (character == '\n' || character == '\r');
343 }
344
345 void emit(UChar character)
346 {
347 m_builder.append(character);
348 }
349
350 enum ParseState {
351 // Have not seen an ASCII non-whitespace character yet on
352 // this line. Possible that we might see a preprocessor
353 // directive.
354 BeginningOfLine,
355
356 // Have seen at least one ASCII non-whitespace character
357 // on this line.
358 MiddleOfLine,
359
360 // Handling a preprocessor directive. Passes through all
361 // characters up to the end of the line. Disables comment
362 // processing.
363 InPreprocessorDirective,
364
365 // Handling a single-line comment. The comment text is
366 // replaced with a single space.
367 InSingleLineComment,
368
369 // Handling a multi-line comment. Newlines are passed
370 // through to preserve line numbers.
371 InMultiLineComment
250 }; 372 };
251 373
252 GLint clamp(GLint value, GLint min, GLint max) 374 ParseState m_parseState;
253 { 375 String m_sourceString;
254 if (value < min) 376 unsigned m_length;
255 value = min; 377 unsigned m_position;
256 if (value > max) 378 StringBuilder m_builder;
257 value = max; 379 };
258 return value; 380
259 } 381 void StripComments::process(UChar c)
260 382 {
261 // Return true if a character belongs to the ASCII subset as defined in 383 if (isNewline(c)) {
262 // GLSL ES 1.0 spec section 3.1. 384 // No matter what state we are in, pass through newlines
263 bool validateCharacter(unsigned char c) 385 // so we preserve line numbers.
264 { 386 emit(c);
265 // Printing characters are valid except " $ ` @ \ ' DEL. 387
266 if (c >= 32 && c <= 126 388 if (m_parseState != InMultiLineComment)
267 && c != '"' && c != '$' && c != '`' && c != '@' && c != '\\' && c != '\'') 389 m_parseState = BeginningOfLine;
268 return true; 390
269 // Horizontal tab, line feed, vertical tab, form feed, carriage return 391 return;
270 // are also valid. 392 }
271 if (c >= 9 && c <= 13) 393
272 return true; 394 UChar temp = 0;
273 return false; 395 switch (m_parseState) {
274 } 396 case BeginningOfLine:
275 397 if (WTF::isASCIISpace(c)) {
276 bool isPrefixReserved(const String& name)
277 {
278 if (name.startsWith("gl_") || name.startsWith("webgl_") || name.startsWi th("_webgl_"))
279 return true;
280 return false;
281 }
282
283 // Strips comments from shader text. This allows non-ASCII characters
284 // to be used in comments without potentially breaking OpenGL
285 // implementations not expecting characters outside the GLSL ES set.
286 class StripComments {
287 public:
288 StripComments(const String& str)
289 : m_parseState(BeginningOfLine)
290 , m_sourceString(str)
291 , m_length(str.length())
292 , m_position(0)
293 {
294 parse();
295 }
296
297 String result()
298 {
299 return m_builder.toString();
300 }
301
302 private:
303 bool hasMoreCharacters() const
304 {
305 return (m_position < m_length);
306 }
307
308 void parse()
309 {
310 while (hasMoreCharacters()) {
311 process(current());
312 // process() might advance the position.
313 if (hasMoreCharacters())
314 advance();
315 }
316 }
317
318 void process(UChar);
319
320 bool peek(UChar& character) const
321 {
322 if (m_position + 1 >= m_length)
323 return false;
324 character = m_sourceString[m_position + 1];
325 return true;
326 }
327
328 UChar current()
329 {
330 ASSERT_WITH_SECURITY_IMPLICATION(m_position < m_length);
331 return m_sourceString[m_position];
332 }
333
334 void advance()
335 {
336 ++m_position;
337 }
338
339 static bool isNewline(UChar character)
340 {
341 // Don't attempt to canonicalize newline related characters.
342 return (character == '\n' || character == '\r');
343 }
344
345 void emit(UChar character)
346 {
347 m_builder.append(character);
348 }
349
350 enum ParseState {
351 // Have not seen an ASCII non-whitespace character yet on
352 // this line. Possible that we might see a preprocessor
353 // directive.
354 BeginningOfLine,
355
356 // Have seen at least one ASCII non-whitespace character
357 // on this line.
358 MiddleOfLine,
359
360 // Handling a preprocessor directive. Passes through all
361 // characters up to the end of the line. Disables comment
362 // processing.
363 InPreprocessorDirective,
364
365 // Handling a single-line comment. The comment text is
366 // replaced with a single space.
367 InSingleLineComment,
368
369 // Handling a multi-line comment. Newlines are passed
370 // through to preserve line numbers.
371 InMultiLineComment
372 };
373
374 ParseState m_parseState;
375 String m_sourceString;
376 unsigned m_length;
377 unsigned m_position;
378 StringBuilder m_builder;
379 };
380
381 void StripComments::process(UChar c)
382 {
383 if (isNewline(c)) {
384 // No matter what state we are in, pass through newlines
385 // so we preserve line numbers.
386 emit(c);
387
388 if (m_parseState != InMultiLineComment)
389 m_parseState = BeginningOfLine;
390
391 return;
392 }
393
394 UChar temp = 0;
395 switch (m_parseState) {
396 case BeginningOfLine:
397 if (WTF::isASCIISpace(c)) {
398 emit(c);
399 break;
400 }
401
402 if (c == '#') {
403 m_parseState = InPreprocessorDirective;
404 emit(c);
405 break;
406 }
407
408 // Transition to normal state and re-handle character.
409 m_parseState = MiddleOfLine;
410 process(c);
411 break;
412
413 case MiddleOfLine:
414 if (c == '/' && peek(temp)) {
415 if (temp == '/') {
416 m_parseState = InSingleLineComment;
417 emit(' ');
418 advance();
419 break;
420 }
421
422 if (temp == '*') {
423 m_parseState = InMultiLineComment;
424 // Emit the comment start in case the user has
425 // an unclosed comment and we want to later
426 // signal an error.
427 emit('/');
428 emit('*');
429 advance();
430 break;
431 }
432 }
433
434 emit(c); 398 emit(c);
435 break; 399 break;
436 400 }
437 case InPreprocessorDirective: 401
438 // No matter what the character is, just pass it 402 if (c == '#') {
439 // through. Do not parse comments in this state. This 403 m_parseState = InPreprocessorDirective;
440 // might not be the right thing to do long term, but it
441 // should handle the #error preprocessor directive.
442 emit(c); 404 emit(c);
443 break; 405 break;
444 406 }
445 case InSingleLineComment: 407
446 // The newline code at the top of this function takes care 408 // Transition to normal state and re-handle character.
447 // of resetting our state when we get out of the 409 m_parseState = MiddleOfLine;
448 // single-line comment. Swallow all other characters. 410 process(c);
449 break; 411 break;
450 412
451 case InMultiLineComment: 413 case MiddleOfLine:
452 if (c == '*' && peek(temp) && temp == '/') { 414 if (c == '/' && peek(temp)) {
453 emit('*'); 415 if (temp == '/') {
454 emit('/'); 416 m_parseState = InSingleLineComment;
455 m_parseState = MiddleOfLine; 417 emit(' ');
456 advance(); 418 advance();
457 break; 419 break;
458 } 420 }
459 421
460 // Swallow all other characters. Unclear whether we may 422 if (temp == '*') {
461 // want or need to just emit a space per character to try 423 m_parseState = InMultiLineComment;
462 // to preserve column numbers for debugging purposes. 424 // Emit the comment start in case the user has
425 // an unclosed comment and we want to later
426 // signal an error.
427 emit('/');
428 emit('*');
429 advance();
430 break;
431 }
432 }
433
434 emit(c);
435 break;
436
437 case InPreprocessorDirective:
438 // No matter what the character is, just pass it
439 // through. Do not parse comments in this state. This
440 // might not be the right thing to do long term, but it
441 // should handle the #error preprocessor directive.
442 emit(c);
443 break;
444
445 case InSingleLineComment:
446 // The newline code at the top of this function takes care
447 // of resetting our state when we get out of the
448 // single-line comment. Swallow all other characters.
449 break;
450
451 case InMultiLineComment:
452 if (c == '*' && peek(temp) && temp == '/') {
453 emit('*');
454 emit('/');
455 m_parseState = MiddleOfLine;
456 advance();
463 break; 457 break;
464 } 458 }
465 } 459
466 460 // Swallow all other characters. Unclear whether we may
467 static bool shouldFailContextCreationForTesting = false; 461 // want or need to just emit a space per character to try
462 // to preserve column numbers for debugging purposes.
463 break;
464 }
465 }
466
467 static bool shouldFailContextCreationForTesting = false;
468 } // namespace anonymous 468 } // namespace anonymous
469 469
470 class ScopedTexture2DRestorer { 470 class ScopedTexture2DRestorer {
471 STACK_ALLOCATED(); 471 STACK_ALLOCATED();
472 public: 472 public:
473 explicit ScopedTexture2DRestorer(WebGLRenderingContextBase* context) 473 explicit ScopedTexture2DRestorer(WebGLRenderingContextBase* context)
474 : m_context(context) 474 : m_context(context)
475 { 475 {
476 } 476 }
477 477
(...skipping 16 matching lines...) Expand all
494 494
495 ~ScopedFramebufferRestorer() 495 ~ScopedFramebufferRestorer()
496 { 496 {
497 m_context->restoreCurrentFramebuffer(); 497 m_context->restoreCurrentFramebuffer();
498 } 498 }
499 499
500 private: 500 private:
501 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; 501 RawPtrWillBeMember<WebGLRenderingContextBase> m_context;
502 }; 502 };
503 503
504 class WebGLRenderingContextLostCallback final : public NoBaseWillBeGarbageCollec tedFinalized<WebGLRenderingContextLostCallback>, public WebGraphicsContext3D::We bGraphicsContextLostCallback { 504 class WebGLRenderingContextLostCallback final : public GarbageCollectedFinalized <WebGLRenderingContextLostCallback>, public WebGraphicsContext3D::WebGraphicsCon textLostCallback {
505 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(WebGLRenderingContextLostCallback);
506 public: 505 public:
507 static PassOwnPtrWillBeRawPtr<WebGLRenderingContextLostCallback> create(WebG LRenderingContextBase* context) 506 static WebGLRenderingContextLostCallback* create(WebGLRenderingContextBase* context)
508 { 507 {
509 return adoptPtrWillBeNoop(new WebGLRenderingContextLostCallback(context) ); 508 return new WebGLRenderingContextLostCallback(context);
510 } 509 }
511 510
512 ~WebGLRenderingContextLostCallback() override { } 511 ~WebGLRenderingContextLostCallback() override { }
513 512
514 virtual void onContextLost() { m_context->forceLostContext(WebGLRenderingCon textBase::RealLostContext, WebGLRenderingContextBase::Auto); } 513 virtual void onContextLost() { m_context->forceLostContext(WebGLRenderingCon textBase::RealLostContext, WebGLRenderingContextBase::Auto); }
515 514
516 DEFINE_INLINE_TRACE() 515 DEFINE_INLINE_TRACE()
517 { 516 {
518 visitor->trace(m_context); 517 visitor->trace(m_context);
519 } 518 }
520 519
521 private: 520 private:
522 explicit WebGLRenderingContextLostCallback(WebGLRenderingContextBase* contex t) 521 explicit WebGLRenderingContextLostCallback(WebGLRenderingContextBase* contex t)
523 : m_context(context) { } 522 : m_context(context) { }
524 523
525 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; 524 RawPtrWillBeMember<WebGLRenderingContextBase> m_context;
526 }; 525 };
527 526
528 class WebGLRenderingContextErrorMessageCallback final : public NoBaseWillBeGarba geCollectedFinalized<WebGLRenderingContextErrorMessageCallback>, public WebGraph icsContext3D::WebGraphicsErrorMessageCallback { 527 class WebGLRenderingContextErrorMessageCallback final : public GarbageCollectedF inalized<WebGLRenderingContextErrorMessageCallback>, public WebGraphicsContext3D ::WebGraphicsErrorMessageCallback {
529 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(WebGLRenderingContextErrorMessageCal lback);
530 public: 528 public:
531 static PassOwnPtrWillBeRawPtr<WebGLRenderingContextErrorMessageCallback> cre ate(WebGLRenderingContextBase* context) 529 static WebGLRenderingContextErrorMessageCallback* create(WebGLRenderingConte xtBase* context)
532 { 530 {
533 return adoptPtrWillBeNoop(new WebGLRenderingContextErrorMessageCallback( context)); 531 return new WebGLRenderingContextErrorMessageCallback(context);
534 } 532 }
535 533
536 ~WebGLRenderingContextErrorMessageCallback() override { } 534 ~WebGLRenderingContextErrorMessageCallback() override { }
537 535
538 virtual void onErrorMessage(const WebString& message, WGC3Dint) 536 virtual void onErrorMessage(const WebString& message, WGC3Dint)
539 { 537 {
540 if (m_context->m_synthesizedErrorsToConsole) 538 if (m_context->m_synthesizedErrorsToConsole)
541 m_context->printGLErrorToConsole(message); 539 m_context->printGLErrorToConsole(message);
542 InspectorInstrumentation::didFireWebGLErrorOrWarning(m_context->canvas() , message); 540 InspectorInstrumentation::didFireWebGLErrorOrWarning(m_context->canvas() , message);
543 } 541 }
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 return; 1909 return;
1912 } 1910 }
1913 WebGLFramebuffer* readFramebufferBinding = nullptr; 1911 WebGLFramebuffer* readFramebufferBinding = nullptr;
1914 if (!validateReadBufferAndGetInfo("copyTexSubImage2D", readFramebufferBindin g, nullptr, nullptr)) 1912 if (!validateReadBufferAndGetInfo("copyTexSubImage2D", readFramebufferBindin g, nullptr, nullptr))
1915 return; 1913 return;
1916 clearIfComposited(); 1914 clearIfComposited();
1917 ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding); 1915 ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding);
1918 webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width , height); 1916 webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width , height);
1919 } 1917 }
1920 1918
1921 PassRefPtrWillBeRawPtr<WebGLBuffer> WebGLRenderingContextBase::createBuffer() 1919 WebGLBuffer* WebGLRenderingContextBase::createBuffer()
1922 { 1920 {
1923 if (isContextLost()) 1921 if (isContextLost())
1924 return nullptr; 1922 return nullptr;
1925 RefPtrWillBeRawPtr<WebGLBuffer> o = WebGLBuffer::create(this); 1923 WebGLBuffer* o = WebGLBuffer::create(this);
1926 addSharedObject(o.get()); 1924 addSharedObject(o);
1927 return o.release(); 1925 return o;
1928 } 1926 }
1929 1927
1930 PassRefPtrWillBeRawPtr<WebGLFramebuffer> WebGLRenderingContextBase::createFrameb uffer() 1928 WebGLFramebuffer* WebGLRenderingContextBase::createFramebuffer()
1931 { 1929 {
1932 if (isContextLost()) 1930 if (isContextLost())
1933 return nullptr; 1931 return nullptr;
1934 RefPtrWillBeRawPtr<WebGLFramebuffer> o = WebGLFramebuffer::create(this); 1932 WebGLFramebuffer* o = WebGLFramebuffer::create(this);
1935 addContextObject(o.get()); 1933 addContextObject(o);
1936 return o.release(); 1934 return o;
1937 } 1935 }
1938 1936
1939 PassRefPtrWillBeRawPtr<WebGLTexture> WebGLRenderingContextBase::createTexture() 1937 WebGLTexture* WebGLRenderingContextBase::createTexture()
1940 { 1938 {
1941 if (isContextLost()) 1939 if (isContextLost())
1942 return nullptr; 1940 return nullptr;
1943 RefPtrWillBeRawPtr<WebGLTexture> o = WebGLTexture::create(this); 1941 WebGLTexture* o = WebGLTexture::create(this);
1944 addSharedObject(o.get()); 1942 addSharedObject(o);
1945 return o.release(); 1943 return o;
1946 } 1944 }
1947 1945
1948 PassRefPtrWillBeRawPtr<WebGLProgram> WebGLRenderingContextBase::createProgram() 1946 WebGLProgram* WebGLRenderingContextBase::createProgram()
1949 { 1947 {
1950 if (isContextLost()) 1948 if (isContextLost())
1951 return nullptr; 1949 return nullptr;
1952 RefPtrWillBeRawPtr<WebGLProgram> o = WebGLProgram::create(this); 1950 WebGLProgram* o = WebGLProgram::create(this);
1953 addSharedObject(o.get()); 1951 addSharedObject(o);
1954 return o.release(); 1952 return o;
1955 } 1953 }
1956 1954
1957 PassRefPtrWillBeRawPtr<WebGLRenderbuffer> WebGLRenderingContextBase::createRende rbuffer() 1955 WebGLRenderbuffer* WebGLRenderingContextBase::createRenderbuffer()
1958 { 1956 {
1959 if (isContextLost()) 1957 if (isContextLost())
1960 return nullptr; 1958 return nullptr;
1961 RefPtrWillBeRawPtr<WebGLRenderbuffer> o = WebGLRenderbuffer::create(this); 1959 WebGLRenderbuffer* o = WebGLRenderbuffer::create(this);
1962 addSharedObject(o.get()); 1960 addSharedObject(o);
1963 return o.release(); 1961 return o;
1964 } 1962 }
1965 1963
1966 WebGLRenderbuffer* WebGLRenderingContextBase::ensureEmulatedStencilBuffer(GLenum target, WebGLRenderbuffer* renderbuffer) 1964 WebGLRenderbuffer* WebGLRenderingContextBase::ensureEmulatedStencilBuffer(GLenum target, WebGLRenderbuffer* renderbuffer)
1967 { 1965 {
1968 if (isContextLost()) 1966 if (isContextLost())
1969 return nullptr; 1967 return nullptr;
1970 if (!renderbuffer->emulatedStencilBuffer()) { 1968 if (!renderbuffer->emulatedStencilBuffer()) {
1971 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); 1969 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer());
1972 webContext()->bindRenderbuffer(target, objectOrZero(renderbuffer->emulat edStencilBuffer())); 1970 webContext()->bindRenderbuffer(target, objectOrZero(renderbuffer->emulat edStencilBuffer()));
1973 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBindin g.get())); 1971 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBindin g.get()));
1974 } 1972 }
1975 return renderbuffer->emulatedStencilBuffer(); 1973 return renderbuffer->emulatedStencilBuffer();
1976 } 1974 }
1977 1975
1978 PassRefPtrWillBeRawPtr<WebGLShader> WebGLRenderingContextBase::createShader(GLen um type) 1976 WebGLShader* WebGLRenderingContextBase::createShader(GLenum type)
1979 { 1977 {
1980 if (isContextLost()) 1978 if (isContextLost())
1981 return nullptr; 1979 return nullptr;
1982 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) { 1980 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) {
1983 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type" ); 1981 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type" );
1984 return nullptr; 1982 return nullptr;
1985 } 1983 }
1986 1984
1987 RefPtrWillBeRawPtr<WebGLShader> o = WebGLShader::create(this, type); 1985 WebGLShader* o = WebGLShader::create(this, type);
1988 addSharedObject(o.get()); 1986 addSharedObject(o);
1989 return o.release(); 1987 return o;
1990 } 1988 }
1991 1989
1992 void WebGLRenderingContextBase::cullFace(GLenum mode) 1990 void WebGLRenderingContextBase::cullFace(GLenum mode)
1993 { 1991 {
1994 if (isContextLost()) 1992 if (isContextLost())
1995 return; 1993 return;
1996 switch (mode) { 1994 switch (mode) {
1997 case GL_FRONT_AND_BACK: 1995 case GL_FRONT_AND_BACK:
1998 case GL_FRONT: 1996 case GL_FRONT:
1999 case GL_BACK: 1997 case GL_BACK:
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
2435 } 2433 }
2436 #endif 2434 #endif
2437 webContext()->generateMipmap(target); 2435 webContext()->generateMipmap(target);
2438 #if OS(MACOSX) 2436 #if OS(MACOSX)
2439 if (needToResetMinFilter) 2437 if (needToResetMinFilter)
2440 webContext()->texParameteri(target, GL_TEXTURE_MIN_FILTER, tex->getMinFi lter()); 2438 webContext()->texParameteri(target, GL_TEXTURE_MIN_FILTER, tex->getMinFi lter());
2441 #endif 2439 #endif
2442 tex->generateMipmapLevelInfo(); 2440 tex->generateMipmapLevelInfo();
2443 } 2441 }
2444 2442
2445 PassRefPtrWillBeRawPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveAttr ib(WebGLProgram* program, GLuint index) 2443 WebGLActiveInfo* WebGLRenderingContextBase::getActiveAttrib(WebGLProgram* progra m, GLuint index)
2446 { 2444 {
2447 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) 2445 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program))
2448 return nullptr; 2446 return nullptr;
2449 WebGraphicsContext3D::ActiveInfo info; 2447 WebGraphicsContext3D::ActiveInfo info;
2450 if (!webContext()->getActiveAttrib(objectOrZero(program), index, info)) 2448 if (!webContext()->getActiveAttrib(objectOrZero(program), index, info))
2451 return nullptr; 2449 return nullptr;
2452 return WebGLActiveInfo::create(info.name, info.type, info.size); 2450 return WebGLActiveInfo::create(info.name, info.type, info.size);
2453 } 2451 }
2454 2452
2455 PassRefPtrWillBeRawPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveUnif orm(WebGLProgram* program, GLuint index) 2453 WebGLActiveInfo* WebGLRenderingContextBase::getActiveUniform(WebGLProgram* progr am, GLuint index)
2456 { 2454 {
2457 if (isContextLost() || !validateWebGLObject("getActiveUniform", program)) 2455 if (isContextLost() || !validateWebGLObject("getActiveUniform", program))
2458 return nullptr; 2456 return nullptr;
2459 WebGraphicsContext3D::ActiveInfo info; 2457 WebGraphicsContext3D::ActiveInfo info;
2460 if (!webContext()->getActiveUniform(objectOrZero(program), index, info)) 2458 if (!webContext()->getActiveUniform(objectOrZero(program), index, info))
2461 return nullptr; 2459 return nullptr;
2462 return WebGLActiveInfo::create(info.name, info.type, info.size); 2460 return WebGLActiveInfo::create(info.name, info.type, info.size);
2463 } 2461 }
2464 2462
2465 Nullable<WillBeHeapVector<RefPtrWillBeMember<WebGLShader>>> WebGLRenderingContex tBase::getAttachedShaders(WebGLProgram* program) 2463 Nullable<HeapVector<Member<WebGLShader>>> WebGLRenderingContextBase::getAttached Shaders(WebGLProgram* program)
2466 { 2464 {
2467 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) 2465 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program))
2468 return nullptr; 2466 return nullptr;
2469 2467
2470 WillBeHeapVector<RefPtrWillBeMember<WebGLShader>> shaderObjects; 2468 HeapVector<Member<WebGLShader>> shaderObjects;
2471 const GLenum shaderType[] = { 2469 const GLenum shaderType[] = {
2472 GL_VERTEX_SHADER, 2470 GL_VERTEX_SHADER,
2473 GL_FRAGMENT_SHADER 2471 GL_FRAGMENT_SHADER
2474 }; 2472 };
2475 for (unsigned i = 0; i < sizeof(shaderType) / sizeof(GLenum); ++i) { 2473 for (unsigned i = 0; i < sizeof(shaderType) / sizeof(GLenum); ++i) {
2476 WebGLShader* shader = program->getAttachedShader(shaderType[i]); 2474 WebGLShader* shader = program->getAttachedShader(shaderType[i]);
2477 if (shader) 2475 if (shader)
2478 shaderObjects.append(shader); 2476 shaderObjects.append(shader);
2479 } 2477 }
2480 return shaderObjects; 2478 return shaderObjects;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2586 { 2584 {
2587 if (tracker->draft() && !RuntimeEnabledFeatures::webGLDraftExtensionsEnabled ()) 2585 if (tracker->draft() && !RuntimeEnabledFeatures::webGLDraftExtensionsEnabled ())
2588 return false; 2586 return false;
2589 if (!tracker->supported(this)) 2587 if (!tracker->supported(this))
2590 return false; 2588 return false;
2591 return true; 2589 return true;
2592 } 2590 }
2593 2591
2594 ScriptValue WebGLRenderingContextBase::getExtension(ScriptState* scriptState, co nst String& name) 2592 ScriptValue WebGLRenderingContextBase::getExtension(ScriptState* scriptState, co nst String& name)
2595 { 2593 {
2596 RefPtrWillBeRawPtr<WebGLExtension> extension = nullptr; 2594 WebGLExtension* extension = nullptr;
2597 2595
2598 if (!isContextLost()) { 2596 if (!isContextLost()) {
2599 for (size_t i = 0; i < m_extensions.size(); ++i) { 2597 for (size_t i = 0; i < m_extensions.size(); ++i) {
2600 ExtensionTracker* tracker = m_extensions[i].get(); 2598 ExtensionTracker* tracker = m_extensions[i].get();
2601 if (tracker->matchesNameWithPrefixes(name)) { 2599 if (tracker->matchesNameWithPrefixes(name)) {
2602 if (extensionSupportedAndAllowed(tracker)) { 2600 if (extensionSupportedAndAllowed(tracker)) {
2603 extension = tracker->getExtension(this); 2601 extension = tracker->getExtension(this);
2604 if (extension) 2602 if (extension)
2605 m_extensionEnabled[extension->name()] = true; 2603 m_extensionEnabled[extension->name()] = true;
2606 } 2604 }
(...skipping 24 matching lines...) Expand all
2631 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name"); 2629 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name");
2632 return ScriptValue::createNull(scriptState); 2630 return ScriptValue::createNull(scriptState);
2633 } 2631 }
2634 2632
2635 ASSERT(attachmentObject->isTexture() || attachmentObject->isRenderbuffer()); 2633 ASSERT(attachmentObject->isTexture() || attachmentObject->isRenderbuffer());
2636 if (attachmentObject->isTexture()) { 2634 if (attachmentObject->isTexture()) {
2637 switch (pname) { 2635 switch (pname) {
2638 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 2636 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2639 return WebGLAny(scriptState, GL_TEXTURE); 2637 return WebGLAny(scriptState, GL_TEXTURE);
2640 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 2638 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2641 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(att achmentObject)); 2639 return WebGLAny(scriptState, attachmentObject);
2642 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: 2640 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2643 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: 2641 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2644 { 2642 {
2645 GLint value = 0; 2643 GLint value = 0;
2646 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value); 2644 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value);
2647 return WebGLAny(scriptState, value); 2645 return WebGLAny(scriptState, value);
2648 } 2646 }
2649 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: 2647 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT:
2650 if (extensionEnabled(EXTsRGBName)) { 2648 if (extensionEnabled(EXTsRGBName)) {
2651 GLint value = 0; 2649 GLint value = 0;
2652 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value); 2650 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value);
2653 return WebGLAny(scriptState, static_cast<unsigned>(value)); 2651 return WebGLAny(scriptState, static_cast<unsigned>(value));
2654 } 2652 }
2655 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment"); 2653 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment");
2656 return ScriptValue::createNull(scriptState); 2654 return ScriptValue::createNull(scriptState);
2657 default: 2655 default:
2658 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for texture attachment"); 2656 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for texture attachment");
2659 return ScriptValue::createNull(scriptState); 2657 return ScriptValue::createNull(scriptState);
2660 } 2658 }
2661 } else { 2659 } else {
2662 switch (pname) { 2660 switch (pname) {
2663 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 2661 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2664 return WebGLAny(scriptState, GL_RENDERBUFFER); 2662 return WebGLAny(scriptState, GL_RENDERBUFFER);
2665 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 2663 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2666 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(att achmentObject)); 2664 return WebGLAny(scriptState, attachmentObject);
2667 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: 2665 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT:
2668 if (extensionEnabled(EXTsRGBName) || isWebGL2OrHigher()) { 2666 if (extensionEnabled(EXTsRGBName) || isWebGL2OrHigher()) {
2669 GLint value = 0; 2667 GLint value = 0;
2670 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value); 2668 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value);
2671 return WebGLAny(scriptState, value); 2669 return WebGLAny(scriptState, value);
2672 } 2670 }
2673 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment"); 2671 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment");
2674 return ScriptValue::createNull(scriptState); 2672 return ScriptValue::createNull(scriptState);
2675 default: 2673 default:
2676 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment"); 2674 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment");
(...skipping 10 matching lines...) Expand all
2687 switch (pname) { 2685 switch (pname) {
2688 case GL_ACTIVE_TEXTURE: 2686 case GL_ACTIVE_TEXTURE:
2689 return getUnsignedIntParameter(scriptState, pname); 2687 return getUnsignedIntParameter(scriptState, pname);
2690 case GL_ALIASED_LINE_WIDTH_RANGE: 2688 case GL_ALIASED_LINE_WIDTH_RANGE:
2691 return getWebGLFloatArrayParameter(scriptState, pname); 2689 return getWebGLFloatArrayParameter(scriptState, pname);
2692 case GL_ALIASED_POINT_SIZE_RANGE: 2690 case GL_ALIASED_POINT_SIZE_RANGE:
2693 return getWebGLFloatArrayParameter(scriptState, pname); 2691 return getWebGLFloatArrayParameter(scriptState, pname);
2694 case GL_ALPHA_BITS: 2692 case GL_ALPHA_BITS:
2695 return getIntParameter(scriptState, pname); 2693 return getIntParameter(scriptState, pname);
2696 case GL_ARRAY_BUFFER_BINDING: 2694 case GL_ARRAY_BUFFER_BINDING:
2697 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(m_bound ArrayBuffer.get())); 2695 return WebGLAny(scriptState, m_boundArrayBuffer.get());
2698 case GL_BLEND: 2696 case GL_BLEND:
2699 return getBooleanParameter(scriptState, pname); 2697 return getBooleanParameter(scriptState, pname);
2700 case GL_BLEND_COLOR: 2698 case GL_BLEND_COLOR:
2701 return getWebGLFloatArrayParameter(scriptState, pname); 2699 return getWebGLFloatArrayParameter(scriptState, pname);
2702 case GL_BLEND_DST_ALPHA: 2700 case GL_BLEND_DST_ALPHA:
2703 return getUnsignedIntParameter(scriptState, pname); 2701 return getUnsignedIntParameter(scriptState, pname);
2704 case GL_BLEND_DST_RGB: 2702 case GL_BLEND_DST_RGB:
2705 return getUnsignedIntParameter(scriptState, pname); 2703 return getUnsignedIntParameter(scriptState, pname);
2706 case GL_BLEND_EQUATION_ALPHA: 2704 case GL_BLEND_EQUATION_ALPHA:
2707 return getUnsignedIntParameter(scriptState, pname); 2705 return getUnsignedIntParameter(scriptState, pname);
2708 case GL_BLEND_EQUATION_RGB: 2706 case GL_BLEND_EQUATION_RGB:
2709 return getUnsignedIntParameter(scriptState, pname); 2707 return getUnsignedIntParameter(scriptState, pname);
2710 case GL_BLEND_SRC_ALPHA: 2708 case GL_BLEND_SRC_ALPHA:
2711 return getUnsignedIntParameter(scriptState, pname); 2709 return getUnsignedIntParameter(scriptState, pname);
2712 case GL_BLEND_SRC_RGB: 2710 case GL_BLEND_SRC_RGB:
2713 return getUnsignedIntParameter(scriptState, pname); 2711 return getUnsignedIntParameter(scriptState, pname);
2714 case GL_BLUE_BITS: 2712 case GL_BLUE_BITS:
2715 return getIntParameter(scriptState, pname); 2713 return getIntParameter(scriptState, pname);
2716 case GL_COLOR_CLEAR_VALUE: 2714 case GL_COLOR_CLEAR_VALUE:
2717 return getWebGLFloatArrayParameter(scriptState, pname); 2715 return getWebGLFloatArrayParameter(scriptState, pname);
2718 case GL_COLOR_WRITEMASK: 2716 case GL_COLOR_WRITEMASK:
2719 return getBooleanArrayParameter(scriptState, pname); 2717 return getBooleanArrayParameter(scriptState, pname);
2720 case GL_COMPRESSED_TEXTURE_FORMATS: 2718 case GL_COMPRESSED_TEXTURE_FORMATS:
2721 return WebGLAny(scriptState, DOMUint32Array::create(m_compressedTextureF ormats.data(), m_compressedTextureFormats.size())); 2719 return WebGLAny(scriptState, DOMUint32Array::create(m_compressedTextureF ormats.data(), m_compressedTextureFormats.size()));
2722 case GL_CULL_FACE: 2720 case GL_CULL_FACE:
2723 return getBooleanParameter(scriptState, pname); 2721 return getBooleanParameter(scriptState, pname);
2724 case GL_CULL_FACE_MODE: 2722 case GL_CULL_FACE_MODE:
2725 return getUnsignedIntParameter(scriptState, pname); 2723 return getUnsignedIntParameter(scriptState, pname);
2726 case GL_CURRENT_PROGRAM: 2724 case GL_CURRENT_PROGRAM:
2727 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(m_curre ntProgram.get())); 2725 return WebGLAny(scriptState, m_currentProgram.get());
2728 case GL_DEPTH_BITS: 2726 case GL_DEPTH_BITS:
2729 if (!m_framebufferBinding && !m_requestedAttributes.depth()) 2727 if (!m_framebufferBinding && !m_requestedAttributes.depth())
2730 return WebGLAny(scriptState, intZero); 2728 return WebGLAny(scriptState, intZero);
2731 return getIntParameter(scriptState, pname); 2729 return getIntParameter(scriptState, pname);
2732 case GL_DEPTH_CLEAR_VALUE: 2730 case GL_DEPTH_CLEAR_VALUE:
2733 return getFloatParameter(scriptState, pname); 2731 return getFloatParameter(scriptState, pname);
2734 case GL_DEPTH_FUNC: 2732 case GL_DEPTH_FUNC:
2735 return getUnsignedIntParameter(scriptState, pname); 2733 return getUnsignedIntParameter(scriptState, pname);
2736 case GL_DEPTH_RANGE: 2734 case GL_DEPTH_RANGE:
2737 return getWebGLFloatArrayParameter(scriptState, pname); 2735 return getWebGLFloatArrayParameter(scriptState, pname);
2738 case GL_DEPTH_TEST: 2736 case GL_DEPTH_TEST:
2739 return getBooleanParameter(scriptState, pname); 2737 return getBooleanParameter(scriptState, pname);
2740 case GL_DEPTH_WRITEMASK: 2738 case GL_DEPTH_WRITEMASK:
2741 return getBooleanParameter(scriptState, pname); 2739 return getBooleanParameter(scriptState, pname);
2742 case GL_DITHER: 2740 case GL_DITHER:
2743 return getBooleanParameter(scriptState, pname); 2741 return getBooleanParameter(scriptState, pname);
2744 case GL_ELEMENT_ARRAY_BUFFER_BINDING: 2742 case GL_ELEMENT_ARRAY_BUFFER_BINDING:
2745 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(m_bound VertexArrayObject->boundElementArrayBuffer())); 2743 return WebGLAny(scriptState, m_boundVertexArrayObject->boundElementArray Buffer());
2746 case GL_FRAMEBUFFER_BINDING: 2744 case GL_FRAMEBUFFER_BINDING:
2747 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(m_frame bufferBinding.get())); 2745 return WebGLAny(scriptState, m_framebufferBinding.get());
2748 case GL_FRONT_FACE: 2746 case GL_FRONT_FACE:
2749 return getUnsignedIntParameter(scriptState, pname); 2747 return getUnsignedIntParameter(scriptState, pname);
2750 case GL_GENERATE_MIPMAP_HINT: 2748 case GL_GENERATE_MIPMAP_HINT:
2751 return getUnsignedIntParameter(scriptState, pname); 2749 return getUnsignedIntParameter(scriptState, pname);
2752 case GL_GREEN_BITS: 2750 case GL_GREEN_BITS:
2753 return getIntParameter(scriptState, pname); 2751 return getIntParameter(scriptState, pname);
2754 case GL_IMPLEMENTATION_COLOR_READ_FORMAT: 2752 case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
2755 return getIntParameter(scriptState, pname); 2753 return getIntParameter(scriptState, pname);
2756 case GL_IMPLEMENTATION_COLOR_READ_TYPE: 2754 case GL_IMPLEMENTATION_COLOR_READ_TYPE:
2757 return getIntParameter(scriptState, pname); 2755 return getIntParameter(scriptState, pname);
(...skipping 28 matching lines...) Expand all
2786 return getIntParameter(scriptState, pname); 2784 return getIntParameter(scriptState, pname);
2787 case GL_POLYGON_OFFSET_FACTOR: 2785 case GL_POLYGON_OFFSET_FACTOR:
2788 return getFloatParameter(scriptState, pname); 2786 return getFloatParameter(scriptState, pname);
2789 case GL_POLYGON_OFFSET_FILL: 2787 case GL_POLYGON_OFFSET_FILL:
2790 return getBooleanParameter(scriptState, pname); 2788 return getBooleanParameter(scriptState, pname);
2791 case GL_POLYGON_OFFSET_UNITS: 2789 case GL_POLYGON_OFFSET_UNITS:
2792 return getFloatParameter(scriptState, pname); 2790 return getFloatParameter(scriptState, pname);
2793 case GL_RED_BITS: 2791 case GL_RED_BITS:
2794 return getIntParameter(scriptState, pname); 2792 return getIntParameter(scriptState, pname);
2795 case GL_RENDERBUFFER_BINDING: 2793 case GL_RENDERBUFFER_BINDING:
2796 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(m_rende rbufferBinding.get())); 2794 return WebGLAny(scriptState, m_renderbufferBinding.get());
2797 case GL_RENDERER: 2795 case GL_RENDERER:
2798 return WebGLAny(scriptState, String("WebKit WebGL")); 2796 return WebGLAny(scriptState, String("WebKit WebGL"));
2799 case GL_SAMPLE_BUFFERS: 2797 case GL_SAMPLE_BUFFERS:
2800 return getIntParameter(scriptState, pname); 2798 return getIntParameter(scriptState, pname);
2801 case GL_SAMPLE_COVERAGE_INVERT: 2799 case GL_SAMPLE_COVERAGE_INVERT:
2802 return getBooleanParameter(scriptState, pname); 2800 return getBooleanParameter(scriptState, pname);
2803 case GL_SAMPLE_COVERAGE_VALUE: 2801 case GL_SAMPLE_COVERAGE_VALUE:
2804 return getFloatParameter(scriptState, pname); 2802 return getFloatParameter(scriptState, pname);
2805 case GL_SAMPLES: 2803 case GL_SAMPLES:
2806 return getIntParameter(scriptState, pname); 2804 return getIntParameter(scriptState, pname);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2842 return getIntParameter(scriptState, pname); 2840 return getIntParameter(scriptState, pname);
2843 case GL_STENCIL_TEST: 2841 case GL_STENCIL_TEST:
2844 return getBooleanParameter(scriptState, pname); 2842 return getBooleanParameter(scriptState, pname);
2845 case GL_STENCIL_VALUE_MASK: 2843 case GL_STENCIL_VALUE_MASK:
2846 return getUnsignedIntParameter(scriptState, pname); 2844 return getUnsignedIntParameter(scriptState, pname);
2847 case GL_STENCIL_WRITEMASK: 2845 case GL_STENCIL_WRITEMASK:
2848 return getUnsignedIntParameter(scriptState, pname); 2846 return getUnsignedIntParameter(scriptState, pname);
2849 case GL_SUBPIXEL_BITS: 2847 case GL_SUBPIXEL_BITS:
2850 return getIntParameter(scriptState, pname); 2848 return getIntParameter(scriptState, pname);
2851 case GL_TEXTURE_BINDING_2D: 2849 case GL_TEXTURE_BINDING_2D:
2852 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(m_textu reUnits[m_activeTextureUnit].m_texture2DBinding.get())); 2850 return WebGLAny(scriptState, m_textureUnits[m_activeTextureUnit].m_textu re2DBinding.get());
2853 case GL_TEXTURE_BINDING_CUBE_MAP: 2851 case GL_TEXTURE_BINDING_CUBE_MAP:
2854 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(m_textu reUnits[m_activeTextureUnit].m_textureCubeMapBinding.get())); 2852 return WebGLAny(scriptState, m_textureUnits[m_activeTextureUnit].m_textu reCubeMapBinding.get());
2855 case GL_UNPACK_ALIGNMENT: 2853 case GL_UNPACK_ALIGNMENT:
2856 return getIntParameter(scriptState, pname); 2854 return getIntParameter(scriptState, pname);
2857 case GC3D_UNPACK_FLIP_Y_WEBGL: 2855 case GC3D_UNPACK_FLIP_Y_WEBGL:
2858 return WebGLAny(scriptState, m_unpackFlipY); 2856 return WebGLAny(scriptState, m_unpackFlipY);
2859 case GC3D_UNPACK_PREMULTIPLY_ALPHA_WEBGL: 2857 case GC3D_UNPACK_PREMULTIPLY_ALPHA_WEBGL:
2860 return WebGLAny(scriptState, m_unpackPremultiplyAlpha); 2858 return WebGLAny(scriptState, m_unpackPremultiplyAlpha);
2861 case GC3D_UNPACK_COLORSPACE_CONVERSION_WEBGL: 2859 case GC3D_UNPACK_COLORSPACE_CONVERSION_WEBGL:
2862 return WebGLAny(scriptState, m_unpackColorspaceConversion); 2860 return WebGLAny(scriptState, m_unpackColorspaceConversion);
2863 case GL_VENDOR: 2861 case GL_VENDOR:
2864 return WebGLAny(scriptState, String("WebKit")); 2862 return WebGLAny(scriptState, String("WebKit"));
(...skipping 12 matching lines...) Expand all
2877 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled"); 2875 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled");
2878 return ScriptValue::createNull(scriptState); 2876 return ScriptValue::createNull(scriptState);
2879 case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL: 2877 case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL:
2880 if (extensionEnabled(WebGLDebugRendererInfoName)) 2878 if (extensionEnabled(WebGLDebugRendererInfoName))
2881 return WebGLAny(scriptState, webContext()->getString(GL_VENDOR)); 2879 return WebGLAny(scriptState, webContext()->getString(GL_VENDOR));
2882 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled"); 2880 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled");
2883 return ScriptValue::createNull(scriptState); 2881 return ScriptValue::createNull(scriptState);
2884 case GL_VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object 2882 case GL_VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object
2885 if (extensionEnabled(OESVertexArrayObjectName) || isWebGL2OrHigher()) { 2883 if (extensionEnabled(OESVertexArrayObjectName) || isWebGL2OrHigher()) {
2886 if (!m_boundVertexArrayObject->isDefaultObject()) 2884 if (!m_boundVertexArrayObject->isDefaultObject())
2887 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject> (m_boundVertexArrayObject.get())); 2885 return WebGLAny(scriptState, m_boundVertexArrayObject.get());
2888 return ScriptValue::createNull(scriptState); 2886 return ScriptValue::createNull(scriptState);
2889 } 2887 }
2890 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, OES_vertex_array_object not enabled"); 2888 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, OES_vertex_array_object not enabled");
2891 return ScriptValue::createNull(scriptState); 2889 return ScriptValue::createNull(scriptState);
2892 case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotropic 2890 case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotropic
2893 if (extensionEnabled(EXTTextureFilterAnisotropicName)) 2891 if (extensionEnabled(EXTTextureFilterAnisotropicName))
2894 return getUnsignedIntParameter(scriptState, GL_MAX_TEXTURE_MAX_ANISO TROPY_EXT); 2892 return getUnsignedIntParameter(scriptState, GL_MAX_TEXTURE_MAX_ANISO TROPY_EXT);
2895 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, EXT_texture_filter_anisotropic not enabled"); 2893 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, EXT_texture_filter_anisotropic not enabled");
2896 return ScriptValue::createNull(scriptState); 2894 return ScriptValue::createNull(scriptState);
2897 case GL_MAX_COLOR_ATTACHMENTS_EXT: // EXT_draw_buffers BEGIN 2895 case GL_MAX_COLOR_ATTACHMENTS_EXT: // EXT_draw_buffers BEGIN
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
3029 } 3027 }
3030 } 3028 }
3031 3029
3032 String WebGLRenderingContextBase::getShaderInfoLog(WebGLShader* shader) 3030 String WebGLRenderingContextBase::getShaderInfoLog(WebGLShader* shader)
3033 { 3031 {
3034 if (isContextLost() || !validateWebGLObject("getShaderInfoLog", shader)) 3032 if (isContextLost() || !validateWebGLObject("getShaderInfoLog", shader))
3035 return String(); 3033 return String();
3036 return ensureNotNull(webContext()->getShaderInfoLog(objectOrZero(shader))); 3034 return ensureNotNull(webContext()->getShaderInfoLog(objectOrZero(shader)));
3037 } 3035 }
3038 3036
3039 PassRefPtrWillBeRawPtr<WebGLShaderPrecisionFormat> WebGLRenderingContextBase::ge tShaderPrecisionFormat(GLenum shaderType, GLenum precisionType) 3037 WebGLShaderPrecisionFormat* WebGLRenderingContextBase::getShaderPrecisionFormat( GLenum shaderType, GLenum precisionType)
3040 { 3038 {
3041 if (isContextLost()) 3039 if (isContextLost())
3042 return nullptr; 3040 return nullptr;
3043 switch (shaderType) { 3041 switch (shaderType) {
3044 case GL_VERTEX_SHADER: 3042 case GL_VERTEX_SHADER:
3045 case GL_FRAGMENT_SHADER: 3043 case GL_FRAGMENT_SHADER:
3046 break; 3044 break;
3047 default: 3045 default:
3048 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid shader type"); 3046 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid shader type");
3049 return nullptr; 3047 return nullptr;
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
3325 notImplemented(); 3323 notImplemented();
3326 } 3324 }
3327 } 3325 }
3328 } 3326 }
3329 } 3327 }
3330 // If we get here, something went wrong in our unfortunately complex logic a bove 3328 // If we get here, something went wrong in our unfortunately complex logic a bove
3331 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unknown error"); 3329 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unknown error");
3332 return ScriptValue::createNull(scriptState); 3330 return ScriptValue::createNull(scriptState);
3333 } 3331 }
3334 3332
3335 PassRefPtrWillBeRawPtr<WebGLUniformLocation> WebGLRenderingContextBase::getUnifo rmLocation(WebGLProgram* program, const String& name) 3333 WebGLUniformLocation* WebGLRenderingContextBase::getUniformLocation(WebGLProgram * program, const String& name)
3336 { 3334 {
3337 if (isContextLost() || !validateWebGLObject("getUniformLocation", program)) 3335 if (isContextLost() || !validateWebGLObject("getUniformLocation", program))
3338 return nullptr; 3336 return nullptr;
3339 if (!validateLocationLength("getUniformLocation", name)) 3337 if (!validateLocationLength("getUniformLocation", name))
3340 return nullptr; 3338 return nullptr;
3341 if (!validateString("getUniformLocation", name)) 3339 if (!validateString("getUniformLocation", name))
3342 return nullptr; 3340 return nullptr;
3343 if (isPrefixReserved(name)) 3341 if (isPrefixReserved(name))
3344 return nullptr; 3342 return nullptr;
3345 if (!program->linkStatus()) { 3343 if (!program->linkStatus()) {
(...skipping 17 matching lines...) Expand all
3363 const WebGLVertexArrayObjectBase::VertexAttribState* state = m_boundVertexAr rayObject->getVertexAttribState(index); 3361 const WebGLVertexArrayObjectBase::VertexAttribState* state = m_boundVertexAr rayObject->getVertexAttribState(index);
3364 3362
3365 if ((extensionEnabled(ANGLEInstancedArraysName) || isWebGL2OrHigher()) 3363 if ((extensionEnabled(ANGLEInstancedArraysName) || isWebGL2OrHigher())
3366 && pname == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE) 3364 && pname == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE)
3367 return WebGLAny(scriptState, state->divisor); 3365 return WebGLAny(scriptState, state->divisor);
3368 3366
3369 switch (pname) { 3367 switch (pname) {
3370 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: 3368 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
3371 if (!state->bufferBinding || !state->bufferBinding->object()) 3369 if (!state->bufferBinding || !state->bufferBinding->object())
3372 return ScriptValue::createNull(scriptState); 3370 return ScriptValue::createNull(scriptState);
3373 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(state-> bufferBinding.get())); 3371 return WebGLAny(scriptState, state->bufferBinding.get());
3374 case GL_VERTEX_ATTRIB_ARRAY_ENABLED: 3372 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
3375 return WebGLAny(scriptState, state->enabled); 3373 return WebGLAny(scriptState, state->enabled);
3376 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: 3374 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
3377 return WebGLAny(scriptState, state->normalized); 3375 return WebGLAny(scriptState, state->normalized);
3378 case GL_VERTEX_ATTRIB_ARRAY_SIZE: 3376 case GL_VERTEX_ATTRIB_ARRAY_SIZE:
3379 return WebGLAny(scriptState, state->size); 3377 return WebGLAny(scriptState, state->size);
3380 case GL_VERTEX_ATTRIB_ARRAY_STRIDE: 3378 case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
3381 return WebGLAny(scriptState, state->originalStride); 3379 return WebGLAny(scriptState, state->originalStride);
3382 case GL_VERTEX_ATTRIB_ARRAY_TYPE: 3380 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
3383 return WebGLAny(scriptState, state->type); 3381 return WebGLAny(scriptState, state->type);
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
3957 webContext()->stencilOp(fail, zfail, zpass); 3955 webContext()->stencilOp(fail, zfail, zpass);
3958 } 3956 }
3959 3957
3960 void WebGLRenderingContextBase::stencilOpSeparate(GLenum face, GLenum fail, GLen um zfail, GLenum zpass) 3958 void WebGLRenderingContextBase::stencilOpSeparate(GLenum face, GLenum fail, GLen um zfail, GLenum zpass)
3961 { 3959 {
3962 if (isContextLost()) 3960 if (isContextLost())
3963 return; 3961 return;
3964 webContext()->stencilOpSeparate(face, fail, zfail, zpass); 3962 webContext()->stencilOpSeparate(face, fail, zfail, zpass);
3965 } 3963 }
3966 3964
3967 PassRefPtrWillBeRawPtr<CHROMIUMValuebuffer> WebGLRenderingContextBase::createVal uebufferCHROMIUM() 3965 CHROMIUMValuebuffer* WebGLRenderingContextBase::createValuebufferCHROMIUM()
3968 { 3966 {
3969 if (isContextLost()) 3967 if (isContextLost())
3970 return nullptr; 3968 return nullptr;
3971 RefPtrWillBeRawPtr<CHROMIUMValuebuffer> o = CHROMIUMValuebuffer::create(this ); 3969 CHROMIUMValuebuffer* o = CHROMIUMValuebuffer::create(this);
3972 addSharedObject(o.get()); 3970 addSharedObject(o);
3973 return o.release(); 3971 return o;
3974 } 3972 }
3975 3973
3976 void WebGLRenderingContextBase::deleteValuebufferCHROMIUM(CHROMIUMValuebuffer *v aluebuffer) 3974 void WebGLRenderingContextBase::deleteValuebufferCHROMIUM(CHROMIUMValuebuffer *v aluebuffer)
3977 { 3975 {
3978 if (!deleteObject(valuebuffer)) 3976 if (!deleteObject(valuebuffer))
3979 return; 3977 return;
3980 if (valuebuffer == m_valuebufferBinding) 3978 if (valuebuffer == m_valuebufferBinding)
3981 m_valuebufferBinding = nullptr; 3979 m_valuebufferBinding = nullptr;
3982 } 3980 }
3983 3981
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
5139 5137
5140 void WebGLRenderingContextBase::addContextObject(WebGLContextObject* object) 5138 void WebGLRenderingContextBase::addContextObject(WebGLContextObject* object)
5141 { 5139 {
5142 ASSERT(!isContextLost()); 5140 ASSERT(!isContextLost());
5143 m_contextObjects.add(object); 5141 m_contextObjects.add(object);
5144 } 5142 }
5145 5143
5146 void WebGLRenderingContextBase::detachAndRemoveAllObjects() 5144 void WebGLRenderingContextBase::detachAndRemoveAllObjects()
5147 { 5145 {
5148 while (m_contextObjects.size() > 0) { 5146 while (m_contextObjects.size() > 0) {
5149 WillBeHeapHashSet<RawPtrWillBeWeakMember<WebGLContextObject>>::iterator it = m_contextObjects.begin(); 5147 auto it = m_contextObjects.begin();
haraken 2015/08/04 00:06:52 It would be worth having a comment and mention tha
peria 2015/08/04 09:10:26 Done.
5150 (*it)->detachContext(); 5148 (*it)->detachContext();
5151 } 5149 }
5152 } 5150 }
5153 5151
5154 void WebGLRenderingContextBase::stop() 5152 void WebGLRenderingContextBase::stop()
5155 { 5153 {
5156 if (!isContextLost()) { 5154 if (!isContextLost()) {
5157 // Never attempt to restore the context because the page is being torn d own. 5155 // Never attempt to restore the context because the page is being torn d own.
5158 forceLostContext(SyntheticLostContext, Manual); 5156 forceLostContext(SyntheticLostContext, Manual);
5159 } 5157 }
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
6027 return false; 6025 return false;
6028 } 6026 }
6029 return true; 6027 return true;
6030 } 6028 }
6031 6029
6032 WebGLBuffer* WebGLRenderingContextBase::validateBufferDataTarget(const char* fun ctionName, GLenum target) 6030 WebGLBuffer* WebGLRenderingContextBase::validateBufferDataTarget(const char* fun ctionName, GLenum target)
6033 { 6031 {
6034 WebGLBuffer* buffer = nullptr; 6032 WebGLBuffer* buffer = nullptr;
6035 switch (target) { 6033 switch (target) {
6036 case GL_ELEMENT_ARRAY_BUFFER: 6034 case GL_ELEMENT_ARRAY_BUFFER:
6037 buffer = m_boundVertexArrayObject->boundElementArrayBuffer().get(); 6035 buffer = m_boundVertexArrayObject->boundElementArrayBuffer();
6038 break; 6036 break;
6039 case GL_ARRAY_BUFFER: 6037 case GL_ARRAY_BUFFER:
6040 buffer = m_boundArrayBuffer.get(); 6038 buffer = m_boundArrayBuffer.get();
6041 break; 6039 break;
6042 default: 6040 default:
6043 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); 6041 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target");
6044 return nullptr; 6042 return nullptr;
6045 } 6043 }
6046 if (!buffer) { 6044 if (!buffer) {
6047 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no buffer"); 6045 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no buffer");
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
6553 DEFINE_TRACE(WebGLRenderingContextBase::TextureUnitState) 6551 DEFINE_TRACE(WebGLRenderingContextBase::TextureUnitState)
6554 { 6552 {
6555 visitor->trace(m_texture2DBinding); 6553 visitor->trace(m_texture2DBinding);
6556 visitor->trace(m_textureCubeMapBinding); 6554 visitor->trace(m_textureCubeMapBinding);
6557 visitor->trace(m_texture3DBinding); 6555 visitor->trace(m_texture3DBinding);
6558 visitor->trace(m_texture2DArrayBinding); 6556 visitor->trace(m_texture2DArrayBinding);
6559 } 6557 }
6560 6558
6561 DEFINE_TRACE(WebGLRenderingContextBase) 6559 DEFINE_TRACE(WebGLRenderingContextBase)
6562 { 6560 {
6563 #if ENABLE(OILPAN)
6564 visitor->trace(m_contextObjects); 6561 visitor->trace(m_contextObjects);
6565 visitor->trace(m_contextLostCallbackAdapter); 6562 visitor->trace(m_contextLostCallbackAdapter);
6566 visitor->trace(m_errorMessageCallbackAdapter); 6563 visitor->trace(m_errorMessageCallbackAdapter);
6567 visitor->trace(m_boundArrayBuffer); 6564 visitor->trace(m_boundArrayBuffer);
6568 visitor->trace(m_defaultVertexArrayObject); 6565 visitor->trace(m_defaultVertexArrayObject);
6569 visitor->trace(m_boundVertexArrayObject); 6566 visitor->trace(m_boundVertexArrayObject);
6570 visitor->trace(m_vertexAttrib0Buffer); 6567 visitor->trace(m_vertexAttrib0Buffer);
6571 visitor->trace(m_currentProgram); 6568 visitor->trace(m_currentProgram);
6572 visitor->trace(m_framebufferBinding); 6569 visitor->trace(m_framebufferBinding);
6573 visitor->trace(m_renderbufferBinding); 6570 visitor->trace(m_renderbufferBinding);
6574 visitor->trace(m_valuebufferBinding); 6571 visitor->trace(m_valuebufferBinding);
6575 visitor->trace(m_textureUnits); 6572 visitor->trace(m_textureUnits);
6576 visitor->trace(m_blackTexture2D); 6573 visitor->trace(m_blackTexture2D);
6577 visitor->trace(m_blackTextureCubeMap); 6574 visitor->trace(m_blackTextureCubeMap);
6578 visitor->trace(m_requestedAttributes);
6579 visitor->trace(m_extensions); 6575 visitor->trace(m_extensions);
6580 #endif
6581 CanvasRenderingContext::trace(visitor); 6576 CanvasRenderingContext::trace(visitor);
6582 } 6577 }
6583 6578
6584 int WebGLRenderingContextBase::externallyAllocatedBytesPerPixel() 6579 int WebGLRenderingContextBase::externallyAllocatedBytesPerPixel()
6585 { 6580 {
6586 if (isContextLost()) 6581 if (isContextLost())
6587 return 0; 6582 return 0;
6588 6583
6589 int bytesPerPixel = 4; 6584 int bytesPerPixel = 4;
6590 int totalBytesPerPixel = bytesPerPixel * 2; // WebGL's front and back color buffers. 6585 int totalBytesPerPixel = bytesPerPixel * 2; // WebGL's front and back color buffers.
(...skipping 15 matching lines...) Expand all
6606 6601
6607 return totalBytesPerPixel; 6602 return totalBytesPerPixel;
6608 } 6603 }
6609 6604
6610 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const 6605 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const
6611 { 6606 {
6612 return m_drawingBuffer.get(); 6607 return m_drawingBuffer.get();
6613 } 6608 }
6614 6609
6615 } // namespace blink 6610 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698