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

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: Addressing comments #40 Created 7 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 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 have_wheel_event_handlers_(false), 44 have_wheel_event_handlers_(false),
45 user_scrollable_horizontal_(true), 45 user_scrollable_horizontal_(true),
46 user_scrollable_vertical_(true), 46 user_scrollable_vertical_(true),
47 background_color_(0), 47 background_color_(0),
48 stacking_order_changed_(false), 48 stacking_order_changed_(false),
49 double_sided_(true), 49 double_sided_(true),
50 layer_property_changed_(false), 50 layer_property_changed_(false),
51 masks_to_bounds_(false), 51 masks_to_bounds_(false),
52 contents_opaque_(false), 52 contents_opaque_(false),
53 opacity_(1.0), 53 opacity_(1.0),
54 blend_mode_(SkXfermode::kSrcOver_Mode),
55 is_root_for_isolated_group_(false),
54 preserves_3d_(false), 56 preserves_3d_(false),
55 use_parent_backface_visibility_(false), 57 use_parent_backface_visibility_(false),
56 draw_checkerboard_for_missing_tiles_(false), 58 draw_checkerboard_for_missing_tiles_(false),
57 draws_content_(false), 59 draws_content_(false),
58 hide_layer_and_subtree_(false), 60 hide_layer_and_subtree_(false),
59 force_render_surface_(false), 61 force_render_surface_(false),
60 is_container_for_fixed_position_layers_(false), 62 is_container_for_fixed_position_layers_(false),
61 draw_depth_(0.f), 63 draw_depth_(0.f),
62 compositing_reasons_(kCompositingReasonUnknown), 64 compositing_reasons_(kCompositingReasonUnknown),
63 current_draw_mode_(DRAW_MODE_NONE), 65 current_draw_mode_(DRAW_MODE_NONE),
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 draw_properties_.render_surface.reset(); 239 draw_properties_.render_surface.reset();
238 } 240 }
239 241
240 scoped_ptr<SharedQuadState> LayerImpl::CreateSharedQuadState() const { 242 scoped_ptr<SharedQuadState> LayerImpl::CreateSharedQuadState() const {
241 scoped_ptr<SharedQuadState> state = SharedQuadState::Create(); 243 scoped_ptr<SharedQuadState> state = SharedQuadState::Create();
242 state->SetAll(draw_properties_.target_space_transform, 244 state->SetAll(draw_properties_.target_space_transform,
243 draw_properties_.content_bounds, 245 draw_properties_.content_bounds,
244 draw_properties_.visible_content_rect, 246 draw_properties_.visible_content_rect,
245 draw_properties_.clip_rect, 247 draw_properties_.clip_rect,
246 draw_properties_.is_clipped, 248 draw_properties_.is_clipped,
247 draw_properties_.opacity); 249 draw_properties_.opacity,
250 blend_mode_);
248 return state.Pass(); 251 return state.Pass();
249 } 252 }
250 253
251 bool LayerImpl::WillDraw(DrawMode draw_mode, 254 bool LayerImpl::WillDraw(DrawMode draw_mode,
252 ResourceProvider* resource_provider) { 255 ResourceProvider* resource_provider) {
253 // WillDraw/DidDraw must be matched. 256 // WillDraw/DidDraw must be matched.
254 DCHECK_NE(DRAW_MODE_NONE, draw_mode); 257 DCHECK_NE(DRAW_MODE_NONE, draw_mode);
255 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); 258 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_);
256 current_draw_mode_ = draw_mode; 259 current_draw_mode_ = draw_mode;
257 return true; 260 return true;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); 518 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_);
516 layer->SetFilters(filters()); 519 layer->SetFilters(filters());
517 layer->SetBackgroundFilters(background_filters()); 520 layer->SetBackgroundFilters(background_filters());
518 layer->SetMasksToBounds(masks_to_bounds_); 521 layer->SetMasksToBounds(masks_to_bounds_);
519 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); 522 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_);
520 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); 523 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_);
521 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); 524 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_);
522 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); 525 layer->SetTouchEventHandlerRegion(touch_event_handler_region_);
523 layer->SetContentsOpaque(contents_opaque_); 526 layer->SetContentsOpaque(contents_opaque_);
524 layer->SetOpacity(opacity_); 527 layer->SetOpacity(opacity_);
528 layer->SetBlendMode(blend_mode_);
529 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_);
525 layer->SetPosition(position_); 530 layer->SetPosition(position_);
526 layer->SetIsContainerForFixedPositionLayers( 531 layer->SetIsContainerForFixedPositionLayers(
527 is_container_for_fixed_position_layers_); 532 is_container_for_fixed_position_layers_);
528 layer->SetFixedContainerSizeDelta(fixed_container_size_delta_); 533 layer->SetFixedContainerSizeDelta(fixed_container_size_delta_);
529 layer->SetPositionConstraint(position_constraint_); 534 layer->SetPositionConstraint(position_constraint_);
530 layer->SetPreserves3d(preserves_3d()); 535 layer->SetPreserves3d(preserves_3d());
531 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); 536 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_);
532 layer->SetSublayerTransform(sublayer_transform_); 537 layer->SetSublayerTransform(sublayer_transform_);
533 layer->SetTransform(transform_); 538 layer->SetTransform(transform_);
534 539
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 bool LayerImpl::OpacityIsAnimating() const { 874 bool LayerImpl::OpacityIsAnimating() const {
870 return layer_animation_controller_->IsAnimatingProperty(Animation::Opacity); 875 return layer_animation_controller_->IsAnimatingProperty(Animation::Opacity);
871 } 876 }
872 877
873 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const { 878 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const {
874 Animation* opacity_animation = 879 Animation* opacity_animation =
875 layer_animation_controller_->GetAnimation(Animation::Opacity); 880 layer_animation_controller_->GetAnimation(Animation::Opacity);
876 return opacity_animation && opacity_animation->is_impl_only(); 881 return opacity_animation && opacity_animation->is_impl_only();
877 } 882 }
878 883
884 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) {
885 if (blend_mode_ == blend_mode)
886 return;
887
888 blend_mode_ = blend_mode;
889 NoteLayerPropertyChangedForSubtree();
890 }
891
892 void LayerImpl::SetIsRootForIsolatedGroup(bool root) {
893 if (is_root_for_isolated_group_ == root)
894 return;
895
896 is_root_for_isolated_group_ = root;
897 }
898
879 void LayerImpl::SetPosition(gfx::PointF position) { 899 void LayerImpl::SetPosition(gfx::PointF position) {
880 if (position_ == position) 900 if (position_ == position)
881 return; 901 return;
882 902
883 position_ = position; 903 position_ = position;
884 NoteLayerPropertyChangedForSubtree(); 904 NoteLayerPropertyChangedForSubtree();
885 } 905 }
886 906
887 void LayerImpl::SetPreserves3d(bool preserves3_d) { 907 void LayerImpl::SetPreserves3d(bool preserves3_d) {
888 if (preserves_3d_ == preserves3_d) 908 if (preserves_3d_ == preserves3_d)
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 1290
1271 if (reasons & kCompositingReasonLayerForMask) 1291 if (reasons & kCompositingReasonLayerForMask)
1272 reason_list->AppendString("Is a mask layer"); 1292 reason_list->AppendString("Is a mask layer");
1273 1293
1274 if (reasons & kCompositingReasonOverflowScrollingParent) 1294 if (reasons & kCompositingReasonOverflowScrollingParent)
1275 reason_list->AppendString("Scroll parent is not an ancestor"); 1295 reason_list->AppendString("Scroll parent is not an ancestor");
1276 1296
1277 if (reasons & kCompositingReasonOutOfFlowClipping) 1297 if (reasons & kCompositingReasonOutOfFlowClipping)
1278 reason_list->AppendString("Has clipping ancestor"); 1298 reason_list->AppendString("Has clipping ancestor");
1279 1299
1300 if (reasons & kCompositingReasonIsolateCompositedDescendants)
1301 reason_list->AppendString("Should isolate composited dscendants");
enne (OOO) 2013/11/06 22:40:19 typo
rosca 2013/11/07 01:58:16 Done.
1302
1280 return reason_list.PassAs<base::Value>(); 1303 return reason_list.PassAs<base::Value>();
1281 } 1304 }
1282 1305
1283 void LayerImpl::AsValueInto(base::DictionaryValue* state) const { 1306 void LayerImpl::AsValueInto(base::DictionaryValue* state) const {
1284 TracedValue::MakeDictIntoImplicitSnapshot(state, LayerTypeAsString(), this); 1307 TracedValue::MakeDictIntoImplicitSnapshot(state, LayerTypeAsString(), this);
1285 state->SetInteger("layer_id", id()); 1308 state->SetInteger("layer_id", id());
1286 state->SetString("layer_name", debug_name()); 1309 state->SetString("layer_name", debug_name());
1287 state->Set("bounds", MathUtil::AsValue(bounds()).release()); 1310 state->Set("bounds", MathUtil::AsValue(bounds()).release());
1288 state->SetInteger("draws_content", DrawsContent()); 1311 state->SetInteger("draws_content", DrawsContent());
1289 state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes()); 1312 state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 1356
1334 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } 1357 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; }
1335 1358
1336 scoped_ptr<base::Value> LayerImpl::AsValue() const { 1359 scoped_ptr<base::Value> LayerImpl::AsValue() const {
1337 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 1360 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
1338 AsValueInto(state.get()); 1361 AsValueInto(state.get());
1339 return state.PassAs<base::Value>(); 1362 return state.PassAs<base::Value>();
1340 } 1363 }
1341 1364
1342 } // namespace cc 1365 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698