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/layers/io_surface_layer_impl.h" | 5 #include "cc/layers/io_surface_layer_impl.h" |
6 | 6 |
7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "cc/layers/quad_sink.h" | 8 #include "cc/layers/quad_sink.h" |
9 #include "cc/output/gl_renderer.h" // For the GLC() macro. | 9 #include "cc/output/gl_renderer.h" // For the GLC() macro. |
10 #include "cc/output/output_surface.h" | 10 #include "cc/output/output_surface.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } | 54 } |
55 | 55 |
56 void IOSurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) { | 56 void IOSurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) { |
57 LayerImpl::PushPropertiesTo(layer); | 57 LayerImpl::PushPropertiesTo(layer); |
58 | 58 |
59 IOSurfaceLayerImpl* io_surface_layer = | 59 IOSurfaceLayerImpl* io_surface_layer = |
60 static_cast<IOSurfaceLayerImpl*>(layer); | 60 static_cast<IOSurfaceLayerImpl*>(layer); |
61 io_surface_layer->SetIOSurfaceProperties(io_surface_id_, io_surface_size_); | 61 io_surface_layer->SetIOSurfaceProperties(io_surface_id_, io_surface_size_); |
62 } | 62 } |
63 | 63 |
64 void IOSurfaceLayerImpl::WillDraw(ResourceProvider* resource_provider) { | 64 bool IOSurfaceLayerImpl::WillDraw(DrawMode draw_mode, |
65 LayerImpl::WillDraw(resource_provider); | 65 ResourceProvider* resource_provider) { |
| 66 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) |
| 67 return false; |
66 | 68 |
67 if (io_surface_changed_) { | 69 if (io_surface_changed_) { |
68 WebKit::WebGraphicsContext3D* context3d = | 70 WebKit::WebGraphicsContext3D* context3d = |
69 resource_provider->GraphicsContext3D(); | 71 resource_provider->GraphicsContext3D(); |
70 if (!context3d) { | 72 if (!context3d) { |
71 // FIXME: Implement this path for software compositing. | 73 // FIXME: Implement this path for software compositing. |
72 return; | 74 return false; |
73 } | 75 } |
74 | 76 |
75 // FIXME: Do this in a way that we can track memory usage. | 77 // FIXME: Do this in a way that we can track memory usage. |
76 if (!io_surface_texture_id_) { | 78 if (!io_surface_texture_id_) { |
77 io_surface_texture_id_ = context3d->createTexture(); | 79 io_surface_texture_id_ = context3d->createTexture(); |
78 io_surface_resource_id_ = | 80 io_surface_resource_id_ = |
79 resource_provider->CreateResourceFromExternalTexture( | 81 resource_provider->CreateResourceFromExternalTexture( |
80 GL_TEXTURE_RECTANGLE_ARB, | 82 GL_TEXTURE_RECTANGLE_ARB, |
81 io_surface_texture_id_); | 83 io_surface_texture_id_); |
82 } | 84 } |
83 | 85 |
84 GLC(context3d, | 86 GLC(context3d, |
85 context3d->bindTexture(GL_TEXTURE_RECTANGLE_ARB, | 87 context3d->bindTexture(GL_TEXTURE_RECTANGLE_ARB, |
86 io_surface_texture_id_)); | 88 io_surface_texture_id_)); |
87 context3d->texImageIOSurface2DCHROMIUM(GL_TEXTURE_RECTANGLE_ARB, | 89 context3d->texImageIOSurface2DCHROMIUM(GL_TEXTURE_RECTANGLE_ARB, |
88 io_surface_size_.width(), | 90 io_surface_size_.width(), |
89 io_surface_size_.height(), | 91 io_surface_size_.height(), |
90 io_surface_id_, | 92 io_surface_id_, |
91 0); | 93 0); |
92 // Do not check for error conditions. texImageIOSurface2DCHROMIUM() is | 94 // Do not check for error conditions. texImageIOSurface2DCHROMIUM() is |
93 // supposed to hold on to the last good IOSurface if the new one is already | 95 // supposed to hold on to the last good IOSurface if the new one is already |
94 // closed. This is only a possibility during live resizing of plugins. | 96 // closed. This is only a possibility during live resizing of plugins. |
95 // However, it seems that this is not sufficient to completely guard against | 97 // However, it seems that this is not sufficient to completely guard against |
96 // garbage being drawn. If this is found to be a significant issue, it may | 98 // garbage being drawn. If this is found to be a significant issue, it may |
97 // be necessary to explicitly tell the embedder when to free the surfaces it | 99 // be necessary to explicitly tell the embedder when to free the surfaces it |
98 // has allocated. | 100 // has allocated. |
99 io_surface_changed_ = false; | 101 io_surface_changed_ = false; |
100 } | 102 } |
| 103 |
| 104 return LayerImpl::WillDraw(draw_mode, resource_provider); |
101 } | 105 } |
102 | 106 |
103 void IOSurfaceLayerImpl::AppendQuads(QuadSink* quad_sink, | 107 void IOSurfaceLayerImpl::AppendQuads(QuadSink* quad_sink, |
104 AppendQuadsData* append_quads_data) { | 108 AppendQuadsData* append_quads_data) { |
105 SharedQuadState* shared_quad_state = | 109 SharedQuadState* shared_quad_state = |
106 quad_sink->UseSharedQuadState(CreateSharedQuadState()); | 110 quad_sink->UseSharedQuadState(CreateSharedQuadState()); |
107 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 111 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
108 | 112 |
109 gfx::Rect quad_rect(content_bounds()); | 113 gfx::Rect quad_rect(content_bounds()); |
110 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); | 114 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 146 |
143 io_surface_id_ = io_surface_id; | 147 io_surface_id_ = io_surface_id; |
144 io_surface_size_ = size; | 148 io_surface_size_ = size; |
145 } | 149 } |
146 | 150 |
147 const char* IOSurfaceLayerImpl::LayerTypeAsString() const { | 151 const char* IOSurfaceLayerImpl::LayerTypeAsString() const { |
148 return "cc::IOSurfaceLayerImpl"; | 152 return "cc::IOSurfaceLayerImpl"; |
149 } | 153 } |
150 | 154 |
151 } // namespace cc | 155 } // namespace cc |
OLD | NEW |