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

Side by Side Diff: ui/cc/ContentLayerChromium.cpp

Issue 10701016: Initial import attempt, just to play with. Many things disabled/removed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months 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
« no previous file with comments | « ui/cc/ContentLayerChromium.h ('k') | ui/cc/FrameBufferSkPictureCanvasLayerTextureUpdater.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "config.h"
32
33 #if USE(ACCELERATED_COMPOSITING)
34
35 #include "ContentLayerChromium.h"
36
37 #include "BitmapCanvasLayerTextureUpdater.h"
38 #include "BitmapSkPictureCanvasLayerTextureUpdater.h"
39 #include "FrameBufferSkPictureCanvasLayerTextureUpdater.h"
40 #include "LayerPainterChromium.h"
41 #include "cc/CCLayerTreeHost.h"
42 #include "cc/CCSettings.h"
43 #include <public/Platform.h>
44 #include <wtf/CurrentTime.h>
45
46 namespace WebCore {
47
48 class ContentLayerPainter : public LayerPainterChromium {
49 WTF_MAKE_NONCOPYABLE(ContentLayerPainter);
50 public:
51 static PassOwnPtr<ContentLayerPainter> create(ContentLayerDelegate* delegate )
52 {
53 return adoptPtr(new ContentLayerPainter(delegate));
54 }
55
56 virtual void paint(SkCanvas* canvas, const IntRect& contentRect, IntRect& op aque)
57 {
58 double paintStart = currentTime();
59 m_delegate->paintContents(canvas, contentRect, opaque);
60 double paintEnd = currentTime();
61 double pixelsPerSec = (contentRect.width() * contentRect.height()) / (pa intEnd - paintStart);
62 WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelConte ntPaintDurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30);
63 WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelConte ntPaintMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30);
64 }
65 private:
66 explicit ContentLayerPainter(ContentLayerDelegate* delegate)
67 : m_delegate(delegate)
68 {
69 }
70
71 ContentLayerDelegate* m_delegate;
72 };
73
74 PassRefPtr<ContentLayerChromium> ContentLayerChromium::create(ContentLayerDelega te* delegate)
75 {
76 return adoptRef(new ContentLayerChromium(delegate));
77 }
78
79 ContentLayerChromium::ContentLayerChromium(ContentLayerDelegate* delegate)
80 : TiledLayerChromium()
81 , m_delegate(delegate)
82 {
83 }
84
85 ContentLayerChromium::~ContentLayerChromium()
86 {
87 }
88
89 bool ContentLayerChromium::drawsContent() const
90 {
91 return TiledLayerChromium::drawsContent() && m_delegate;
92 }
93
94 void ContentLayerChromium::update(CCTextureUpdater& updater, const CCOcclusionTr acker* occlusion)
95 {
96 updateTileSizeAndTilingOption();
97 createTextureUpdaterIfNeeded();
98
99 IntRect layerRect;
100
101 // Always call updateLayerRect() but with an empty layer rectangle when
102 // layer doesn't draw contents.
103 if (drawsContent())
104 layerRect = visibleLayerRect();
105
106 updateLayerRect(updater, layerRect, occlusion);
107 m_needsDisplay = false;
108 }
109
110 void ContentLayerChromium::idleUpdate(CCTextureUpdater& updater, const CCOcclusi onTracker* occlusion)
111 {
112 if (!drawsContent())
113 return;
114
115 const IntRect layerRect = visibleLayerRect();
116 idleUpdateLayerRect(updater, layerRect, occlusion);
117 if (needsIdlePaint(layerRect))
118 setNeedsCommit();
119 }
120
121 void ContentLayerChromium::createTextureUpdaterIfNeeded()
122 {
123 if (m_textureUpdater)
124 return;
125 if (layerTreeHost()->settings().acceleratePainting)
126 m_textureUpdater = FrameBufferSkPictureCanvasLayerTextureUpdater::create (ContentLayerPainter::create(m_delegate));
127 else if (CCSettings::perTilePaintingEnabled())
128 m_textureUpdater = BitmapSkPictureCanvasLayerTextureUpdater::create(Cont entLayerPainter::create(m_delegate), layerTreeHost()->layerRendererCapabilities( ).usingMapSub);
129 else
130 m_textureUpdater = BitmapCanvasLayerTextureUpdater::create(ContentLayerP ainter::create(m_delegate), layerTreeHost()->layerRendererCapabilities().usingMa pSub);
131 m_textureUpdater->setOpaque(opaque());
132
133 GC3Denum textureFormat = layerTreeHost()->layerRendererCapabilities().bestTe xtureFormat;
134 setTextureFormat(textureFormat);
135 setSampledTexelFormat(textureUpdater()->sampledTexelFormat(textureFormat));
136 }
137
138 void ContentLayerChromium::setOpaque(bool opaque)
139 {
140 LayerChromium::setOpaque(opaque);
141 if (m_textureUpdater)
142 m_textureUpdater->setOpaque(opaque);
143 }
144
145 }
146 #endif // USE(ACCELERATED_COMPOSITING)
OLDNEW
« no previous file with comments | « ui/cc/ContentLayerChromium.h ('k') | ui/cc/FrameBufferSkPictureCanvasLayerTextureUpdater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698