| OLD | NEW |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/content_layer.h" | 5 #include "cc/content_layer.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "cc/bitmap_content_layer_updater.h" | 10 #include "cc/bitmap_content_layer_updater.h" |
| 11 #include "cc/bitmap_skpicture_content_layer_updater.h" | 11 #include "cc/bitmap_skpicture_content_layer_updater.h" |
| 12 #include "cc/content_layer_client.h" | 12 #include "cc/content_layer_client.h" |
| 13 #include "cc/layer_painter.h" | 13 #include "cc/layer_painter.h" |
| 14 #include "cc/layer_tree_host.h" | 14 #include "cc/layer_tree_host.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 ContentLayerPainter::ContentLayerPainter(ContentLayerClient* client) | 18 ContentLayerPainter::ContentLayerPainter(ContentLayerClient* client) |
| 19 : m_client(client) | 19 : m_client(client) |
| 20 { | 20 { |
| 21 } | 21 } |
| 22 | 22 |
| 23 scoped_ptr<ContentLayerPainter> ContentLayerPainter::create(ContentLayerClient*
client) | 23 scoped_ptr<ContentLayerPainter> ContentLayerPainter::Create(ContentLayerClient*
client) |
| 24 { | 24 { |
| 25 return make_scoped_ptr(new ContentLayerPainter(client)); | 25 return make_scoped_ptr(new ContentLayerPainter(client)); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void ContentLayerPainter::Paint(SkCanvas* canvas, gfx::Rect contentRect, gfx::Re
ctF* opaque) | 28 void ContentLayerPainter::Paint(SkCanvas* canvas, gfx::Rect contentRect, gfx::Re
ctF* opaque) |
| 29 { | 29 { |
| 30 base::TimeTicks paintStart = base::TimeTicks::HighResNow(); | 30 base::TimeTicks paintStart = base::TimeTicks::HighResNow(); |
| 31 m_client->paintContents(canvas, contentRect, *opaque); | 31 m_client->paintContents(canvas, contentRect, *opaque); |
| 32 base::TimeTicks paintEnd = base::TimeTicks::HighResNow(); | 32 base::TimeTicks paintEnd = base::TimeTicks::HighResNow(); |
| 33 double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintE
nd - paintStart).InSecondsF(); | 33 double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintE
nd - paintStart).InSecondsF(); |
| 34 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintDurationMS", | 34 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintDurationMS", |
| 35 (paintEnd - paintStart).InMilliseconds(), | 35 (paintEnd - paintStart).InMilliseconds(), |
| 36 0, 120, 30); | 36 0, 120, 30); |
| 37 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintMegapixPerSecond", | 37 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintMegapixPerSecond", |
| 38 pixelsPerSec / 1000000, 10, 210, 30); | 38 pixelsPerSec / 1000000, 10, 210, 30); |
| 39 } | 39 } |
| 40 | 40 |
| 41 scoped_refptr<ContentLayer> ContentLayer::create(ContentLayerClient* client) | 41 scoped_refptr<ContentLayer> ContentLayer::Create(ContentLayerClient* client) |
| 42 { | 42 { |
| 43 return make_scoped_refptr(new ContentLayer(client)); | 43 return make_scoped_refptr(new ContentLayer(client)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 ContentLayer::ContentLayer(ContentLayerClient* client) | 46 ContentLayer::ContentLayer(ContentLayerClient* client) |
| 47 : TiledLayer() | 47 : TiledLayer() |
| 48 , m_client(client) | 48 , m_client(client) |
| 49 { | 49 { |
| 50 } | 50 } |
| 51 | 51 |
| 52 ContentLayer::~ContentLayer() | 52 ContentLayer::~ContentLayer() |
| 53 { | 53 { |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool ContentLayer::drawsContent() const | 56 bool ContentLayer::DrawsContent() const |
| 57 { | 57 { |
| 58 return TiledLayer::drawsContent() && m_client; | 58 return TiledLayer::DrawsContent() && m_client; |
| 59 } | 59 } |
| 60 | 60 |
| 61 void ContentLayer::setTexturePriorities(const PriorityCalculator& priorityCalc) | 61 void ContentLayer::SetTexturePriorities(const PriorityCalculator& priorityCalc) |
| 62 { | 62 { |
| 63 // Update the tile data before creating all the layer's tiles. | 63 // Update the tile data before creating all the layer's tiles. |
| 64 updateTileSizeAndTilingOption(); | 64 updateTileSizeAndTilingOption(); |
| 65 | 65 |
| 66 TiledLayer::setTexturePriorities(priorityCalc); | 66 TiledLayer::SetTexturePriorities(priorityCalc); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void ContentLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* oc
clusion, RenderingStats* stats) | 69 void ContentLayer::Update(ResourceUpdateQueue* queue, const OcclusionTracker* oc
clusion, RenderingStats* stats) |
| 70 { | 70 { |
| 71 { | 71 { |
| 72 base::AutoReset<bool> ignoreSetNeedsCommit(&m_ignoreSetNeedsCommit, true
); | 72 base::AutoReset<bool> ignoreSetNeedsCommit(&ignore_set_needs_commit_, tr
ue); |
| 73 | 73 |
| 74 createUpdaterIfNeeded(); | 74 createUpdaterIfNeeded(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 TiledLayer::update(queue, occlusion, stats); | 77 TiledLayer::Update(queue, occlusion, stats); |
| 78 m_needsDisplay = false; | 78 needs_display_ = false; |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool ContentLayer::needMoreUpdates() | 81 bool ContentLayer::NeedMoreUpdates() |
| 82 { | 82 { |
| 83 return needsIdlePaint(); | 83 return needsIdlePaint(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 LayerUpdater* ContentLayer::updater() const | 86 LayerUpdater* ContentLayer::updater() const |
| 87 { | 87 { |
| 88 return m_updater.get(); | 88 return m_updater.get(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void ContentLayer::createUpdaterIfNeeded() | 91 void ContentLayer::createUpdaterIfNeeded() |
| 92 { | 92 { |
| 93 if (m_updater) | 93 if (m_updater) |
| 94 return; | 94 return; |
| 95 scoped_ptr<LayerPainter> painter = ContentLayerPainter::create(m_client).Pas
sAs<LayerPainter>(); | 95 scoped_ptr<LayerPainter> painter = ContentLayerPainter::Create(m_client).Pas
sAs<LayerPainter>(); |
| 96 if (layerTreeHost()->settings().acceleratePainting) | 96 if (layer_tree_host()->settings().acceleratePainting) |
| 97 m_updater = SkPictureContentLayerUpdater::create(painter.Pass()); | 97 m_updater = SkPictureContentLayerUpdater::create(painter.Pass()); |
| 98 else if (layerTreeHost()->settings().perTilePaintingEnabled) | 98 else if (layer_tree_host()->settings().perTilePaintingEnabled) |
| 99 m_updater = BitmapSkPictureContentLayerUpdater::create(painter.Pass()); | 99 m_updater = BitmapSkPictureContentLayerUpdater::create(painter.Pass()); |
| 100 else | 100 else |
| 101 m_updater = BitmapContentLayerUpdater::create(painter.Pass()); | 101 m_updater = BitmapContentLayerUpdater::create(painter.Pass()); |
| 102 m_updater->setOpaque(contentsOpaque()); | 102 m_updater->setOpaque(contents_opaque()); |
| 103 | 103 |
| 104 unsigned textureFormat = layerTreeHost()->rendererCapabilities().bestTexture
Format; | 104 unsigned textureFormat = layer_tree_host()->rendererCapabilities().bestTextu
reFormat; |
| 105 setTextureFormat(textureFormat); | 105 setTextureFormat(textureFormat); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void ContentLayer::setContentsOpaque(bool opaque) | 108 void ContentLayer::SetContentsOpaque(bool opaque) |
| 109 { | 109 { |
| 110 Layer::setContentsOpaque(opaque); | 110 Layer::SetContentsOpaque(opaque); |
| 111 if (m_updater) | 111 if (m_updater) |
| 112 m_updater->setOpaque(opaque); | 112 m_updater->setOpaque(opaque); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace cc | 115 } // namespace cc |
| OLD | NEW |