| OLD | NEW | 
|    1 // Copyright 2016 The Chromium Authors. All rights reserved. |    1 // Copyright 2016 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/blimp/compositor_state_deserializer.h" |    5 #include "cc/blimp/compositor_state_deserializer.h" | 
|    6  |    6  | 
|    7 #include "base/bind.h" |    7 #include "base/bind.h" | 
|    8 #include "base/memory/ptr_util.h" |    8 #include "base/memory/ptr_util.h" | 
|    9 #include "cc/blimp/client_picture_cache.h" |    9 #include "cc/blimp/client_picture_cache.h" | 
|   10 #include "cc/blimp/compositor_state_deserializer_client.h" |   10 #include "cc/blimp/compositor_state_deserializer_client.h" | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
|   31  |   31  | 
|   32   // LayerFactory implementation. |   32   // LayerFactory implementation. | 
|   33   scoped_refptr<Layer> CreateLayer(int engine_layer_id) override { |   33   scoped_refptr<Layer> CreateLayer(int engine_layer_id) override { | 
|   34     return Layer::Create(); |   34     return Layer::Create(); | 
|   35   } |   35   } | 
|   36   scoped_refptr<PictureLayer> CreatePictureLayer( |   36   scoped_refptr<PictureLayer> CreatePictureLayer( | 
|   37       int engine_layer_id, |   37       int engine_layer_id, | 
|   38       ContentLayerClient* content_layer_client) override { |   38       ContentLayerClient* content_layer_client) override { | 
|   39     return PictureLayer::Create(content_layer_client); |   39     return PictureLayer::Create(content_layer_client); | 
|   40   } |   40   } | 
|   41  |  | 
|   42   scoped_refptr<PictureLayer> CreateFakePictureLayer( |  | 
|   43       int engine_layer_id, |  | 
|   44       ContentLayerClient* content_layer_client) override { |  | 
|   45     // We should never create fake layers in production code. |  | 
|   46     NOTREACHED(); |  | 
|   47     return PictureLayer::Create(content_layer_client); |  | 
|   48   } |  | 
|   49  |  | 
|   50   scoped_refptr<SolidColorScrollbarLayer> CreateSolidColorScrollbarLayer( |   41   scoped_refptr<SolidColorScrollbarLayer> CreateSolidColorScrollbarLayer( | 
|   51       int engine_layer_id, |   42       int engine_layer_id, | 
|   52       ScrollbarOrientation orientation, |   43       ScrollbarOrientation orientation, | 
|   53       int thumb_thickness, |   44       int thumb_thickness, | 
|   54       int track_start, |   45       int track_start, | 
|   55       bool is_left_side_vertical_scrollbar, |   46       bool is_left_side_vertical_scrollbar, | 
|   56       int scroll_layer_id) override { |   47       int scroll_layer_id) override { | 
|   57     return SolidColorScrollbarLayer::Create( |   48     return SolidColorScrollbarLayer::Create( | 
|   58         orientation, thumb_thickness, track_start, |   49         orientation, thumb_thickness, track_start, | 
|   59         is_left_side_vertical_scrollbar, scroll_layer_id); |   50         is_left_side_vertical_scrollbar, scroll_layer_id); | 
|   60   } |   51   } | 
 |   52   scoped_refptr<PictureLayer> CreateFakePictureLayer( | 
 |   53       int engine_layer_id, | 
 |   54       ContentLayerClient* content_layer_client) override { | 
 |   55     // We should never create fake layers in production code. | 
 |   56     NOTREACHED(); | 
 |   57     return PictureLayer::Create(content_layer_client); | 
 |   58   } | 
 |   59   scoped_refptr<Layer> CreatePushPropertiesCountingLayer( | 
 |   60       int engine_layer_id) override { | 
 |   61     // We should never create fake layers in production code. | 
 |   62     NOTREACHED(); | 
 |   63     return Layer::Create(); | 
 |   64   } | 
|   61 }; |   65 }; | 
|   62  |   66  | 
|   63 }  // namespace |   67 }  // namespace | 
|   64  |   68  | 
|   65 CompositorStateDeserializer::LayerData::LayerData() = default; |   69 CompositorStateDeserializer::LayerData::LayerData() = default; | 
|   66  |   70  | 
|   67 CompositorStateDeserializer::LayerData::~LayerData() = default; |   71 CompositorStateDeserializer::LayerData::~LayerData() = default; | 
|   68  |   72  | 
|   69 CompositorStateDeserializer::LayerData::LayerData(LayerData&& other) = default; |   73 CompositorStateDeserializer::LayerData::LayerData(LayerData&& other) = default; | 
|   70  |   74  | 
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  364     case proto::LayerNode::LAYER: |  368     case proto::LayerNode::LAYER: | 
|  365       layer_data.layer = layer_factory_->CreateLayer(layer_node.id()); |  369       layer_data.layer = layer_factory_->CreateLayer(layer_node.id()); | 
|  366       break; |  370       break; | 
|  367     case proto::LayerNode::PICTURE_LAYER: |  371     case proto::LayerNode::PICTURE_LAYER: | 
|  368       layer_data.content_layer_client = |  372       layer_data.content_layer_client = | 
|  369           base::MakeUnique<DeserializedContentLayerClient>(); |  373           base::MakeUnique<DeserializedContentLayerClient>(); | 
|  370       layer_data.layer = layer_factory_->CreatePictureLayer( |  374       layer_data.layer = layer_factory_->CreatePictureLayer( | 
|  371           layer_node.id(), layer_data.content_layer_client.get()); |  375           layer_node.id(), layer_data.content_layer_client.get()); | 
|  372       break; |  376       break; | 
|  373     case proto::LayerNode::FAKE_PICTURE_LAYER: |  377     case proto::LayerNode::FAKE_PICTURE_LAYER: | 
 |  378       // FAKE_PICTURE_LAYER is for testing only. | 
|  374       layer_data.content_layer_client = |  379       layer_data.content_layer_client = | 
|  375           base::MakeUnique<DeserializedContentLayerClient>(); |  380           base::MakeUnique<DeserializedContentLayerClient>(); | 
|  376       layer_data.layer = layer_factory_->CreateFakePictureLayer( |  381       layer_data.layer = layer_factory_->CreateFakePictureLayer( | 
|  377           layer_node.id(), layer_data.content_layer_client.get()); |  382           layer_node.id(), layer_data.content_layer_client.get()); | 
|  378       break; |  383       break; | 
|  379     case proto::LayerNode::SOLID_COLOR_SCROLLBAR_LAYER: { |  384     case proto::LayerNode::SOLID_COLOR_SCROLLBAR_LAYER: { | 
|  380       // SolidColorScrollbarLayers attach their properties in the LayerNode |  385       // SolidColorScrollbarLayers attach their properties in the LayerNode | 
|  381       // itself. |  386       // itself. | 
|  382       const proto::SolidColorScrollbarLayerProperties& scrollbar = |  387       const proto::SolidColorScrollbarLayerProperties& scrollbar = | 
|  383           layer_node.solid_scrollbar(); |  388           layer_node.solid_scrollbar(); | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
|  396  |  401  | 
|  397       // We use the invalid id for the |scroll_layer_id| because the |  402       // We use the invalid id for the |scroll_layer_id| because the | 
|  398       // corresponding layer on the client may not have been created yet. |  403       // corresponding layer on the client may not have been created yet. | 
|  399       layer_data.layer = layer_factory_->CreateSolidColorScrollbarLayer( |  404       layer_data.layer = layer_factory_->CreateSolidColorScrollbarLayer( | 
|  400           layer_node.id(), orientation, thumb_thickness, track_start, |  405           layer_node.id(), orientation, thumb_thickness, track_start, | 
|  401           is_left_side_vertical_scrollbar, Layer::LayerIdLabels::INVALID_ID); |  406           is_left_side_vertical_scrollbar, Layer::LayerIdLabels::INVALID_ID); | 
|  402     } break; |  407     } break; | 
|  403     case proto::LayerNode::HEADS_UP_DISPLAY_LAYER: |  408     case proto::LayerNode::HEADS_UP_DISPLAY_LAYER: | 
|  404       // TODO(khushalsagar): Remove this from proto. |  409       // TODO(khushalsagar): Remove this from proto. | 
|  405       NOTREACHED(); |  410       NOTREACHED(); | 
 |  411       break; | 
 |  412     case proto::LayerNode::PUSH_PROPERTIES_COUNTING_LAYER: | 
 |  413       // PUSH_PROPERTIES_COUNTING_LAYER is for testing only. | 
 |  414       layer_data.layer = | 
 |  415           layer_factory_->CreatePushPropertiesCountingLayer(layer_node.id()); | 
 |  416       break; | 
|  406   } |  417   } | 
|  407  |  418  | 
|  408   layer = layer_data.layer; |  419   layer = layer_data.layer; | 
|  409   return layer; |  420   return layer; | 
|  410 } |  421 } | 
|  411  |  422  | 
|  412 int CompositorStateDeserializer::GetClientIdFromEngineId( |  423 int CompositorStateDeserializer::GetClientIdFromEngineId( | 
|  413     int engine_layer_id) const { |  424     int engine_layer_id) const { | 
|  414   Layer* layer = GetLayerForEngineId(engine_layer_id); |  425   Layer* layer = GetLayerForEngineId(engine_layer_id); | 
|  415   return layer ? layer->id() : Layer::LayerIdLabels::INVALID_ID; |  426   return layer ? layer->id() : Layer::LayerIdLabels::INVALID_ID; | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|  426 DeserializedContentLayerClient* |  437 DeserializedContentLayerClient* | 
|  427 CompositorStateDeserializer::GetContentLayerClient(int engine_layer_id) const { |  438 CompositorStateDeserializer::GetContentLayerClient(int engine_layer_id) const { | 
|  428   EngineIdToLayerMap::const_iterator layer_it = |  439   EngineIdToLayerMap::const_iterator layer_it = | 
|  429       engine_id_to_layer_.find(engine_layer_id); |  440       engine_id_to_layer_.find(engine_layer_id); | 
|  430   return layer_it != engine_id_to_layer_.end() |  441   return layer_it != engine_id_to_layer_.end() | 
|  431              ? layer_it->second.content_layer_client.get() |  442              ? layer_it->second.content_layer_client.get() | 
|  432              : nullptr; |  443              : nullptr; | 
|  433 } |  444 } | 
|  434  |  445  | 
|  435 }  // namespace cc |  446 }  // namespace cc | 
| OLD | NEW |