| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/exo/surface.h" | 5 #include "components/exo/surface.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 render_pass->SetAll(cc::RenderPassId(1, 1), gfx::Rect(contents_surface_size), | 785 render_pass->SetAll(cc::RenderPassId(1, 1), gfx::Rect(contents_surface_size), |
| 786 damage_rect, gfx::Transform(), true); | 786 damage_rect, gfx::Transform(), true); |
| 787 | 787 |
| 788 gfx::Rect quad_rect = gfx::Rect(contents_surface_size); | 788 gfx::Rect quad_rect = gfx::Rect(contents_surface_size); |
| 789 cc::SharedQuadState* quad_state = | 789 cc::SharedQuadState* quad_state = |
| 790 render_pass->CreateAndAppendSharedQuadState(); | 790 render_pass->CreateAndAppendSharedQuadState(); |
| 791 quad_state->quad_layer_bounds = contents_surface_size; | 791 quad_state->quad_layer_bounds = contents_surface_size; |
| 792 quad_state->visible_quad_layer_rect = quad_rect; | 792 quad_state->visible_quad_layer_rect = quad_rect; |
| 793 quad_state->opacity = state_.alpha; | 793 quad_state->opacity = state_.alpha; |
| 794 | 794 |
| 795 std::unique_ptr<cc::DelegatedFrameData> delegated_frame( | 795 cc::CompositorFrame frame; |
| 796 new cc::DelegatedFrameData); | |
| 797 if (current_resource_.id) { | 796 if (current_resource_.id) { |
| 798 // Texture quad is only needed if buffer is not fully transparent. | 797 // Texture quad is only needed if buffer is not fully transparent. |
| 799 if (state_.alpha) { | 798 if (state_.alpha) { |
| 800 cc::TextureDrawQuad* texture_quad = | 799 cc::TextureDrawQuad* texture_quad = |
| 801 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); | 800 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); |
| 802 float vertex_opacity[4] = {1.0, 1.0, 1.0, 1.0}; | 801 float vertex_opacity[4] = {1.0, 1.0, 1.0, 1.0}; |
| 803 gfx::Rect opaque_rect; | 802 gfx::Rect opaque_rect; |
| 804 if (state_.blend_mode == SkXfermode::kSrc_Mode || | 803 if (state_.blend_mode == SkXfermode::kSrc_Mode || |
| 805 state_.opaque_region.contains(gfx::RectToSkIRect(quad_rect))) { | 804 state_.opaque_region.contains(gfx::RectToSkIRect(quad_rect))) { |
| 806 opaque_rect = quad_rect; | 805 opaque_rect = quad_rect; |
| 807 } else if (state_.opaque_region.isRect()) { | 806 } else if (state_.opaque_region.isRect()) { |
| 808 opaque_rect = gfx::SkIRectToRect(state_.opaque_region.getBounds()); | 807 opaque_rect = gfx::SkIRectToRect(state_.opaque_region.getBounds()); |
| 809 } | 808 } |
| 810 | 809 |
| 811 texture_quad->SetNew(quad_state, quad_rect, opaque_rect, quad_rect, | 810 texture_quad->SetNew(quad_state, quad_rect, opaque_rect, quad_rect, |
| 812 current_resource_.id, true, uv_top_left, | 811 current_resource_.id, true, uv_top_left, |
| 813 uv_bottom_right, SK_ColorTRANSPARENT, vertex_opacity, | 812 uv_bottom_right, SK_ColorTRANSPARENT, vertex_opacity, |
| 814 false, false, state_.only_visible_on_secure_output); | 813 false, false, state_.only_visible_on_secure_output); |
| 815 if (current_resource_.is_overlay_candidate) | 814 if (current_resource_.is_overlay_candidate) |
| 816 texture_quad->set_resource_size_in_pixels(current_resource_.size); | 815 texture_quad->set_resource_size_in_pixels(current_resource_.size); |
| 817 delegated_frame->resource_list.push_back(current_resource_); | 816 frame.resource_list.push_back(current_resource_); |
| 818 } | 817 } |
| 819 } else { | 818 } else { |
| 820 cc::SolidColorDrawQuad* solid_quad = | 819 cc::SolidColorDrawQuad* solid_quad = |
| 821 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); | 820 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); |
| 822 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); | 821 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); |
| 823 } | 822 } |
| 824 | 823 |
| 825 delegated_frame->render_pass_list.push_back(std::move(render_pass)); | 824 frame.render_pass_list.push_back(std::move(render_pass)); |
| 826 cc::CompositorFrame frame; | |
| 827 frame.delegated_frame_data = std::move(delegated_frame); | |
| 828 | 825 |
| 829 factory_owner_->surface_factory_->SubmitCompositorFrame( | 826 factory_owner_->surface_factory_->SubmitCompositorFrame( |
| 830 local_frame_id_, std::move(frame), cc::SurfaceFactory::DrawCallback()); | 827 local_frame_id_, std::move(frame), cc::SurfaceFactory::DrawCallback()); |
| 831 } | 828 } |
| 832 | 829 |
| 833 int64_t Surface::SetPropertyInternal(const void* key, | 830 int64_t Surface::SetPropertyInternal(const void* key, |
| 834 const char* name, | 831 const char* name, |
| 835 PropertyDeallocator deallocator, | 832 PropertyDeallocator deallocator, |
| 836 int64_t value, | 833 int64_t value, |
| 837 int64_t default_value) { | 834 int64_t default_value) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 850 | 847 |
| 851 int64_t Surface::GetPropertyInternal(const void* key, | 848 int64_t Surface::GetPropertyInternal(const void* key, |
| 852 int64_t default_value) const { | 849 int64_t default_value) const { |
| 853 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); | 850 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); |
| 854 if (iter == prop_map_.end()) | 851 if (iter == prop_map_.end()) |
| 855 return default_value; | 852 return default_value; |
| 856 return iter->second.value; | 853 return iter->second.value; |
| 857 } | 854 } |
| 858 | 855 |
| 859 } // namespace exo | 856 } // namespace exo |
| OLD | NEW |