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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 gfx::Rect quad_rect = gfx::Rect(contents_surface_size); | 784 gfx::Rect quad_rect = gfx::Rect(contents_surface_size); |
785 cc::SharedQuadState* quad_state = | 785 cc::SharedQuadState* quad_state = |
786 render_pass->CreateAndAppendSharedQuadState(); | 786 render_pass->CreateAndAppendSharedQuadState(); |
787 quad_state->quad_layer_bounds = contents_surface_size; | 787 quad_state->quad_layer_bounds = contents_surface_size; |
788 quad_state->visible_quad_layer_rect = quad_rect; | 788 quad_state->visible_quad_layer_rect = quad_rect; |
789 quad_state->opacity = state_.alpha; | 789 quad_state->opacity = state_.alpha; |
790 | 790 |
791 std::unique_ptr<cc::DelegatedFrameData> delegated_frame( | 791 std::unique_ptr<cc::DelegatedFrameData> delegated_frame( |
792 new cc::DelegatedFrameData); | 792 new cc::DelegatedFrameData); |
793 if (current_resource_.id) { | 793 if (current_resource_.id) { |
794 cc::TextureDrawQuad* texture_quad = | 794 // Texture quad is only needed if buffer is not fully transparent. |
795 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); | 795 if (state_.alpha) { |
796 float vertex_opacity[4] = {1.0, 1.0, 1.0, 1.0}; | 796 cc::TextureDrawQuad* texture_quad = |
797 gfx::Rect opaque_rect; | 797 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); |
798 if (state_.blend_mode == SkXfermode::kSrc_Mode || | 798 float vertex_opacity[4] = {1.0, 1.0, 1.0, 1.0}; |
799 state_.opaque_region.contains(gfx::RectToSkIRect(quad_rect))) { | 799 gfx::Rect opaque_rect; |
800 opaque_rect = quad_rect; | 800 if (state_.blend_mode == SkXfermode::kSrc_Mode || |
801 } else if (state_.opaque_region.isRect()) { | 801 state_.opaque_region.contains(gfx::RectToSkIRect(quad_rect))) { |
802 opaque_rect = gfx::SkIRectToRect(state_.opaque_region.getBounds()); | 802 opaque_rect = quad_rect; |
| 803 } else if (state_.opaque_region.isRect()) { |
| 804 opaque_rect = gfx::SkIRectToRect(state_.opaque_region.getBounds()); |
| 805 } |
| 806 |
| 807 texture_quad->SetNew(quad_state, quad_rect, opaque_rect, quad_rect, |
| 808 current_resource_.id, true, uv_top_left, |
| 809 uv_bottom_right, SK_ColorTRANSPARENT, vertex_opacity, |
| 810 false, false, state_.only_visible_on_secure_output); |
| 811 if (current_resource_.is_overlay_candidate) |
| 812 texture_quad->set_resource_size_in_pixels(current_resource_.size); |
| 813 delegated_frame->resource_list.push_back(current_resource_); |
803 } | 814 } |
804 | |
805 texture_quad->SetNew(quad_state, quad_rect, opaque_rect, quad_rect, | |
806 current_resource_.id, true, uv_top_left, | |
807 uv_bottom_right, SK_ColorTRANSPARENT, vertex_opacity, | |
808 false, false, state_.only_visible_on_secure_output); | |
809 if (current_resource_.is_overlay_candidate) | |
810 texture_quad->set_resource_size_in_pixels(current_resource_.size); | |
811 delegated_frame->resource_list.push_back(current_resource_); | |
812 } else { | 815 } else { |
813 cc::SolidColorDrawQuad* solid_quad = | 816 cc::SolidColorDrawQuad* solid_quad = |
814 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); | 817 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); |
815 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); | 818 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); |
816 } | 819 } |
817 | 820 |
818 delegated_frame->render_pass_list.push_back(std::move(render_pass)); | 821 delegated_frame->render_pass_list.push_back(std::move(render_pass)); |
819 cc::CompositorFrame frame; | 822 cc::CompositorFrame frame; |
820 frame.delegated_frame_data = std::move(delegated_frame); | 823 frame.delegated_frame_data = std::move(delegated_frame); |
821 | 824 |
(...skipping 21 matching lines...) Expand all Loading... |
843 | 846 |
844 int64_t Surface::GetPropertyInternal(const void* key, | 847 int64_t Surface::GetPropertyInternal(const void* key, |
845 int64_t default_value) const { | 848 int64_t default_value) const { |
846 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); | 849 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); |
847 if (iter == prop_map_.end()) | 850 if (iter == prop_map_.end()) |
848 return default_value; | 851 return default_value; |
849 return iter->second.value; | 852 return iter->second.value; |
850 } | 853 } |
851 | 854 |
852 } // namespace exo | 855 } // namespace exo |
OLD | NEW |