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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 pending_state_.crop = crop; | 413 pending_state_.crop = crop; |
414 } | 414 } |
415 | 415 |
416 void Surface::SetOnlyVisibleOnSecureOutput(bool only_visible_on_secure_output) { | 416 void Surface::SetOnlyVisibleOnSecureOutput(bool only_visible_on_secure_output) { |
417 TRACE_EVENT1("exo", "Surface::SetOnlyVisibleOnSecureOutput", | 417 TRACE_EVENT1("exo", "Surface::SetOnlyVisibleOnSecureOutput", |
418 "only_visible_on_secure_output", only_visible_on_secure_output); | 418 "only_visible_on_secure_output", only_visible_on_secure_output); |
419 | 419 |
420 pending_state_.only_visible_on_secure_output = only_visible_on_secure_output; | 420 pending_state_.only_visible_on_secure_output = only_visible_on_secure_output; |
421 } | 421 } |
422 | 422 |
423 void Surface::SetBlendMode(SkXfermode::Mode blend_mode) { | 423 void Surface::SetBlendMode(SkBlendMode blend_mode) { |
424 TRACE_EVENT1("exo", "Surface::SetBlendMode", "blend_mode", blend_mode); | 424 TRACE_EVENT1("exo", "Surface::SetBlendMode", "blend_mode", |
| 425 static_cast<int>(blend_mode)); |
425 | 426 |
426 pending_state_.blend_mode = blend_mode; | 427 pending_state_.blend_mode = blend_mode; |
427 } | 428 } |
428 | 429 |
429 void Surface::SetAlpha(float alpha) { | 430 void Surface::SetAlpha(float alpha) { |
430 TRACE_EVENT1("exo", "Surface::SetAlpha", "alpha", alpha); | 431 TRACE_EVENT1("exo", "Surface::SetAlpha", "alpha", alpha); |
431 | 432 |
432 pending_state_.alpha = alpha; | 433 pending_state_.alpha = alpha; |
433 } | 434 } |
434 | 435 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 // the layer may be mirrored, in which case a surface change causes the | 496 // the layer may be mirrored, in which case a surface change causes the |
496 // mirror layer to update its surface using the latest bounds. | 497 // mirror layer to update its surface using the latest bounds. |
497 window_->layer()->SetBounds( | 498 window_->layer()->SetBounds( |
498 gfx::Rect(window_->layer()->bounds().origin(), content_size_)); | 499 gfx::Rect(window_->layer()->bounds().origin(), content_size_)); |
499 window_->layer()->SetShowSurface( | 500 window_->layer()->SetShowSurface( |
500 cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_), | 501 cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_), |
501 base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)), | 502 base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)), |
502 base::Bind(&RequireCallback, base::Unretained(surface_manager_)), | 503 base::Bind(&RequireCallback, base::Unretained(surface_manager_)), |
503 content_size_, contents_surface_to_layer_scale, content_size_); | 504 content_size_, contents_surface_to_layer_scale, content_size_); |
504 window_->layer()->SetFillsBoundsOpaquely( | 505 window_->layer()->SetFillsBoundsOpaquely( |
505 state_.blend_mode == SkXfermode::kSrc_Mode || | 506 state_.blend_mode == SkBlendMode::kSrc || |
506 state_.opaque_region.contains( | 507 state_.opaque_region.contains( |
507 gfx::RectToSkIRect(gfx::Rect(content_size_)))); | 508 gfx::RectToSkIRect(gfx::Rect(content_size_)))); |
508 } | 509 } |
509 | 510 |
510 // Reset damage. | 511 // Reset damage. |
511 pending_damage_.setEmpty(); | 512 pending_damage_.setEmpty(); |
512 | 513 |
513 DCHECK(!current_resource_.id || | 514 DCHECK(!current_resource_.id || |
514 factory_owner_->release_callbacks_.count(current_resource_.id)); | 515 factory_owner_->release_callbacks_.count(current_resource_.id)); |
515 | 516 |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 quad_state->opacity = state_.alpha; | 813 quad_state->opacity = state_.alpha; |
813 | 814 |
814 cc::CompositorFrame frame; | 815 cc::CompositorFrame frame; |
815 if (current_resource_.id) { | 816 if (current_resource_.id) { |
816 // Texture quad is only needed if buffer is not fully transparent. | 817 // Texture quad is only needed if buffer is not fully transparent. |
817 if (state_.alpha) { | 818 if (state_.alpha) { |
818 cc::TextureDrawQuad* texture_quad = | 819 cc::TextureDrawQuad* texture_quad = |
819 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); | 820 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); |
820 float vertex_opacity[4] = {1.0, 1.0, 1.0, 1.0}; | 821 float vertex_opacity[4] = {1.0, 1.0, 1.0, 1.0}; |
821 gfx::Rect opaque_rect; | 822 gfx::Rect opaque_rect; |
822 if (state_.blend_mode == SkXfermode::kSrc_Mode || | 823 if (state_.blend_mode == SkBlendMode::kSrc || |
823 state_.opaque_region.contains(gfx::RectToSkIRect(quad_rect))) { | 824 state_.opaque_region.contains(gfx::RectToSkIRect(quad_rect))) { |
824 opaque_rect = quad_rect; | 825 opaque_rect = quad_rect; |
825 } else if (state_.opaque_region.isRect()) { | 826 } else if (state_.opaque_region.isRect()) { |
826 opaque_rect = gfx::SkIRectToRect(state_.opaque_region.getBounds()); | 827 opaque_rect = gfx::SkIRectToRect(state_.opaque_region.getBounds()); |
827 } | 828 } |
828 | 829 |
829 texture_quad->SetNew(quad_state, quad_rect, opaque_rect, quad_rect, | 830 texture_quad->SetNew(quad_state, quad_rect, opaque_rect, quad_rect, |
830 current_resource_.id, true, uv_top_left, | 831 current_resource_.id, true, uv_top_left, |
831 uv_bottom_right, SK_ColorTRANSPARENT, vertex_opacity, | 832 uv_bottom_right, SK_ColorTRANSPARENT, vertex_opacity, |
832 false, false, state_.only_visible_on_secure_output); | 833 false, false, state_.only_visible_on_secure_output); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 | 882 |
882 int64_t Surface::GetPropertyInternal(const void* key, | 883 int64_t Surface::GetPropertyInternal(const void* key, |
883 int64_t default_value) const { | 884 int64_t default_value) const { |
884 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); | 885 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); |
885 if (iter == prop_map_.end()) | 886 if (iter == prop_map_.end()) |
886 return default_value; | 887 return default_value; |
887 return iter->second.value; | 888 return iter->second.value; |
888 } | 889 } |
889 | 890 |
890 } // namespace exo | 891 } // namespace exo |
OLD | NEW |