OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 | |
7 #if USE(ACCELERATED_COMPOSITING) | |
8 | |
9 #include "ContentLayerChromium.h" | |
10 | |
11 #include "base/time.h" | |
12 #include "BitmapCanvasLayerTextureUpdater.h" | |
13 #include "BitmapSkPictureCanvasLayerTextureUpdater.h" | |
14 #include "CCLayerTreeHost.h" | |
15 #include "CCSettings.h" | |
16 #include "ContentLayerChromiumClient.h" | |
17 #include "FrameBufferSkPictureCanvasLayerTextureUpdater.h" | |
18 #include "LayerPainterChromium.h" | |
19 #include <public/Platform.h> | |
20 | |
21 namespace cc { | |
22 | |
23 ContentLayerPainter::ContentLayerPainter(ContentLayerChromiumClient* client) | |
24 : m_client(client) | |
25 { | |
26 } | |
27 | |
28 PassOwnPtr<ContentLayerPainter> ContentLayerPainter::create(ContentLayerChromium
Client* client) | |
29 { | |
30 return adoptPtr(new ContentLayerPainter(client)); | |
31 } | |
32 | |
33 void ContentLayerPainter::paint(SkCanvas* canvas, const IntRect& contentRect, Fl
oatRect& opaque) | |
34 { | |
35 base::TimeTicks paintStart = base::TimeTicks::HighResNow(); | |
36 m_client->paintContents(canvas, contentRect, opaque); | |
37 base::TimeTicks paintEnd = base::TimeTicks::HighResNow(); | |
38 double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintE
nd - paintStart).InSecondsF(); | |
39 WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPa
intDurationMS", (paintEnd - paintStart).InMillisecondsF(), 0, 120, 30); | |
40 WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPa
intMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30); | |
41 } | |
42 | |
43 scoped_refptr<ContentLayerChromium> ContentLayerChromium::create(ContentLayerChr
omiumClient* client) | |
44 { | |
45 return make_scoped_refptr(new ContentLayerChromium(client)); | |
46 } | |
47 | |
48 ContentLayerChromium::ContentLayerChromium(ContentLayerChromiumClient* client) | |
49 : TiledLayerChromium() | |
50 , m_client(client) | |
51 { | |
52 } | |
53 | |
54 ContentLayerChromium::~ContentLayerChromium() | |
55 { | |
56 } | |
57 | |
58 bool ContentLayerChromium::drawsContent() const | |
59 { | |
60 return TiledLayerChromium::drawsContent() && m_client; | |
61 } | |
62 | |
63 void ContentLayerChromium::setTexturePriorities(const CCPriorityCalculator& prio
rityCalc) | |
64 { | |
65 // Update the tile data before creating all the layer's tiles. | |
66 updateTileSizeAndTilingOption(); | |
67 | |
68 TiledLayerChromium::setTexturePriorities(priorityCalc); | |
69 } | |
70 | |
71 void ContentLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusion
Tracker* occlusion, CCRenderingStats& stats) | |
72 { | |
73 createTextureUpdaterIfNeeded(); | |
74 TiledLayerChromium::update(queue, occlusion, stats); | |
75 m_needsDisplay = false; | |
76 } | |
77 | |
78 bool ContentLayerChromium::needMoreUpdates() | |
79 { | |
80 return needsIdlePaint(); | |
81 } | |
82 | |
83 LayerTextureUpdater* ContentLayerChromium::textureUpdater() const | |
84 { | |
85 return m_textureUpdater.get(); | |
86 } | |
87 | |
88 void ContentLayerChromium::createTextureUpdaterIfNeeded() | |
89 { | |
90 if (m_textureUpdater) | |
91 return; | |
92 if (layerTreeHost()->settings().acceleratePainting) | |
93 m_textureUpdater = FrameBufferSkPictureCanvasLayerTextureUpdater::create
(ContentLayerPainter::create(m_client)); | |
94 else if (CCSettings::perTilePaintingEnabled()) | |
95 m_textureUpdater = BitmapSkPictureCanvasLayerTextureUpdater::create(Cont
entLayerPainter::create(m_client)); | |
96 else | |
97 m_textureUpdater = BitmapCanvasLayerTextureUpdater::create(ContentLayerP
ainter::create(m_client)); | |
98 m_textureUpdater->setOpaque(contentsOpaque()); | |
99 | |
100 GC3Denum textureFormat = layerTreeHost()->rendererCapabilities().bestTexture
Format; | |
101 setTextureFormat(textureFormat); | |
102 setSampledTexelFormat(textureUpdater()->sampledTexelFormat(textureFormat)); | |
103 } | |
104 | |
105 void ContentLayerChromium::setContentsOpaque(bool opaque) | |
106 { | |
107 LayerChromium::setContentsOpaque(opaque); | |
108 if (m_textureUpdater) | |
109 m_textureUpdater->setOpaque(opaque); | |
110 } | |
111 | |
112 } | |
113 #endif // USE(ACCELERATED_COMPOSITING) | |
OLD | NEW |