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 "cc/io_surface_layer_impl.h" | 5 #include "cc/io_surface_layer_impl.h" |
6 | 6 |
7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "cc/gl_renderer.h" // For the GLC() macro. | 8 #include "cc/gl_renderer.h" // For the GLC() macro. |
9 #include "cc/graphics_context.h" | |
10 #include "cc/io_surface_draw_quad.h" | 9 #include "cc/io_surface_draw_quad.h" |
11 #include "cc/layer_tree_host_impl.h" | 10 #include "cc/layer_tree_host_impl.h" |
| 11 #include "cc/output_surface.h" |
12 #include "cc/quad_sink.h" | 12 #include "cc/quad_sink.h" |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
13 #include "third_party/khronos/GLES2/gl2.h" | 14 #include "third_party/khronos/GLES2/gl2.h" |
14 #include "third_party/khronos/GLES2/gl2ext.h" | 15 #include "third_party/khronos/GLES2/gl2ext.h" |
15 #include <public/WebGraphicsContext3D.h> | |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 | 18 |
19 IOSurfaceLayerImpl::IOSurfaceLayerImpl(int id) | 19 IOSurfaceLayerImpl::IOSurfaceLayerImpl(int id) |
20 : LayerImpl(id) | 20 : LayerImpl(id) |
21 , m_ioSurfaceId(0) | 21 , m_ioSurfaceId(0) |
22 , m_ioSurfaceChanged(false) | 22 , m_ioSurfaceChanged(false) |
23 , m_ioSurfaceTextureId(0) | 23 , m_ioSurfaceTextureId(0) |
24 { | 24 { |
25 } | 25 } |
26 | 26 |
27 IOSurfaceLayerImpl::~IOSurfaceLayerImpl() | 27 IOSurfaceLayerImpl::~IOSurfaceLayerImpl() |
28 { | 28 { |
29 if (!m_ioSurfaceTextureId) | 29 if (!m_ioSurfaceTextureId) |
30 return; | 30 return; |
31 | 31 |
32 GraphicsContext* context = layerTreeHostImpl()->context(); | 32 OutputSurface* outputSurface = layerTreeHostImpl()->outputSurface(); |
33 // FIXME: Implement this path for software compositing. | 33 // FIXME: Implement this path for software compositing. |
34 WebKit::WebGraphicsContext3D* context3d = context->context3D(); | 34 WebKit::WebGraphicsContext3D* context3d = outputSurface->context3D(); |
35 if (context3d) | 35 if (context3d) |
36 context3d->deleteTexture(m_ioSurfaceTextureId); | 36 context3d->deleteTexture(m_ioSurfaceTextureId); |
37 } | 37 } |
38 | 38 |
39 void IOSurfaceLayerImpl::willDraw(ResourceProvider* resourceProvider) | 39 void IOSurfaceLayerImpl::willDraw(ResourceProvider* resourceProvider) |
40 { | 40 { |
41 LayerImpl::willDraw(resourceProvider); | 41 LayerImpl::willDraw(resourceProvider); |
42 | 42 |
43 if (m_ioSurfaceChanged) { | 43 if (m_ioSurfaceChanged) { |
44 WebKit::WebGraphicsContext3D* context3d = resourceProvider->graphicsCont
ext3D(); | 44 WebKit::WebGraphicsContext3D* context3d = resourceProvider->graphicsCont
ext3D(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 84 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
85 } | 85 } |
86 | 86 |
87 void IOSurfaceLayerImpl::dumpLayerProperties(std::string* str, int indent) const | 87 void IOSurfaceLayerImpl::dumpLayerProperties(std::string* str, int indent) const |
88 { | 88 { |
89 str->append(indentString(indent)); | 89 str->append(indentString(indent)); |
90 base::StringAppendF(str, "iosurface id: %u texture id: %u\n", m_ioSurfaceId,
m_ioSurfaceTextureId); | 90 base::StringAppendF(str, "iosurface id: %u texture id: %u\n", m_ioSurfaceId,
m_ioSurfaceTextureId); |
91 LayerImpl::dumpLayerProperties(str, indent); | 91 LayerImpl::dumpLayerProperties(str, indent); |
92 } | 92 } |
93 | 93 |
94 void IOSurfaceLayerImpl::didLoseContext() | 94 void IOSurfaceLayerImpl::didLoseOutputSurface() |
95 { | 95 { |
96 // We don't have a valid texture ID in the new context; however, | 96 // We don't have a valid texture ID in the new context; however, |
97 // the IOSurface is still valid. | 97 // the IOSurface is still valid. |
98 m_ioSurfaceTextureId = 0; | 98 m_ioSurfaceTextureId = 0; |
99 m_ioSurfaceChanged = true; | 99 m_ioSurfaceChanged = true; |
100 } | 100 } |
101 | 101 |
102 void IOSurfaceLayerImpl::setIOSurfaceProperties(unsigned ioSurfaceId, const gfx:
:Size& size) | 102 void IOSurfaceLayerImpl::setIOSurfaceProperties(unsigned ioSurfaceId, const gfx:
:Size& size) |
103 { | 103 { |
104 if (m_ioSurfaceId != ioSurfaceId) | 104 if (m_ioSurfaceId != ioSurfaceId) |
105 m_ioSurfaceChanged = true; | 105 m_ioSurfaceChanged = true; |
106 | 106 |
107 m_ioSurfaceId = ioSurfaceId; | 107 m_ioSurfaceId = ioSurfaceId; |
108 m_ioSurfaceSize = size; | 108 m_ioSurfaceSize = size; |
109 } | 109 } |
110 | 110 |
111 const char* IOSurfaceLayerImpl::layerTypeAsString() const | 111 const char* IOSurfaceLayerImpl::layerTypeAsString() const |
112 { | 112 { |
113 return "IOSurfaceLayer"; | 113 return "IOSurfaceLayer"; |
114 } | 114 } |
115 | 115 |
116 } // namespace cc | 116 } // namespace cc |
OLD | NEW |