Source/WebCore/ChangeLog

 12013-02-06 Bruno de Oliveira Abinader <bruno.abinader@basyskom.com>
 2
 3 [texmap] Implement frames-per-second debug counter
 4 https://bugs.webkit.org/show_bug.cgi?id=107942
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Added TextureMapper' FPS counter via WEBKIT_SHOW_FPS=<interval> envvar,
 9 where <interval> is the period (in seconds - i.e. WEBKIT_SHOW_FPS=1.0)
 10 between FPS value udpates.
 11
 12 Visual debugging feature, no need to tests.
 13
 14 * platform/graphics/texmap/TextureMapperLayer.cpp:
 15 (WebCore::TextureMapperLayer::paint): Paints FPS after all recursive layer paintings.
 16 (WebCore::TextureMapperLayer::setShowFPS): Toggles FPS visible.
 17 (WebCore::TextureMapperLayer::setFPS): Updates FPS value.
 18 * platform/graphics/texmap/TextureMapperLayer.h:
 19 (TextureMapperLayer): Added setters set{Show}FPS.
 20 (State): Added 'fps' and 'showFPS'.
 21 (WebCore::TextureMapperLayer::State::State): Added 'fps' and 'showFPS' to init list.
 22 * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:
 23 (WebCore::CoordinatedGraphicsScene::CoordinatedGraphicsScene): Added envvar check code to trigger timer updates.
 24 (WebCore::CoordinatedGraphicsScene::paintToCurrentGLContext): Increments paint count.
 25 (WebCore::CoordinatedGraphicsScene::paintToGraphicsContext): Increments paint count.
 26 (WebCore::CoordinatedGraphicsScene::fpsTimerFired): Updates FPS value to root layer.
 27 * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h: Added FPS variables/timer functions.
 28
1292013-02-04 Bruno de Oliveira Abinader <bruno.abinader@basyskom.com>
230
331 [WK2] CoordinatedLayerInfo is a struct, not a class

Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp

@@void TextureMapperLayer::paint()
8585 options.textureMapper = m_textureMapper;
8686 options.textureMapper->bindSurface(0);
8787 paintRecursive(options);
 88
 89 static Color fpsColor = Color::black;
 90 static FloatPoint fpsPoint;
 91
 92 // FIXME: Using drawRepaintCounter() from TextureMapper.
 93 if (m_state.showFPS)
 94 options.textureMapper->drawRepaintCounter(m_state.fps, fpsColor, fpsPoint, m_currentTransform.combined());
8895}
8996
9097static Color blendWithOpacity(const Color& color, float opacity)

@@void TextureMapperLayer::setRepaintCount(int repaintCount)
537544 m_state.repaintCount = repaintCount;
538545}
539546
 547void TextureMapperLayer::setShowFPS(bool showFPS)
 548{
 549 m_state.showFPS = showFPS;
 550}
 551
 552void TextureMapperLayer::setFPS(int fps)
 553{
 554 m_state.fps = fps;
 555}
 556
540557void TextureMapperLayer::setContentsLayer(TextureMapperPlatformLayer* platformLayer)
541558{
542559 m_contentsLayer = platformLayer;

Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h

@@public:
8080#endif
8181 void setDebugVisuals(bool showDebugBorders, const Color& debugBorderColor, float debugBorderWidth, bool showRepaintCounter);
8282 void setRepaintCount(int);
 83 void setShowFPS(bool);
 84 void setFPS(int);
8385 void setContentsLayer(TextureMapperPlatformLayer*);
8486 void setAnimations(const GraphicsLayerAnimations&);
8587 void setFixedToViewport(bool);

@@private:
173175 Color debugBorderColor;
174176 float debugBorderWidth;
175177 int repaintCount;
 178 int fps;
176179
177180 bool preserves3D : 1;
178181 bool masksToBounds : 1;

@@private:
183186 bool visible : 1;
184187 bool showDebugBorders : 1;
185188 bool showRepaintCounter : 1;
 189 bool showFPS : 1;
186190
187191 State()
188192 : opacity(1)

@@private:
190194 , replicaLayer(0)
191195 , debugBorderWidth(0)
192196 , repaintCount(0)
 197 , fps(0)
193198 , preserves3D(false)
194199 , masksToBounds(false)
195200 , drawsContent(false)

@@private:
199204 , visible(true)
200205 , showDebugBorders(false)
201206 , showRepaintCounter(false)
 207 , showFPS(false)
202208 {
203209 }
204210 };

Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp

@@CoordinatedGraphicsScene::CoordinatedGraphicsScene(CoordinatedGraphicsSceneClien
7676#endif
7777 , m_backgroundColor(Color::white)
7878 , m_setDrawsBackground(false)
 79 , m_paintCount(0)
 80 , m_fpsInterval(0)
 81 , m_fpsTimer(this, &CoordinatedGraphicsScene::fpsTimerFired)
7982{
8083 ASSERT(isMainThread());
 84
 85 String showFPSEnvironment = getenv("WEBKIT_SHOW_FPS");
 86 bool ok = false;
 87 m_fpsInterval = showFPSEnvironment.toDouble(&ok);
 88 if (ok && m_fpsInterval) {
 89 ensureRootLayer();
 90 TextureMapperLayer* layer = toTextureMapperLayer(rootLayer());
 91 if (layer) {
 92 layer->setShowFPS(true);
 93 m_fpsTimer.startRepeating(m_fpsInterval);
 94 }
 95 }
8196}
8297
8398CoordinatedGraphicsScene::~CoordinatedGraphicsScene()

@@void CoordinatedGraphicsScene::paintToCurrentGLContext(const TransformationMatri
126141 layer->paint();
127142 m_textureMapper->endClip();
128143 m_textureMapper->endPainting();
 144 m_paintCount++;
129145
130146 if (layer->descendantsOrSelfHaveRunningAnimations())
131147 dispatchOnMainThread(bind(&CoordinatedGraphicsScene::updateViewport, this));

@@void CoordinatedGraphicsScene::paintToGraphicsContext(cairo_t* painter)
177193 layer->paint();
178194 m_textureMapper->endPainting();
179195 m_textureMapper->setGraphicsContext(0);
 196 m_paintCount++;
180197}
181198
182199void CoordinatedGraphicsScene::setContentsSize(const FloatSize& contentsSize)

@@void CoordinatedGraphicsScene::setBackgroundColor(const Color& color)
693710 m_backgroundColor = color;
694711}
695712
 713void CoordinatedGraphicsScene::fpsTimerFired(SceneTimer*)
 714{
 715 TextureMapperLayer* layer = toTextureMapperLayer(rootLayer());
 716 layer->setFPS((int)(m_paintCount / m_fpsInterval));
 717 m_paintCount = 0;
 718}
 719
696720} // namespace WebCore
697721
698722#endif // USE(COORDINATED_GRAPHICS)

Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h

@@private:
220220 typedef HashMap<int, RefPtr<CustomFilterProgram> > CustomFilterProgramMap;
221221 CustomFilterProgramMap m_customFilterPrograms;
222222#endif
 223
 224 int m_paintCount;
 225 double m_fpsInterval;
 226
 227 typedef Timer<CoordinatedGraphicsScene> SceneTimer;
 228 void fpsTimerFired(SceneTimer*);
 229 SceneTimer m_fpsTimer;
223230};
224231
225232} // namespace WebCore