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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (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
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 #include "wtf/text/StringBuilder.h" 98 #include "wtf/text/StringBuilder.h"
99 99
100 namespace blink { 100 namespace blink {
101 101
102 namespace { 102 namespace {
103 103
104 const double secondsBetweenRestoreAttempts = 1.0; 104 const double secondsBetweenRestoreAttempts = 1.0;
105 const int maxGLErrorsAllowedToConsole = 256; 105 const int maxGLErrorsAllowedToConsole = 256;
106 const unsigned maxGLActiveContexts = 16; 106 const unsigned maxGLActiveContexts = 16;
107 107
108 using WebGLRenderingContextBaseSet = WillBePersistentHeapHashSet<RawPtrWillBeWea kMember<WebGLRenderingContextBase>>; 108 using WebGLRenderingContextBaseSet = PersistentHeapHashSet<WeakMember<WebGLRende ringContextBase>>;
109 WebGLRenderingContextBaseSet& activeContexts() 109 WebGLRenderingContextBaseSet& activeContexts()
110 { 110 {
111 DEFINE_STATIC_LOCAL(WebGLRenderingContextBaseSet, activeContexts, ()); 111 DEFINE_STATIC_LOCAL(WebGLRenderingContextBaseSet, activeContexts, ());
112 return activeContexts; 112 return activeContexts;
113 } 113 }
114 114
115 using WebGLRenderingContextBaseMap = WillBePersistentHeapHashMap<RawPtrWillBeWea kMember<WebGLRenderingContextBase>, int>; 115 using WebGLRenderingContextBaseMap = PersistentHeapHashMap<WeakMember<WebGLRende ringContextBase>, int>;
116 WebGLRenderingContextBaseMap& forciblyEvictedContexts() 116 WebGLRenderingContextBaseMap& forciblyEvictedContexts()
117 { 117 {
118 DEFINE_STATIC_LOCAL(WebGLRenderingContextBaseMap, forciblyEvictedContexts, ( )); 118 DEFINE_STATIC_LOCAL(WebGLRenderingContextBaseMap, forciblyEvictedContexts, ( ));
119 return forciblyEvictedContexts; 119 return forciblyEvictedContexts;
120 } 120 }
121 121
122 } // namespace 122 } // namespace
123 123
124 void WebGLRenderingContextBase::forciblyLoseOldestContext(const String& reason) 124 void WebGLRenderingContextBase::forciblyLoseOldestContext(const String& reason)
125 { 125 {
126 WebGLRenderingContextBase* candidate = oldestContext(); 126 WebGLRenderingContextBase* candidate = oldestContext();
127 if (!candidate) 127 if (!candidate)
128 return; 128 return;
129 129
130 // This context could belong to a dead page and the last JavaScript referenc e has already 130 // This context could belong to a dead page and the last JavaScript referenc e has already
131 // been lost. Garbage collection might be triggered in the middle of this fu nction, for 131 // been lost. Garbage collection might be triggered in the middle of this fu nction, for
132 // example, printWarningToConsole() causes an upcall to JavaScript. 132 // example, printWarningToConsole() causes an upcall to JavaScript.
133 // Must make sure that the context is not deleted until the call stack unwin ds. 133 // Must make sure that the context is not deleted until the call stack unwin ds.
134 RefPtrWillBeRawPtr<WebGLRenderingContextBase> protect(candidate); 134 RawPtr<WebGLRenderingContextBase> protect(candidate);
135 135
136 candidate->printWarningToConsole(reason); 136 candidate->printWarningToConsole(reason);
137 InspectorInstrumentation::didFireWebGLWarning(candidate->canvas()); 137 InspectorInstrumentation::didFireWebGLWarning(candidate->canvas());
138 138
139 // This will call deactivateContext once the context has actually been lost. 139 // This will call deactivateContext once the context has actually been lost.
140 candidate->forceLostContext(WebGLRenderingContextBase::SyntheticLostContext, WebGLRenderingContextBase::WhenAvailable); 140 candidate->forceLostContext(WebGLRenderingContextBase::SyntheticLostContext, WebGLRenderingContextBase::WhenAvailable);
141 } 141 }
142 142
143 WebGLRenderingContextBase* WebGLRenderingContextBase::oldestContext() 143 WebGLRenderingContextBase* WebGLRenderingContextBase::oldestContext()
144 { 144 {
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 : m_context(context) 453 : m_context(context)
454 { 454 {
455 } 455 }
456 456
457 ~ScopedTexture2DRestorer() 457 ~ScopedTexture2DRestorer()
458 { 458 {
459 m_context->restoreCurrentTexture2D(); 459 m_context->restoreCurrentTexture2D();
460 } 460 }
461 461
462 private: 462 private:
463 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; 463 Member<WebGLRenderingContextBase> m_context;
464 }; 464 };
465 465
466 class ScopedFramebufferRestorer { 466 class ScopedFramebufferRestorer {
467 STACK_ALLOCATED(); 467 STACK_ALLOCATED();
468 public: 468 public:
469 explicit ScopedFramebufferRestorer(WebGLRenderingContextBase* context) 469 explicit ScopedFramebufferRestorer(WebGLRenderingContextBase* context)
470 : m_context(context) 470 : m_context(context)
471 { 471 {
472 } 472 }
473 473
474 ~ScopedFramebufferRestorer() 474 ~ScopedFramebufferRestorer()
475 { 475 {
476 m_context->restoreCurrentFramebuffer(); 476 m_context->restoreCurrentFramebuffer();
477 } 477 }
478 478
479 private: 479 private:
480 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; 480 Member<WebGLRenderingContextBase> m_context;
481 }; 481 };
482 482
483 class WebGLRenderingContextLostCallback final : public GarbageCollectedFinalized <WebGLRenderingContextLostCallback>, public WebGraphicsContext3D::WebGraphicsCon textLostCallback { 483 class WebGLRenderingContextLostCallback final : public GarbageCollectedFinalized <WebGLRenderingContextLostCallback>, public WebGraphicsContext3D::WebGraphicsCon textLostCallback {
484 public: 484 public:
485 static WebGLRenderingContextLostCallback* create(WebGLRenderingContextBase* context) 485 static WebGLRenderingContextLostCallback* create(WebGLRenderingContextBase* context)
486 { 486 {
487 return new WebGLRenderingContextLostCallback(context); 487 return new WebGLRenderingContextLostCallback(context);
488 } 488 }
489 489
490 ~WebGLRenderingContextLostCallback() override { } 490 ~WebGLRenderingContextLostCallback() override { }
491 491
492 virtual void onContextLost() { m_context->forceLostContext(WebGLRenderingCon textBase::RealLostContext, WebGLRenderingContextBase::Auto); } 492 virtual void onContextLost() { m_context->forceLostContext(WebGLRenderingCon textBase::RealLostContext, WebGLRenderingContextBase::Auto); }
493 493
494 DEFINE_INLINE_TRACE() 494 DEFINE_INLINE_TRACE()
495 { 495 {
496 visitor->trace(m_context); 496 visitor->trace(m_context);
497 } 497 }
498 498
499 private: 499 private:
500 explicit WebGLRenderingContextLostCallback(WebGLRenderingContextBase* contex t) 500 explicit WebGLRenderingContextLostCallback(WebGLRenderingContextBase* contex t)
501 : m_context(context) { } 501 : m_context(context) { }
502 502
503 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; 503 Member<WebGLRenderingContextBase> m_context;
504 }; 504 };
505 505
506 class WebGLRenderingContextErrorMessageCallback final : public GarbageCollectedF inalized<WebGLRenderingContextErrorMessageCallback>, public WebGraphicsContext3D ::WebGraphicsErrorMessageCallback { 506 class WebGLRenderingContextErrorMessageCallback final : public GarbageCollectedF inalized<WebGLRenderingContextErrorMessageCallback>, public WebGraphicsContext3D ::WebGraphicsErrorMessageCallback {
507 public: 507 public:
508 static WebGLRenderingContextErrorMessageCallback* create(WebGLRenderingConte xtBase* context) 508 static WebGLRenderingContextErrorMessageCallback* create(WebGLRenderingConte xtBase* context)
509 { 509 {
510 return new WebGLRenderingContextErrorMessageCallback(context); 510 return new WebGLRenderingContextErrorMessageCallback(context);
511 } 511 }
512 512
513 ~WebGLRenderingContextErrorMessageCallback() override { } 513 ~WebGLRenderingContextErrorMessageCallback() override { }
514 514
515 virtual void onErrorMessage(const WebString& message, WGC3Dint) 515 virtual void onErrorMessage(const WebString& message, WGC3Dint)
516 { 516 {
517 if (m_context->m_synthesizedErrorsToConsole) 517 if (m_context->m_synthesizedErrorsToConsole)
518 m_context->printGLErrorToConsole(message); 518 m_context->printGLErrorToConsole(message);
519 InspectorInstrumentation::didFireWebGLErrorOrWarning(m_context->canvas() , message); 519 InspectorInstrumentation::didFireWebGLErrorOrWarning(m_context->canvas() , message);
520 } 520 }
521 521
522 DEFINE_INLINE_TRACE() 522 DEFINE_INLINE_TRACE()
523 { 523 {
524 visitor->trace(m_context); 524 visitor->trace(m_context);
525 } 525 }
526 526
527 private: 527 private:
528 explicit WebGLRenderingContextErrorMessageCallback(WebGLRenderingContextBase * context) 528 explicit WebGLRenderingContextErrorMessageCallback(WebGLRenderingContextBase * context)
529 : m_context(context) { } 529 : m_context(context) { }
530 530
531 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; 531 Member<WebGLRenderingContextBase> m_context;
532 }; 532 };
533 533
534 static void formatWebGLStatusString(const String& glInfo, const String& infostri ng, String& statusMessage) 534 static void formatWebGLStatusString(const String& glInfo, const String& infostri ng, String& statusMessage)
535 { 535 {
536 if (!infostring.isEmpty()) 536 if (!infostring.isEmpty())
537 statusMessage.append(", " + glInfo + " = " + infostring); 537 statusMessage.append(", " + glInfo + " = " + infostring);
538 } 538 }
539 539
540 static String extractWebGLContextCreationError(const WebGraphicsContext3D::WebGr aphicsInfo& info) 540 static String extractWebGLContextCreationError(const WebGraphicsContext3D::WebGr aphicsInfo& info)
541 { 541 {
(...skipping 3920 matching lines...) Expand 10 before | Expand all | Expand 10 after
4462 } 4462 }
4463 4463
4464 // Normal pure SW path. 4464 // Normal pure SW path.
4465 RefPtr<Image> image = videoFrameToImage(video); 4465 RefPtr<Image> image = videoFrameToImage(video);
4466 if (!image) 4466 if (!image)
4467 return; 4467 return;
4468 texImage2DImpl(target, level, internalformat, format, type, image.get(), Web GLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha); 4468 texImage2DImpl(target, level, internalformat, format, type, image.get(), Web GLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha);
4469 } 4469 }
4470 4470
4471 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLint int ernalformat, 4471 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLint int ernalformat,
4472 GLenum format, GLenum type, PassRefPtrWillBeRawPtr<ImageBitmap> bitmap, Exce ptionState& exceptionState) 4472 GLenum format, GLenum type, RawPtr<ImageBitmap> bitmap, ExceptionState& exce ptionState)
4473 { 4473 {
4474 ASSERT(bitmap->bitmapImage()); 4474 ASSERT(bitmap->bitmapImage());
4475 if (isContextLost() || !validateImageBitmap("texImage2D", bitmap.get(), exce ptionState) || !validateTexFunc("texImage2D", TexImage, SourceImageBitmap, targe t, level, internalformat, bitmap->width(), bitmap->height(), 1, 0, format, type, 0, 0, 0)) 4475 if (isContextLost() || !validateImageBitmap("texImage2D", bitmap.get(), exce ptionState) || !validateTexFunc("texImage2D", TexImage, SourceImageBitmap, targe t, level, internalformat, bitmap->width(), bitmap->height(), 1, 0, format, type, 0, 0, 0))
4476 return; 4476 return;
4477 StaticBitmapImage* imageForRender = bitmap->bitmapImage(); 4477 StaticBitmapImage* imageForRender = bitmap->bitmapImage();
4478 texImage2DImpl(target, level, internalformat, format, type, imageForRender, WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha); 4478 texImage2DImpl(target, level, internalformat, format, type, imageForRender, WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha);
4479 } 4479 }
4480 4480
4481 void WebGLRenderingContextBase::texParameter(GLenum target, GLenum pname, GLfloa t paramf, GLint parami, bool isFloat) 4481 void WebGLRenderingContextBase::texParameter(GLenum target, GLenum pname, GLfloa t paramf, GLint parami, bool isFloat)
4482 { 4482 {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
4684 || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLVideoElement , target, level, 0, video->videoWidth(), video->videoHeight(), 1, 0, format, typ e, xoffset, yoffset, 0)) 4684 || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLVideoElement , target, level, 0, video->videoWidth(), video->videoHeight(), 1, 0, format, typ e, xoffset, yoffset, 0))
4685 return; 4685 return;
4686 4686
4687 RefPtr<Image> image = videoFrameToImage(video); 4687 RefPtr<Image> image = videoFrameToImage(video);
4688 if (!image) 4688 if (!image)
4689 return; 4689 return;
4690 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get() , WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha); 4690 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get() , WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha);
4691 } 4691 }
4692 4692
4693 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 4693 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
4694 GLenum format, GLenum type, PassRefPtrWillBeRawPtr<ImageBitmap> bitmap, Exce ptionState& exceptionState) 4694 GLenum format, GLenum type, RawPtr<ImageBitmap> bitmap, ExceptionState& exce ptionState)
4695 { 4695 {
4696 ASSERT(bitmap->bitmapImage()); 4696 ASSERT(bitmap->bitmapImage());
4697 if (isContextLost() || !validateImageBitmap("texSubImage2D", bitmap.get(), e xceptionState) || !validateTexFunc("texSubImage2D", TexSubImage, SourceImageBitm ap, target, level, 0, bitmap->width(), bitmap->height(), 1, 0, format, type, 0, 0, 0)) 4697 if (isContextLost() || !validateImageBitmap("texSubImage2D", bitmap.get(), e xceptionState) || !validateTexFunc("texSubImage2D", TexSubImage, SourceImageBitm ap, target, level, 0, bitmap->width(), bitmap->height(), 1, 0, format, type, 0, 0, 0))
4698 return; 4698 return;
4699 StaticBitmapImage* imageForRender = bitmap->bitmapImage(); 4699 StaticBitmapImage* imageForRender = bitmap->bitmapImage();
4700 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen der, WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha ); 4700 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen der, WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha );
4701 } 4701 }
4702 4702
4703 void WebGLRenderingContextBase::uniform1f(const WebGLUniformLocation* location, GLfloat x) 4703 void WebGLRenderingContextBase::uniform1f(const WebGLUniformLocation* location, GLfloat x)
4704 { 4704 {
(...skipping 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after
6457 if (m_framebufferBinding && m_framebufferBinding->checkDepthStencilStatus(&r eason) != GL_FRAMEBUFFER_COMPLETE) { 6457 if (m_framebufferBinding && m_framebufferBinding->checkDepthStencilStatus(&r eason) != GL_FRAMEBUFFER_COMPLETE) {
6458 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason ); 6458 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason );
6459 return false; 6459 return false;
6460 } 6460 }
6461 6461
6462 return true; 6462 return true;
6463 } 6463 }
6464 6464
6465 void WebGLRenderingContextBase::dispatchContextLostEvent(Timer<WebGLRenderingCon textBase>*) 6465 void WebGLRenderingContextBase::dispatchContextLostEvent(Timer<WebGLRenderingCon textBase>*)
6466 { 6466 {
6467 RefPtrWillBeRawPtr<WebGLContextEvent> event = WebGLContextEvent::create(Even tTypeNames::webglcontextlost, false, true, ""); 6467 RawPtr<WebGLContextEvent> event = WebGLContextEvent::create(EventTypeNames:: webglcontextlost, false, true, "");
6468 canvas()->dispatchEvent(event); 6468 canvas()->dispatchEvent(event);
6469 m_restoreAllowed = event->defaultPrevented(); 6469 m_restoreAllowed = event->defaultPrevented();
6470 if (m_restoreAllowed) { 6470 if (m_restoreAllowed) {
6471 if (m_autoRecoveryMethod == Auto) 6471 if (m_autoRecoveryMethod == Auto)
6472 m_restoreTimer.startOneShot(0, BLINK_FROM_HERE); 6472 m_restoreTimer.startOneShot(0, BLINK_FROM_HERE);
6473 } 6473 }
6474 } 6474 }
6475 6475
6476 void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB ase>*) 6476 void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB ase>*)
6477 { 6477 {
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
6844 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); 6844 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
6845 } 6845 }
6846 6846
6847 void WebGLRenderingContextBase::restoreUnpackParameters() 6847 void WebGLRenderingContextBase::restoreUnpackParameters()
6848 { 6848 {
6849 if (m_unpackAlignment != 1) 6849 if (m_unpackAlignment != 1)
6850 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); 6850 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
6851 } 6851 }
6852 6852
6853 } // namespace blink 6853 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698