| OLD | NEW |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/layer.h" | 7 #include "cc/layer.h" |
| 8 | 8 |
| 9 #include "CCActiveAnimation.h" | 9 #include "CCActiveAnimation.h" |
| 10 #include "CCAnimationEvents.h" | 10 #include "CCAnimationEvents.h" |
| 11 #include "CCLayerAnimationController.h" | 11 #include "CCLayerAnimationController.h" |
| 12 #include "CCLayerImpl.h" | 12 #include "CCLayerImpl.h" |
| 13 #include "CCLayerTreeHost.h" | 13 #include "CCLayerTreeHost.h" |
| 14 #include "cc/settings.h" | 14 #include "cc/settings.h" |
| 15 #include "third_party/skia/include/core/SkImageFilter.h" |
| 15 #include <public/WebAnimationDelegate.h> | 16 #include <public/WebAnimationDelegate.h> |
| 16 #include <public/WebLayerScrollClient.h> | 17 #include <public/WebLayerScrollClient.h> |
| 17 #include <public/WebSize.h> | 18 #include <public/WebSize.h> |
| 18 | 19 |
| 19 using namespace std; | 20 using namespace std; |
| 20 using WebKit::WebTransformationMatrix; | 21 using WebKit::WebTransformationMatrix; |
| 21 | 22 |
| 22 namespace cc { | 23 namespace cc { |
| 23 | 24 |
| 24 static int s_nextLayerId = 1; | 25 static int s_nextLayerId = 1; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 37 , m_layerAnimationController(LayerAnimationController::create(this)) | 38 , m_layerAnimationController(LayerAnimationController::create(this)) |
| 38 , m_scrollable(false) | 39 , m_scrollable(false) |
| 39 , m_shouldScrollOnMainThread(false) | 40 , m_shouldScrollOnMainThread(false) |
| 40 , m_haveWheelEventHandlers(false) | 41 , m_haveWheelEventHandlers(false) |
| 41 , m_nonFastScrollableRegionChanged(false) | 42 , m_nonFastScrollableRegionChanged(false) |
| 42 , m_anchorPoint(0.5, 0.5) | 43 , m_anchorPoint(0.5, 0.5) |
| 43 , m_backgroundColor(0) | 44 , m_backgroundColor(0) |
| 44 , m_debugBorderColor(0) | 45 , m_debugBorderColor(0) |
| 45 , m_debugBorderWidth(0) | 46 , m_debugBorderWidth(0) |
| 46 , m_opacity(1.0) | 47 , m_opacity(1.0) |
| 48 , m_filter(0) |
| 47 , m_anchorPointZ(0) | 49 , m_anchorPointZ(0) |
| 48 , m_isContainerForFixedPositionLayers(false) | 50 , m_isContainerForFixedPositionLayers(false) |
| 49 , m_fixedToContainerLayer(false) | 51 , m_fixedToContainerLayer(false) |
| 50 , m_isDrawable(false) | 52 , m_isDrawable(false) |
| 51 , m_masksToBounds(false) | 53 , m_masksToBounds(false) |
| 52 , m_contentsOpaque(false) | 54 , m_contentsOpaque(false) |
| 53 , m_doubleSided(true) | 55 , m_doubleSided(true) |
| 54 , m_useLCDText(false) | 56 , m_useLCDText(false) |
| 55 , m_preserves3D(false) | 57 , m_preserves3D(false) |
| 56 , m_useParentBackfaceVisibility(false) | 58 , m_useParentBackfaceVisibility(false) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 74 } | 76 } |
| 75 | 77 |
| 76 Layer::~Layer() | 78 Layer::~Layer() |
| 77 { | 79 { |
| 78 // Our parent should be holding a reference to us so there should be no | 80 // Our parent should be holding a reference to us so there should be no |
| 79 // way for us to be destroyed while we still have a parent. | 81 // way for us to be destroyed while we still have a parent. |
| 80 DCHECK(!parent()); | 82 DCHECK(!parent()); |
| 81 | 83 |
| 82 // Remove the parent reference from all children. | 84 // Remove the parent reference from all children. |
| 83 removeAllChildren(); | 85 removeAllChildren(); |
| 86 |
| 87 SkSafeUnref(m_filter); |
| 84 } | 88 } |
| 85 | 89 |
| 86 void Layer::setUseLCDText(bool useLCDText) | 90 void Layer::setUseLCDText(bool useLCDText) |
| 87 { | 91 { |
| 88 m_useLCDText = useLCDText; | 92 m_useLCDText = useLCDText; |
| 89 } | 93 } |
| 90 | 94 |
| 91 void Layer::setLayerTreeHost(LayerTreeHost* host) | 95 void Layer::setLayerTreeHost(LayerTreeHost* host) |
| 92 { | 96 { |
| 93 if (m_layerTreeHost == host) | 97 if (m_layerTreeHost == host) |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 if (m_replicaLayer) | 312 if (m_replicaLayer) |
| 309 m_replicaLayer->setLayerTreeHost(0); | 313 m_replicaLayer->setLayerTreeHost(0); |
| 310 m_replicaLayer = layer; | 314 m_replicaLayer = layer; |
| 311 if (m_replicaLayer) | 315 if (m_replicaLayer) |
| 312 m_replicaLayer->setLayerTreeHost(m_layerTreeHost); | 316 m_replicaLayer->setLayerTreeHost(m_layerTreeHost); |
| 313 setNeedsCommit(); | 317 setNeedsCommit(); |
| 314 } | 318 } |
| 315 | 319 |
| 316 void Layer::setFilters(const WebKit::WebFilterOperations& filters) | 320 void Layer::setFilters(const WebKit::WebFilterOperations& filters) |
| 317 { | 321 { |
| 322 DCHECK(!m_filter); |
| 318 if (m_filters == filters) | 323 if (m_filters == filters) |
| 319 return; | 324 return; |
| 320 m_filters = filters; | 325 m_filters = filters; |
| 321 setNeedsCommit(); | 326 setNeedsCommit(); |
| 322 if (!filters.isEmpty()) | 327 if (!filters.isEmpty()) |
| 323 LayerTreeHost::setNeedsFilterContext(true); | 328 LayerTreeHost::setNeedsFilterContext(true); |
| 324 } | 329 } |
| 325 | 330 |
| 331 void Layer::setFilter(SkImageFilter* filter) |
| 332 { |
| 333 DCHECK(m_filters.isEmpty()); |
| 334 if (m_filter == filter) |
| 335 return; |
| 336 SkRefCnt_SafeAssign(m_filter, filter); |
| 337 setNeedsCommit(); |
| 338 if (filter) |
| 339 LayerTreeHost::setNeedsFilterContext(true); |
| 340 } |
| 341 |
| 326 void Layer::setBackgroundFilters(const WebKit::WebFilterOperations& backgroundFi
lters) | 342 void Layer::setBackgroundFilters(const WebKit::WebFilterOperations& backgroundFi
lters) |
| 327 { | 343 { |
| 328 if (m_backgroundFilters == backgroundFilters) | 344 if (m_backgroundFilters == backgroundFilters) |
| 329 return; | 345 return; |
| 330 m_backgroundFilters = backgroundFilters; | 346 m_backgroundFilters = backgroundFilters; |
| 331 setNeedsCommit(); | 347 setNeedsCommit(); |
| 332 if (!backgroundFilters.isEmpty()) | 348 if (!backgroundFilters.isEmpty()) |
| 333 LayerTreeHost::setNeedsFilterContext(true); | 349 LayerTreeHost::setNeedsFilterContext(true); |
| 334 } | 350 } |
| 335 | 351 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 layer->setBounds(m_bounds); | 553 layer->setBounds(m_bounds); |
| 538 layer->setContentBounds(contentBounds()); | 554 layer->setContentBounds(contentBounds()); |
| 539 layer->setDebugBorderColor(m_debugBorderColor); | 555 layer->setDebugBorderColor(m_debugBorderColor); |
| 540 layer->setDebugBorderWidth(m_debugBorderWidth); | 556 layer->setDebugBorderWidth(m_debugBorderWidth); |
| 541 layer->setDebugName(m_debugName); | 557 layer->setDebugName(m_debugName); |
| 542 layer->setDoubleSided(m_doubleSided); | 558 layer->setDoubleSided(m_doubleSided); |
| 543 layer->setDrawCheckerboardForMissingTiles(m_drawCheckerboardForMissingTiles)
; | 559 layer->setDrawCheckerboardForMissingTiles(m_drawCheckerboardForMissingTiles)
; |
| 544 layer->setForceRenderSurface(m_forceRenderSurface); | 560 layer->setForceRenderSurface(m_forceRenderSurface); |
| 545 layer->setDrawsContent(drawsContent()); | 561 layer->setDrawsContent(drawsContent()); |
| 546 layer->setFilters(filters()); | 562 layer->setFilters(filters()); |
| 563 layer->setFilter(filter()); |
| 547 layer->setBackgroundFilters(backgroundFilters()); | 564 layer->setBackgroundFilters(backgroundFilters()); |
| 548 layer->setUseLCDText(m_useLCDText); | 565 layer->setUseLCDText(m_useLCDText); |
| 549 layer->setMasksToBounds(m_masksToBounds); | 566 layer->setMasksToBounds(m_masksToBounds); |
| 550 layer->setScrollable(m_scrollable); | 567 layer->setScrollable(m_scrollable); |
| 551 layer->setShouldScrollOnMainThread(m_shouldScrollOnMainThread); | 568 layer->setShouldScrollOnMainThread(m_shouldScrollOnMainThread); |
| 552 layer->setHaveWheelEventHandlers(m_haveWheelEventHandlers); | 569 layer->setHaveWheelEventHandlers(m_haveWheelEventHandlers); |
| 553 // Copying a Region is more expensive than most layer properties, since it i
nvolves copying two Vectors that may be | 570 // Copying a Region is more expensive than most layer properties, since it i
nvolves copying two Vectors that may be |
| 554 // arbitrarily large depending on page content, so we only push the property
if it's changed. | 571 // arbitrarily large depending on page content, so we only push the property
if it's changed. |
| 555 if (m_nonFastScrollableRegionChanged) { | 572 if (m_nonFastScrollableRegionChanged) { |
| 556 layer->setNonFastScrollableRegion(m_nonFastScrollableRegion); | 573 layer->setNonFastScrollableRegion(m_nonFastScrollableRegion); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 { | 805 { |
| 789 return 0; | 806 return 0; |
| 790 } | 807 } |
| 791 | 808 |
| 792 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*) | 809 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*) |
| 793 { | 810 { |
| 794 // Currently we don't use z-order to decide what to paint, so there's no nee
d to actually sort Layers. | 811 // Currently we don't use z-order to decide what to paint, so there's no nee
d to actually sort Layers. |
| 795 } | 812 } |
| 796 | 813 |
| 797 } | 814 } |
| OLD | NEW |