| OLD | NEW |
| 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/resources/bitmap_content_layer_updater.h" | 5 #include "cc/resources/bitmap_content_layer_updater.h" |
| 6 | 6 |
| 7 #include "cc/debug/devtools_instrumentation.h" | 7 #include "cc/debug/devtools_instrumentation.h" |
| 8 #include "cc/debug/rendering_stats_instrumentation.h" | 8 #include "cc/debug/rendering_stats_instrumentation.h" |
| 9 #include "cc/resources/layer_painter.h" | 9 #include "cc/resources/layer_painter.h" |
| 10 #include "cc/resources/prioritized_resource.h" | 10 #include "cc/resources/prioritized_resource.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 ResourceUpdateQueue* queue, | 25 ResourceUpdateQueue* queue, |
| 26 const gfx::Rect& source_rect, | 26 const gfx::Rect& source_rect, |
| 27 const gfx::Vector2d& dest_offset, | 27 const gfx::Vector2d& dest_offset, |
| 28 bool partial_update) { | 28 bool partial_update) { |
| 29 updater_->UpdateTexture( | 29 updater_->UpdateTexture( |
| 30 queue, texture(), source_rect, dest_offset, partial_update); | 30 queue, texture(), source_rect, dest_offset, partial_update); |
| 31 } | 31 } |
| 32 | 32 |
| 33 scoped_refptr<BitmapContentLayerUpdater> BitmapContentLayerUpdater::Create( | 33 scoped_refptr<BitmapContentLayerUpdater> BitmapContentLayerUpdater::Create( |
| 34 scoped_ptr<LayerPainter> painter, | 34 scoped_ptr<LayerPainter> painter, |
| 35 RenderingStatsInstrumentation* stats_instrumentation, | |
| 36 int layer_id) { | 35 int layer_id) { |
| 37 return make_scoped_refptr( | 36 return make_scoped_refptr( |
| 38 new BitmapContentLayerUpdater(painter.Pass(), | 37 new BitmapContentLayerUpdater(painter.Pass(), |
| 39 stats_instrumentation, | |
| 40 layer_id)); | 38 layer_id)); |
| 41 } | 39 } |
| 42 | 40 |
| 43 BitmapContentLayerUpdater::BitmapContentLayerUpdater( | 41 BitmapContentLayerUpdater::BitmapContentLayerUpdater( |
| 44 scoped_ptr<LayerPainter> painter, | 42 scoped_ptr<LayerPainter> painter, |
| 45 RenderingStatsInstrumentation* stats_instrumentation, | |
| 46 int layer_id) | 43 int layer_id) |
| 47 : ContentLayerUpdater(painter.Pass(), stats_instrumentation, layer_id) {} | 44 : ContentLayerUpdater(painter.Pass(), layer_id) { |
| 45 } |
| 48 | 46 |
| 49 BitmapContentLayerUpdater::~BitmapContentLayerUpdater() {} | 47 BitmapContentLayerUpdater::~BitmapContentLayerUpdater() {} |
| 50 | 48 |
| 51 scoped_ptr<LayerUpdater::Resource> BitmapContentLayerUpdater::CreateResource( | 49 scoped_ptr<LayerUpdater::Resource> BitmapContentLayerUpdater::CreateResource( |
| 52 PrioritizedResourceManager* manager) { | 50 PrioritizedResourceManager* manager) { |
| 53 return make_scoped_ptr( | 51 return make_scoped_ptr( |
| 54 new Resource(this, PrioritizedResource::Create(manager))); | 52 new Resource(this, PrioritizedResource::Create(manager))); |
| 55 } | 53 } |
| 56 | 54 |
| 57 void BitmapContentLayerUpdater::PrepareToUpdate(const gfx::Size& content_size, | 55 void BitmapContentLayerUpdater::PrepareToUpdate(const gfx::Size& content_size, |
| 58 const gfx::Rect& paint_rect, | 56 const gfx::Rect& paint_rect, |
| 59 const gfx::Size& tile_size, | 57 const gfx::Size& tile_size, |
| 60 float contents_width_scale, | 58 float contents_width_scale, |
| 61 float contents_height_scale) { | 59 float contents_height_scale) { |
| 62 if (canvas_size_ != paint_rect.size()) { | 60 if (canvas_size_ != paint_rect.size()) { |
| 63 devtools_instrumentation::ScopedLayerTask paint_setup( | 61 devtools_instrumentation::ScopedLayerTask paint_setup( |
| 64 devtools_instrumentation::kPaintSetup, layer_id_); | 62 devtools_instrumentation::kPaintSetup, layer_id_); |
| 65 canvas_size_ = paint_rect.size(); | 63 canvas_size_ = paint_rect.size(); |
| 66 bitmap_backing_.allocN32Pixels( | 64 bitmap_backing_.allocN32Pixels( |
| 67 canvas_size_.width(), canvas_size_.height(), layer_is_opaque_); | 65 canvas_size_.width(), canvas_size_.height(), layer_is_opaque_); |
| 68 // TODO(danak): Remove when skia does the check for us: crbug.com/360384 | 66 // TODO(danak): Remove when skia does the check for us: crbug.com/360384 |
| 69 canvas_ = skia::AdoptRef(new SkCanvas(bitmap_backing_)); | 67 canvas_ = skia::AdoptRef(new SkCanvas(bitmap_backing_)); |
| 70 DCHECK_EQ(paint_rect.width(), canvas_->getBaseLayerSize().width()); | 68 DCHECK_EQ(paint_rect.width(), canvas_->getBaseLayerSize().width()); |
| 71 DCHECK_EQ(paint_rect.height(), canvas_->getBaseLayerSize().height()); | 69 DCHECK_EQ(paint_rect.height(), canvas_->getBaseLayerSize().height()); |
| 72 } | 70 } |
| 73 | 71 |
| 74 base::TimeTicks start_time = | |
| 75 rendering_stats_instrumentation_->StartRecording(); | |
| 76 PaintContents(canvas_.get(), | 72 PaintContents(canvas_.get(), |
| 77 content_size, | 73 content_size, |
| 78 paint_rect, | 74 paint_rect, |
| 79 contents_width_scale, | 75 contents_width_scale, |
| 80 contents_height_scale); | 76 contents_height_scale); |
| 81 base::TimeDelta duration = | |
| 82 rendering_stats_instrumentation_->EndRecording(start_time); | |
| 83 rendering_stats_instrumentation_->AddPaint( | |
| 84 duration, paint_rect.width() * paint_rect.height()); | |
| 85 } | 77 } |
| 86 | 78 |
| 87 void BitmapContentLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue, | 79 void BitmapContentLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue, |
| 88 PrioritizedResource* texture, | 80 PrioritizedResource* texture, |
| 89 const gfx::Rect& source_rect, | 81 const gfx::Rect& source_rect, |
| 90 const gfx::Vector2d& dest_offset, | 82 const gfx::Vector2d& dest_offset, |
| 91 bool partial_update) { | 83 bool partial_update) { |
| 92 CHECK(canvas_); | 84 CHECK(canvas_); |
| 93 ResourceUpdate upload = ResourceUpdate::Create( | 85 ResourceUpdate upload = ResourceUpdate::Create( |
| 94 texture, &bitmap_backing_, paint_rect(), source_rect, dest_offset); | 86 texture, &bitmap_backing_, paint_rect(), source_rect, dest_offset); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 106 void BitmapContentLayerUpdater::SetOpaque(bool opaque) { | 98 void BitmapContentLayerUpdater::SetOpaque(bool opaque) { |
| 107 if (opaque != layer_is_opaque_) { | 99 if (opaque != layer_is_opaque_) { |
| 108 canvas_.clear(); | 100 canvas_.clear(); |
| 109 canvas_size_ = gfx::Size(); | 101 canvas_size_ = gfx::Size(); |
| 110 } | 102 } |
| 111 | 103 |
| 112 ContentLayerUpdater::SetOpaque(opaque); | 104 ContentLayerUpdater::SetOpaque(opaque); |
| 113 } | 105 } |
| 114 | 106 |
| 115 } // namespace cc | 107 } // namespace cc |
| OLD | NEW |