| OLD | NEW | 
|    1 // Copyright 2012 The Chromium Authors. All rights reserved. |    1 // Copyright 2012 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/picture_layer.h" |    5 #include "cc/layers/picture_layer.h" | 
|    6  |    6  | 
|    7 #include "base/auto_reset.h" |    7 #include "base/auto_reset.h" | 
|    8 #include "cc/layers/content_layer_client.h" |    8 #include "cc/layers/content_layer_client.h" | 
|    9 #include "cc/layers/picture_layer_impl.h" |    9 #include "cc/layers/picture_layer_impl.h" | 
 |   10 #include "cc/resources/display_list_recording_source.h" | 
|   10 #include "cc/resources/picture_pile.h" |   11 #include "cc/resources/picture_pile.h" | 
|   11 #include "cc/trees/layer_tree_impl.h" |   12 #include "cc/trees/layer_tree_impl.h" | 
|   12 #include "third_party/skia/include/core/SkPictureRecorder.h" |   13 #include "third_party/skia/include/core/SkPictureRecorder.h" | 
|   13 #include "ui/gfx/geometry/rect_conversions.h" |   14 #include "ui/gfx/geometry/rect_conversions.h" | 
|   14  |   15  | 
|   15 namespace cc { |   16 namespace cc { | 
|   16  |   17  | 
|   17 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { |   18 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { | 
|   18   return make_scoped_refptr(new PictureLayer(client)); |   19   return make_scoped_refptr(new PictureLayer(client)); | 
|   19 } |   20 } | 
|   20  |   21  | 
|   21 PictureLayer::PictureLayer(ContentLayerClient* client) |   22 PictureLayer::PictureLayer(ContentLayerClient* client) | 
|   22     : client_(client), |   23     : client_(client), | 
|   23       recording_source_(new PicturePile), |  | 
|   24       instrumentation_object_tracker_(id()), |   24       instrumentation_object_tracker_(id()), | 
|   25       update_source_frame_number_(-1), |   25       update_source_frame_number_(-1), | 
|   26       can_use_lcd_text_for_update_(true), |   26       can_use_lcd_text_for_update_(true), | 
|   27       is_mask_(false) { |   27       is_mask_(false) { | 
|   28 } |   28 } | 
|   29  |   29  | 
|   30 PictureLayer::PictureLayer(ContentLayerClient* client, |   30 PictureLayer::PictureLayer(ContentLayerClient* client, | 
|   31                            scoped_ptr<RecordingSource> source) |   31                            scoped_ptr<RecordingSource> source) | 
|   32     : PictureLayer(client) { |   32     : PictureLayer(client) { | 
|   33   recording_source_ = source.Pass(); |   33   recording_source_ = source.Pass(); | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   72       recording_source_->CreateRasterSource(); |   72       recording_source_->CreateRasterSource(); | 
|   73   raster_source->SetBackgoundColor(SafeOpaqueBackgroundColor()); |   73   raster_source->SetBackgoundColor(SafeOpaqueBackgroundColor()); | 
|   74   raster_source->SetRequiresClear(!contents_opaque() && |   74   raster_source->SetRequiresClear(!contents_opaque() && | 
|   75                                   !client_->FillsBoundsCompletely()); |   75                                   !client_->FillsBoundsCompletely()); | 
|   76   layer_impl->UpdateRasterSource(raster_source); |   76   layer_impl->UpdateRasterSource(raster_source); | 
|   77 } |   77 } | 
|   78  |   78  | 
|   79 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { |   79 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { | 
|   80   Layer::SetLayerTreeHost(host); |   80   Layer::SetLayerTreeHost(host); | 
|   81   if (host) { |   81   if (host) { | 
 |   82     if (!recording_source_) { | 
 |   83       if (host->settings().use_display_lists) { | 
 |   84         recording_source_.reset(new DisplayListRecordingSource); | 
 |   85       } else { | 
 |   86         recording_source_.reset(new PicturePile); | 
 |   87       } | 
 |   88     } | 
|   82     recording_source_->SetMinContentsScale( |   89     recording_source_->SetMinContentsScale( | 
|   83         host->settings().minimum_contents_scale); |   90         host->settings().minimum_contents_scale); | 
|   84     recording_source_->SetTileGridSize(host->settings().default_tile_grid_size); |   91     recording_source_->SetTileGridSize(host->settings().default_tile_grid_size); | 
|   85     recording_source_->SetSlowdownRasterScaleFactor( |   92     recording_source_->SetSlowdownRasterScaleFactor( | 
|   86         host->debug_state().slow_down_raster_scale_factor); |   93         host->debug_state().slow_down_raster_scale_factor); | 
|   87   } |   94   } | 
|   88 } |   95 } | 
|   89  |   96  | 
|   90 void PictureLayer::SetNeedsDisplayRect(const gfx::Rect& layer_rect) { |   97 void PictureLayer::SetNeedsDisplayRect(const gfx::Rect& layer_rect) { | 
|   91   if (!layer_rect.IsEmpty()) { |   98   if (!layer_rect.IsEmpty()) { | 
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  201  |  208  | 
|  202 bool PictureLayer::HasDrawableContent() const { |  209 bool PictureLayer::HasDrawableContent() const { | 
|  203   return client_ && Layer::HasDrawableContent(); |  210   return client_ && Layer::HasDrawableContent(); | 
|  204 } |  211 } | 
|  205  |  212  | 
|  206 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |  213 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 
|  207   benchmark->RunOnLayer(this); |  214   benchmark->RunOnLayer(this); | 
|  208 } |  215 } | 
|  209  |  216  | 
|  210 }  // namespace cc |  217 }  // namespace cc | 
| OLD | NEW |