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

Side by Side Diff: cc/CCHeadsUpDisplayLayerImpl.cpp

Issue 10900021: Use std::string instead of WTF::String / TextStream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | « cc/CCFontAtlas.cpp ('k') | cc/CCIOSurfaceLayerImpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "CCHeadsUpDisplayLayerImpl.h" 7 #include "CCHeadsUpDisplayLayerImpl.h"
8 8
9 #include "base/stringprintf.h"
9 #include "CCDebugRectHistory.h" 10 #include "CCDebugRectHistory.h"
10 #include "CCFontAtlas.h" 11 #include "CCFontAtlas.h"
11 #include "CCFrameRateCounter.h" 12 #include "CCFrameRateCounter.h"
12 #include "CCLayerTreeHostImpl.h" 13 #include "CCLayerTreeHostImpl.h"
13 #include "CCQuadSink.h" 14 #include "CCQuadSink.h"
14 #include "CCTextureDrawQuad.h" 15 #include "CCTextureDrawQuad.h"
15 #include "Extensions3DChromium.h" 16 #include "Extensions3DChromium.h"
16 #include "GraphicsContext3D.h" 17 #include "GraphicsContext3D.h"
17 #include "SkBitmap.h" 18 #include "SkBitmap.h"
18 #include "SkColorMatrixFilter.h" 19 #include "SkColorMatrixFilter.h"
19 #include "SkPaint.h" 20 #include "SkPaint.h"
20 #include "skia/ext/platform_canvas.h" 21 #include "skia/ext/platform_canvas.h"
21 #include <wtf/text/WTFString.h>
22 22
23 namespace WebCore { 23 namespace WebCore {
24 24
25 static inline SkPaint createPaint() 25 static inline SkPaint createPaint()
26 { 26 {
27 // The SkCanvas is in RGBA but the shader is expecting BGRA, so we need to 27 // The SkCanvas is in RGBA but the shader is expecting BGRA, so we need to
28 // swizzle our colors when drawing to the SkCanvas. 28 // swizzle our colors when drawing to the SkCanvas.
29 SkColorMatrix swizzleMatrix; 29 SkColorMatrix swizzleMatrix;
30 for (int i = 0; i < 20; ++i) 30 for (int i = 0; i < 20; ++i)
31 swizzleMatrix.fMat[i] = 0; 31 swizzleMatrix.fMat[i] = 0;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 if (settings.showFPSCounter) 143 if (settings.showFPSCounter)
144 platformLayerTreeTop = fpsCounterTop + fpsCounterHeight; 144 platformLayerTreeTop = fpsCounterTop + fpsCounterHeight;
145 else 145 else
146 platformLayerTreeTop = 0; 146 platformLayerTreeTop = 0;
147 147
148 if (settings.showFPSCounter) 148 if (settings.showFPSCounter)
149 drawFPSCounter(canvas, layerTreeHostImpl()->fpsCounter(), fpsCounterTop, fpsCounterHeight); 149 drawFPSCounter(canvas, layerTreeHostImpl()->fpsCounter(), fpsCounterTop, fpsCounterHeight);
150 150
151 if (settings.showPlatformLayerTree && m_fontAtlas) { 151 if (settings.showPlatformLayerTree && m_fontAtlas) {
152 String layerTree = layerTreeHostImpl()->layerTreeAsText(); 152 std::string layerTree = layerTreeHostImpl()->layerTreeAsText();
153 m_fontAtlas->drawText(canvas, createPaint(), layerTree, IntPoint(2, plat formLayerTreeTop), bounds()); 153 m_fontAtlas->drawText(canvas, createPaint(), layerTree, IntPoint(2, plat formLayerTreeTop), bounds());
154 } 154 }
155 155
156 if (settings.showDebugRects()) 156 if (settings.showDebugRects())
157 drawDebugRects(canvas, layerTreeHostImpl()->debugRectHistory()); 157 drawDebugRects(canvas, layerTreeHostImpl()->debugRectHistory());
158 } 158 }
159 159
160 void CCHeadsUpDisplayLayerImpl::drawFPSCounter(SkCanvas* canvas, CCFrameRateCoun ter* fpsCounter, int top, int height) 160 void CCHeadsUpDisplayLayerImpl::drawFPSCounter(SkCanvas* canvas, CCFrameRateCoun ter* fpsCounter, int top, int height)
161 { 161 {
162 float textWidth = 170; // so text fits on linux. 162 float textWidth = 170; // so text fits on linux.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 double averageFPS, stdDeviation; 218 double averageFPS, stdDeviation;
219 fpsCounter->getAverageFPSAndStandardDeviation(averageFPS, stdDeviation); 219 fpsCounter->getAverageFPSAndStandardDeviation(averageFPS, stdDeviation);
220 220
221 // Draw background. 221 // Draw background.
222 SkPaint paint = createPaint(); 222 SkPaint paint = createPaint();
223 paint.setColor(SK_ColorBLACK); 223 paint.setColor(SK_ColorBLACK);
224 canvas->drawRect(SkRect::MakeXYWH(2, top, width, height), paint); 224 canvas->drawRect(SkRect::MakeXYWH(2, top, width, height), paint);
225 225
226 // Draw FPS text. 226 // Draw FPS text.
227 if (m_fontAtlas) 227 if (m_fontAtlas)
228 m_fontAtlas->drawText(canvas, createPaint(), String::format("FPS: %4.1f +/- %3.1f", averageFPS, stdDeviation), IntPoint(10, height / 3), IntSize(width, height)); 228 m_fontAtlas->drawText(canvas, createPaint(), base::StringPrintf("FPS: %4 .1f +/- %3.1f", averageFPS, stdDeviation), IntPoint(10, height / 3), IntSize(wid th, height));
229 } 229 }
230 230
231 void CCHeadsUpDisplayLayerImpl::drawDebugRects(SkCanvas* canvas, CCDebugRectHist ory* debugRectHistory) 231 void CCHeadsUpDisplayLayerImpl::drawDebugRects(SkCanvas* canvas, CCDebugRectHist ory* debugRectHistory)
232 { 232 {
233 const Vector<CCDebugRect>& debugRects = debugRectHistory->debugRects(); 233 const Vector<CCDebugRect>& debugRects = debugRectHistory->debugRects();
234 234
235 for (size_t i = 0; i < debugRects.size(); ++i) { 235 for (size_t i = 0; i < debugRects.size(); ++i) {
236 SkColor strokeColor = 0; 236 SkColor strokeColor = 0;
237 SkColor fillColor = 0; 237 SkColor fillColor = 0;
238 238
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 canvas->drawRect(skRect, paint); 276 canvas->drawRect(skRect, paint);
277 277
278 paint.setColor(strokeColor); 278 paint.setColor(strokeColor);
279 paint.setStyle(SkPaint::kStroke_Style); 279 paint.setStyle(SkPaint::kStroke_Style);
280 paint.setStrokeWidth(2); 280 paint.setStrokeWidth(2);
281 canvas->drawRect(skRect, paint); 281 canvas->drawRect(skRect, paint);
282 } 282 }
283 } 283 }
284 284
285 } 285 }
OLDNEW
« no previous file with comments | « cc/CCFontAtlas.cpp ('k') | cc/CCIOSurfaceLayerImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698