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

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

Issue 2091713002: Specialize base::IsWeakReceiver for Blink weak pointers to support base::Bind (1/5) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: +test. rebase for WTF::unretained(). Created 4 years, 5 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 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; 914 m_maxViewportDims[0] = m_maxViewportDims[1] = 0;
915 contextProvider->contextGL()->GetIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewpor tDims); 915 contextProvider->contextGL()->GetIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewpor tDims);
916 916
917 RefPtr<DrawingBuffer> buffer = createDrawingBuffer(std::move(contextProvider )); 917 RefPtr<DrawingBuffer> buffer = createDrawingBuffer(std::move(contextProvider ));
918 if (!buffer) { 918 if (!buffer) {
919 m_contextLostMode = SyntheticLostContext; 919 m_contextLostMode = SyntheticLostContext;
920 return; 920 return;
921 } 921 }
922 922
923 m_drawingBuffer = buffer.release(); 923 m_drawingBuffer = buffer.release();
924 m_drawingBuffer->addNewMailboxCallback(WTF::bind(&WebGLRenderingContextBase: :notifyCanvasContextChanged, createWeakThisPointer())); 924 m_drawingBuffer->addNewMailboxCallback(WTF::bind(&WebGLRenderingContextBase: :notifyCanvasContextChanged, wrapWeakPersistent(this)));
925 drawingBuffer()->bind(GL_FRAMEBUFFER); 925 drawingBuffer()->bind(GL_FRAMEBUFFER);
926 setupFlags(); 926 setupFlags();
927 927
928 #define ADD_VALUES_TO_SET(set, values) \ 928 #define ADD_VALUES_TO_SET(set, values) \
929 for (size_t i = 0; i < WTF_ARRAY_LENGTH(values); ++i) { \ 929 for (size_t i = 0; i < WTF_ARRAY_LENGTH(values); ++i) { \
930 set.insert(values[i]); \ 930 set.insert(values[i]); \
931 } 931 }
932 932
933 ADD_VALUES_TO_SET(m_supportedInternalFormats, kSupportedInternalFormatsES2); 933 ADD_VALUES_TO_SET(m_supportedInternalFormats, kSupportedInternalFormatsES2);
934 ADD_VALUES_TO_SET(m_supportedInternalFormatsCopyTexImage, kSupportedInternal FormatsES2); 934 ADD_VALUES_TO_SET(m_supportedInternalFormatsCopyTexImage, kSupportedInternal FormatsES2);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 m_boundVertexArrayObject = m_defaultVertexArrayObject; 1034 m_boundVertexArrayObject = m_defaultVertexArrayObject;
1035 1035
1036 m_vertexAttribType.resize(m_maxVertexAttribs); 1036 m_vertexAttribType.resize(m_maxVertexAttribs);
1037 1037
1038 contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); 1038 contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight());
1039 contextGL()->Scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); 1039 contextGL()->Scissor(0, 0, drawingBufferWidth(), drawingBufferHeight());
1040 1040
1041 drawingBuffer()->contextProvider()->setLostContextCallback( 1041 drawingBuffer()->contextProvider()->setLostContextCallback(
1042 WebClosure(bind( 1042 WebClosure(bind(
1043 &WebGLRenderingContextBase::forceLostContext, 1043 &WebGLRenderingContextBase::forceLostContext,
1044 createWeakThisPointer(), 1044 wrapWeakPersistent(this),
1045 WebGLRenderingContextBase::RealLostContext, 1045 WebGLRenderingContextBase::RealLostContext,
1046 WebGLRenderingContextBase::Auto))); 1046 WebGLRenderingContextBase::Auto)));
1047 drawingBuffer()->contextProvider()->setErrorMessageCallback( 1047 drawingBuffer()->contextProvider()->setErrorMessageCallback(
1048 WebFunction<void(const char*, int32_t)>(bind( 1048 WebFunction<void(const char*, int32_t)>(bind(
1049 &WebGLRenderingContextBase::onErrorMessage, 1049 &WebGLRenderingContextBase::onErrorMessage,
1050 createWeakThisPointer()))); 1050 wrapWeakPersistent(this))));
1051 1051
1052 // If WebGL 2, the PRIMITIVE_RESTART_FIXED_INDEX should be always enabled. 1052 // If WebGL 2, the PRIMITIVE_RESTART_FIXED_INDEX should be always enabled.
1053 // See the section <Primitive Restart is Always Enabled> in WebGL 2 spec: 1053 // See the section <Primitive Restart is Always Enabled> in WebGL 2 spec:
1054 // https://www.khronos.org/registry/webgl/specs/latest/2.0/#4.1.4 1054 // https://www.khronos.org/registry/webgl/specs/latest/2.0/#4.1.4
1055 if (isWebGL2OrHigher()) 1055 if (isWebGL2OrHigher())
1056 contextGL()->Enable(GL_PRIMITIVE_RESTART_FIXED_INDEX); 1056 contextGL()->Enable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
1057 1057
1058 // This ensures that the context has a valid "lastFlushID" and won't be mist akenly identified as the "least recently used" context. 1058 // This ensures that the context has a valid "lastFlushID" and won't be mist akenly identified as the "least recently used" context.
1059 contextGL()->Flush(); 1059 contextGL()->Flush();
1060 1060
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 1151
1152 void WebGLRenderingContextBase::destroyContext() 1152 void WebGLRenderingContextBase::destroyContext()
1153 { 1153 {
1154 if (!drawingBuffer()) 1154 if (!drawingBuffer())
1155 return; 1155 return;
1156 1156
1157 m_extensionsUtil.reset(); 1157 m_extensionsUtil.reset();
1158 1158
1159 drawingBuffer()->contextProvider()->setLostContextCallback(WebClosure()); 1159 drawingBuffer()->contextProvider()->setLostContextCallback(WebClosure());
1160 drawingBuffer()->contextProvider()->setErrorMessageCallback(WebFunction<void (const char*, int32_t)>()); 1160 drawingBuffer()->contextProvider()->setErrorMessageCallback(WebFunction<void (const char*, int32_t)>());
1161 drawingBuffer()->addNewMailboxCallback(nullptr);
sof 2016/06/24 05:24:08 It makes sense, but why is this needed now?
tzik 2016/06/24 05:57:06 The error caught a Persistent leak after the termi
sof 2016/06/24 06:45:32 CT(W)Ps are exempt from checking for leaks when ru
tzik 2016/06/24 07:04:58 Makes sense.
1161 1162
1162 ASSERT(drawingBuffer()); 1163 ASSERT(drawingBuffer());
1163 m_drawingBuffer->beginDestruction(); 1164 m_drawingBuffer->beginDestruction();
1164 m_drawingBuffer.clear(); 1165 m_drawingBuffer.clear();
1165 } 1166 }
1166 1167
1167 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType) 1168 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType)
1168 { 1169 {
1169 if (m_framebufferBinding || isContextLost()) 1170 if (m_framebufferBinding || isContextLost())
1170 return; 1171 return;
(...skipping 4931 matching lines...) Expand 10 before | Expand all | Expand 10 after
6102 if (m_contextLostMode == RealLostContext) { 6103 if (m_contextLostMode == RealLostContext) {
6103 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, BLINK_FRO M_HERE); 6104 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, BLINK_FRO M_HERE);
6104 } else { 6105 } else {
6105 // This likely shouldn't happen but is the best way to report it to the WebGL app. 6106 // This likely shouldn't happen but is the best way to report it to the WebGL app.
6106 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context "); 6107 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context ");
6107 } 6108 }
6108 return; 6109 return;
6109 } 6110 }
6110 6111
6111 m_drawingBuffer = buffer.release(); 6112 m_drawingBuffer = buffer.release();
6112 m_drawingBuffer->addNewMailboxCallback(WTF::bind(&WebGLRenderingContextBase: :notifyCanvasContextChanged, createWeakThisPointer())); 6113 m_drawingBuffer->addNewMailboxCallback(WTF::bind(&WebGLRenderingContextBase: :notifyCanvasContextChanged, wrapWeakPersistent(this)));
6113 6114
6114 drawingBuffer()->bind(GL_FRAMEBUFFER); 6115 drawingBuffer()->bind(GL_FRAMEBUFFER);
6115 m_lostContextErrors.clear(); 6116 m_lostContextErrors.clear();
6116 m_contextLostMode = NotLostContext; 6117 m_contextLostMode = NotLostContext;
6117 m_autoRecoveryMethod = Manual; 6118 m_autoRecoveryMethod = Manual;
6118 m_restoreAllowed = false; 6119 m_restoreAllowed = false;
6119 removeFromEvictedList(this); 6120 removeFromEvictedList(this);
6120 6121
6121 setupFlags(); 6122 setupFlags();
6122 initializeNewContext(); 6123 initializeNewContext();
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
6424 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); 6425 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
6425 } 6426 }
6426 6427
6427 void WebGLRenderingContextBase::restoreUnpackParameters() 6428 void WebGLRenderingContextBase::restoreUnpackParameters()
6428 { 6429 {
6429 if (m_unpackAlignment != 1) 6430 if (m_unpackAlignment != 1)
6430 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); 6431 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
6431 } 6432 }
6432 6433
6433 } // namespace blink 6434 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698