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" | |
9 #include "cc/output/gl_renderer.h" // For the GLC() macro. | 8 #include "cc/output/gl_renderer.h" // For the GLC() macro. |
10 #include "cc/output/output_surface.h" | 9 #include "cc/output/output_surface.h" |
11 #include "cc/quads/io_surface_draw_quad.h" | 10 #include "cc/quads/io_surface_draw_quad.h" |
12 #include "cc/trees/layer_tree_impl.h" | 11 #include "cc/trees/layer_tree_impl.h" |
| 12 #include "cc/trees/occlusion_tracker.h" |
13 #include "gpu/GLES2/gl2extchromium.h" | 13 #include "gpu/GLES2/gl2extchromium.h" |
14 #include "gpu/command_buffer/client/gles2_interface.h" | 14 #include "gpu/command_buffer/client/gles2_interface.h" |
15 #include "third_party/khronos/GLES2/gl2.h" | 15 #include "third_party/khronos/GLES2/gl2.h" |
16 #include "third_party/khronos/GLES2/gl2ext.h" | 16 #include "third_party/khronos/GLES2/gl2ext.h" |
17 | 17 |
18 namespace cc { | 18 namespace cc { |
19 | 19 |
20 IOSurfaceLayerImpl::IOSurfaceLayerImpl(LayerTreeImpl* tree_impl, int id) | 20 IOSurfaceLayerImpl::IOSurfaceLayerImpl(LayerTreeImpl* tree_impl, int id) |
21 : LayerImpl(tree_impl, id), | 21 : LayerImpl(tree_impl, id), |
22 io_surface_id_(0), | 22 io_surface_id_(0), |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 if (io_surface_changed_) { | 57 if (io_surface_changed_) { |
58 DestroyResource(); | 58 DestroyResource(); |
59 io_surface_resource_id_ = resource_provider->CreateResourceFromIOSurface( | 59 io_surface_resource_id_ = resource_provider->CreateResourceFromIOSurface( |
60 io_surface_size_, io_surface_id_); | 60 io_surface_size_, io_surface_id_); |
61 io_surface_changed_ = false; | 61 io_surface_changed_ = false; |
62 } | 62 } |
63 | 63 |
64 return LayerImpl::WillDraw(draw_mode, resource_provider); | 64 return LayerImpl::WillDraw(draw_mode, resource_provider); |
65 } | 65 } |
66 | 66 |
67 void IOSurfaceLayerImpl::AppendQuads(QuadSink* quad_sink, | 67 void IOSurfaceLayerImpl::AppendQuads( |
68 AppendQuadsData* append_quads_data) { | 68 RenderPass* render_pass, |
69 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); | 69 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 70 AppendQuadsData* append_quads_data) { |
| 71 SharedQuadState* shared_quad_state = |
| 72 render_pass->CreateAndAppendSharedQuadState(); |
70 PopulateSharedQuadState(shared_quad_state); | 73 PopulateSharedQuadState(shared_quad_state); |
71 | 74 |
72 AppendDebugBorderQuad( | 75 AppendDebugBorderQuad( |
73 quad_sink, content_bounds(), shared_quad_state, append_quads_data); | 76 render_pass, content_bounds(), shared_quad_state, append_quads_data); |
74 | 77 |
75 gfx::Rect quad_rect(content_bounds()); | 78 gfx::Rect quad_rect(content_bounds()); |
76 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); | 79 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); |
77 gfx::Rect visible_quad_rect = quad_sink->UnoccludedContentRect( | 80 gfx::Rect visible_quad_rect = occlusion_tracker.UnoccludedContentRect( |
78 quad_rect, draw_properties().target_space_transform); | 81 quad_rect, draw_properties().target_space_transform); |
79 if (visible_quad_rect.IsEmpty()) | 82 if (visible_quad_rect.IsEmpty()) |
80 return; | 83 return; |
81 | 84 |
82 scoped_ptr<IOSurfaceDrawQuad> quad = IOSurfaceDrawQuad::Create(); | 85 scoped_ptr<IOSurfaceDrawQuad> quad = IOSurfaceDrawQuad::Create(); |
83 quad->SetNew(shared_quad_state, | 86 quad->SetNew(shared_quad_state, |
84 quad_rect, | 87 quad_rect, |
85 opaque_rect, | 88 opaque_rect, |
86 visible_quad_rect, | 89 visible_quad_rect, |
87 io_surface_size_, | 90 io_surface_size_, |
88 io_surface_resource_id_, | 91 io_surface_resource_id_, |
89 IOSurfaceDrawQuad::FLIPPED); | 92 IOSurfaceDrawQuad::FLIPPED); |
90 quad_sink->Append(quad.PassAs<DrawQuad>()); | 93 render_pass->AppendDrawQuad(quad.PassAs<DrawQuad>()); |
91 } | 94 } |
92 | 95 |
93 void IOSurfaceLayerImpl::ReleaseResources() { | 96 void IOSurfaceLayerImpl::ReleaseResources() { |
94 // We don't have a valid resource ID in the new context; however, | 97 // We don't have a valid resource ID in the new context; however, |
95 // the IOSurface is still valid. | 98 // the IOSurface is still valid. |
96 DestroyResource(); | 99 DestroyResource(); |
97 io_surface_changed_ = true; | 100 io_surface_changed_ = true; |
98 } | 101 } |
99 | 102 |
100 void IOSurfaceLayerImpl::SetIOSurfaceProperties(unsigned io_surface_id, | 103 void IOSurfaceLayerImpl::SetIOSurfaceProperties(unsigned io_surface_id, |
101 const gfx::Size& size) { | 104 const gfx::Size& size) { |
102 if (io_surface_id_ != io_surface_id) | 105 if (io_surface_id_ != io_surface_id) |
103 io_surface_changed_ = true; | 106 io_surface_changed_ = true; |
104 | 107 |
105 io_surface_id_ = io_surface_id; | 108 io_surface_id_ = io_surface_id; |
106 io_surface_size_ = size; | 109 io_surface_size_ = size; |
107 } | 110 } |
108 | 111 |
109 const char* IOSurfaceLayerImpl::LayerTypeAsString() const { | 112 const char* IOSurfaceLayerImpl::LayerTypeAsString() const { |
110 return "cc::IOSurfaceLayerImpl"; | 113 return "cc::IOSurfaceLayerImpl"; |
111 } | 114 } |
112 | 115 |
113 } // namespace cc | 116 } // namespace cc |
OLD | NEW |