| 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(quad_sink, shared_quad_state, append_quads_data); | 75 AppendDebugBorderQuad(render_pass, shared_quad_state, append_quads_data); |
| 73 | 76 |
| 74 gfx::Rect quad_rect(content_bounds()); | 77 gfx::Rect quad_rect(content_bounds()); |
| 75 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); | 78 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); |
| 76 gfx::Rect visible_quad_rect = quad_sink->UnoccludedContentRect( | 79 gfx::Rect visible_quad_rect = occlusion_tracker.UnoccludedContentRect( |
| 77 this, quad_rect, draw_properties().target_space_transform); | 80 this->render_target(), |
| 81 quad_rect, |
| 82 draw_properties().target_space_transform); |
| 78 if (visible_quad_rect.IsEmpty()) | 83 if (visible_quad_rect.IsEmpty()) |
| 79 return; | 84 return; |
| 80 | 85 |
| 81 scoped_ptr<IOSurfaceDrawQuad> quad = IOSurfaceDrawQuad::Create(); | 86 scoped_ptr<IOSurfaceDrawQuad> quad = IOSurfaceDrawQuad::Create(); |
| 82 quad->SetNew(shared_quad_state, | 87 quad->SetNew(shared_quad_state, |
| 83 quad_rect, | 88 quad_rect, |
| 84 opaque_rect, | 89 opaque_rect, |
| 85 visible_quad_rect, | 90 visible_quad_rect, |
| 86 io_surface_size_, | 91 io_surface_size_, |
| 87 io_surface_resource_id_, | 92 io_surface_resource_id_, |
| 88 IOSurfaceDrawQuad::FLIPPED); | 93 IOSurfaceDrawQuad::FLIPPED); |
| 89 quad_sink->Append(quad.PassAs<DrawQuad>()); | 94 render_pass->AppendDrawQuad(quad.PassAs<DrawQuad>()); |
| 90 } | 95 } |
| 91 | 96 |
| 92 void IOSurfaceLayerImpl::ReleaseResources() { | 97 void IOSurfaceLayerImpl::ReleaseResources() { |
| 93 // We don't have a valid resource ID in the new context; however, | 98 // We don't have a valid resource ID in the new context; however, |
| 94 // the IOSurface is still valid. | 99 // the IOSurface is still valid. |
| 95 DestroyResource(); | 100 DestroyResource(); |
| 96 io_surface_changed_ = true; | 101 io_surface_changed_ = true; |
| 97 } | 102 } |
| 98 | 103 |
| 99 void IOSurfaceLayerImpl::SetIOSurfaceProperties(unsigned io_surface_id, | 104 void IOSurfaceLayerImpl::SetIOSurfaceProperties(unsigned io_surface_id, |
| 100 const gfx::Size& size) { | 105 const gfx::Size& size) { |
| 101 if (io_surface_id_ != io_surface_id) | 106 if (io_surface_id_ != io_surface_id) |
| 102 io_surface_changed_ = true; | 107 io_surface_changed_ = true; |
| 103 | 108 |
| 104 io_surface_id_ = io_surface_id; | 109 io_surface_id_ = io_surface_id; |
| 105 io_surface_size_ = size; | 110 io_surface_size_ = size; |
| 106 } | 111 } |
| 107 | 112 |
| 108 const char* IOSurfaceLayerImpl::LayerTypeAsString() const { | 113 const char* IOSurfaceLayerImpl::LayerTypeAsString() const { |
| 109 return "cc::IOSurfaceLayerImpl"; | 114 return "cc::IOSurfaceLayerImpl"; |
| 110 } | 115 } |
| 111 | 116 |
| 112 } // namespace cc | 117 } // namespace cc |
| OLD | NEW |