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

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: moving blend_mode property to SharedQuadState 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 layer_surface_property_changed_(false), 49 layer_surface_property_changed_(false),
50 masks_to_bounds_(false), 50 masks_to_bounds_(false),
51 contents_opaque_(false), 51 contents_opaque_(false),
52 opacity_(1.0), 52 opacity_(1.0),
53 blend_mode_(SkXfermode::kSrcOver_Mode),
54 is_root_for_isolated_group_(false),
53 preserves_3d_(false), 55 preserves_3d_(false),
54 use_parent_backface_visibility_(false), 56 use_parent_backface_visibility_(false),
55 draw_checkerboard_for_missing_tiles_(false), 57 draw_checkerboard_for_missing_tiles_(false),
56 draws_content_(false), 58 draws_content_(false),
57 hide_layer_and_subtree_(false), 59 hide_layer_and_subtree_(false),
58 force_render_surface_(false), 60 force_render_surface_(false),
59 is_container_for_fixed_position_layers_(false), 61 is_container_for_fixed_position_layers_(false),
60 draw_depth_(0.f), 62 draw_depth_(0.f),
61 compositing_reasons_(kCompositingReasonUnknown), 63 compositing_reasons_(kCompositingReasonUnknown),
62 current_draw_mode_(DRAW_MODE_NONE), 64 current_draw_mode_(DRAW_MODE_NONE),
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 draw_properties_.render_surface.reset(); 238 draw_properties_.render_surface.reset();
237 } 239 }
238 240
239 scoped_ptr<SharedQuadState> LayerImpl::CreateSharedQuadState() const { 241 scoped_ptr<SharedQuadState> LayerImpl::CreateSharedQuadState() const {
240 scoped_ptr<SharedQuadState> state = SharedQuadState::Create(); 242 scoped_ptr<SharedQuadState> state = SharedQuadState::Create();
241 state->SetAll(draw_properties_.target_space_transform, 243 state->SetAll(draw_properties_.target_space_transform,
242 draw_properties_.content_bounds, 244 draw_properties_.content_bounds,
243 draw_properties_.visible_content_rect, 245 draw_properties_.visible_content_rect,
244 draw_properties_.clip_rect, 246 draw_properties_.clip_rect,
245 draw_properties_.is_clipped, 247 draw_properties_.is_clipped,
246 draw_properties_.opacity); 248 draw_properties_.opacity,
249 blend_mode_);
247 return state.Pass(); 250 return state.Pass();
248 } 251 }
249 252
250 bool LayerImpl::WillDraw(DrawMode draw_mode, 253 bool LayerImpl::WillDraw(DrawMode draw_mode,
251 ResourceProvider* resource_provider) { 254 ResourceProvider* resource_provider) {
252 // WillDraw/DidDraw must be matched. 255 // WillDraw/DidDraw must be matched.
253 DCHECK_NE(DRAW_MODE_NONE, draw_mode); 256 DCHECK_NE(DRAW_MODE_NONE, draw_mode);
254 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); 257 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_);
255 current_draw_mode_ = draw_mode; 258 current_draw_mode_ = draw_mode;
256 return true; 259 return true;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 layer->SetFilters(filters()); 505 layer->SetFilters(filters());
503 layer->SetFilter(filter()); 506 layer->SetFilter(filter());
504 layer->SetBackgroundFilters(background_filters()); 507 layer->SetBackgroundFilters(background_filters());
505 layer->SetMasksToBounds(masks_to_bounds_); 508 layer->SetMasksToBounds(masks_to_bounds_);
506 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); 509 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_);
507 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); 510 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_);
508 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); 511 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_);
509 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); 512 layer->SetTouchEventHandlerRegion(touch_event_handler_region_);
510 layer->SetContentsOpaque(contents_opaque_); 513 layer->SetContentsOpaque(contents_opaque_);
511 layer->SetOpacity(opacity_); 514 layer->SetOpacity(opacity_);
515 layer->SetBlendMode(blend_mode_);
516 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_);
512 layer->SetPosition(position_); 517 layer->SetPosition(position_);
513 layer->SetIsContainerForFixedPositionLayers( 518 layer->SetIsContainerForFixedPositionLayers(
514 is_container_for_fixed_position_layers_); 519 is_container_for_fixed_position_layers_);
515 layer->SetFixedContainerSizeDelta(fixed_container_size_delta_); 520 layer->SetFixedContainerSizeDelta(fixed_container_size_delta_);
516 layer->SetPositionConstraint(position_constraint_); 521 layer->SetPositionConstraint(position_constraint_);
517 layer->SetPreserves3d(preserves_3d()); 522 layer->SetPreserves3d(preserves_3d());
518 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); 523 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_);
519 layer->SetSublayerTransform(sublayer_transform_); 524 layer->SetSublayerTransform(sublayer_transform_);
520 layer->SetTransform(transform_); 525 layer->SetTransform(transform_);
521 526
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 bool LayerImpl::OpacityIsAnimating() const { 873 bool LayerImpl::OpacityIsAnimating() const {
869 return layer_animation_controller_->IsAnimatingProperty(Animation::Opacity); 874 return layer_animation_controller_->IsAnimatingProperty(Animation::Opacity);
870 } 875 }
871 876
872 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const { 877 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const {
873 Animation* opacity_animation = 878 Animation* opacity_animation =
874 layer_animation_controller_->GetAnimation(Animation::Opacity); 879 layer_animation_controller_->GetAnimation(Animation::Opacity);
875 return opacity_animation && opacity_animation->is_impl_only(); 880 return opacity_animation && opacity_animation->is_impl_only();
876 } 881 }
877 882
883 void LayerImpl::SetBlendMode(SkXfermode::Mode blendMode) {
884 if (blend_mode_ == blendMode)
885 return;
886
887 blend_mode_ = blendMode;
888 NoteLayerSurfacePropertyChanged();
889 }
890
891 void LayerImpl::SetIsRootForIsolatedGroup(bool root) {
892 if (is_root_for_isolated_group_ == root)
893 return;
894
895 is_root_for_isolated_group_ = root;
896 NoteLayerSurfacePropertyChanged();
897 }
898
878 void LayerImpl::SetPosition(gfx::PointF position) { 899 void LayerImpl::SetPosition(gfx::PointF position) {
879 if (position_ == position) 900 if (position_ == position)
880 return; 901 return;
881 902
882 position_ = position; 903 position_ = position;
883 NoteLayerPropertyChangedForSubtree(); 904 NoteLayerPropertyChangedForSubtree();
884 } 905 }
885 906
886 void LayerImpl::SetPreserves3d(bool preserves3_d) { 907 void LayerImpl::SetPreserves3d(bool preserves3_d) {
887 if (preserves_3d_ == preserves3_d) 908 if (preserves_3d_ == preserves3_d)
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 1280
1260 if (reasons & kCompositingReasonLayerForMask) 1281 if (reasons & kCompositingReasonLayerForMask)
1261 reason_list->AppendString("Is a mask layer"); 1282 reason_list->AppendString("Is a mask layer");
1262 1283
1263 if (reasons & kCompositingReasonOverflowScrollingParent) 1284 if (reasons & kCompositingReasonOverflowScrollingParent)
1264 reason_list->AppendString("Scroll parent is not an ancestor"); 1285 reason_list->AppendString("Scroll parent is not an ancestor");
1265 1286
1266 if (reasons & kCompositingReasonOutOfFlowClipping) 1287 if (reasons & kCompositingReasonOutOfFlowClipping)
1267 reason_list->AppendString("Has clipping ancestor"); 1288 reason_list->AppendString("Has clipping ancestor");
1268 1289
1290 if (reasons & kCompositingReasonIsolateCompositedDescendants)
1291 reason_list->AppendString("Should isolate composited dscendants");
1292
1269 return reason_list.PassAs<base::Value>(); 1293 return reason_list.PassAs<base::Value>();
1270 } 1294 }
1271 1295
1272 void LayerImpl::AsValueInto(base::DictionaryValue* state) const { 1296 void LayerImpl::AsValueInto(base::DictionaryValue* state) const {
1273 TracedValue::MakeDictIntoImplicitSnapshot(state, LayerTypeAsString(), this); 1297 TracedValue::MakeDictIntoImplicitSnapshot(state, LayerTypeAsString(), this);
1274 state->SetInteger("layer_id", id()); 1298 state->SetInteger("layer_id", id());
1275 state->SetString("layer_name", debug_name()); 1299 state->SetString("layer_name", debug_name());
1276 state->Set("bounds", MathUtil::AsValue(bounds()).release()); 1300 state->Set("bounds", MathUtil::AsValue(bounds()).release());
1277 state->SetInteger("draws_content", DrawsContent()); 1301 state->SetInteger("draws_content", DrawsContent());
1278 state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes()); 1302 state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 1343
1320 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } 1344 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; }
1321 1345
1322 scoped_ptr<base::Value> LayerImpl::AsValue() const { 1346 scoped_ptr<base::Value> LayerImpl::AsValue() const {
1323 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 1347 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
1324 AsValueInto(state.get()); 1348 AsValueInto(state.get());
1325 return state.PassAs<base::Value>(); 1349 return state.PassAs<base::Value>();
1326 } 1350 }
1327 1351
1328 } // namespace cc 1352 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698