OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkPath.h" | 10 #include "SkPath.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 makePaint(&fOpPaint[kIntersect_PathOp], blendColor); | 29 makePaint(&fOpPaint[kIntersect_PathOp], blendColor); |
30 makePaint(&fOpPaint[kUnion_PathOp], 0xFFc0FFc0); | 30 makePaint(&fOpPaint[kUnion_PathOp], 0xFFc0FFc0); |
31 makePaint(&fOpPaint[kReverseDifference_PathOp], twoColor); | 31 makePaint(&fOpPaint[kReverseDifference_PathOp], twoColor); |
32 makePaint(&fOpPaint[kXOR_PathOp], 0xFFa0FFe0); | 32 makePaint(&fOpPaint[kXOR_PathOp], 0xFFa0FFe0); |
33 makePaint(&fOutlinePaint, 0xFF000000); | 33 makePaint(&fOutlinePaint, 0xFF000000); |
34 fOutlinePaint.setStyle(SkPaint::kStroke_Style); | 34 fOutlinePaint.setStyle(SkPaint::kStroke_Style); |
35 } | 35 } |
36 | 36 |
37 SkColor blend(SkColor one, SkColor two) { | 37 SkColor blend(SkColor one, SkColor two) { |
38 SkBitmap temp; | 38 SkBitmap temp; |
39 temp.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); | 39 temp.allocN32Pixels(1, 1); |
40 temp.allocPixels(); | |
41 SkCanvas canvas(temp); | 40 SkCanvas canvas(temp); |
42 canvas.drawColor(one); | 41 canvas.drawColor(one); |
43 canvas.drawColor(two); | 42 canvas.drawColor(two); |
44 void* pixels = temp.getPixels(); | 43 void* pixels = temp.getPixels(); |
45 return *(SkColor*) pixels; | 44 return *(SkColor*) pixels; |
46 } | 45 } |
47 | 46 |
48 void makePaint(SkPaint* paint, SkColor color) { | 47 void makePaint(SkPaint* paint, SkColor color) { |
49 paint->setAntiAlias(true); | 48 paint->setAntiAlias(true); |
50 paint->setStyle(SkPaint::kFill_Style); | 49 paint->setStyle(SkPaint::kFill_Style); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 SkPaint fOpPaint[kReverseDifference_PathOp - kDifference_PathOp + 1]; | 105 SkPaint fOpPaint[kReverseDifference_PathOp - kDifference_PathOp + 1]; |
107 typedef GM INHERITED; | 106 typedef GM INHERITED; |
108 }; | 107 }; |
109 | 108 |
110 ////////////////////////////////////////////////////////////////////////////// | 109 ////////////////////////////////////////////////////////////////////////////// |
111 | 110 |
112 static GM* MyFactory(void*) { return new PathOpsInverseGM; } | 111 static GM* MyFactory(void*) { return new PathOpsInverseGM; } |
113 static GMRegistry reg(MyFactory); | 112 static GMRegistry reg(MyFactory); |
114 | 113 |
115 } | 114 } |
OLD | NEW |