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

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

Issue 988693005: Chromium roll (https://codereview.chromium.org/976353002) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fixed bad android build patch Created 5 years, 9 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
« no previous file with comments | « skia/config/SkUserConfig.h ('k') | skia/ext/benchmarking_canvas.cc » ('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 (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, unsigned flags = 0);
20 ~BenchmarkingCanvas() override; 16 ~BenchmarkingCanvas() override;
21 17
18 enum Flags {
19 // TODO(fmalita): add overdraw visualization support
20 // (http://crbug.com/461534)
21 kOverdrawVisualization_Flag = 0x01,
22 };
23
22 // Returns the number of draw commands executed on this canvas. 24 // Returns the number of draw commands executed on this canvas.
23 size_t CommandCount() const; 25 size_t CommandCount() const;
24 26
25 // Get draw command info for a given index. 27 // Returns the list of executed draw commands.
26 SkDrawCommand* GetCommand(size_t index); 28 const base::ListValue& Commands() const;
27 29
28 // Return the recorded render time (milliseconds) for a draw command index. 30 // Return the recorded render time (milliseconds) for a draw command index.
29 double GetTime(size_t index); 31 double GetTime(size_t index);
30 32
33 protected:
34 // SkCanvas overrides
35 void willSave() override;
36 SaveLayerStrategy willSaveLayer(const SkRect*,
37 const SkPaint*,
38 SaveFlags) override;
39 void willRestore() override;
40
41 void didConcat(const SkMatrix&) override;
42 void didSetMatrix(const SkMatrix&) override;
43
44 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override;
45 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override;
46 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override;
47 void onClipRegion(const SkRegion&, SkRegion::Op) override;
48
49 void onDrawPaint(const SkPaint&) override;
50 void onDrawPoints(PointMode, size_t count, const SkPoint pts[],
51 const SkPaint&) override;
52 void onDrawRect(const SkRect&, const SkPaint&) override;
53 void onDrawOval(const SkRect&, const SkPaint&) override;
54 void onDrawRRect(const SkRRect&, const SkPaint&) override;
55 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
56 void onDrawPath(const SkPath&, const SkPaint&) override;
57
58 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override ;
59
60 void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint* ) override;
61 void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst,
62 const SkPaint*, DrawBitmapRectFlags flags) override;
63 void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
64 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
65 const SkPaint*) override;
66 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& ds t,
67 const SkPaint*) override;
68 void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) override ;
69
70 void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
71 const SkPaint&) override;
72 void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
73 const SkPaint&) override;
74 void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[] ,
75 SkScalar constY, const SkPaint&) override;
76 void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
77 const SkMatrix* matrix, const SkPaint&) override;
78 void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
79 const SkPaint& paint) override;
80
31 private: 81 private:
32 // In order to avoid introducing a Skia version dependency, this 82 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 83
45 skia::RefPtr<SkDebugCanvas> debug_canvas_; 84 class AutoOp;
46 skia::RefPtr<TimingCanvas> timing_canvas_; 85
86 base::ListValue op_records_;
87 unsigned flags_;
47 }; 88 };
48 89
49 } 90 }
50 #endif // SKIA_EXT_BENCHMARKING_CANVAS_H 91 #endif // SKIA_EXT_BENCHMARKING_CANVAS_H
OLDNEW
« no previous file with comments | « skia/config/SkUserConfig.h ('k') | skia/ext/benchmarking_canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698