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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/bitmap_skpicture_content_layer_updater.h" | 7 #include "cc/bitmap_skpicture_content_layer_updater.h" |
8 | 8 |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "cc/layer_painter.h" | 10 #include "cc/layer_painter.h" |
11 #include "cc/rendering_stats.h" | 11 #include "cc/rendering_stats.h" |
12 #include "cc/resource_update_queue.h" | 12 #include "cc/resource_update_queue.h" |
13 #include "third_party/skia/include/core/SkCanvas.h" | 13 #include "third_party/skia/include/core/SkCanvas.h" |
14 #include "third_party/skia/include/core/SkDevice.h" | 14 #include "third_party/skia/include/core/SkDevice.h" |
15 | 15 |
16 namespace cc { | 16 namespace cc { |
17 | 17 |
18 BitmapSkPictureContentLayerUpdater::Resource::Resource(BitmapSkPictureContentLay
erUpdater* updater, scoped_ptr<PrioritizedTexture> texture) | 18 BitmapSkPictureContentLayerUpdater::Resource::Resource(BitmapSkPictureContentLay
erUpdater* updater, scoped_ptr<PrioritizedTexture> texture) |
19 : ContentLayerUpdater::Resource(texture.Pass()) | 19 : ContentLayerUpdater::Resource(texture.Pass()) |
20 , m_updater(updater) | 20 , m_updater(updater) |
21 { | 21 { |
22 } | 22 } |
23 | 23 |
24 void BitmapSkPictureContentLayerUpdater::Resource::update(ResourceUpdateQueue& q
ueue, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate,
RenderingStats& stats) | 24 void BitmapSkPictureContentLayerUpdater::Resource::update(ResourceUpdateQueue& q
ueue, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partial
Update, RenderingStats& stats) |
25 { | 25 { |
26 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, sourceRect.width(), sourceRe
ct.height()); | 26 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, sourceRect.width(), sourceRe
ct.height()); |
27 m_bitmap.allocPixels(); | 27 m_bitmap.allocPixels(); |
28 m_bitmap.setIsOpaque(m_updater->layerIsOpaque()); | 28 m_bitmap.setIsOpaque(m_updater->layerIsOpaque()); |
29 SkDevice device(m_bitmap); | 29 SkDevice device(m_bitmap); |
30 SkCanvas canvas(&device); | 30 SkCanvas canvas(&device); |
31 base::TimeTicks paintBeginTime = base::TimeTicks::Now(); | 31 base::TimeTicks paintBeginTime = base::TimeTicks::Now(); |
32 updater()->paintContentsRect(&canvas, sourceRect, stats); | 32 updater()->paintContentsRect(&canvas, sourceRect, stats); |
33 stats.totalPaintTimeInSeconds += (base::TimeTicks::Now() - paintBeginTime).I
nSecondsF(); | 33 stats.totalPaintTimeInSeconds += (base::TimeTicks::Now() - paintBeginTime).I
nSecondsF(); |
34 | 34 |
(...skipping 17 matching lines...) Expand all Loading... |
52 | 52 |
53 BitmapSkPictureContentLayerUpdater::~BitmapSkPictureContentLayerUpdater() | 53 BitmapSkPictureContentLayerUpdater::~BitmapSkPictureContentLayerUpdater() |
54 { | 54 { |
55 } | 55 } |
56 | 56 |
57 scoped_ptr<LayerUpdater::Resource> BitmapSkPictureContentLayerUpdater::createRes
ource(PrioritizedTextureManager* manager) | 57 scoped_ptr<LayerUpdater::Resource> BitmapSkPictureContentLayerUpdater::createRes
ource(PrioritizedTextureManager* manager) |
58 { | 58 { |
59 return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedText
ure::create(manager))); | 59 return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedText
ure::create(manager))); |
60 } | 60 } |
61 | 61 |
62 void BitmapSkPictureContentLayerUpdater::paintContentsRect(SkCanvas* canvas, con
st IntRect& sourceRect, RenderingStats& stats) | 62 void BitmapSkPictureContentLayerUpdater::paintContentsRect(SkCanvas* canvas, con
st gfx::Rect& sourceRect, RenderingStats& stats) |
63 { | 63 { |
64 // Translate the origin of contentRect to that of sourceRect. | 64 // Translate the origin of contentRect to that of sourceRect. |
65 canvas->translate(contentRect().x() - sourceRect.x(), | 65 canvas->translate(contentRect().x() - sourceRect.x(), |
66 contentRect().y() - sourceRect.y()); | 66 contentRect().y() - sourceRect.y()); |
67 base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now(); | 67 base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now(); |
68 drawPicture(canvas); | 68 drawPicture(canvas); |
69 stats.totalRasterizeTimeInSeconds += (base::TimeTicks::Now() - rasterizeBegi
nTime).InSecondsF(); | 69 stats.totalRasterizeTimeInSeconds += (base::TimeTicks::Now() - rasterizeBegi
nTime).InSecondsF(); |
70 } | 70 } |
71 | 71 |
72 } // namespace cc | 72 } // namespace cc |
OLD | NEW |