Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(665)

Side by Side Diff: cc/content_layer.cc

Issue 11360093: Mark layers that can use LCD text based on layer transform and opacity. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed build Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
18 // Maximum number of times LCD text setting can be changed.
19 static const int kLCDTextMaxChangeCount = 1;
20
17 ContentLayerPainter::ContentLayerPainter(ContentLayerClient* client) 21 ContentLayerPainter::ContentLayerPainter(ContentLayerClient* client)
18 : m_client(client) 22 : m_client(client)
19 { 23 {
20 } 24 }
21 25
22 scoped_ptr<ContentLayerPainter> ContentLayerPainter::create(ContentLayerClient* client) 26 scoped_ptr<ContentLayerPainter> ContentLayerPainter::create(ContentLayerClient* client)
23 { 27 {
24 return make_scoped_ptr(new ContentLayerPainter(client)); 28 return make_scoped_ptr(new ContentLayerPainter(client));
25 } 29 }
26 30
27 void ContentLayerPainter::paint(SkCanvas* canvas, const gfx::Rect& contentRect, gfx::RectF& opaque) 31 void ContentLayerPainter::paint(SkCanvas* canvas, const gfx::Rect& contentRect, gfx::RectF& opaque)
28 { 32 {
29 base::TimeTicks paintStart = base::TimeTicks::HighResNow(); 33 base::TimeTicks paintStart = base::TimeTicks::HighResNow();
30 m_client->paintContents(canvas, contentRect, opaque); 34 m_client->paintContents(canvas, contentRect, opaque);
31 base::TimeTicks paintEnd = base::TimeTicks::HighResNow(); 35 base::TimeTicks paintEnd = base::TimeTicks::HighResNow();
32 double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintE nd - paintStart).InSecondsF(); 36 double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintE nd - paintStart).InSecondsF();
33 HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintDurationMS", (paintEnd - paintStart).InMilliseconds(), 0, 120, 30); 37 HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintDurationMS", (paintEnd - paintStart).InMilliseconds(), 0, 120, 30);
34 HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintMegapixPerSecond", pixel sPerSec / 1000000, 10, 210, 30); 38 HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintMegapixPerSecond", pixel sPerSec / 1000000, 10, 210, 30);
35 } 39 }
36 40
37 scoped_refptr<ContentLayer> ContentLayer::create(ContentLayerClient* client) 41 scoped_refptr<ContentLayer> ContentLayer::create(ContentLayerClient* client)
38 { 42 {
39 return make_scoped_refptr(new ContentLayer(client)); 43 return make_scoped_refptr(new ContentLayer(client));
40 } 44 }
41 45
42 ContentLayer::ContentLayer(ContentLayerClient* client) 46 ContentLayer::ContentLayer(ContentLayerClient* client)
43 : TiledLayer() 47 : TiledLayer()
44 , m_client(client) 48 , m_client(client)
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;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 setTextureFormat(textureFormat); 101 setTextureFormat(textureFormat);
97 } 102 }
98 103
99 void ContentLayer::setContentsOpaque(bool opaque) 104 void ContentLayer::setContentsOpaque(bool opaque)
100 { 105 {
101 Layer::setContentsOpaque(opaque); 106 Layer::setContentsOpaque(opaque);
102 if (m_updater) 107 if (m_updater)
103 m_updater->setOpaque(opaque); 108 m_updater->setOpaque(opaque);
104 } 109 }
105 110
111 bool ContentLayer::canUseLCDTextWillChange()
112 {
113 // Always allow disabling LCD text.
114 if (canUseLCDText())
115 return true;
116
117 return m_lcdTextChangeCount < kLCDTextMaxChangeCount;
118 }
119
120 void ContentLayer::canUseLCDTextDidChange()
121 {
122 TiledLayer::canUseLCDTextDidChange();
123
124 if (m_lcdTextChangeCount > 0) {
125 // Do not record the first time LCD text is enabled because
126 // it does not really cause any invalidation.
127 TRACE_EVENT_INSTANT0("cc", "ContentLayer::canUseLCDTextDidChange");
128 }
129 ++m_lcdTextChangeCount;
130
131 // Need to repaint the layer with different text AA setting.
132 setNeedsDisplay();
133 }
134
106 } // namespace cc 135 } // namespace cc
OLDNEW
« no previous file with comments | « cc/content_layer.h ('k') | cc/content_layer_unittest.cc » ('j') | cc/layer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698