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/strings/stringprintf.h" | 7 #include "base/strings/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 21 matching lines...) Expand all Loading... |
32 | 32 |
33 void IOSurfaceLayerImpl::DestroyTexture() { | 33 void IOSurfaceLayerImpl::DestroyTexture() { |
34 if (io_surface_resource_id_) { | 34 if (io_surface_resource_id_) { |
35 ResourceProvider* resource_provider = | 35 ResourceProvider* resource_provider = |
36 layer_tree_impl()->resource_provider(); | 36 layer_tree_impl()->resource_provider(); |
37 resource_provider->DeleteResource(io_surface_resource_id_); | 37 resource_provider->DeleteResource(io_surface_resource_id_); |
38 io_surface_resource_id_ = 0; | 38 io_surface_resource_id_ = 0; |
39 } | 39 } |
40 | 40 |
41 if (io_surface_texture_id_) { | 41 if (io_surface_texture_id_) { |
42 OutputSurface* output_surface = layer_tree_impl()->output_surface(); | 42 ContextProvider* context_provider = |
| 43 layer_tree_impl()->output_surface()->context_provider().get(); |
43 // TODO(skaslev): Implement this path for software compositing. | 44 // TODO(skaslev): Implement this path for software compositing. |
44 WebKit::WebGraphicsContext3D* context3d = output_surface->context3d(); | 45 if (context_provider) |
45 if (context3d) | 46 context_provider->Context3d()->deleteTexture(io_surface_texture_id_); |
46 context3d->deleteTexture(io_surface_texture_id_); | |
47 io_surface_texture_id_ = 0; | 47 io_surface_texture_id_ = 0; |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 scoped_ptr<LayerImpl> IOSurfaceLayerImpl::CreateLayerImpl( | 51 scoped_ptr<LayerImpl> IOSurfaceLayerImpl::CreateLayerImpl( |
52 LayerTreeImpl* tree_impl) { | 52 LayerTreeImpl* tree_impl) { |
53 return IOSurfaceLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); | 53 return IOSurfaceLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); |
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 bool IOSurfaceLayerImpl::WillDraw(DrawMode draw_mode, | 64 bool IOSurfaceLayerImpl::WillDraw(DrawMode draw_mode, |
65 ResourceProvider* resource_provider) { | 65 ResourceProvider* resource_provider) { |
66 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) | 66 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) |
67 return false; | 67 return false; |
68 | 68 |
69 if (io_surface_changed_) { | 69 if (io_surface_changed_) { |
70 WebKit::WebGraphicsContext3D* context3d = | 70 ContextProvider* context_provider = |
71 resource_provider->GraphicsContext3D(); | 71 layer_tree_impl()->output_surface()->context_provider().get(); |
72 if (!context3d) { | 72 if (!context_provider) { |
73 // TODO(skaslev): Implement this path for software compositing. | 73 // TODO(skaslev): Implement this path for software compositing. |
74 return false; | 74 return false; |
75 } | 75 } |
76 | 76 |
| 77 WebKit::WebGraphicsContext3D* context3d = context_provider->Context3d(); |
| 78 |
77 // TODO(ernstm): Do this in a way that we can track memory usage. | 79 // TODO(ernstm): Do this in a way that we can track memory usage. |
78 if (!io_surface_texture_id_) { | 80 if (!io_surface_texture_id_) { |
79 io_surface_texture_id_ = context3d->createTexture(); | 81 io_surface_texture_id_ = context3d->createTexture(); |
80 io_surface_resource_id_ = | 82 io_surface_resource_id_ = |
81 resource_provider->CreateResourceFromExternalTexture( | 83 resource_provider->CreateResourceFromExternalTexture( |
82 GL_TEXTURE_RECTANGLE_ARB, | 84 GL_TEXTURE_RECTANGLE_ARB, |
83 io_surface_texture_id_); | 85 io_surface_texture_id_); |
84 } | 86 } |
85 | 87 |
86 GLC(context3d, | 88 GLC(context3d, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 138 |
137 io_surface_id_ = io_surface_id; | 139 io_surface_id_ = io_surface_id; |
138 io_surface_size_ = size; | 140 io_surface_size_ = size; |
139 } | 141 } |
140 | 142 |
141 const char* IOSurfaceLayerImpl::LayerTypeAsString() const { | 143 const char* IOSurfaceLayerImpl::LayerTypeAsString() const { |
142 return "cc::IOSurfaceLayerImpl"; | 144 return "cc::IOSurfaceLayerImpl"; |
143 } | 145 } |
144 | 146 |
145 } // namespace cc | 147 } // namespace cc |
OLD | NEW |