| 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 "CCGraphicsContext.h" | 10 #include "CCGraphicsContext.h" |
| 11 #include "CCIOSurfaceDrawQuad.h" | 11 #include "CCIOSurfaceDrawQuad.h" |
| 12 #include "CCLayerTreeHostImpl.h" | 12 #include "CCLayerTreeHostImpl.h" |
| 13 #include "CCQuadSink.h" | 13 #include "CCQuadSink.h" |
| 14 #include "CCRendererGL.h" // For the GLC() macro. | 14 #include "CCRendererGL.h" // For the GLC() macro. |
| 15 #include "Extensions3D.h" | 15 #include "Extensions3D.h" |
| 16 #include <public/WebGraphicsContext3D.h> | 16 #include <public/WebGraphicsContext3D.h> |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 | 19 |
| 20 CCIOSurfaceLayerImpl::CCIOSurfaceLayerImpl(int id) | 20 IOSurfaceLayerImpl::IOSurfaceLayerImpl(int id) |
| 21 : CCLayerImpl(id) | 21 : LayerImpl(id) |
| 22 , m_ioSurfaceId(0) | 22 , m_ioSurfaceId(0) |
| 23 , m_ioSurfaceChanged(false) | 23 , m_ioSurfaceChanged(false) |
| 24 , m_ioSurfaceTextureId(0) | 24 , m_ioSurfaceTextureId(0) |
| 25 { | 25 { |
| 26 } | 26 } |
| 27 | 27 |
| 28 CCIOSurfaceLayerImpl::~CCIOSurfaceLayerImpl() | 28 IOSurfaceLayerImpl::~IOSurfaceLayerImpl() |
| 29 { | 29 { |
| 30 if (!m_ioSurfaceTextureId) | 30 if (!m_ioSurfaceTextureId) |
| 31 return; | 31 return; |
| 32 | 32 |
| 33 CCGraphicsContext* context = layerTreeHostImpl()->context(); | 33 GraphicsContext* context = layerTreeHostImpl()->context(); |
| 34 // FIXME: Implement this path for software compositing. | 34 // FIXME: Implement this path for software compositing. |
| 35 WebKit::WebGraphicsContext3D* context3d = context->context3D(); | 35 WebKit::WebGraphicsContext3D* context3d = context->context3D(); |
| 36 if (context3d) | 36 if (context3d) |
| 37 context3d->deleteTexture(m_ioSurfaceTextureId); | 37 context3d->deleteTexture(m_ioSurfaceTextureId); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void CCIOSurfaceLayerImpl::willDraw(CCResourceProvider* resourceProvider) | 40 void IOSurfaceLayerImpl::willDraw(ResourceProvider* resourceProvider) |
| 41 { | 41 { |
| 42 CCLayerImpl::willDraw(resourceProvider); | 42 LayerImpl::willDraw(resourceProvider); |
| 43 | 43 |
| 44 if (m_ioSurfaceChanged) { | 44 if (m_ioSurfaceChanged) { |
| 45 WebKit::WebGraphicsContext3D* context3d = resourceProvider->graphicsCont
ext3D(); | 45 WebKit::WebGraphicsContext3D* context3d = resourceProvider->graphicsCont
ext3D(); |
| 46 if (!context3d) { | 46 if (!context3d) { |
| 47 // FIXME: Implement this path for software compositing. | 47 // FIXME: Implement this path for software compositing. |
| 48 return; | 48 return; |
| 49 } | 49 } |
| 50 | 50 |
| 51 // FIXME: Do this in a way that we can track memory usage. | 51 // FIXME: Do this in a way that we can track memory usage. |
| 52 if (!m_ioSurfaceTextureId) | 52 if (!m_ioSurfaceTextureId) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 66 // Do not check for error conditions. texImageIOSurface2DCHROMIUM is sup
posed to hold on to | 66 // 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 | 67 // 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 | 68 // 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, | 69 // 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 | 70 // it may be necessary to explicitly tell the embedder when to free the
surfaces it has |
| 71 // allocated. | 71 // allocated. |
| 72 m_ioSurfaceChanged = false; | 72 m_ioSurfaceChanged = false; |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 void CCIOSurfaceLayerImpl::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData&
appendQuadsData) | 76 void IOSurfaceLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& append
QuadsData) |
| 77 { | 77 { |
| 78 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createShare
dQuadState()); | 78 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ
uadState()); |
| 79 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); | 79 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); |
| 80 | 80 |
| 81 IntRect quadRect(IntPoint(), contentBounds()); | 81 IntRect quadRect(IntPoint(), contentBounds()); |
| 82 quadSink.append(CCIOSurfaceDrawQuad::create(sharedQuadState, quadRect, m_ioS
urfaceSize, m_ioSurfaceTextureId, CCIOSurfaceDrawQuad::Flipped).PassAs<CCDrawQua
d>(), appendQuadsData); | 82 quadSink.append(IOSurfaceDrawQuad::create(sharedQuadState, quadRect, m_ioSur
faceSize, m_ioSurfaceTextureId, IOSurfaceDrawQuad::Flipped).PassAs<DrawQuad>(),
appendQuadsData); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void CCIOSurfaceLayerImpl::dumpLayerProperties(std::string* str, int indent) con
st | 85 void IOSurfaceLayerImpl::dumpLayerProperties(std::string* str, int indent) const |
| 86 { | 86 { |
| 87 str->append(indentString(indent)); | 87 str->append(indentString(indent)); |
| 88 base::StringAppendF(str, "iosurface id: %u texture id: %u\n", m_ioSurfaceId,
m_ioSurfaceTextureId); | 88 base::StringAppendF(str, "iosurface id: %u texture id: %u\n", m_ioSurfaceId,
m_ioSurfaceTextureId); |
| 89 CCLayerImpl::dumpLayerProperties(str, indent); | 89 LayerImpl::dumpLayerProperties(str, indent); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void CCIOSurfaceLayerImpl::didLoseContext() | 92 void IOSurfaceLayerImpl::didLoseContext() |
| 93 { | 93 { |
| 94 // We don't have a valid texture ID in the new context; however, | 94 // We don't have a valid texture ID in the new context; however, |
| 95 // the IOSurface is still valid. | 95 // the IOSurface is still valid. |
| 96 m_ioSurfaceTextureId = 0; | 96 m_ioSurfaceTextureId = 0; |
| 97 m_ioSurfaceChanged = true; | 97 m_ioSurfaceChanged = true; |
| 98 } | 98 } |
| 99 | 99 |
| 100 void CCIOSurfaceLayerImpl::setIOSurfaceProperties(unsigned ioSurfaceId, const In
tSize& size) | 100 void IOSurfaceLayerImpl::setIOSurfaceProperties(unsigned ioSurfaceId, const IntS
ize& size) |
| 101 { | 101 { |
| 102 if (m_ioSurfaceId != ioSurfaceId) | 102 if (m_ioSurfaceId != ioSurfaceId) |
| 103 m_ioSurfaceChanged = true; | 103 m_ioSurfaceChanged = true; |
| 104 | 104 |
| 105 m_ioSurfaceId = ioSurfaceId; | 105 m_ioSurfaceId = ioSurfaceId; |
| 106 m_ioSurfaceSize = size; | 106 m_ioSurfaceSize = size; |
| 107 } | 107 } |
| 108 | 108 |
| 109 const char* CCIOSurfaceLayerImpl::layerTypeAsString() const | 109 const char* IOSurfaceLayerImpl::layerTypeAsString() const |
| 110 { | 110 { |
| 111 return "IOSurfaceLayer"; | 111 return "IOSurfaceLayer"; |
| 112 } | 112 } |
| 113 | 113 |
| 114 } | 114 } |
| OLD | NEW |