OLD | NEW |
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 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 contextGL()->GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &m_maxRenderbufferSize); | 1202 contextGL()->GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &m_maxRenderbufferSize); |
1203 | 1203 |
1204 // These two values from EXT_draw_buffers are lazily queried. | 1204 // These two values from EXT_draw_buffers are lazily queried. |
1205 m_maxDrawBuffers = 0; | 1205 m_maxDrawBuffers = 0; |
1206 m_maxColorAttachments = 0; | 1206 m_maxColorAttachments = 0; |
1207 | 1207 |
1208 m_backDrawBuffer = GL_BACK; | 1208 m_backDrawBuffer = GL_BACK; |
1209 | 1209 |
1210 m_readBufferOfDefaultFramebuffer = GL_BACK; | 1210 m_readBufferOfDefaultFramebuffer = GL_BACK; |
1211 | 1211 |
| 1212 m_surfaceHandle = 0; |
| 1213 |
1212 m_defaultVertexArrayObject = WebGLVertexArrayObject::create( | 1214 m_defaultVertexArrayObject = WebGLVertexArrayObject::create( |
1213 this, WebGLVertexArrayObjectBase::VaoTypeDefault); | 1215 this, WebGLVertexArrayObjectBase::VaoTypeDefault); |
1214 | 1216 |
1215 m_boundVertexArrayObject = m_defaultVertexArrayObject; | 1217 m_boundVertexArrayObject = m_defaultVertexArrayObject; |
1216 | 1218 |
1217 m_vertexAttribType.resize(m_maxVertexAttribs); | 1219 m_vertexAttribType.resize(m_maxVertexAttribs); |
1218 | 1220 |
1219 contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 1221 contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
1220 m_scissorBox[0] = m_scissorBox[1] = 0; | 1222 m_scissorBox[0] = m_scissorBox[1] = 0; |
1221 m_scissorBox[2] = drawingBufferWidth(); | 1223 m_scissorBox[2] = drawingBufferWidth(); |
(...skipping 6429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7651 if (!m_maxColorAttachments) | 7653 if (!m_maxColorAttachments) |
7652 contextGL()->GetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, | 7654 contextGL()->GetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, |
7653 &m_maxColorAttachments); | 7655 &m_maxColorAttachments); |
7654 return m_maxColorAttachments; | 7656 return m_maxColorAttachments; |
7655 } | 7657 } |
7656 | 7658 |
7657 void WebGLRenderingContextBase::setBackDrawBuffer(GLenum buf) { | 7659 void WebGLRenderingContextBase::setBackDrawBuffer(GLenum buf) { |
7658 m_backDrawBuffer = buf; | 7660 m_backDrawBuffer = buf; |
7659 } | 7661 } |
7660 | 7662 |
| 7663 void WebGLRenderingContextBase::setSurfaceHandle(int handle) { |
| 7664 if (handle == m_surfaceHandle) |
| 7665 return; |
| 7666 |
| 7667 if (isContextLost()) |
| 7668 return; |
| 7669 |
| 7670 // LOG(INFO) << "klausw:WebGLRenderingContextBase::setSurfaceHandle(" << |
| 7671 // handle << ") isBoundForDraw=" << DrawingBufferClientIsBoundForDraw(); |
| 7672 m_surfaceHandle = handle; |
| 7673 |
| 7674 // Rebind to the drawing buffer first before releasing the surface, |
| 7675 // but only if we're currently using the default framebuffer. If |
| 7676 // we're drawing elsewhere, this will be rebound in a future |
| 7677 // bindFramebuffer call at the appropriate time. |
| 7678 if (drawingBuffer() && DrawingBufferClientIsBoundForDraw() && !handle) { |
| 7679 drawingBuffer()->bind(GL_FRAMEBUFFER); |
| 7680 } |
| 7681 |
| 7682 contextGL()->SetSurfaceHandleCHROMIUM(m_surfaceHandle); |
| 7683 contextGL()->Flush(); |
| 7684 contextGL()->Finish(); |
| 7685 |
| 7686 // Bind to the surface once it's set up. |
| 7687 if (DrawingBufferClientIsBoundForDraw() && handle) { |
| 7688 contextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); |
| 7689 } |
| 7690 } |
| 7691 |
7661 void WebGLRenderingContextBase::setFramebuffer(GLenum target, | 7692 void WebGLRenderingContextBase::setFramebuffer(GLenum target, |
7662 WebGLFramebuffer* buffer) { | 7693 WebGLFramebuffer* buffer) { |
7663 if (buffer) | 7694 if (buffer) |
7664 buffer->setHasEverBeenBound(); | 7695 buffer->setHasEverBeenBound(); |
7665 | 7696 |
7666 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) { | 7697 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) { |
7667 m_framebufferBinding = buffer; | 7698 m_framebufferBinding = buffer; |
7668 applyStencilTest(); | 7699 applyStencilTest(); |
7669 } | 7700 } |
7670 if (!buffer) { | 7701 if (!buffer) { |
7671 // Instead of binding fb 0, bind the drawing buffer. | 7702 if (m_surfaceHandle) { |
7672 drawingBuffer()->bind(target); | 7703 contextGL()->BindFramebuffer(target, 0); |
| 7704 } else { |
| 7705 // Instead of binding fb 0, bind the drawing buffer. |
| 7706 drawingBuffer()->bind(target); |
| 7707 } |
7673 } else { | 7708 } else { |
7674 contextGL()->BindFramebuffer(target, buffer->object()); | 7709 contextGL()->BindFramebuffer(target, buffer->object()); |
7675 } | 7710 } |
7676 } | 7711 } |
7677 | 7712 |
7678 void WebGLRenderingContextBase::restoreCurrentFramebuffer() { | 7713 void WebGLRenderingContextBase::restoreCurrentFramebuffer() { |
7679 bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding.get()); | 7714 bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding.get()); |
7680 } | 7715 } |
7681 | 7716 |
7682 void WebGLRenderingContextBase::restoreCurrentTexture2D() { | 7717 void WebGLRenderingContextBase::restoreCurrentTexture2D() { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7784 | 7819 |
7785 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7820 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
7786 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7821 HTMLCanvasElementOrOffscreenCanvas& result) const { |
7787 if (canvas()) | 7822 if (canvas()) |
7788 result.setHTMLCanvasElement(canvas()); | 7823 result.setHTMLCanvasElement(canvas()); |
7789 else | 7824 else |
7790 result.setOffscreenCanvas(getOffscreenCanvas()); | 7825 result.setOffscreenCanvas(getOffscreenCanvas()); |
7791 } | 7826 } |
7792 | 7827 |
7793 } // namespace blink | 7828 } // namespace blink |
OLD | NEW |