Chromium Code Reviews| 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_skpicture_content_layer_updater.h" | 5 #include "cc/resources/bitmap_skpicture_content_layer_updater.h" |
| 6 | 6 |
| 7 #include "base/time.h" | 7 #include "base/time.h" |
| 8 #include "cc/debug/rendering_stats.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" |
| 11 #include "cc/resources/resource_update_queue.h" | 11 #include "cc/resources/resource_update_queue.h" |
| 12 #include "third_party/skia/include/core/SkCanvas.h" | 12 #include "third_party/skia/include/core/SkCanvas.h" |
| 13 #include "third_party/skia/include/core/SkDevice.h" | 13 #include "third_party/skia/include/core/SkDevice.h" |
| 14 | 14 |
| 15 namespace cc { | 15 namespace cc { |
| 16 | 16 |
| 17 BitmapSkPictureContentLayerUpdater::Resource::Resource( | 17 BitmapSkPictureContentLayerUpdater::Resource::Resource( |
| 18 BitmapSkPictureContentLayerUpdater* updater, | 18 BitmapSkPictureContentLayerUpdater* updater, |
| 19 scoped_ptr<PrioritizedResource> texture) | 19 scoped_ptr<PrioritizedResource> texture) |
| 20 : ContentLayerUpdater::Resource(texture.Pass()), updater_(updater) {} | 20 : ContentLayerUpdater::Resource(texture.Pass()), updater_(updater) {} |
| 21 | 21 |
| 22 void BitmapSkPictureContentLayerUpdater::Resource::Update( | 22 void BitmapSkPictureContentLayerUpdater::Resource::Update( |
| 23 ResourceUpdateQueue* queue, | 23 ResourceUpdateQueue* queue, |
| 24 gfx::Rect source_rect, | 24 gfx::Rect source_rect, |
| 25 gfx::Vector2d dest_offset, | 25 gfx::Vector2d dest_offset, |
| 26 bool partial_update, | 26 bool partial_update) { |
| 27 RenderingStats* stats) { | |
| 28 bitmap_.setConfig( | 27 bitmap_.setConfig( |
| 29 SkBitmap::kARGB_8888_Config, source_rect.width(), source_rect.height()); | 28 SkBitmap::kARGB_8888_Config, source_rect.width(), source_rect.height()); |
| 30 bitmap_.allocPixels(); | 29 bitmap_.allocPixels(); |
| 31 bitmap_.setIsOpaque(updater_->layer_is_opaque()); | 30 bitmap_.setIsOpaque(updater_->layer_is_opaque()); |
| 32 SkDevice device(bitmap_); | 31 SkDevice device(bitmap_); |
| 33 SkCanvas canvas(&device); | 32 SkCanvas canvas(&device); |
| 34 base::TimeTicks paint_begin_time; | 33 |
| 35 if (stats) | 34 updater_->PaintContentsRect(&canvas, source_rect); |
| 36 paint_begin_time = base::TimeTicks::Now(); | |
|
danakj
2013/03/23 01:56:32
Hm, this was called paint time but was recording r
egraether
2013/03/25 21:07:44
I will leave behaviour the same here as well, so I
| |
| 37 updater_->PaintContentsRect(&canvas, source_rect, stats); | |
| 38 if (stats) | |
| 39 stats->totalPaintTime += base::TimeTicks::Now() - paint_begin_time; | |
| 40 | 35 |
| 41 ResourceUpdate upload = ResourceUpdate::Create( | 36 ResourceUpdate upload = ResourceUpdate::Create( |
| 42 texture(), &bitmap_, source_rect, source_rect, dest_offset); | 37 texture(), &bitmap_, source_rect, source_rect, dest_offset); |
| 43 if (partial_update) | 38 if (partial_update) |
| 44 queue->AppendPartialUpload(upload); | 39 queue->AppendPartialUpload(upload); |
| 45 else | 40 else |
| 46 queue->AppendFullUpload(upload); | 41 queue->AppendFullUpload(upload); |
| 47 } | 42 } |
| 48 | 43 |
| 49 scoped_refptr<BitmapSkPictureContentLayerUpdater> | 44 scoped_refptr<BitmapSkPictureContentLayerUpdater> |
| 50 BitmapSkPictureContentLayerUpdater::Create(scoped_ptr<LayerPainter> painter) { | 45 BitmapSkPictureContentLayerUpdater::Create( |
| 46 scoped_ptr<LayerPainter> painter, | |
| 47 RenderingStatsInstrumentation* stats_instrumentation) { | |
| 51 return make_scoped_refptr( | 48 return make_scoped_refptr( |
| 52 new BitmapSkPictureContentLayerUpdater(painter.Pass())); | 49 new BitmapSkPictureContentLayerUpdater(painter.Pass(), |
| 50 stats_instrumentation)); | |
| 53 } | 51 } |
| 54 | 52 |
| 55 BitmapSkPictureContentLayerUpdater::BitmapSkPictureContentLayerUpdater( | 53 BitmapSkPictureContentLayerUpdater::BitmapSkPictureContentLayerUpdater( |
| 56 scoped_ptr<LayerPainter> painter) | 54 scoped_ptr<LayerPainter> painter, |
| 57 : SkPictureContentLayerUpdater(painter.Pass()) {} | 55 RenderingStatsInstrumentation* stats_instrumentation) |
| 56 : SkPictureContentLayerUpdater(painter.Pass(), stats_instrumentation) {} | |
| 58 | 57 |
| 59 BitmapSkPictureContentLayerUpdater::~BitmapSkPictureContentLayerUpdater() {} | 58 BitmapSkPictureContentLayerUpdater::~BitmapSkPictureContentLayerUpdater() {} |
| 60 | 59 |
| 61 scoped_ptr<LayerUpdater::Resource> | 60 scoped_ptr<LayerUpdater::Resource> |
| 62 BitmapSkPictureContentLayerUpdater::CreateResource( | 61 BitmapSkPictureContentLayerUpdater::CreateResource( |
| 63 PrioritizedResourceManager* manager) { | 62 PrioritizedResourceManager* manager) { |
| 64 return scoped_ptr<LayerUpdater::Resource>( | 63 return scoped_ptr<LayerUpdater::Resource>( |
| 65 new Resource(this, PrioritizedResource::Create(manager))); | 64 new Resource(this, PrioritizedResource::Create(manager))); |
| 66 } | 65 } |
| 67 | 66 |
| 68 void BitmapSkPictureContentLayerUpdater::PaintContentsRect( | 67 void BitmapSkPictureContentLayerUpdater::PaintContentsRect( |
| 69 SkCanvas* canvas, | 68 SkCanvas* canvas, |
| 70 gfx::Rect source_rect, | 69 gfx::Rect source_rect) { |
| 71 RenderingStats* stats) { | |
| 72 // Translate the origin of content_rect to that of source_rect. | 70 // Translate the origin of content_rect to that of source_rect. |
| 73 canvas->translate(content_rect().x() - source_rect.x(), | 71 canvas->translate(content_rect().x() - source_rect.x(), |
| 74 content_rect().y() - source_rect.y()); | 72 content_rect().y() - source_rect.y()); |
| 75 base::TimeTicks rasterize_begin_time; | 73 |
| 76 if (stats) | 74 base::TimeTicks start_time = |
| 77 rasterize_begin_time = base::TimeTicks::Now(); | 75 rendering_stats_instrumentation_->StartRecording(); |
| 76 | |
| 78 DrawPicture(canvas); | 77 DrawPicture(canvas); |
| 79 if (stats) { | 78 |
| 80 stats->totalRasterizeTime += base::TimeTicks::Now() - rasterize_begin_time; | 79 base::TimeDelta duration = |
| 81 stats->totalPixelsRasterized += source_rect.width() * source_rect.height(); | 80 rendering_stats_instrumentation_->EndRecording(start_time); |
| 82 } | 81 rendering_stats_instrumentation_->AddPaint(duration, 0); |
|
egraether
2013/03/23 00:15:40
I moved the paint time saving down from above. Sho
danakj
2013/03/23 01:56:32
This is actually not paint time at all, this is al
egraether
2013/03/25 21:07:44
I will leave it to keep behaviour the same.
| |
| 82 rendering_stats_instrumentation_->AddRaster( | |
| 83 duration, | |
| 84 source_rect.width() * source_rect.height(), | |
| 85 false); | |
| 83 } | 86 } |
| 84 | 87 |
| 85 } // namespace cc | 88 } // namespace cc |
| OLD | NEW |