| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 | 9 |
| 10 #include "SkColorFilter.h" | 10 #include "SkColorFilter.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 // Create a hexagon with its center at the origin | 92 // Create a hexagon with its center at the origin |
| 93 SkPath hex = make_hex_path(0, 0); | 93 SkPath hex = make_hex_path(0, 0); |
| 94 | 94 |
| 95 SkPaint whiteFill; | 95 SkPaint whiteFill; |
| 96 whiteFill.setStyle(SkPaint::kFill_Style); | 96 whiteFill.setStyle(SkPaint::kFill_Style); |
| 97 whiteFill.setColor(SK_ColorWHITE); | 97 whiteFill.setColor(SK_ColorWHITE); |
| 98 | 98 |
| 99 SkPaint greyFill; | 99 SkPaint greyFill; |
| 100 greyFill.setStyle(SkPaint::kFill_Style); | 100 greyFill.setStyle(SkPaint::kFill_Style); |
| 101 greyFill.setColor(SK_ColorLTGRAY); | 101 greyFill.setColor(sk_tool_utils::color_to_565(SK_ColorLTGRAY)); |
| 102 | 102 |
| 103 SkPaint stroke; | 103 SkPaint stroke; |
| 104 stroke.setStyle(SkPaint::kStroke_Style); | 104 stroke.setStyle(SkPaint::kStroke_Style); |
| 105 stroke.setStrokeWidth(3); | 105 stroke.setStrokeWidth(3); |
| 106 | 106 |
| 107 SkPictureRecorder recorder; | 107 SkPictureRecorder recorder; |
| 108 SkRTreeFactory bbhFactory; | 108 SkRTreeFactory bbhFactory; |
| 109 | 109 |
| 110 static const SkScalar kBig = 10000.0f; | 110 static const SkScalar kBig = 10000.0f; |
| 111 SkCanvas* canvas = recorder.beginRecording(kBig, kBig, &bbhFactory, | 111 SkCanvas* canvas = recorder.beginRecording(kBig, kBig, &bbhFactory, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 tri.rLineTo(-kTriSide, 0); | 147 tri.rLineTo(-kTriSide, 0); |
| 148 tri.close(); | 148 tri.close(); |
| 149 return tri; | 149 return tri; |
| 150 } | 150 } |
| 151 | 151 |
| 152 static const SkPicture* make_tri_picture() { | 152 static const SkPicture* make_tri_picture() { |
| 153 SkPath tri = make_tri_path(SkScalarHalf(kTriSide), 0); | 153 SkPath tri = make_tri_path(SkScalarHalf(kTriSide), 0); |
| 154 | 154 |
| 155 SkPaint fill; | 155 SkPaint fill; |
| 156 fill.setStyle(SkPaint::kFill_Style); | 156 fill.setStyle(SkPaint::kFill_Style); |
| 157 fill.setColor(SK_ColorLTGRAY); | 157 fill.setColor(sk_tool_utils::color_to_565(SK_ColorLTGRAY)); |
| 158 | 158 |
| 159 SkPaint stroke; | 159 SkPaint stroke; |
| 160 stroke.setStyle(SkPaint::kStroke_Style); | 160 stroke.setStyle(SkPaint::kStroke_Style); |
| 161 stroke.setStrokeWidth(3); | 161 stroke.setStrokeWidth(3); |
| 162 | 162 |
| 163 SkPictureRecorder recorder; | 163 SkPictureRecorder recorder; |
| 164 SkRTreeFactory bbhFactory; | 164 SkRTreeFactory bbhFactory; |
| 165 | 165 |
| 166 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kPicWidth), | 166 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kPicWidth), |
| 167 SkIntToScalar(kPicHeight), | 167 SkIntToScalar(kPicHeight), |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 } | 481 } |
| 482 } | 482 } |
| 483 | 483 |
| 484 protected: | 484 protected: |
| 485 Content fContent; | 485 Content fContent; |
| 486 Layout fLayout; | 486 Layout fLayout; |
| 487 const SkPicture* fPictures[kNumPictures]; | 487 const SkPicture* fPictures[kNumPictures]; |
| 488 | 488 |
| 489 void onOnceBeforeDraw() override { | 489 void onOnceBeforeDraw() override { |
| 490 fPictures[0] = make_hex_plane_picture(SK_ColorWHITE); | 490 fPictures[0] = make_hex_plane_picture(SK_ColorWHITE); |
| 491 fPictures[1] = make_hex_plane_picture(SK_ColorGRAY); | 491 fPictures[1] = make_hex_plane_picture(sk_tool_utils::color_to_565(SK
_ColorGRAY)); |
| 492 fPictures[2] = make_sierpinski_picture(); | 492 fPictures[2] = make_sierpinski_picture(); |
| 493 fPictures[3] = make_single_layer_hex_plane_picture(); | 493 fPictures[3] = make_single_layer_hex_plane_picture(); |
| 494 } | 494 } |
| 495 | 495 |
| 496 void onDraw(SkCanvas* canvas) override { | 496 void onDraw(SkCanvas* canvas) override { |
| 497 SkMultiPictureDraw mpd; | 497 SkMultiPictureDraw mpd; |
| 498 SkTArray<ComposeStep> composeSteps; | 498 SkTArray<ComposeStep> composeSteps; |
| 499 | 499 |
| 500 // Fill up the MultiPictureDraw | 500 // Fill up the MultiPictureDraw |
| 501 (*gLayoutMthds[fLayout])(canvas, &mpd, | 501 (*gLayoutMthds[fLayout])(canvas, &mpd, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 MultiPictureDraw::kTiled_Layout)
);) | 563 MultiPictureDraw::kTiled_Layout)
);) |
| 564 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kPathClipMulti
_Content, | 564 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kPathClipMulti
_Content, |
| 565 MultiPictureDraw::kTiled_Layout)
);) | 565 MultiPictureDraw::kTiled_Layout)
);) |
| 566 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kInvPathClipMu
lti_Content, | 566 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kInvPathClipMu
lti_Content, |
| 567 MultiPictureDraw::kTiled_Layout)
);) | 567 MultiPictureDraw::kTiled_Layout)
);) |
| 568 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kSierpinski_Co
ntent, | 568 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kSierpinski_Co
ntent, |
| 569 MultiPictureDraw::kTiled_Layout)
);) | 569 MultiPictureDraw::kTiled_Layout)
);) |
| 570 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kBigLayer_Cont
ent, | 570 DEF_GM(return SkNEW_ARGS(MultiPictureDraw, (MultiPictureDraw::kBigLayer_Cont
ent, |
| 571 MultiPictureDraw::kTiled_Layout)
);) | 571 MultiPictureDraw::kTiled_Layout)
);) |
| 572 } | 572 } |
| OLD | NEW |