| 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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 render_pass->SetAll(cc::RenderPassId(1, 1), gfx::Rect(contents_surface_size), | 762 render_pass->SetAll(cc::RenderPassId(1, 1), gfx::Rect(contents_surface_size), |
| 763 damage_rect, gfx::Transform(), true); | 763 damage_rect, gfx::Transform(), true); |
| 764 | 764 |
| 765 gfx::Rect quad_rect = gfx::Rect(contents_surface_size); | 765 gfx::Rect quad_rect = gfx::Rect(contents_surface_size); |
| 766 cc::SharedQuadState* quad_state = | 766 cc::SharedQuadState* quad_state = |
| 767 render_pass->CreateAndAppendSharedQuadState(); | 767 render_pass->CreateAndAppendSharedQuadState(); |
| 768 quad_state->quad_layer_bounds = contents_surface_size; | 768 quad_state->quad_layer_bounds = contents_surface_size; |
| 769 quad_state->visible_quad_layer_rect = quad_rect; | 769 quad_state->visible_quad_layer_rect = quad_rect; |
| 770 quad_state->opacity = state_.alpha; | 770 quad_state->opacity = state_.alpha; |
| 771 | 771 |
| 772 std::unique_ptr<cc::DelegatedFrameData> delegated_frame( | 772 cc::CompositorFrame frame; |
| 773 new cc::DelegatedFrameData); | |
| 774 if (current_resource_.id) { | 773 if (current_resource_.id) { |
| 775 // Texture quad is only needed if buffer is not fully transparent. | 774 // Texture quad is only needed if buffer is not fully transparent. |
| 776 if (state_.alpha) { | 775 if (state_.alpha) { |
| 777 cc::TextureDrawQuad* texture_quad = | 776 cc::TextureDrawQuad* texture_quad = |
| 778 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); | 777 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); |
| 779 float vertex_opacity[4] = {1.0, 1.0, 1.0, 1.0}; | 778 float vertex_opacity[4] = {1.0, 1.0, 1.0, 1.0}; |
| 780 gfx::Rect opaque_rect; | 779 gfx::Rect opaque_rect; |
| 781 if (state_.blend_mode == SkXfermode::kSrc_Mode || | 780 if (state_.blend_mode == SkXfermode::kSrc_Mode || |
| 782 state_.opaque_region.contains(gfx::RectToSkIRect(quad_rect))) { | 781 state_.opaque_region.contains(gfx::RectToSkIRect(quad_rect))) { |
| 783 opaque_rect = quad_rect; | 782 opaque_rect = quad_rect; |
| 784 } else if (state_.opaque_region.isRect()) { | 783 } else if (state_.opaque_region.isRect()) { |
| 785 opaque_rect = gfx::SkIRectToRect(state_.opaque_region.getBounds()); | 784 opaque_rect = gfx::SkIRectToRect(state_.opaque_region.getBounds()); |
| 786 } | 785 } |
| 787 | 786 |
| 788 texture_quad->SetNew(quad_state, quad_rect, opaque_rect, quad_rect, | 787 texture_quad->SetNew(quad_state, quad_rect, opaque_rect, quad_rect, |
| 789 current_resource_.id, true, uv_top_left, | 788 current_resource_.id, true, uv_top_left, |
| 790 uv_bottom_right, SK_ColorTRANSPARENT, vertex_opacity, | 789 uv_bottom_right, SK_ColorTRANSPARENT, vertex_opacity, |
| 791 false, false, state_.only_visible_on_secure_output); | 790 false, false, state_.only_visible_on_secure_output); |
| 792 if (current_resource_.is_overlay_candidate) | 791 if (current_resource_.is_overlay_candidate) |
| 793 texture_quad->set_resource_size_in_pixels(current_resource_.size); | 792 texture_quad->set_resource_size_in_pixels(current_resource_.size); |
| 794 delegated_frame->resource_list.push_back(current_resource_); | 793 frame.resource_list.push_back(current_resource_); |
| 795 } | 794 } |
| 796 } else { | 795 } else { |
| 797 cc::SolidColorDrawQuad* solid_quad = | 796 cc::SolidColorDrawQuad* solid_quad = |
| 798 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); | 797 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); |
| 799 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); | 798 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); |
| 800 } | 799 } |
| 801 | 800 |
| 802 delegated_frame->render_pass_list.push_back(std::move(render_pass)); | 801 frame.render_pass_list.push_back(std::move(render_pass)); |
| 803 cc::CompositorFrame frame; | |
| 804 frame.delegated_frame_data = std::move(delegated_frame); | |
| 805 | 802 |
| 806 factory_owner_->surface_factory_->SubmitCompositorFrame( | 803 factory_owner_->surface_factory_->SubmitCompositorFrame( |
| 807 local_frame_id_, std::move(frame), cc::SurfaceFactory::DrawCallback()); | 804 local_frame_id_, std::move(frame), cc::SurfaceFactory::DrawCallback()); |
| 808 } | 805 } |
| 809 | 806 |
| 810 int64_t Surface::SetPropertyInternal(const void* key, | 807 int64_t Surface::SetPropertyInternal(const void* key, |
| 811 const char* name, | 808 const char* name, |
| 812 PropertyDeallocator deallocator, | 809 PropertyDeallocator deallocator, |
| 813 int64_t value, | 810 int64_t value, |
| 814 int64_t default_value) { | 811 int64_t default_value) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 827 | 824 |
| 828 int64_t Surface::GetPropertyInternal(const void* key, | 825 int64_t Surface::GetPropertyInternal(const void* key, |
| 829 int64_t default_value) const { | 826 int64_t default_value) const { |
| 830 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); | 827 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); |
| 831 if (iter == prop_map_.end()) | 828 if (iter == prop_map_.end()) |
| 832 return default_value; | 829 return default_value; |
| 833 return iter->second.value; | 830 return iter->second.value; |
| 834 } | 831 } |
| 835 | 832 |
| 836 } // namespace exo | 833 } // namespace exo |
| OLD | NEW |