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

Side by Side Diff: experimental/PdfViewer/SkTrackDevice.h

Issue 1266093003: Remove experimental/PdfViewer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-03 (Monday) 10:43:56 EDT Created 5 years, 4 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 | « experimental/PdfViewer/SkPdfUtils.cpp ('k') | experimental/PdfViewer/SkTrackDevice.cpp » ('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 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkTrackDevice_DEFINED
9 #define SkTrackDevice_DEFINED
10
11 #include "SkBitmapDevice.h"
12 #include "SkTracker.h"
13
14 /** \class SkTrackDevice
15 *
16 * A Track Device is used to track the callstack of an operation that affected some pixels.
17 * It can be used with SampleApp to investigate bugs (CL not checked in yet).
18 *
19 * every drawFoo is implemented as such:
20 * before(); // - collects state of interesting pixels
21 * INHERITED::drawFoo(...);
22 * after(); // - checks if pixels of interest, and issue a breakpoint.
23 *
24 */
25 // TODO: can this be derived from SkBaseDevice instead?
26 class SkTrackDevice : public SkBitmapDevice {
27 public:
28 SkTrackDevice(const SkBitmap& bitmap)
29 : INHERITED(bitmap, SkSurfaceProps(0, kUnknown_SkPixelGeometry))
30 , fTracker(NULL) {
31 }
32
33 virtual ~SkTrackDevice() {}
34
35 // Install a tracker - we can reuse the tracker between multiple devices, an d the state of the
36 // tracker is preserved - number and location of poinbts, ...
37 void installTracker(SkTracker* tracker) {
38 fTracker = tracker;
39 fTracker->newFrame();
40 }
41
42 protected:
43 #if 0 // clear is deprecated (and private)
44 virtual void clear(SkColor color) {
45 before();
46 INHERITED::clear(color);
47 after();
48 }
49 #endif
50
51 void drawPaint(const SkDraw& dummy1, const SkPaint& paint) override {
52 before();
53 INHERITED::drawPaint(dummy1, paint);
54 after();
55 }
56
57 void drawPoints(const SkDraw& dummy1, SkCanvas::PointMode mode, size_t count ,
58 const SkPoint dummy2[], const SkPaint& paint) override {
59 before();
60 INHERITED::drawPoints(dummy1, mode, count, dummy2, paint);
61 after();
62 }
63
64 void drawRect(const SkDraw& dummy1, const SkRect& r, const SkPaint& paint) o verride {
65 before();
66 INHERITED::drawRect(dummy1, r, paint);
67 after();
68 }
69
70
71 void drawOval(const SkDraw& dummy1, const SkRect& oval, const SkPaint& paint ) override {
72 before();
73 INHERITED::drawOval(dummy1, oval, paint);
74 after();
75 }
76
77 void drawRRect(const SkDraw& dummy1, const SkRRect& rr, const SkPaint& paint ) override {
78 before();
79 INHERITED::drawRRect(dummy1, rr, paint);
80 after();
81 }
82
83 void drawPath(const SkDraw& dummy1, const SkPath& path,
84 const SkPaint& paint,
85 const SkMatrix* prePathMatrix = NULL,
86 bool pathIsMutable = false) override {
87 before();
88 INHERITED::drawPath(dummy1, path, paint, prePathMatrix, pathIsMutable);
89 after();
90 }
91
92 void drawBitmap(const SkDraw& dummy1, const SkBitmap& bitmap,
93 const SkMatrix& matrix, const SkPaint& paint) override {
94 before();
95 INHERITED::drawBitmap(dummy1, bitmap, matrix, paint);
96 after();
97 }
98
99 void drawSprite(const SkDraw& dummy1, const SkBitmap& bitmap,
100 int x, int y, const SkPaint& paint) override {
101 before();
102 INHERITED::drawSprite(dummy1, bitmap, x, y, paint);
103 after();
104 }
105
106 void drawBitmapRect(const SkDraw& dummy1, const SkBitmap& dummy2,
107 const SkRect* srcOrNull, const SkRect& dst,
108 const SkPaint& paint,
109 SK_VIRTUAL_CONSTRAINT_TYPE flags) override {
110 before();
111 INHERITED::drawBitmapRect(dummy1, dummy2, srcOrNull, dst, paint, flags);
112 after();
113 }
114
115 void drawText(const SkDraw& dummy1, const void* text, size_t len,
116 SkScalar x, SkScalar y, const SkPaint& paint) override {
117 before();
118 INHERITED::drawText(dummy1, text, len, x, y, paint);
119 after();
120 }
121
122 void drawPosText(const SkDraw& dummy1, const void* text, size_t len,
123 const SkScalar pos[], int scalarsPerPos,
124 const SkPoint& offset, const SkPaint& paint) override {
125 before();
126 INHERITED::drawPosText(dummy1, text, len, pos, scalarsPerPos, offset, pa int);
127 after();
128 }
129
130 void drawTextOnPath(const SkDraw& dummy1, const void* text, size_t len,
131 const SkPath& path, const SkMatrix* matrix,
132 const SkPaint& paint) override {
133 before();
134 INHERITED::drawTextOnPath(dummy1, text, len, path, matrix, paint);
135 after();
136 }
137
138 void drawVertices(const SkDraw& dummy1, SkCanvas::VertexMode dummy2, int ver texCount,
139 const SkPoint verts[], const SkPoint texs[],
140 const SkColor colors[], SkXfermode* xmode,
141 const uint16_t indices[], int indexCount,
142 const SkPaint& paint) override {
143 before();
144 INHERITED::drawVertices(dummy1, dummy2, vertexCount,verts, texs,colors, xmode, indices,
145 indexCount, paint);
146 after();
147 }
148
149 void drawDevice(const SkDraw& dummy1, SkBaseDevice* dummy2, int x, int y,
150 const SkPaint& dummy3) override {
151 before();
152 INHERITED::drawDevice(dummy1, dummy2, x, y, dummy3);
153 after();
154 }
155
156 private:
157 void before() {
158 if (fTracker) {
159 fTracker->before(accessBitmap(false));
160 }
161 }
162
163 // any/all of the expected touched has to be changed, and all expected untou ched must be intact
164 void after() {
165 if (fTracker) {
166 fTracker->after(accessBitmap(false));
167 }
168 }
169
170 private:
171 SkTracker* fTracker;
172
173 typedef SkBitmapDevice INHERITED;
174 };
175
176 #endif // SkTrackDevice_DEFINED
OLDNEW
« no previous file with comments | « experimental/PdfViewer/SkPdfUtils.cpp ('k') | experimental/PdfViewer/SkTrackDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698