Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: components/exo/surface.cc

Issue 2502373003: stop using SkXfermode -- use SkBlendMode instead (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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", blend_mode);
425 425
426 pending_state_.blend_mode = blend_mode; 426 pending_state_.blend_mode = blend_mode;
427 } 427 }
428 428
429 void Surface::SetAlpha(float alpha) { 429 void Surface::SetAlpha(float alpha) {
430 TRACE_EVENT1("exo", "Surface::SetAlpha", "alpha", alpha); 430 TRACE_EVENT1("exo", "Surface::SetAlpha", "alpha", alpha);
431 431
432 pending_state_.alpha = alpha; 432 pending_state_.alpha = alpha;
433 } 433 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 // the layer may be mirrored, in which case a surface change causes the 495 // the layer may be mirrored, in which case a surface change causes the
496 // mirror layer to update its surface using the latest bounds. 496 // mirror layer to update its surface using the latest bounds.
497 window_->layer()->SetBounds( 497 window_->layer()->SetBounds(
498 gfx::Rect(window_->layer()->bounds().origin(), content_size_)); 498 gfx::Rect(window_->layer()->bounds().origin(), content_size_));
499 window_->layer()->SetShowSurface( 499 window_->layer()->SetShowSurface(
500 cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_), 500 cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_),
501 base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)), 501 base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)),
502 base::Bind(&RequireCallback, base::Unretained(surface_manager_)), 502 base::Bind(&RequireCallback, base::Unretained(surface_manager_)),
503 content_size_, contents_surface_to_layer_scale, content_size_); 503 content_size_, contents_surface_to_layer_scale, content_size_);
504 window_->layer()->SetFillsBoundsOpaquely( 504 window_->layer()->SetFillsBoundsOpaquely(
505 state_.blend_mode == SkXfermode::kSrc_Mode || 505 state_.blend_mode == SkBlendMode::kSrc ||
506 state_.opaque_region.contains( 506 state_.opaque_region.contains(
507 gfx::RectToSkIRect(gfx::Rect(content_size_)))); 507 gfx::RectToSkIRect(gfx::Rect(content_size_))));
508 } 508 }
509 509
510 // Reset damage. 510 // Reset damage.
511 pending_damage_.setEmpty(); 511 pending_damage_.setEmpty();
512 512
513 DCHECK(!current_resource_.id || 513 DCHECK(!current_resource_.id ||
514 factory_owner_->release_callbacks_.count(current_resource_.id)); 514 factory_owner_->release_callbacks_.count(current_resource_.id));
515 515
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 813
814 std::unique_ptr<cc::DelegatedFrameData> delegated_frame( 814 std::unique_ptr<cc::DelegatedFrameData> delegated_frame(
815 new cc::DelegatedFrameData); 815 new cc::DelegatedFrameData);
816 if (current_resource_.id) { 816 if (current_resource_.id) {
817 // Texture quad is only needed if buffer is not fully transparent. 817 // Texture quad is only needed if buffer is not fully transparent.
818 if (state_.alpha) { 818 if (state_.alpha) {
819 cc::TextureDrawQuad* texture_quad = 819 cc::TextureDrawQuad* texture_quad =
820 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); 820 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>();
821 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};
822 gfx::Rect opaque_rect; 822 gfx::Rect opaque_rect;
823 if (state_.blend_mode == SkXfermode::kSrc_Mode || 823 if (state_.blend_mode == SkBlendMode::kSrc ||
824 state_.opaque_region.contains(gfx::RectToSkIRect(quad_rect))) { 824 state_.opaque_region.contains(gfx::RectToSkIRect(quad_rect))) {
825 opaque_rect = quad_rect; 825 opaque_rect = quad_rect;
826 } else if (state_.opaque_region.isRect()) { 826 } else if (state_.opaque_region.isRect()) {
827 opaque_rect = gfx::SkIRectToRect(state_.opaque_region.getBounds()); 827 opaque_rect = gfx::SkIRectToRect(state_.opaque_region.getBounds());
828 } 828 }
829 829
830 texture_quad->SetNew(quad_state, quad_rect, opaque_rect, quad_rect, 830 texture_quad->SetNew(quad_state, quad_rect, opaque_rect, quad_rect,
831 current_resource_.id, true, uv_top_left, 831 current_resource_.id, true, uv_top_left,
832 uv_bottom_right, SK_ColorTRANSPARENT, vertex_opacity, 832 uv_bottom_right, SK_ColorTRANSPARENT, vertex_opacity,
833 false, false, state_.only_visible_on_secure_output); 833 false, false, state_.only_visible_on_secure_output);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 884
885 int64_t Surface::GetPropertyInternal(const void* key, 885 int64_t Surface::GetPropertyInternal(const void* key,
886 int64_t default_value) const { 886 int64_t default_value) const {
887 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); 887 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key);
888 if (iter == prop_map_.end()) 888 if (iter == prop_map_.end())
889 return default_value; 889 return default_value;
890 return iter->second.value; 890 return iter->second.value;
891 } 891 }
892 892
893 } // namespace exo 893 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698