| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "CCIOSurfaceLayerImpl.h" | 7 #include "CCIOSurfaceLayerImpl.h" |
| 8 | 8 |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "third_party/khronos/GLES2/gl2.h" |
| 11 #include "third_party/khronos/GLES2/gl2ext.h" |
| 10 #include "CCGraphicsContext.h" | 12 #include "CCGraphicsContext.h" |
| 11 #include "CCIOSurfaceDrawQuad.h" | 13 #include "CCIOSurfaceDrawQuad.h" |
| 12 #include "CCLayerTreeHostImpl.h" | 14 #include "CCLayerTreeHostImpl.h" |
| 13 #include "CCQuadSink.h" | 15 #include "CCQuadSink.h" |
| 14 #include "CCRendererGL.h" // For the GLC() macro. | 16 #include "CCRendererGL.h" // For the GLC() macro. |
| 15 #include "Extensions3D.h" | |
| 16 #include <public/WebGraphicsContext3D.h> | 17 #include <public/WebGraphicsContext3D.h> |
| 17 | 18 |
| 18 namespace cc { | 19 namespace cc { |
| 19 | 20 |
| 20 CCIOSurfaceLayerImpl::CCIOSurfaceLayerImpl(int id) | 21 CCIOSurfaceLayerImpl::CCIOSurfaceLayerImpl(int id) |
| 21 : CCLayerImpl(id) | 22 : CCLayerImpl(id) |
| 22 , m_ioSurfaceId(0) | 23 , m_ioSurfaceId(0) |
| 23 , m_ioSurfaceChanged(false) | 24 , m_ioSurfaceChanged(false) |
| 24 , m_ioSurfaceTextureId(0) | 25 , m_ioSurfaceTextureId(0) |
| 25 { | 26 { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 45 WebKit::WebGraphicsContext3D* context3d = resourceProvider->graphicsCont
ext3D(); | 46 WebKit::WebGraphicsContext3D* context3d = resourceProvider->graphicsCont
ext3D(); |
| 46 if (!context3d) { | 47 if (!context3d) { |
| 47 // FIXME: Implement this path for software compositing. | 48 // FIXME: Implement this path for software compositing. |
| 48 return; | 49 return; |
| 49 } | 50 } |
| 50 | 51 |
| 51 // FIXME: Do this in a way that we can track memory usage. | 52 // FIXME: Do this in a way that we can track memory usage. |
| 52 if (!m_ioSurfaceTextureId) | 53 if (!m_ioSurfaceTextureId) |
| 53 m_ioSurfaceTextureId = context3d->createTexture(); | 54 m_ioSurfaceTextureId = context3d->createTexture(); |
| 54 | 55 |
| 55 GLC(context3d, context3d->activeTexture(GraphicsContext3D::TEXTURE0)); | 56 GLC(context3d, context3d->activeTexture(GL_TEXTURE0)); |
| 56 GLC(context3d, context3d->bindTexture(Extensions3D::TEXTURE_RECTANGLE_AR
B, m_ioSurfaceTextureId)); | 57 GLC(context3d, context3d->bindTexture(GL_TEXTURE_RECTANGLE_ARB, m_ioSurf
aceTextureId)); |
| 57 GLC(context3d, context3d->texParameteri(Extensions3D::TEXTURE_RECTANGLE_
ARB, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR)); | 58 GLC(context3d, context3d->texParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEX
TURE_MIN_FILTER, GL_LINEAR)); |
| 58 GLC(context3d, context3d->texParameteri(Extensions3D::TEXTURE_RECTANGLE_
ARB, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); | 59 GLC(context3d, context3d->texParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEX
TURE_MAG_FILTER, GL_LINEAR)); |
| 59 GLC(context3d, context3d->texParameteri(Extensions3D::TEXTURE_RECTANGLE_
ARB, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE)); | 60 GLC(context3d, context3d->texParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEX
TURE_WRAP_S, GL_CLAMP_TO_EDGE)); |
| 60 GLC(context3d, context3d->texParameteri(Extensions3D::TEXTURE_RECTANGLE_
ARB, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); | 61 GLC(context3d, context3d->texParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEX
TURE_WRAP_T, GL_CLAMP_TO_EDGE)); |
| 61 context3d->texImageIOSurface2DCHROMIUM(Extensions3D::TEXTURE_RECTANGLE_A
RB, | 62 context3d->texImageIOSurface2DCHROMIUM(GL_TEXTURE_RECTANGLE_ARB, |
| 62 m_ioSurfaceSize.width(), | 63 m_ioSurfaceSize.width(), |
| 63 m_ioSurfaceSize.height(), | 64 m_ioSurfaceSize.height(), |
| 64 m_ioSurfaceId, | 65 m_ioSurfaceId, |
| 65 0); | 66 0); |
| 66 // Do not check for error conditions. texImageIOSurface2DCHROMIUM is sup
posed to hold on to | 67 // Do not check for error conditions. texImageIOSurface2DCHROMIUM is sup
posed to hold on to |
| 67 // the last good IOSurface if the new one is already closed. This is onl
y a possibility | 68 // the last good IOSurface if the new one is already closed. This is onl
y a possibility |
| 68 // during live resizing of plugins. However, it seems that this is not s
ufficient to | 69 // during live resizing of plugins. However, it seems that this is not s
ufficient to |
| 69 // completely guard against garbage being drawn. If this is found to be
a significant issue, | 70 // completely guard against garbage being drawn. If this is found to be
a significant issue, |
| 70 // it may be necessary to explicitly tell the embedder when to free the
surfaces it has | 71 // it may be necessary to explicitly tell the embedder when to free the
surfaces it has |
| 71 // allocated. | 72 // allocated. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 m_ioSurfaceId = ioSurfaceId; | 106 m_ioSurfaceId = ioSurfaceId; |
| 106 m_ioSurfaceSize = size; | 107 m_ioSurfaceSize = size; |
| 107 } | 108 } |
| 108 | 109 |
| 109 const char* CCIOSurfaceLayerImpl::layerTypeAsString() const | 110 const char* CCIOSurfaceLayerImpl::layerTypeAsString() const |
| 110 { | 111 { |
| 111 return "IOSurfaceLayer"; | 112 return "IOSurfaceLayer"; |
| 112 } | 113 } |
| 113 | 114 |
| 114 } | 115 } |
| OLD | NEW |