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 27 matching lines...) Expand all Loading... |
38 protected: | 38 protected: |
39 virtual SkString onShortName() { | 39 virtual SkString onShortName() { |
40 return SkString("mixed_xfermodes"); | 40 return SkString("mixed_xfermodes"); |
41 } | 41 } |
42 | 42 |
43 virtual SkISize onISize() { | 43 virtual SkISize onISize() { |
44 return make_isize(790, 640); | 44 return make_isize(790, 640); |
45 } | 45 } |
46 | 46 |
47 virtual void onDraw(SkCanvas* canvas) { | 47 virtual void onDraw(SkCanvas* canvas) { |
48 // FIXME: Currently necessary for GPU to be able to make dst-copy in Sam
pleApp because | |
49 // main layer is not a texture. | |
50 SkPaint layerPaint; | |
51 layerPaint.setXfermodeMode(SkXfermode::kSrc_Mode); | |
52 canvas->saveLayer(NULL, &layerPaint); | |
53 | |
54 SkPaint bgPaint; | 48 SkPaint bgPaint; |
55 bgPaint.setShader(fBG.get()); | 49 bgPaint.setShader(fBG.get()); |
56 canvas->drawPaint(bgPaint); | 50 canvas->drawPaint(bgPaint); |
57 SkISize size = canvas->getDeviceSize(); | 51 SkISize size = canvas->getDeviceSize(); |
58 SkScalar areaSqrt = SkScalarSqrt((SkIntToScalar(size.fWidth * size.fHeig
ht))); | 52 SkScalar areaSqrt = SkScalarSqrt((SkIntToScalar(size.fWidth * size.fHeig
ht))); |
59 SkScalar minR = areaSqrt / 10; | 53 SkScalar minR = areaSqrt / 10; |
60 SkScalar maxR = areaSqrt / 4; | 54 SkScalar maxR = areaSqrt / 4; |
61 SkMWCRandom random; | 55 SkMWCRandom random; |
62 for (int i = 0; i < kNumCircles; ++i) { | 56 for (int i = 0; i < kNumCircles; ++i) { |
63 SkScalar cx = random.nextRangeScalar(0, SkIntToScalar(size.fWidth)); | 57 SkScalar cx = random.nextRangeScalar(0, SkIntToScalar(size.fWidth)); |
(...skipping 15 matching lines...) Expand all Loading... |
79 | 73 |
80 // FIXME: Remove text draw once this GM is finished. | 74 // FIXME: Remove text draw once this GM is finished. |
81 SkPaint txtPaint; | 75 SkPaint txtPaint; |
82 txtPaint.setTextSize(areaSqrt / 20); | 76 txtPaint.setTextSize(areaSqrt / 20); |
83 txtPaint.setAntiAlias(true); | 77 txtPaint.setAntiAlias(true); |
84 static const char kTxt[] = "Work in progres... Do not baseline."; | 78 static const char kTxt[] = "Work in progres... Do not baseline."; |
85 canvas->drawText(kTxt, strlen(kTxt), | 79 canvas->drawText(kTxt, strlen(kTxt), |
86 areaSqrt/50, | 80 areaSqrt/50, |
87 SkIntToScalar(size.fHeight / 2), | 81 SkIntToScalar(size.fHeight / 2), |
88 txtPaint); | 82 txtPaint); |
89 | |
90 canvas->restore(); | |
91 } | 83 } |
92 | 84 |
93 private: | 85 private: |
94 enum { | 86 enum { |
95 kMinR = 10, | 87 kMinR = 10, |
96 kMaxR = 50, | 88 kMaxR = 50, |
97 kNumCircles = 50, | 89 kNumCircles = 50, |
98 }; | 90 }; |
99 SkAutoTUnref<SkShader> fBG; | 91 SkAutoTUnref<SkShader> fBG; |
100 typedef GM INHERITED; | 92 typedef GM INHERITED; |
101 }; | 93 }; |
102 | 94 |
103 ////////////////////////////////////////////////////////////////////////////// | 95 ////////////////////////////////////////////////////////////////////////////// |
104 | 96 |
105 static GM* MyFactory(void*) { return new MixedXfermodesGM; } | 97 static GM* MyFactory(void*) { return new MixedXfermodesGM; } |
106 static GMRegistry reg(MyFactory); | 98 static GMRegistry reg(MyFactory); |
107 | 99 |
108 } | 100 } |
OLD | NEW |