| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 protected: | 24 protected: |
| 25 enum ShapeType { | 25 enum ShapeType { |
| 26 kShapeTypeCircle, | 26 kShapeTypeCircle, |
| 27 kShapeTypeRoundRect, | 27 kShapeTypeRoundRect, |
| 28 kShapeTypeRect, | 28 kShapeTypeRect, |
| 29 kShapeTypeConvexPath, | 29 kShapeTypeConvexPath, |
| 30 kShapeTypeConcavePath, | 30 kShapeTypeConcavePath, |
| 31 kNumShapeTypes | 31 kNumShapeTypes |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 virtual SkString onShortName() SK_OVERRIDE { | 34 SkString onShortName() SK_OVERRIDE { |
| 35 return SkString("mixed_xfermodes"); | 35 return SkString("mixed_xfermodes"); |
| 36 } | 36 } |
| 37 | 37 |
| 38 virtual SkISize onISize() SK_OVERRIDE { | 38 SkISize onISize() SK_OVERRIDE { |
| 39 return SkISize::Make(790, 640); | 39 return SkISize::Make(790, 640); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void drawShape(SkCanvas* canvas, | 42 void drawShape(SkCanvas* canvas, |
| 43 const SkPaint& paint, | 43 const SkPaint& paint, |
| 44 ShapeType type) { | 44 ShapeType type) { |
| 45 static const SkRect kRect = SkRect::MakeXYWH(SkIntToScalar(-50), SkIntTo
Scalar(-50), | 45 static const SkRect kRect = SkRect::MakeXYWH(SkIntToScalar(-50), SkIntTo
Scalar(-50), |
| 46 SkIntToScalar(75), SkIntToS
calar(105)); | 46 SkIntToScalar(75), SkIntToS
calar(105)); |
| 47 switch (type) { | 47 switch (type) { |
| 48 case kShapeTypeCircle: | 48 case kShapeTypeCircle: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 fConcavePath.setFillType(SkPath::kEvenOdd_FillType); | 80 fConcavePath.setFillType(SkPath::kEvenOdd_FillType); |
| 81 SkASSERT(!fConcavePath.isConvex()); | 81 SkASSERT(!fConcavePath.isConvex()); |
| 82 } | 82 } |
| 83 canvas->drawPath(fConcavePath, paint); | 83 canvas->drawPath(fConcavePath, paint); |
| 84 break; | 84 break; |
| 85 default: | 85 default: |
| 86 break; | 86 break; |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 90 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 91 if (NULL == fBG.get()) { | 91 if (NULL == fBG.get()) { |
| 92 static uint32_t kCheckerPixelData[] = { 0xFFFFFFFF, | 92 static uint32_t kCheckerPixelData[] = { 0xFFFFFFFF, |
| 93 0xFFCCCCCC, | 93 0xFFCCCCCC, |
| 94 0xFFCCCCCC, | 94 0xFFCCCCCC, |
| 95 0xFFFFFFFF }; | 95 0xFFFFFFFF }; |
| 96 SkBitmap bitmap; | 96 SkBitmap bitmap; |
| 97 bitmap.allocN32Pixels(2, 2); | 97 bitmap.allocN32Pixels(2, 2); |
| 98 memcpy(bitmap.getPixels(), kCheckerPixelData, sizeof(kCheckerPixelDa
ta)); | 98 memcpy(bitmap.getPixels(), kCheckerPixelData, sizeof(kCheckerPixelDa
ta)); |
| 99 SkMatrix lm; | 99 SkMatrix lm; |
| 100 lm.setScale(SkIntToScalar(20), SkIntToScalar(20)); | 100 lm.setScale(SkIntToScalar(20), SkIntToScalar(20)); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 SkPath fConvexPath; | 178 SkPath fConvexPath; |
| 179 typedef GM INHERITED; | 179 typedef GM INHERITED; |
| 180 }; | 180 }; |
| 181 | 181 |
| 182 ////////////////////////////////////////////////////////////////////////////// | 182 ////////////////////////////////////////////////////////////////////////////// |
| 183 | 183 |
| 184 static GM* MyFactory(void*) { return new MixedXfermodesGM; } | 184 static GM* MyFactory(void*) { return new MixedXfermodesGM; } |
| 185 static GMRegistry reg(MyFactory); | 185 static GMRegistry reg(MyFactory); |
| 186 | 186 |
| 187 } | 187 } |
| OLD | NEW |