| 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 "gm.h" | 8 #include "gm.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 canvas->translate(160, 0); | 81 canvas->translate(160, 0); |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 typedef skiagm::GM INHERITED; | 86 typedef skiagm::GM INHERITED; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 ////////////////////////////////////////////////////////////////////////////// | 89 ////////////////////////////////////////////////////////////////////////////// |
| 90 |
| 90 static void make_3x3_bitmap(SkBitmap* bitmap) { | 91 static void make_3x3_bitmap(SkBitmap* bitmap) { |
| 92 const int xSize = 3; |
| 93 const int ySize = 3; |
| 91 | 94 |
| 92 static const int gXSize = 3; | 95 const SkColor textureData[xSize][ySize] = { |
| 93 static const int gYSize = 3; | |
| 94 | |
| 95 SkColor textureData[gXSize][gYSize] = { | |
| 96 { SK_ColorRED, SK_ColorWHITE, SK_ColorBLUE }, | 96 { SK_ColorRED, SK_ColorWHITE, SK_ColorBLUE }, |
| 97 { SK_ColorGREEN, SK_ColorBLACK, SK_ColorCYAN }, | 97 { SK_ColorGREEN, SK_ColorBLACK, SK_ColorCYAN }, |
| 98 { SK_ColorYELLOW, SK_ColorGRAY, SK_ColorMAGENTA } | 98 { SK_ColorYELLOW, SK_ColorGRAY, SK_ColorMAGENTA } |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 bitmap->allocN32Pixels(xSize, ySize, true); |
| 102 SkCanvas canvas(*bitmap); |
| 103 SkPaint paint; |
| 101 | 104 |
| 102 bitmap->allocN32Pixels(gXSize, gYSize); | 105 for (int y = 0; y < ySize; y++) { |
| 103 for (int y = 0; y < gYSize; y++) { | 106 for (int x = 0; x < xSize; x++) { |
| 104 for (int x = 0; x < gXSize; x++) { | 107 paint.setColor(textureData[x][y]); |
| 105 *bitmap->getAddr32(x, y) = textureData[x][y]; | 108 canvas.drawIRect(SkIRect::MakeXYWH(x, y, 1, 1), paint); |
| 106 } | 109 } |
| 107 } | 110 } |
| 108 } | 111 } |
| 109 | 112 |
| 110 // This GM attempts to make visible any issues drawBitmapRectToRect may have | 113 // This GM attempts to make visible any issues drawBitmapRectToRect may have |
| 111 // with partial source rects. In this case the eight pixels on the border | 114 // with partial source rects. In this case the eight pixels on the border |
| 112 // should be half the width/height of the central pixel, i.e.: | 115 // should be half the width/height of the central pixel, i.e.: |
| 113 // __|____|__ | 116 // __|____|__ |
| 114 // | | | 117 // | | |
| 115 // __|____|__ | 118 // __|____|__ |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 static skiagm::GMRegistry reg0(MyFactory0); | 288 static skiagm::GMRegistry reg0(MyFactory0); |
| 286 static skiagm::GMRegistry reg1(MyFactory1); | 289 static skiagm::GMRegistry reg1(MyFactory1); |
| 287 | 290 |
| 288 static skiagm::GMRegistry reg2(MyFactory2); | 291 static skiagm::GMRegistry reg2(MyFactory2); |
| 289 | 292 |
| 290 #ifndef SK_BUILD_FOR_ANDROID | 293 #ifndef SK_BUILD_FOR_ANDROID |
| 291 static skiagm::GMRegistry reg3(MyFactory3); | 294 static skiagm::GMRegistry reg3(MyFactory3); |
| 292 static skiagm::GMRegistry reg4(MyFactory4); | 295 static skiagm::GMRegistry reg4(MyFactory4); |
| 293 #endif | 296 #endif |
| 294 | 297 |
| OLD | NEW |