Chromium Code Reviews| Index: cc/content_layer.cc |
| diff --git a/cc/content_layer.cc b/cc/content_layer.cc |
| index b34ce107e0ced197af3d767f4dc3b8c67f74016f..6f70913ca55786077850a146e66de09233ded938 100644 |
| --- a/cc/content_layer.cc |
| +++ b/cc/content_layer.cc |
| @@ -4,6 +4,7 @@ |
| #include "cc/content_layer.h" |
| +#include "base/debug/trace_event.h" |
| #include "base/metrics/histogram.h" |
| #include "base/time.h" |
| #include "cc/bitmap_content_layer_updater.h" |
| @@ -34,6 +35,8 @@ void ContentLayerPainter::paint(SkCanvas* canvas, const gfx::Rect& contentRect, |
| HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30); |
| } |
| +const int ContentLayer::kLCDTextMaxChangeCount = 1; |
| + |
| scoped_refptr<ContentLayer> ContentLayer::create(ContentLayerClient* client) |
| { |
| return make_scoped_refptr(new ContentLayer(client)); |
| @@ -42,6 +45,7 @@ scoped_refptr<ContentLayer> ContentLayer::create(ContentLayerClient* client) |
| ContentLayer::ContentLayer(ContentLayerClient* client) |
| : TiledLayer() |
| , m_client(client) |
| + , m_lcdTextChangeCount(0) |
| { |
| } |
| @@ -65,6 +69,8 @@ void ContentLayer::setTexturePriorities(const PriorityCalculator& priorityCalc) |
| void ContentLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats) |
| { |
| createUpdaterIfNeeded(); |
| + syncCanUseLCDText(); |
| + |
| TiledLayer::update(queue, occlusion, stats); |
| m_needsDisplay = false; |
| } |
| @@ -103,4 +109,40 @@ void ContentLayer::setContentsOpaque(bool opaque) |
| m_updater->setOpaque(opaque); |
| } |
| +void ContentLayer::syncCanUseLCDText() |
| +{ |
| + if (m_canUseLCDText == drawProperties().can_use_lcd_text) |
| + return; |
| + |
| + if (!canUseLCDTextWillChange()) { |
| + 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
|
| + return; |
| + } |
| + |
| + m_canUseLCDText = drawProperties().can_use_lcd_text; |
| + canUseLCDTextDidChange(); |
| +} |
| + |
| +bool ContentLayer::canUseLCDTextWillChange() const |
| +{ |
| + // Always allow disabling LCD text. |
| + if (m_canUseLCDText) |
| + return true; |
| + |
| + return m_lcdTextChangeCount < kLCDTextMaxChangeCount; |
| +} |
| + |
| +void ContentLayer::canUseLCDTextDidChange() |
| +{ |
| + if (m_lcdTextChangeCount > 0) { |
| + // Do not record the first time LCD text is enabled because |
| + // it does not really cause any invalidation. |
| + TRACE_EVENT_INSTANT0("cc", "ContentLayer::canUseLCDTextDidChange"); |
| + } |
| + ++m_lcdTextChangeCount; |
| + |
| + // Need to repaint the layer with different text AA setting. |
| + setNeedsDisplay(); |
| +} |
| + |
| } // namespace cc |