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

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

Issue 1864243004: Remove RawPtr from Source/modules Part 2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 127
128 } // namespace 128 } // namespace
129 129
130 void WebGLRenderingContextBase::forciblyLoseOldestContext(const String& reason) 130 void WebGLRenderingContextBase::forciblyLoseOldestContext(const String& reason)
131 { 131 {
132 WebGLRenderingContextBase* candidate = oldestContext(); 132 WebGLRenderingContextBase* candidate = oldestContext();
133 if (!candidate) 133 if (!candidate)
134 return; 134 return;
135 135
136 // This context could belong to a dead page and the last JavaScript referenc e has already
137 // been lost. Garbage collection might be triggered in the middle of this fu nction, for
138 // example, printWarningToConsole() causes an upcall to JavaScript.
139 // Must make sure that the context is not deleted until the call stack unwin ds.
140 RawPtr<WebGLRenderingContextBase> protect(candidate);
141
142 candidate->printWarningToConsole(reason); 136 candidate->printWarningToConsole(reason);
143 InspectorInstrumentation::didFireWebGLWarning(candidate->canvas()); 137 InspectorInstrumentation::didFireWebGLWarning(candidate->canvas());
144 138
145 // This will call deactivateContext once the context has actually been lost. 139 // This will call deactivateContext once the context has actually been lost.
146 candidate->forceLostContext(WebGLRenderingContextBase::SyntheticLostContext, WebGLRenderingContextBase::WhenAvailable); 140 candidate->forceLostContext(WebGLRenderingContextBase::SyntheticLostContext, WebGLRenderingContextBase::WhenAvailable);
147 } 141 }
148 142
149 WebGLRenderingContextBase* WebGLRenderingContextBase::oldestContext() 143 WebGLRenderingContextBase* WebGLRenderingContextBase::oldestContext()
150 { 144 {
151 if (activeContexts().isEmpty()) 145 if (activeContexts().isEmpty())
(...skipping 4081 matching lines...) Expand 10 before | Expand all | Expand 10 after
4233 } 4227 }
4234 4228
4235 // Normal pure SW path. 4229 // Normal pure SW path.
4236 RefPtr<Image> image = videoFrameToImage(video); 4230 RefPtr<Image> image = videoFrameToImage(video);
4237 if (!image) 4231 if (!image)
4238 return; 4232 return;
4239 texImage2DImpl(target, level, internalformat, format, type, image.get(), Web GLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha); 4233 texImage2DImpl(target, level, internalformat, format, type, image.get(), Web GLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha);
4240 } 4234 }
4241 4235
4242 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLint int ernalformat, 4236 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLint int ernalformat,
4243 GLenum format, GLenum type, RawPtr<ImageBitmap> bitmap, ExceptionState& exce ptionState) 4237 GLenum format, GLenum type, ImageBitmap* bitmap, ExceptionState& exceptionSt ate)
4244 { 4238 {
4245 if (isContextLost()) 4239 if (isContextLost())
4246 return; 4240 return;
4247 if (!validateImageBitmap("texImage2D", bitmap.get(), exceptionState)) 4241 if (!validateImageBitmap("texImage2D", bitmap, exceptionState))
4248 return; 4242 return;
4249 if (!validateTexture2DBinding("texImage2D", target)) 4243 if (!validateTexture2DBinding("texImage2D", target))
4250 return; 4244 return;
4251 if (!validateTexFunc("texImage2D", TexImage, SourceImageBitmap, target, leve l, internalformat, bitmap->width(), bitmap->height(), 1, 0, format, type, 0, 0, 0)) 4245 if (!validateTexFunc("texImage2D", TexImage, SourceImageBitmap, target, leve l, internalformat, bitmap->width(), bitmap->height(), 1, 0, format, type, 0, 0, 0))
4252 return; 4246 return;
4253 ASSERT(bitmap->bitmapImage()); 4247 ASSERT(bitmap->bitmapImage());
4254 OwnPtr<uint8_t[]> pixelData = bitmap->copyBitmapData(bitmap->isPremultiplied () ? PremultiplyAlpha : DontPremultiplyAlpha); 4248 OwnPtr<uint8_t[]> pixelData = bitmap->copyBitmapData(bitmap->isPremultiplied () ? PremultiplyAlpha : DontPremultiplyAlpha);
4255 Vector<uint8_t> data; 4249 Vector<uint8_t> data;
4256 bool needConversion = true; 4250 bool needConversion = true;
4257 if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) { 4251 if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
4499 if (!validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLVideoElement, t arget, level, 0, video->videoWidth(), video->videoHeight(), 1, 0, format, type, xoffset, yoffset, 0)) 4493 if (!validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLVideoElement, t arget, level, 0, video->videoWidth(), video->videoHeight(), 1, 0, format, type, xoffset, yoffset, 0))
4500 return; 4494 return;
4501 4495
4502 RefPtr<Image> image = videoFrameToImage(video); 4496 RefPtr<Image> image = videoFrameToImage(video);
4503 if (!image) 4497 if (!image)
4504 return; 4498 return;
4505 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get() , WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha); 4499 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get() , WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha);
4506 } 4500 }
4507 4501
4508 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 4502 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
4509 GLenum format, GLenum type, RawPtr<ImageBitmap> bitmap, ExceptionState& exce ptionState) 4503 GLenum format, GLenum type, ImageBitmap* bitmap, ExceptionState& exceptionSt ate)
4510 { 4504 {
4511 if (isContextLost()) 4505 if (isContextLost())
4512 return; 4506 return;
4513 if (!validateImageBitmap("texSubImage2D", bitmap.get(), exceptionState)) 4507 if (!validateImageBitmap("texSubImage2D", bitmap, exceptionState))
4514 return; 4508 return;
4515 if (!validateTexture2DBinding("texSubImage2D", target)) 4509 if (!validateTexture2DBinding("texSubImage2D", target))
4516 return; 4510 return;
4517 if (!validateTexFunc("texSubImage2D", TexSubImage, SourceImageBitmap, target , level, 0, bitmap->width(), bitmap->height(), 1, 0, format, type, 0, 0, 0)) 4511 if (!validateTexFunc("texSubImage2D", TexSubImage, SourceImageBitmap, target , level, 0, bitmap->width(), bitmap->height(), 1, 0, format, type, 0, 0, 0))
4518 return; 4512 return;
4519 if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) { 4513 if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) {
4520 // The UNSIGNED_INT_10F_11F_11F_REV type pack/unpack isn't implemented. 4514 // The UNSIGNED_INT_10F_11F_11F_REV type pack/unpack isn't implemented.
4521 type = GL_FLOAT; 4515 type = GL_FLOAT;
4522 } 4516 }
4523 ASSERT(bitmap->bitmapImage()); 4517 ASSERT(bitmap->bitmapImage());
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after
5948 if (m_framebufferBinding && m_framebufferBinding->checkDepthStencilStatus(&r eason) != GL_FRAMEBUFFER_COMPLETE) { 5942 if (m_framebufferBinding && m_framebufferBinding->checkDepthStencilStatus(&r eason) != GL_FRAMEBUFFER_COMPLETE) {
5949 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason ); 5943 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason );
5950 return false; 5944 return false;
5951 } 5945 }
5952 5946
5953 return true; 5947 return true;
5954 } 5948 }
5955 5949
5956 void WebGLRenderingContextBase::dispatchContextLostEvent(Timer<WebGLRenderingCon textBase>*) 5950 void WebGLRenderingContextBase::dispatchContextLostEvent(Timer<WebGLRenderingCon textBase>*)
5957 { 5951 {
5958 RawPtr<WebGLContextEvent> event = WebGLContextEvent::create(EventTypeNames:: webglcontextlost, false, true, ""); 5952 WebGLContextEvent* event = WebGLContextEvent::create(EventTypeNames::webglco ntextlost, false, true, "");
5959 canvas()->dispatchEvent(event); 5953 canvas()->dispatchEvent(event);
5960 m_restoreAllowed = event->defaultPrevented(); 5954 m_restoreAllowed = event->defaultPrevented();
5961 if (m_restoreAllowed && !m_isHidden) { 5955 if (m_restoreAllowed && !m_isHidden) {
5962 if (m_autoRecoveryMethod == Auto) 5956 if (m_autoRecoveryMethod == Auto)
5963 m_restoreTimer.startOneShot(0, BLINK_FROM_HERE); 5957 m_restoreTimer.startOneShot(0, BLINK_FROM_HERE);
5964 } 5958 }
5965 } 5959 }
5966 5960
5967 void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB ase>*) 5961 void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB ase>*)
5968 { 5962 {
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
6327 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); 6321 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
6328 } 6322 }
6329 6323
6330 void WebGLRenderingContextBase::restoreUnpackParameters() 6324 void WebGLRenderingContextBase::restoreUnpackParameters()
6331 { 6325 {
6332 if (m_unpackAlignment != 1) 6326 if (m_unpackAlignment != 1)
6333 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); 6327 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
6334 } 6328 }
6335 6329
6336 } // namespace blink 6330 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698