diff options
author | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-13 09:18:59 +0000 |
---|---|---|
committer | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-13 09:18:59 +0000 |
commit | 10aabcc348711dc3544ceb20773ddd2fb6ceb773 (patch) | |
tree | 0b94311df1dfca512e6775273a39dfb341b7c260 /cc/content_layer.cc | |
parent | 27036a1728b42e82bb461f4c54270c29e7a181fc (diff) | |
download | chromium_src-10aabcc348711dc3544ceb20773ddd2fb6ceb773.zip chromium_src-10aabcc348711dc3544ceb20773ddd2fb6ceb773.tar.gz chromium_src-10aabcc348711dc3544ceb20773ddd2fb6ceb773.tar.bz2 |
Mark layers that can use LCD text based on layer transform and opacity.
- Text AA settings are not adjusted during animation to avoid repaints.
- Renamed Layer::useLCDText to Layer::canUseLCDText.
BUG=100666
Review URL: https://chromiumcodereview.appspot.com/11360093
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172842 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/content_layer.cc')
-rw-r--r-- | cc/content_layer.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/cc/content_layer.cc b/cc/content_layer.cc index b34ce10..3b97dcd 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,8 @@ scoped_refptr<ContentLayer> ContentLayer::create(ContentLayerClient* client) ContentLayer::ContentLayer(ContentLayerClient* client) : TiledLayer() , m_client(client) + , m_useLCDText(false) + , m_lcdTextChangeCount(0) { } @@ -65,6 +70,8 @@ void ContentLayer::setTexturePriorities(const PriorityCalculator& priorityCalc) void ContentLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats) { createUpdaterIfNeeded(); + updateUseLCDText(); + TiledLayer::update(queue, occlusion, stats); m_needsDisplay = false; } @@ -103,4 +110,38 @@ void ContentLayer::setContentsOpaque(bool opaque) m_updater->setOpaque(opaque); } +void ContentLayer::updateUseLCDText() +{ + if (m_useLCDText == drawProperties().can_use_lcd_text) + return; + + if (!useLCDTextWillChange()) + return; + + m_useLCDText = drawProperties().can_use_lcd_text; + useLCDTextDidChange(); +} + +bool ContentLayer::useLCDTextWillChange() const +{ + // Always allow disabling LCD text. + if (m_useLCDText) + return true; + + return m_lcdTextChangeCount < kLCDTextMaxChangeCount; +} + +void ContentLayer::useLCDTextDidChange() +{ + 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 |