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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "ContentLayerChromium.h" | 7 #include "ContentLayerChromium.h" |
8 | 8 |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "BitmapCanvasLayerTextureUpdater.h" | 10 #include "BitmapCanvasLayerTextureUpdater.h" |
11 #include "BitmapSkPictureCanvasLayerTextureUpdater.h" | 11 #include "BitmapSkPictureCanvasLayerTextureUpdater.h" |
12 #include "CCLayerTreeHost.h" | 12 #include "CCLayerTreeHost.h" |
13 #include "CCSettings.h" | 13 #include "CCSettings.h" |
14 #include "ContentLayerChromiumClient.h" | 14 #include "ContentLayerChromiumClient.h" |
15 #include "FrameBufferSkPictureCanvasLayerTextureUpdater.h" | 15 #include "FrameBufferSkPictureCanvasLayerTextureUpdater.h" |
16 #include "LayerPainterChromium.h" | 16 #include "LayerPainterChromium.h" |
17 #include <public/Platform.h> | 17 #include <public/Platform.h> |
18 | 18 |
19 namespace cc { | 19 namespace cc { |
20 | 20 |
21 ContentLayerPainter::ContentLayerPainter(ContentLayerChromiumClient* client) | 21 ContentLayerPainter::ContentLayerPainter(ContentLayerChromiumClient* client) |
22 : m_client(client) | 22 : m_client(client) |
23 { | 23 { |
24 } | 24 } |
25 | 25 |
26 PassOwnPtr<ContentLayerPainter> ContentLayerPainter::create(ContentLayerChromium
Client* client) | 26 scoped_ptr<ContentLayerPainter> ContentLayerPainter::create(ContentLayerChromium
Client* client) |
27 { | 27 { |
28 return adoptPtr(new ContentLayerPainter(client)); | 28 return make_scoped_ptr(new ContentLayerPainter(client)); |
29 } | 29 } |
30 | 30 |
31 void ContentLayerPainter::paint(SkCanvas* canvas, const IntRect& contentRect, Fl
oatRect& opaque) | 31 void ContentLayerPainter::paint(SkCanvas* canvas, const IntRect& contentRect, Fl
oatRect& opaque) |
32 { | 32 { |
33 base::TimeTicks paintStart = base::TimeTicks::HighResNow(); | 33 base::TimeTicks paintStart = base::TimeTicks::HighResNow(); |
34 m_client->paintContents(canvas, contentRect, opaque); | 34 m_client->paintContents(canvas, contentRect, opaque); |
35 base::TimeTicks paintEnd = base::TimeTicks::HighResNow(); | 35 base::TimeTicks paintEnd = base::TimeTicks::HighResNow(); |
36 double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintE
nd - paintStart).InSecondsF(); | 36 double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintE
nd - paintStart).InSecondsF(); |
37 WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPa
intDurationMS", (paintEnd - paintStart).InMillisecondsF(), 0, 120, 30); | 37 WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPa
intDurationMS", (paintEnd - paintStart).InMillisecondsF(), 0, 120, 30); |
38 WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPa
intMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30); | 38 WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPa
intMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 LayerTextureUpdater* ContentLayerChromium::textureUpdater() const | 81 LayerTextureUpdater* ContentLayerChromium::textureUpdater() const |
82 { | 82 { |
83 return m_textureUpdater.get(); | 83 return m_textureUpdater.get(); |
84 } | 84 } |
85 | 85 |
86 void ContentLayerChromium::createTextureUpdaterIfNeeded() | 86 void ContentLayerChromium::createTextureUpdaterIfNeeded() |
87 { | 87 { |
88 if (m_textureUpdater) | 88 if (m_textureUpdater) |
89 return; | 89 return; |
| 90 scoped_ptr<LayerPainterChromium> painter = ContentLayerPainter::create(m_cli
ent).PassAs<LayerPainterChromium>(); |
90 if (layerTreeHost()->settings().acceleratePainting) | 91 if (layerTreeHost()->settings().acceleratePainting) |
91 m_textureUpdater = FrameBufferSkPictureCanvasLayerTextureUpdater::create
(ContentLayerPainter::create(m_client)); | 92 m_textureUpdater = FrameBufferSkPictureCanvasLayerTextureUpdater::create
(painter.Pass()); |
92 else if (CCSettings::perTilePaintingEnabled()) | 93 else if (CCSettings::perTilePaintingEnabled()) |
93 m_textureUpdater = BitmapSkPictureCanvasLayerTextureUpdater::create(Cont
entLayerPainter::create(m_client)); | 94 m_textureUpdater = BitmapSkPictureCanvasLayerTextureUpdater::create(pain
ter.Pass()); |
94 else | 95 else |
95 m_textureUpdater = BitmapCanvasLayerTextureUpdater::create(ContentLayerP
ainter::create(m_client)); | 96 m_textureUpdater = BitmapCanvasLayerTextureUpdater::create(painter.Pass(
)); |
96 m_textureUpdater->setOpaque(contentsOpaque()); | 97 m_textureUpdater->setOpaque(contentsOpaque()); |
97 | 98 |
98 GC3Denum textureFormat = layerTreeHost()->rendererCapabilities().bestTexture
Format; | 99 GC3Denum textureFormat = layerTreeHost()->rendererCapabilities().bestTexture
Format; |
99 setTextureFormat(textureFormat); | 100 setTextureFormat(textureFormat); |
100 setSampledTexelFormat(textureUpdater()->sampledTexelFormat(textureFormat)); | 101 setSampledTexelFormat(textureUpdater()->sampledTexelFormat(textureFormat)); |
101 } | 102 } |
102 | 103 |
103 void ContentLayerChromium::setContentsOpaque(bool opaque) | 104 void ContentLayerChromium::setContentsOpaque(bool opaque) |
104 { | 105 { |
105 LayerChromium::setContentsOpaque(opaque); | 106 LayerChromium::setContentsOpaque(opaque); |
106 if (m_textureUpdater) | 107 if (m_textureUpdater) |
107 m_textureUpdater->setOpaque(opaque); | 108 m_textureUpdater->setOpaque(opaque); |
108 } | 109 } |
109 | 110 |
110 } | 111 } |
OLD | NEW |