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

Side by Side Diff: third_party/WebKit/Source/web/tests/sim/SimCanvas.cpp

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 4 years 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "web/tests/sim/SimCanvas.h" 5 #include "web/tests/sim/SimCanvas.h"
6 6
7 #include "skia/ext/cdl_paint.h"
7 #include "third_party/skia/include/core/SkPaint.h" 8 #include "third_party/skia/include/core/SkPaint.h"
8 #include "third_party/skia/include/core/SkPath.h" 9 #include "third_party/skia/include/core/SkPath.h"
9 #include "third_party/skia/include/core/SkRRect.h" 10 #include "third_party/skia/include/core/SkRRect.h"
10 #include "third_party/skia/include/core/SkRect.h" 11 #include "third_party/skia/include/core/SkRect.h"
11 12
12 namespace blink { 13 namespace blink {
13 14
14 static int s_depth = 0; 15 static int s_depth = 0;
15 16
16 class DrawScope { 17 class DrawScope {
17 public: 18 public:
18 DrawScope() { ++s_depth; } 19 DrawScope() { ++s_depth; }
19 ~DrawScope() { --s_depth; } 20 ~DrawScope() { --s_depth; }
20 }; 21 };
21 22
22 SimCanvas::SimCanvas(int width, int height) : SkCanvas(width, height) {} 23 SimCanvas::SimCanvas(int width, int height) : CdlCanvas(width, height) {}
23 24
24 void SimCanvas::addCommand(CommandType type, RGBA32 color) { 25 void SimCanvas::addCommand(CommandType type, RGBA32 color) {
25 if (s_depth > 1) 26 if (s_depth > 1)
26 return; 27 return;
27 Command command = {type, color}; 28 Command command = {type, color};
28 m_commands.append(command); 29 m_commands.append(command);
29 } 30 }
30 31
31 void SimCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) { 32 void SimCanvas::onDrawRect(const SkRect& rect, const CdlPaint& paint) {
32 DrawScope scope; 33 DrawScope scope;
33 addCommand(CommandType::Rect, paint.getColor()); 34 addCommand(CommandType::Rect, paint.getColor());
34 SkCanvas::onDrawRect(rect, paint); 35 CdlCanvas::onDrawRect(rect, paint);
35 } 36 }
36 37
37 void SimCanvas::onDrawOval(const SkRect& oval, const SkPaint& paint) { 38 void SimCanvas::onDrawOval(const SkRect& oval, const CdlPaint& paint) {
38 DrawScope scope; 39 DrawScope scope;
39 addCommand(CommandType::Shape, paint.getColor()); 40 addCommand(CommandType::Shape, paint.getColor());
40 SkCanvas::onDrawOval(oval, paint); 41 CdlCanvas::onDrawOval(oval, paint);
41 } 42 }
42 43
43 void SimCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) { 44 void SimCanvas::onDrawRRect(const SkRRect& rrect, const CdlPaint& paint) {
44 DrawScope scope; 45 DrawScope scope;
45 addCommand(CommandType::Shape, paint.getColor()); 46 addCommand(CommandType::Shape, paint.getColor());
46 SkCanvas::onDrawRRect(rrect, paint); 47 CdlCanvas::onDrawRRect(rrect, paint);
47 } 48 }
48 49
49 void SimCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) { 50 void SimCanvas::onDrawPath(const SkPath& path, const CdlPaint& paint) {
50 DrawScope scope; 51 DrawScope scope;
51 addCommand(CommandType::Shape, paint.getColor()); 52 addCommand(CommandType::Shape, paint.getColor());
52 SkCanvas::onDrawPath(path, paint); 53 CdlCanvas::onDrawPath(path, paint);
53 } 54 }
54 55
55 void SimCanvas::onDrawImage(const SkImage* image, 56 void SimCanvas::onDrawImage(const SkImage* image,
56 SkScalar left, 57 SkScalar left,
57 SkScalar top, 58 SkScalar top,
58 const SkPaint* paint) { 59 const CdlPaint* paint) {
59 DrawScope scope; 60 DrawScope scope;
60 addCommand(CommandType::Image); 61 addCommand(CommandType::Image);
61 SkCanvas::onDrawImage(image, left, top, paint); 62 CdlCanvas::onDrawImage(image, left, top, paint);
62 } 63 }
63 64
64 void SimCanvas::onDrawImageRect(const SkImage* image, 65 void SimCanvas::onDrawImageRect(const SkImage* image,
65 const SkRect* src, 66 const SkRect* src,
66 const SkRect& dst, 67 const SkRect& dst,
67 const SkPaint* paint, 68 const CdlPaint* paint,
68 SrcRectConstraint constraint) { 69 SkCanvas::SrcRectConstraint constraint) {
69 DrawScope scope; 70 DrawScope scope;
70 addCommand(CommandType::Image); 71 addCommand(CommandType::Image);
71 SkCanvas::onDrawImageRect(image, src, dst, paint, constraint); 72 CdlCanvas::onDrawImageRect(image, src, dst, paint, constraint);
72 } 73 }
73 74
74 void SimCanvas::onDrawText(const void* text, 75 void SimCanvas::onDrawText(const void* text,
75 size_t byteLength, 76 size_t byteLength,
76 SkScalar x, 77 SkScalar x,
77 SkScalar y, 78 SkScalar y,
78 const SkPaint& paint) { 79 const CdlPaint& paint) {
79 DrawScope scope; 80 DrawScope scope;
80 addCommand(CommandType::Text, paint.getColor()); 81 addCommand(CommandType::Text, paint.getColor());
81 SkCanvas::onDrawText(text, byteLength, x, y, paint); 82 CdlCanvas::onDrawText(text, byteLength, x, y, paint);
82 } 83 }
83 84
84 void SimCanvas::onDrawPosText(const void* text, 85 void SimCanvas::onDrawPosText(const void* text,
85 size_t byteLength, 86 size_t byteLength,
86 const SkPoint pos[], 87 const SkPoint pos[],
87 const SkPaint& paint) { 88 const CdlPaint& paint) {
88 DrawScope scope; 89 DrawScope scope;
89 addCommand(CommandType::Text, paint.getColor()); 90 addCommand(CommandType::Text, paint.getColor());
90 SkCanvas::onDrawPosText(text, byteLength, pos, paint); 91 CdlCanvas::onDrawPosText(text, byteLength, pos, paint);
91 } 92 }
92 93
94 /*
93 void SimCanvas::onDrawPosTextH(const void* text, 95 void SimCanvas::onDrawPosTextH(const void* text,
94 size_t byteLength, 96 size_t byteLength,
95 const SkScalar xpos[], 97 const SkScalar xpos[],
96 SkScalar constY, 98 SkScalar constY,
97 const SkPaint& paint) { 99 const CdlPaint& paint) {
98 DrawScope scope; 100 DrawScope scope;
99 addCommand(CommandType::Text, paint.getColor()); 101 addCommand(CommandType::Text, paint.getColor());
100 SkCanvas::onDrawPosTextH(text, byteLength, xpos, constY, paint); 102 CdlCanvas::onDrawPosTextH(text, byteLength, xpos, constY, paint);
101 } 103 }
102 104
103 void SimCanvas::onDrawTextOnPath(const void* text, 105 void SimCanvas::onDrawTextOnPath(const void* text,
104 size_t byteLength, 106 size_t byteLength,
105 const SkPath& path, 107 const SkPath& path,
106 const SkMatrix* matrix, 108 const SkMatrix* matrix,
107 const SkPaint& paint) { 109 const CdlPaint& paint) {
108 DrawScope scope; 110 DrawScope scope;
109 addCommand(CommandType::Text, paint.getColor()); 111 addCommand(CommandType::Text, paint.getColor());
110 SkCanvas::onDrawTextOnPath(text, byteLength, path, matrix, paint); 112 CdlCanvas::onDrawTextOnPath(text, byteLength, path, matrix, paint);
111 } 113 }
114 */
112 115
113 void SimCanvas::onDrawTextBlob(const SkTextBlob* blob, 116 void SimCanvas::onDrawTextBlob(const SkTextBlob* blob,
114 SkScalar x, 117 SkScalar x,
115 SkScalar y, 118 SkScalar y,
116 const SkPaint& paint) { 119 const CdlPaint& paint) {
117 DrawScope scope; 120 DrawScope scope;
118 addCommand(CommandType::Text, paint.getColor()); 121 addCommand(CommandType::Text, paint.getColor());
119 SkCanvas::onDrawTextBlob(blob, x, y, paint); 122 CdlCanvas::onDrawTextBlob(blob, x, y, paint);
120 } 123 }
121 124
122 } // namespace blink 125 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/sim/SimCanvas.h ('k') | third_party/WebKit/Source/web/tests/sim/SimDisplayItemList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698