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_useLCDText(false) | |
|
enne (OOO)
2012/12/12 21:49:48
Am I reading this code right that m_useLCDText sta
alokp
2012/12/12 21:53:23
See line 128: We always disable LCD text if needed
enne (OOO)
2012/12/12 21:54:31
Oh, quite right. My mistake. :)
| |
| 49 , m_lcdTextChangeCount(0) | |
| 45 { | 50 { |
| 46 } | 51 } |
| 47 | 52 |
| 48 ContentLayer::~ContentLayer() | 53 ContentLayer::~ContentLayer() |
| 49 { | 54 { |
| 50 } | 55 } |
| 51 | 56 |
| 52 bool ContentLayer::drawsContent() const | 57 bool ContentLayer::drawsContent() const |
| 53 { | 58 { |
| 54 return TiledLayer::drawsContent() && m_client; | 59 return TiledLayer::drawsContent() && m_client; |
| 55 } | 60 } |
| 56 | 61 |
| 57 void ContentLayer::setTexturePriorities(const PriorityCalculator& priorityCalc) | 62 void ContentLayer::setTexturePriorities(const PriorityCalculator& priorityCalc) |
| 58 { | 63 { |
| 59 // Update the tile data before creating all the layer's tiles. | 64 // Update the tile data before creating all the layer's tiles. |
| 60 updateTileSizeAndTilingOption(); | 65 updateTileSizeAndTilingOption(); |
| 61 | 66 |
| 62 TiledLayer::setTexturePriorities(priorityCalc); | 67 TiledLayer::setTexturePriorities(priorityCalc); |
| 63 } | 68 } |
| 64 | 69 |
| 65 void ContentLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* oc clusion, RenderingStats& stats) | 70 void ContentLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* oc clusion, RenderingStats& stats) |
| 66 { | 71 { |
| 67 createUpdaterIfNeeded(); | 72 createUpdaterIfNeeded(); |
| 73 updateUseLCDText(); | |
| 74 | |
| 68 TiledLayer::update(queue, occlusion, stats); | 75 TiledLayer::update(queue, occlusion, stats); |
| 69 m_needsDisplay = false; | 76 m_needsDisplay = false; |
| 70 } | 77 } |
| 71 | 78 |
| 72 bool ContentLayer::needMoreUpdates() | 79 bool ContentLayer::needMoreUpdates() |
| 73 { | 80 { |
| 74 return needsIdlePaint(); | 81 return needsIdlePaint(); |
| 75 } | 82 } |
| 76 | 83 |
| 77 LayerUpdater* ContentLayer::updater() const | 84 LayerUpdater* ContentLayer::updater() const |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 96 setTextureFormat(textureFormat); | 103 setTextureFormat(textureFormat); |
| 97 } | 104 } |
| 98 | 105 |
| 99 void ContentLayer::setContentsOpaque(bool opaque) | 106 void ContentLayer::setContentsOpaque(bool opaque) |
| 100 { | 107 { |
| 101 Layer::setContentsOpaque(opaque); | 108 Layer::setContentsOpaque(opaque); |
| 102 if (m_updater) | 109 if (m_updater) |
| 103 m_updater->setOpaque(opaque); | 110 m_updater->setOpaque(opaque); |
| 104 } | 111 } |
| 105 | 112 |
| 113 void ContentLayer::updateUseLCDText() | |
| 114 { | |
| 115 if (m_useLCDText == drawProperties().can_use_lcd_text) | |
| 116 return; | |
| 117 | |
| 118 if (!useLCDTextWillChange()) | |
| 119 return; | |
| 120 | |
| 121 m_useLCDText = drawProperties().can_use_lcd_text; | |
| 122 useLCDTextDidChange(); | |
| 123 } | |
| 124 | |
| 125 bool ContentLayer::useLCDTextWillChange() const | |
| 126 { | |
| 127 // Always allow disabling LCD text. | |
| 128 if (m_useLCDText) | |
| 129 return true; | |
| 130 | |
| 131 return m_lcdTextChangeCount < kLCDTextMaxChangeCount; | |
| 132 } | |
| 133 | |
| 134 void ContentLayer::useLCDTextDidChange() | |
| 135 { | |
| 136 if (m_lcdTextChangeCount > 0) { | |
| 137 // Do not record the first time LCD text is enabled because | |
| 138 // it does not really cause any invalidation. | |
| 139 TRACE_EVENT_INSTANT0("cc", "ContentLayer::canUseLCDTextDidChange"); | |
| 140 } | |
| 141 ++m_lcdTextChangeCount; | |
| 142 | |
| 143 // Need to repaint the layer with different text AA setting. | |
| 144 setNeedsDisplay(); | |
| 145 } | |
| 146 | |
| 106 } // namespace cc | 147 } // namespace cc |
| OLD | NEW |