OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // ultimately thye iwll be flushed in the order first, third, and then secon
d | 51 // ultimately thye iwll be flushed in the order first, third, and then secon
d |
52 void onDraw(SkCanvas* canvas) override { | 52 void onDraw(SkCanvas* canvas) override { |
53 canvas->drawColor(sk_tool_utils::color_to_565(SK_ColorGRAY)); | 53 canvas->drawColor(sk_tool_utils::color_to_565(SK_ColorGRAY)); |
54 | 54 |
55 SkPaint paint; | 55 SkPaint paint; |
56 canvas->translate(10, 40); | 56 canvas->translate(10, 40); |
57 | 57 |
58 SkRect bounds = fBlob->bounds(); | 58 SkRect bounds = fBlob->bounds(); |
59 const int yDelta = SkScalarFloorToInt(bounds.height()) + 20; | 59 const int yDelta = SkScalarFloorToInt(bounds.height()) + 20; |
60 const int xDelta = SkScalarFloorToInt(bounds.width()); | 60 const int xDelta = SkScalarFloorToInt(bounds.width()); |
61 | 61 |
62 canvas->drawTextBlob(fBlob, 0, 0, paint); | 62 canvas->drawTextBlob(fBlob, 0, 0, paint); |
63 | 63 |
64 canvas->translate(SkIntToScalar(xDelta), SkIntToScalar(yDelta)); | 64 canvas->translate(SkIntToScalar(xDelta), SkIntToScalar(yDelta)); |
65 | 65 |
66 // draw a rect where the text should be, and then twiddle the xfermode | 66 // draw a rect where the text should be, and then twiddle the xfermode |
67 // so we don't batch | 67 // so we don't batch |
68 SkPaint redPaint; | 68 SkPaint redPaint; |
69 redPaint.setColor(SK_ColorRED); | 69 redPaint.setColor(SK_ColorRED); |
70 canvas->drawRect(bounds, redPaint); | 70 canvas->drawRect(bounds, redPaint); |
71 SkPaint srcInPaint(paint); | 71 SkPaint srcInPaint(paint); |
72 srcInPaint.setXfermodeMode(SkXfermode::kSrcIn_Mode); | 72 srcInPaint.setXfermodeMode(SkXfermode::kSrcIn_Mode); |
73 canvas->drawTextBlob(fBlob, 0, 0, srcInPaint); | 73 canvas->drawTextBlob(fBlob, 0, 0, srcInPaint); |
74 | 74 |
75 canvas->translate(SkIntToScalar(xDelta), SkIntToScalar(yDelta)); | 75 canvas->translate(SkIntToScalar(xDelta), SkIntToScalar(yDelta)); |
76 canvas->drawTextBlob(fBlob, 0, 0, paint); | 76 canvas->drawTextBlob(fBlob, 0, 0, paint); |
77 } | 77 } |
78 | 78 |
79 private: | 79 private: |
80 SkAutoTUnref<const SkTextBlob> fBlob; | 80 SkAutoTUnref<const SkTextBlob> fBlob; |
81 | 81 |
82 static const int kWidth = 275; | 82 static const int kWidth = 275; |
83 static const int kHeight = 200; | 83 static const int kHeight = 200; |
84 | 84 |
85 typedef GM INHERITED; | 85 typedef GM INHERITED; |
86 }; | 86 }; |
87 | 87 |
88 ////////////////////////////////////////////////////////////////////////////// | 88 ////////////////////////////////////////////////////////////////////////////// |
89 | 89 |
90 DEF_GM(return new TextBlobBlockReordering;) | 90 DEF_GM(return new TextBlobBlockReordering;) |
91 } | 91 } |
OLD | NEW |