| OLD | NEW | 
|---|
| 1 | 1 | 
| 2 /* | 2 /* | 
| 3  * Copyright 2011 Google Inc. | 3  * Copyright 2011 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 "SampleCode.h" | 8 #include "SampleCode.h" | 
| 9 #include "SkView.h" | 9 #include "SkView.h" | 
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 55 } | 55 } | 
| 56 | 56 | 
| 57 static const SkColorType gColorTypes[] = { | 57 static const SkColorType gColorTypes[] = { | 
| 58     kN32_SkColorType, | 58     kN32_SkColorType, | 
| 59     kRGB_565_SkColorType, | 59     kRGB_565_SkColorType, | 
| 60 }; | 60 }; | 
| 61 static const int gWidth = 32; | 61 static const int gWidth = 32; | 
| 62 static const int gHeight = 32; | 62 static const int gHeight = 32; | 
| 63 | 63 | 
| 64 class TilingView : public SampleView { | 64 class TilingView : public SampleView { | 
| 65     SkAutoTUnref<SkPicture> fTextPicture; | 65     SkAutoTUnref<SkPicture>        fTextPicture; | 
| 66     SkBlurDrawLooper        fLooper; | 66     SkAutoTUnref<SkBlurDrawLooper> fLooper; | 
| 67 public: | 67 public: | 
| 68     TilingView() | 68     TilingView() | 
| 69             : fLooper(0x88000000, | 69             : fLooper(SkBlurDrawLooper::Create(0x88000000, | 
| 70                       SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(1)), | 70                                                SkBlurMask::ConvertRadiusToSigma(
     SkIntToScalar(1)), | 
| 71                       SkIntToScalar(2), SkIntToScalar(2)) { | 71                                                SkIntToScalar(2), SkIntToScalar(2
     ))) { | 
| 72         for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) { | 72         for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) { | 
| 73             makebm(&fTexture[i], gColorTypes[i], gWidth, gHeight); | 73             makebm(&fTexture[i], gColorTypes[i], gWidth, gHeight); | 
| 74         } | 74         } | 
| 75     } | 75     } | 
| 76 | 76 | 
| 77     virtual ~TilingView() { | 77     virtual ~TilingView() { | 
| 78     } | 78     } | 
| 79 | 79 | 
| 80     SkBitmap    fTexture[SK_ARRAY_COUNT(gColorTypes)]; | 80     SkBitmap    fTexture[SK_ARRAY_COUNT(gColorTypes)]; | 
| 81 | 81 | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 109             textCanvas = recorder.beginRecording(1000, 1000); | 109             textCanvas = recorder.beginRecording(1000, 1000); | 
| 110         } | 110         } | 
| 111 | 111 | 
| 112         if (NULL != textCanvas) { | 112         if (NULL != textCanvas) { | 
| 113             for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { | 113             for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { | 
| 114                 for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) { | 114                 for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) { | 
| 115                     SkPaint p; | 115                     SkPaint p; | 
| 116                     SkString str; | 116                     SkString str; | 
| 117                     p.setAntiAlias(true); | 117                     p.setAntiAlias(true); | 
| 118                     p.setDither(true); | 118                     p.setDither(true); | 
| 119                     p.setLooper(&fLooper); | 119                     p.setLooper(fLooper); | 
| 120                     str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]); | 120                     str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]); | 
| 121 | 121 | 
| 122                     p.setTextAlign(SkPaint::kCenter_Align); | 122                     p.setTextAlign(SkPaint::kCenter_Align); | 
| 123                     textCanvas->drawText(str.c_str(), str.size(), x + r.width()/
     2, y, p); | 123                     textCanvas->drawText(str.c_str(), str.size(), x + r.width()/
     2, y, p); | 
| 124 | 124 | 
| 125                     x += r.width() * 4 / 3; | 125                     x += r.width() * 4 / 3; | 
| 126                 } | 126                 } | 
| 127             } | 127             } | 
| 128         } | 128         } | 
| 129 | 129 | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 143                         canvas->drawRect(r, paint); | 143                         canvas->drawRect(r, paint); | 
| 144                         canvas->restore(); | 144                         canvas->restore(); | 
| 145 | 145 | 
| 146                         x += r.width() * 4 / 3; | 146                         x += r.width() * 4 / 3; | 
| 147                     } | 147                     } | 
| 148                 } | 148                 } | 
| 149                 if (textCanvas) { | 149                 if (textCanvas) { | 
| 150                     SkPaint p; | 150                     SkPaint p; | 
| 151                     SkString str; | 151                     SkString str; | 
| 152                     p.setAntiAlias(true); | 152                     p.setAntiAlias(true); | 
| 153                     p.setLooper(&fLooper); | 153                     p.setLooper(fLooper); | 
| 154                     str.printf("%s, %s", gConfigNames[i], gFilterNames[j]); | 154                     str.printf("%s, %s", gConfigNames[i], gFilterNames[j]); | 
| 155                     textCanvas->drawText(str.c_str(), str.size(), x, y + r.heigh
     t() * 2 / 3, p); | 155                     textCanvas->drawText(str.c_str(), str.size(), x, y + r.heigh
     t() * 2 / 3, p); | 
| 156                 } | 156                 } | 
| 157 | 157 | 
| 158                 y += r.height() * 4 / 3; | 158                 y += r.height() * 4 / 3; | 
| 159             } | 159             } | 
| 160         } | 160         } | 
| 161 | 161 | 
| 162         fTextPicture.reset(recorder.endRecording()); | 162         fTextPicture.reset(recorder.endRecording()); | 
| 163 | 163 | 
| 164         canvas->drawPicture(*fTextPicture); | 164         canvas->drawPicture(*fTextPicture); | 
| 165     } | 165     } | 
| 166 | 166 | 
| 167 private: | 167 private: | 
| 168     typedef SampleView INHERITED; | 168     typedef SampleView INHERITED; | 
| 169 }; | 169 }; | 
| 170 | 170 | 
| 171 ////////////////////////////////////////////////////////////////////////////// | 171 ////////////////////////////////////////////////////////////////////////////// | 
| 172 | 172 | 
| 173 static SkView* MyFactory() { return new TilingView; } | 173 static SkView* MyFactory() { return new TilingView; } | 
| 174 static SkViewRegister reg(MyFactory); | 174 static SkViewRegister reg(MyFactory); | 
| OLD | NEW | 
|---|