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

Side by Side Diff: cc/layers/layer_impl.cc

Issue 23455060: mix-blend-mode implementation for accelerated layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding compositor pixel tests, clang-format Created 7 years, 2 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
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/layers/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "cc/animation/animation_registrar.h" 9 #include "cc/animation/animation_registrar.h"
10 #include "cc/animation/scrollbar_animation_controller.h" 10 #include "cc/animation/scrollbar_animation_controller.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 scrollable_(false), 42 scrollable_(false),
43 should_scroll_on_main_thread_(false), 43 should_scroll_on_main_thread_(false),
44 have_wheel_event_handlers_(false), 44 have_wheel_event_handlers_(false),
45 background_color_(0), 45 background_color_(0),
46 stacking_order_changed_(false), 46 stacking_order_changed_(false),
47 double_sided_(true), 47 double_sided_(true),
48 layer_property_changed_(false), 48 layer_property_changed_(false),
49 masks_to_bounds_(false), 49 masks_to_bounds_(false),
50 contents_opaque_(false), 50 contents_opaque_(false),
51 opacity_(1.0), 51 opacity_(1.0),
52 blend_mode_(SkXfermode::kSrcOver_Mode),
53 is_root_for_isolated_group_(false),
52 preserves_3d_(false), 54 preserves_3d_(false),
53 use_parent_backface_visibility_(false), 55 use_parent_backface_visibility_(false),
54 draw_checkerboard_for_missing_tiles_(false), 56 draw_checkerboard_for_missing_tiles_(false),
55 draws_content_(false), 57 draws_content_(false),
56 hide_layer_and_subtree_(false), 58 hide_layer_and_subtree_(false),
57 force_render_surface_(false), 59 force_render_surface_(false),
58 is_container_for_fixed_position_layers_(false), 60 is_container_for_fixed_position_layers_(false),
59 draw_depth_(0.f), 61 draw_depth_(0.f),
60 compositing_reasons_(kCompositingReasonUnknown), 62 compositing_reasons_(kCompositingReasonUnknown),
61 current_draw_mode_(DRAW_MODE_NONE), 63 current_draw_mode_(DRAW_MODE_NONE),
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 draw_properties_.render_surface.reset(); 237 draw_properties_.render_surface.reset();
236 } 238 }
237 239
238 scoped_ptr<SharedQuadState> LayerImpl::CreateSharedQuadState() const { 240 scoped_ptr<SharedQuadState> LayerImpl::CreateSharedQuadState() const {
239 scoped_ptr<SharedQuadState> state = SharedQuadState::Create(); 241 scoped_ptr<SharedQuadState> state = SharedQuadState::Create();
240 state->SetAll(draw_properties_.target_space_transform, 242 state->SetAll(draw_properties_.target_space_transform,
241 draw_properties_.content_bounds, 243 draw_properties_.content_bounds,
242 draw_properties_.visible_content_rect, 244 draw_properties_.visible_content_rect,
243 draw_properties_.clip_rect, 245 draw_properties_.clip_rect,
244 draw_properties_.is_clipped, 246 draw_properties_.is_clipped,
245 draw_properties_.opacity); 247 draw_properties_.opacity,
248 blend_mode_);
246 return state.Pass(); 249 return state.Pass();
247 } 250 }
248 251
249 bool LayerImpl::WillDraw(DrawMode draw_mode, 252 bool LayerImpl::WillDraw(DrawMode draw_mode,
250 ResourceProvider* resource_provider) { 253 ResourceProvider* resource_provider) {
251 // WillDraw/DidDraw must be matched. 254 // WillDraw/DidDraw must be matched.
252 DCHECK_NE(DRAW_MODE_NONE, draw_mode); 255 DCHECK_NE(DRAW_MODE_NONE, draw_mode);
253 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); 256 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_);
254 current_draw_mode_ = draw_mode; 257 current_draw_mode_ = draw_mode;
255 return true; 258 return true;
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); 499 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_);
497 layer->SetFilters(filters()); 500 layer->SetFilters(filters());
498 layer->SetBackgroundFilters(background_filters()); 501 layer->SetBackgroundFilters(background_filters());
499 layer->SetMasksToBounds(masks_to_bounds_); 502 layer->SetMasksToBounds(masks_to_bounds_);
500 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); 503 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_);
501 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); 504 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_);
502 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); 505 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_);
503 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); 506 layer->SetTouchEventHandlerRegion(touch_event_handler_region_);
504 layer->SetContentsOpaque(contents_opaque_); 507 layer->SetContentsOpaque(contents_opaque_);
505 layer->SetOpacity(opacity_); 508 layer->SetOpacity(opacity_);
509 layer->SetBlendMode(blend_mode_);
510 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_);
506 layer->SetPosition(position_); 511 layer->SetPosition(position_);
507 layer->SetIsContainerForFixedPositionLayers( 512 layer->SetIsContainerForFixedPositionLayers(
508 is_container_for_fixed_position_layers_); 513 is_container_for_fixed_position_layers_);
509 layer->SetFixedContainerSizeDelta(fixed_container_size_delta_); 514 layer->SetFixedContainerSizeDelta(fixed_container_size_delta_);
510 layer->SetPositionConstraint(position_constraint_); 515 layer->SetPositionConstraint(position_constraint_);
511 layer->SetPreserves3d(preserves_3d()); 516 layer->SetPreserves3d(preserves_3d());
512 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); 517 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_);
513 layer->SetSublayerTransform(sublayer_transform_); 518 layer->SetSublayerTransform(sublayer_transform_);
514 layer->SetTransform(transform_); 519 layer->SetTransform(transform_);
515 520
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 bool LayerImpl::OpacityIsAnimating() const { 846 bool LayerImpl::OpacityIsAnimating() const {
842 return layer_animation_controller_->IsAnimatingProperty(Animation::Opacity); 847 return layer_animation_controller_->IsAnimatingProperty(Animation::Opacity);
843 } 848 }
844 849
845 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const { 850 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const {
846 Animation* opacity_animation = 851 Animation* opacity_animation =
847 layer_animation_controller_->GetAnimation(Animation::Opacity); 852 layer_animation_controller_->GetAnimation(Animation::Opacity);
848 return opacity_animation && opacity_animation->is_impl_only(); 853 return opacity_animation && opacity_animation->is_impl_only();
849 } 854 }
850 855
856 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) {
857 if (blend_mode_ == blend_mode)
858 return;
859
860 blend_mode_ = blend_mode;
861 NoteLayerPropertyChangedForSubtree();
862 }
863
864 void LayerImpl::SetIsRootForIsolatedGroup(bool root) {
865 if (is_root_for_isolated_group_ == root)
866 return;
867
868 is_root_for_isolated_group_ = root;
869 }
870
851 void LayerImpl::SetPosition(gfx::PointF position) { 871 void LayerImpl::SetPosition(gfx::PointF position) {
852 if (position_ == position) 872 if (position_ == position)
853 return; 873 return;
854 874
855 position_ = position; 875 position_ = position;
856 NoteLayerPropertyChangedForSubtree(); 876 NoteLayerPropertyChangedForSubtree();
857 } 877 }
858 878
859 void LayerImpl::SetPreserves3d(bool preserves3_d) { 879 void LayerImpl::SetPreserves3d(bool preserves3_d) {
860 if (preserves_3d_ == preserves3_d) 880 if (preserves_3d_ == preserves3_d)
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 1262
1243 if (reasons & kCompositingReasonLayerForMask) 1263 if (reasons & kCompositingReasonLayerForMask)
1244 reason_list->AppendString("Is a mask layer"); 1264 reason_list->AppendString("Is a mask layer");
1245 1265
1246 if (reasons & kCompositingReasonOverflowScrollingParent) 1266 if (reasons & kCompositingReasonOverflowScrollingParent)
1247 reason_list->AppendString("Scroll parent is not an ancestor"); 1267 reason_list->AppendString("Scroll parent is not an ancestor");
1248 1268
1249 if (reasons & kCompositingReasonOutOfFlowClipping) 1269 if (reasons & kCompositingReasonOutOfFlowClipping)
1250 reason_list->AppendString("Has clipping ancestor"); 1270 reason_list->AppendString("Has clipping ancestor");
1251 1271
1272 if (reasons & kCompositingReasonIsolateCompositedDescendants)
1273 reason_list->AppendString("Should isolate composited dscendants");
1274
1252 return reason_list.PassAs<base::Value>(); 1275 return reason_list.PassAs<base::Value>();
1253 } 1276 }
1254 1277
1255 void LayerImpl::AsValueInto(base::DictionaryValue* state) const { 1278 void LayerImpl::AsValueInto(base::DictionaryValue* state) const {
1256 TracedValue::MakeDictIntoImplicitSnapshot(state, LayerTypeAsString(), this); 1279 TracedValue::MakeDictIntoImplicitSnapshot(state, LayerTypeAsString(), this);
1257 state->SetInteger("layer_id", id()); 1280 state->SetInteger("layer_id", id());
1258 state->SetString("layer_name", debug_name()); 1281 state->SetString("layer_name", debug_name());
1259 state->Set("bounds", MathUtil::AsValue(bounds()).release()); 1282 state->Set("bounds", MathUtil::AsValue(bounds()).release());
1260 state->SetInteger("draws_content", DrawsContent()); 1283 state->SetInteger("draws_content", DrawsContent());
1261 state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes()); 1284 state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 1328
1306 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } 1329 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; }
1307 1330
1308 scoped_ptr<base::Value> LayerImpl::AsValue() const { 1331 scoped_ptr<base::Value> LayerImpl::AsValue() const {
1309 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 1332 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
1310 AsValueInto(state.get()); 1333 AsValueInto(state.get());
1311 return state.PassAs<base::Value>(); 1334 return state.PassAs<base::Value>();
1312 } 1335 }
1313 1336
1314 } // namespace cc 1337 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698