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

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

Issue 2293223002: exo: Avoid creating transparent texture quads. (Closed)
Patch Set: Created 4 years, 3 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 gfx::Rect quad_rect = gfx::Rect(contents_surface_size); 777 gfx::Rect quad_rect = gfx::Rect(contents_surface_size);
778 cc::SharedQuadState* quad_state = 778 cc::SharedQuadState* quad_state =
779 render_pass->CreateAndAppendSharedQuadState(); 779 render_pass->CreateAndAppendSharedQuadState();
780 quad_state->quad_layer_bounds = contents_surface_size; 780 quad_state->quad_layer_bounds = contents_surface_size;
781 quad_state->visible_quad_layer_rect = quad_rect; 781 quad_state->visible_quad_layer_rect = quad_rect;
782 quad_state->opacity = state_.alpha; 782 quad_state->opacity = state_.alpha;
783 783
784 std::unique_ptr<cc::DelegatedFrameData> delegated_frame( 784 std::unique_ptr<cc::DelegatedFrameData> delegated_frame(
785 new cc::DelegatedFrameData); 785 new cc::DelegatedFrameData);
786 if (current_resource_.id) { 786 if (current_resource_.id) {
787 cc::TextureDrawQuad* texture_quad = 787 // Texture quad is only needed if buffer is not fully transparent.
788 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); 788 if (state_.alpha) {
789 float vertex_opacity[4] = {1.0, 1.0, 1.0, 1.0}; 789 cc::TextureDrawQuad* texture_quad =
790 gfx::Rect opaque_rect; 790 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>();
791 if (state_.blend_mode == SkXfermode::kSrc_Mode || 791 float vertex_opacity[4] = {1.0, 1.0, 1.0, 1.0};
792 state_.opaque_region.contains(gfx::RectToSkIRect(quad_rect))) { 792 gfx::Rect opaque_rect;
793 opaque_rect = quad_rect; 793 if (state_.blend_mode == SkXfermode::kSrc_Mode ||
794 } else if (state_.opaque_region.isRect()) { 794 state_.opaque_region.contains(gfx::RectToSkIRect(quad_rect))) {
795 opaque_rect = gfx::SkIRectToRect(state_.opaque_region.getBounds()); 795 opaque_rect = quad_rect;
796 } else if (state_.opaque_region.isRect()) {
797 opaque_rect = gfx::SkIRectToRect(state_.opaque_region.getBounds());
798 }
799
800 texture_quad->SetNew(quad_state, quad_rect, opaque_rect, quad_rect,
801 current_resource_.id, true, uv_top_left,
802 uv_bottom_right, SK_ColorTRANSPARENT, vertex_opacity,
803 false, false, state_.only_visible_on_secure_output);
804 delegated_frame->resource_list.push_back(current_resource_);
796 } 805 }
797
798 texture_quad->SetNew(quad_state, quad_rect, opaque_rect, quad_rect,
799 current_resource_.id, true, uv_top_left,
800 uv_bottom_right, SK_ColorTRANSPARENT, vertex_opacity,
801 false, false, state_.only_visible_on_secure_output);
802 delegated_frame->resource_list.push_back(current_resource_);
803 } else { 806 } else {
804 cc::SolidColorDrawQuad* solid_quad = 807 cc::SolidColorDrawQuad* solid_quad =
805 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); 808 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>();
806 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); 809 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false);
807 } 810 }
808 811
809 delegated_frame->render_pass_list.push_back(std::move(render_pass)); 812 delegated_frame->render_pass_list.push_back(std::move(render_pass));
810 cc::CompositorFrame frame; 813 cc::CompositorFrame frame;
811 frame.delegated_frame_data = std::move(delegated_frame); 814 frame.delegated_frame_data = std::move(delegated_frame);
812 815
(...skipping 21 matching lines...) Expand all
834 837
835 int64_t Surface::GetPropertyInternal(const void* key, 838 int64_t Surface::GetPropertyInternal(const void* key,
836 int64_t default_value) const { 839 int64_t default_value) const {
837 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); 840 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key);
838 if (iter == prop_map_.end()) 841 if (iter == prop_map_.end())
839 return default_value; 842 return default_value;
840 return iter->second.value; 843 return iter->second.value;
841 } 844 }
842 845
843 } // namespace exo 846 } // namespace exo
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698