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

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

Issue 2384593002: Encode frame number in pixel data for pose sync (Closed)
Patch Set: bajones #4: use contextGL(), auto-restore state, add poseNum to VRPosePtr Created 4 years, 2 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 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 1129
1130 m_defaultVertexArrayObject = WebGLVertexArrayObject::create( 1130 m_defaultVertexArrayObject = WebGLVertexArrayObject::create(
1131 this, WebGLVertexArrayObjectBase::VaoTypeDefault); 1131 this, WebGLVertexArrayObjectBase::VaoTypeDefault);
1132 addContextObject(m_defaultVertexArrayObject.get()); 1132 addContextObject(m_defaultVertexArrayObject.get());
1133 1133
1134 m_boundVertexArrayObject = m_defaultVertexArrayObject; 1134 m_boundVertexArrayObject = m_defaultVertexArrayObject;
1135 1135
1136 m_vertexAttribType.resize(m_maxVertexAttribs); 1136 m_vertexAttribType.resize(m_maxVertexAttribs);
1137 1137
1138 contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); 1138 contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight());
1139 contextGL()->Scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); 1139 m_scissorBox[0] = m_scissorBox[1] = 0;
1140 m_scissorBox[2] = drawingBufferWidth();
1141 m_scissorBox[3] = drawingBufferHeight();
1142 contextGL()->Scissor(m_scissorBox[0], m_scissorBox[1], m_scissorBox[2],
1143 m_scissorBox[3]);
1140 1144
1141 drawingBuffer()->contextProvider()->setLostContextCallback( 1145 drawingBuffer()->contextProvider()->setLostContextCallback(
1142 convertToBaseCallback(WTF::bind( 1146 convertToBaseCallback(WTF::bind(
1143 &WebGLRenderingContextBase::forceLostContext, 1147 &WebGLRenderingContextBase::forceLostContext,
1144 wrapWeakPersistent(this), WebGLRenderingContextBase::RealLostContext, 1148 wrapWeakPersistent(this), WebGLRenderingContextBase::RealLostContext,
1145 WebGLRenderingContextBase::Auto))); 1149 WebGLRenderingContextBase::Auto)));
1146 drawingBuffer()->contextProvider()->setErrorMessageCallback( 1150 drawingBuffer()->contextProvider()->setErrorMessageCallback(
1147 convertToBaseCallback( 1151 convertToBaseCallback(
1148 WTF::bind(&WebGLRenderingContextBase::onErrorMessage, 1152 WTF::bind(&WebGLRenderingContextBase::onErrorMessage,
1149 wrapWeakPersistent(this)))); 1153 wrapWeakPersistent(this))));
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 drawingBuffer()->setBufferClearNeeded(false); 1372 drawingBuffer()->setBufferClearNeeded(false);
1369 1373
1370 return combinedClear ? CombinedClear : JustClear; 1374 return combinedClear ? CombinedClear : JustClear;
1371 } 1375 }
1372 1376
1373 void WebGLRenderingContextBase::restoreStateAfterClear() { 1377 void WebGLRenderingContextBase::restoreStateAfterClear() {
1374 if (isContextLost()) 1378 if (isContextLost())
1375 return; 1379 return;
1376 1380
1377 // Restore the state that the context set. 1381 // Restore the state that the context set.
1378 if (m_scissorEnabled) 1382 if (m_scissorEnabled) {
1379 contextGL()->Enable(GL_SCISSOR_TEST); 1383 contextGL()->Enable(GL_SCISSOR_TEST);
1384 // WebVR's VRDisplay uses a custom scissor box, need to restore that too.
1385 contextGL()->Scissor(m_scissorBox[0], m_scissorBox[1], m_scissorBox[2],
1386 m_scissorBox[3]);
1387 }
1380 contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2], 1388 contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2],
1381 m_clearColor[3]); 1389 m_clearColor[3]);
1382 contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], 1390 contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2],
1383 m_colorMask[3]); 1391 m_colorMask[3]);
1384 contextGL()->ClearDepthf(m_clearDepth); 1392 contextGL()->ClearDepthf(m_clearDepth);
1385 contextGL()->ClearStencil(m_clearStencil); 1393 contextGL()->ClearStencil(m_clearStencil);
1386 contextGL()->StencilMaskSeparate(GL_FRONT, m_stencilMask); 1394 contextGL()->StencilMaskSeparate(GL_FRONT, m_stencilMask);
1387 contextGL()->DepthMask(m_depthMask); 1395 contextGL()->DepthMask(m_depthMask);
1388 } 1396 }
1389 1397
(...skipping 2759 matching lines...) Expand 10 before | Expand all | Expand 10 after
4149 return; 4157 return;
4150 contextGL()->SampleCoverage(value, invert); 4158 contextGL()->SampleCoverage(value, invert);
4151 } 4159 }
4152 4160
4153 void WebGLRenderingContextBase::scissor(GLint x, 4161 void WebGLRenderingContextBase::scissor(GLint x,
4154 GLint y, 4162 GLint y,
4155 GLsizei width, 4163 GLsizei width,
4156 GLsizei height) { 4164 GLsizei height) {
4157 if (isContextLost()) 4165 if (isContextLost())
4158 return; 4166 return;
4167 m_scissorBox[0] = x;
4168 m_scissorBox[1] = y;
4169 m_scissorBox[2] = width;
4170 m_scissorBox[3] = height;
4159 contextGL()->Scissor(x, y, width, height); 4171 contextGL()->Scissor(x, y, width, height);
4160 } 4172 }
4161 4173
4162 void WebGLRenderingContextBase::shaderSource(WebGLShader* shader, 4174 void WebGLRenderingContextBase::shaderSource(WebGLShader* shader,
4163 const String& string) { 4175 const String& string) {
4164 if (isContextLost() || !validateWebGLObject("shaderSource", shader)) 4176 if (isContextLost() || !validateWebGLObject("shaderSource", shader))
4165 return; 4177 return;
4166 String stringWithoutComments = StripComments(string).result(); 4178 String stringWithoutComments = StripComments(string).result();
4167 // TODO(danakj): Make validateShaderSource reject characters > 255 (or utf16 S trings) 4179 // TODO(danakj): Make validateShaderSource reject characters > 255 (or utf16 S trings)
4168 // so we don't need to use StringUTF8Adaptor. 4180 // so we don't need to use StringUTF8Adaptor.
(...skipping 3259 matching lines...) Expand 10 before | Expand all | Expand 10 after
7428 7440
7429 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( 7441 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(
7430 HTMLCanvasElementOrOffscreenCanvas& result) const { 7442 HTMLCanvasElementOrOffscreenCanvas& result) const {
7431 if (canvas()) 7443 if (canvas())
7432 result.setHTMLCanvasElement(canvas()); 7444 result.setHTMLCanvasElement(canvas());
7433 else 7445 else
7434 result.setOffscreenCanvas(getOffscreenCanvas()); 7446 result.setOffscreenCanvas(getOffscreenCanvas());
7435 } 7447 }
7436 7448
7437 } // namespace blink 7449 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698