Chromium Code Reviews| 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/debug/trace_event.h" | |
| 7 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 8 #include "base/time.h" | 9 #include "base/time.h" |
| 9 #include "cc/bitmap_content_layer_updater.h" | 10 #include "cc/bitmap_content_layer_updater.h" |
| 10 #include "cc/bitmap_skpicture_content_layer_updater.h" | 11 #include "cc/bitmap_skpicture_content_layer_updater.h" |
| 11 #include "cc/content_layer_client.h" | 12 #include "cc/content_layer_client.h" |
| 12 #include "cc/layer_painter.h" | 13 #include "cc/layer_painter.h" |
| 13 #include "cc/layer_tree_host.h" | 14 #include "cc/layer_tree_host.h" |
| 14 | 15 |
| 15 namespace cc { | 16 namespace cc { |
| 16 | 17 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 27 void ContentLayerPainter::paint(SkCanvas* canvas, const gfx::Rect& contentRect, gfx::RectF& opaque) | 28 void ContentLayerPainter::paint(SkCanvas* canvas, const gfx::Rect& contentRect, gfx::RectF& opaque) |
| 28 { | 29 { |
| 29 base::TimeTicks paintStart = base::TimeTicks::HighResNow(); | 30 base::TimeTicks paintStart = base::TimeTicks::HighResNow(); |
| 30 m_client->paintContents(canvas, contentRect, opaque); | 31 m_client->paintContents(canvas, contentRect, opaque); |
| 31 base::TimeTicks paintEnd = base::TimeTicks::HighResNow(); | 32 base::TimeTicks paintEnd = base::TimeTicks::HighResNow(); |
| 32 double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintE nd - paintStart).InSecondsF(); | 33 double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintE nd - paintStart).InSecondsF(); |
| 33 HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintDurationMS", (paintEnd - paintStart).InMilliseconds(), 0, 120, 30); | 34 HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintDurationMS", (paintEnd - paintStart).InMilliseconds(), 0, 120, 30); |
| 34 HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintMegapixPerSecond", pixel sPerSec / 1000000, 10, 210, 30); | 35 HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintMegapixPerSecond", pixel sPerSec / 1000000, 10, 210, 30); |
| 35 } | 36 } |
| 36 | 37 |
| 38 const int ContentLayer::kLCDTextMaxChangeCount = 1; | |
| 39 | |
| 37 scoped_refptr<ContentLayer> ContentLayer::create(ContentLayerClient* client) | 40 scoped_refptr<ContentLayer> ContentLayer::create(ContentLayerClient* client) |
| 38 { | 41 { |
| 39 return make_scoped_refptr(new ContentLayer(client)); | 42 return make_scoped_refptr(new ContentLayer(client)); |
| 40 } | 43 } |
| 41 | 44 |
| 42 ContentLayer::ContentLayer(ContentLayerClient* client) | 45 ContentLayer::ContentLayer(ContentLayerClient* client) |
| 43 : TiledLayer() | 46 : TiledLayer() |
| 44 , m_client(client) | 47 , m_client(client) |
| 48 , m_lcdTextChangeCount(0) | |
| 45 { | 49 { |
| 46 } | 50 } |
| 47 | 51 |
| 48 ContentLayer::~ContentLayer() | 52 ContentLayer::~ContentLayer() |
| 49 { | 53 { |
| 50 } | 54 } |
| 51 | 55 |
| 52 bool ContentLayer::drawsContent() const | 56 bool ContentLayer::drawsContent() const |
| 53 { | 57 { |
| 54 return TiledLayer::drawsContent() && m_client; | 58 return TiledLayer::drawsContent() && m_client; |
| 55 } | 59 } |
| 56 | 60 |
| 57 void ContentLayer::setTexturePriorities(const PriorityCalculator& priorityCalc) | 61 void ContentLayer::setTexturePriorities(const PriorityCalculator& priorityCalc) |
| 58 { | 62 { |
| 59 // Update the tile data before creating all the layer's tiles. | 63 // Update the tile data before creating all the layer's tiles. |
| 60 updateTileSizeAndTilingOption(); | 64 updateTileSizeAndTilingOption(); |
| 61 | 65 |
| 62 TiledLayer::setTexturePriorities(priorityCalc); | 66 TiledLayer::setTexturePriorities(priorityCalc); |
| 63 } | 67 } |
| 64 | 68 |
| 65 void ContentLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* oc clusion, RenderingStats& stats) | 69 void ContentLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* oc clusion, RenderingStats& stats) |
| 66 { | 70 { |
| 67 createUpdaterIfNeeded(); | 71 createUpdaterIfNeeded(); |
| 72 syncCanUseLCDText(); | |
| 73 | |
| 68 TiledLayer::update(queue, occlusion, stats); | 74 TiledLayer::update(queue, occlusion, stats); |
| 69 m_needsDisplay = false; | 75 m_needsDisplay = false; |
| 70 } | 76 } |
| 71 | 77 |
| 72 bool ContentLayer::needMoreUpdates() | 78 bool ContentLayer::needMoreUpdates() |
| 73 { | 79 { |
| 74 return needsIdlePaint(); | 80 return needsIdlePaint(); |
| 75 } | 81 } |
| 76 | 82 |
| 77 LayerUpdater* ContentLayer::updater() const | 83 LayerUpdater* ContentLayer::updater() const |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 96 setTextureFormat(textureFormat); | 102 setTextureFormat(textureFormat); |
| 97 } | 103 } |
| 98 | 104 |
| 99 void ContentLayer::setContentsOpaque(bool opaque) | 105 void ContentLayer::setContentsOpaque(bool opaque) |
| 100 { | 106 { |
| 101 Layer::setContentsOpaque(opaque); | 107 Layer::setContentsOpaque(opaque); |
| 102 if (m_updater) | 108 if (m_updater) |
| 103 m_updater->setOpaque(opaque); | 109 m_updater->setOpaque(opaque); |
| 104 } | 110 } |
| 105 | 111 |
| 112 void ContentLayer::syncCanUseLCDText() | |
| 113 { | |
| 114 if (m_canUseLCDText == drawProperties().can_use_lcd_text) | |
| 115 return; | |
| 116 | |
| 117 if (!canUseLCDTextWillChange()) { | |
| 118 drawProperties().can_use_lcd_text = m_canUseLCDText; | |
|
enne (OOO)
2012/12/12 17:56:52
Draw properties should only be set during calcDraw
alokp
2012/12/12 19:03:04
Not sure if this is what you meant, but I moved m_
enne (OOO)
2012/12/12 19:14:46
Sorry that I wasn't clear enough. Here's some mor
| |
| 119 return; | |
| 120 } | |
| 121 | |
| 122 m_canUseLCDText = drawProperties().can_use_lcd_text; | |
| 123 canUseLCDTextDidChange(); | |
| 124 } | |
| 125 | |
| 126 bool ContentLayer::canUseLCDTextWillChange() const | |
| 127 { | |
| 128 // Always allow disabling LCD text. | |
| 129 if (m_canUseLCDText) | |
| 130 return true; | |
| 131 | |
| 132 return m_lcdTextChangeCount < kLCDTextMaxChangeCount; | |
| 133 } | |
| 134 | |
| 135 void ContentLayer::canUseLCDTextDidChange() | |
| 136 { | |
| 137 if (m_lcdTextChangeCount > 0) { | |
| 138 // Do not record the first time LCD text is enabled because | |
| 139 // it does not really cause any invalidation. | |
| 140 TRACE_EVENT_INSTANT0("cc", "ContentLayer::canUseLCDTextDidChange"); | |
| 141 } | |
| 142 ++m_lcdTextChangeCount; | |
| 143 | |
| 144 // Need to repaint the layer with different text AA setting. | |
| 145 setNeedsDisplay(); | |
| 146 } | |
| 147 | |
| 106 } // namespace cc | 148 } // namespace cc |
| OLD | NEW |