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

Side by Side Diff: skia/ext/benchmarking_canvas.h

Issue 942533002: Refactor BenchmarkingCanvas to avoid internal Skia dependencies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: speculative Win warnings fix Created 5 years, 10 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #ifndef SKIA_EXT_BENCHMARKING_CANVAS_H_ 5 #ifndef SKIA_EXT_BENCHMARKING_CANVAS_H_
6 #define SKIA_EXT_BENCHMARKING_CANVAS_H_ 6 #define SKIA_EXT_BENCHMARKING_CANVAS_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/values.h"
9 #include "skia/ext/refptr.h"
10 #include "third_party/skia/include/utils/SkNWayCanvas.h" 9 #include "third_party/skia/include/utils/SkNWayCanvas.h"
11 #include "third_party/skia/src/utils/debugger/SkDebugCanvas.h"
12 10
13 namespace skia { 11 namespace skia {
14 12
15 class TimingCanvas;
16
17 class SK_API BenchmarkingCanvas : public SkNWayCanvas { 13 class SK_API BenchmarkingCanvas : public SkNWayCanvas {
18 public: 14 public:
19 BenchmarkingCanvas(int width, int height); 15 BenchmarkingCanvas(SkCanvas* canvas);
20 ~BenchmarkingCanvas() override; 16 ~BenchmarkingCanvas() override;
21 17
22 // Returns the number of draw commands executed on this canvas. 18 // Returns the number of draw commands executed on this canvas.
23 size_t CommandCount() const; 19 size_t CommandCount() const;
24 20
25 // Get draw command info for a given index. 21 // Returns the list of executed draw commands.
26 SkDrawCommand* GetCommand(size_t index); 22 const base::ListValue& Commands() const;
27 23
28 // Return the recorded render time (milliseconds) for a draw command index. 24 // Return the recorded render time (milliseconds) for a draw command index.
29 double GetTime(size_t index); 25 double GetTime(size_t index);
30 26
27 protected:
28 // SkCanvas overrides
29 void willSave() override;
30 SaveLayerStrategy willSaveLayer(const SkRect*,
31 const SkPaint*,
32 SaveFlags) override;
33 void willRestore() override;
34
35 void didConcat(const SkMatrix&) override;
36 void didSetMatrix(const SkMatrix&) override;
37
38 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override;
39 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override;
40 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override;
41 void onClipRegion(const SkRegion&, SkRegion::Op) override;
42
43 void onDrawPaint(const SkPaint&) override;
44 void onDrawPoints(PointMode, size_t count, const SkPoint pts[],
45 const SkPaint&) override;
46 void onDrawRect(const SkRect&, const SkPaint&) override;
47 void onDrawOval(const SkRect&, const SkPaint&) override;
48 void onDrawRRect(const SkRRect&, const SkPaint&) override;
49 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
50 void onDrawPath(const SkPath&, const SkPaint&) override;
51
52 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override ;
53
54 void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint* ) override;
55 void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst,
56 const SkPaint*, DrawBitmapRectFlags flags) override;
57 void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
58 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
59 const SkPaint*) override;
60 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& ds t,
61 const SkPaint*) override;
62 void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) override ;
63
64 void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
65 const SkPaint&) override;
66 void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
67 const SkPaint&) override;
68 void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[] ,
69 SkScalar constY, const SkPaint&) override;
70 void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
71 const SkMatrix* matrix, const SkPaint&) override;
72 void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
73 const SkPaint& paint) override;
74
31 private: 75 private:
32 // In order to avoid introducing a Skia version dependency, this 76 typedef SkNWayCanvas INHERITED;
33 // implementation dispatches draw commands in lock-step to two distinct
34 // canvases:
35 // * a SkDebugCanvas used for gathering command info and tracking
36 // the current command index
37 // * a SkiaTimingCanvas used for measuring raster paint times (and relying
38 // on the former for tracking the current command index).
39 //
40 // This way, if the SkCanvas API is extended, we don't need to worry about
41 // updating content::SkiaTimingCanvas to accurately override all new methods
42 // (to avoid timing info indices from getting out of sync), as SkDebugCanvas
43 // already does that for us.
44 77
45 skia::RefPtr<SkDebugCanvas> debug_canvas_; 78 class AutoOp;
46 skia::RefPtr<TimingCanvas> timing_canvas_; 79
80 base::ListValue op_records_;
47 }; 81 };
48 82
49 } 83 }
50 #endif // SKIA_EXT_BENCHMARKING_CANVAS_H 84 #endif // SKIA_EXT_BENCHMARKING_CANVAS_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698