| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  226  |  226  | 
|  227             canvas->drawBitmapRect(fBigBitmap, &iSrcR1, dstR1, &paint); |  227             canvas->drawBitmapRect(fBigBitmap, &iSrcR1, dstR1, &paint); | 
|  228             canvas->drawBitmapRect(fBigBitmap, &iSrcR2, dstR2, &paint); |  228             canvas->drawBitmapRect(fBigBitmap, &iSrcR2, dstR2, &paint); | 
|  229         } |  229         } | 
|  230     } |  230     } | 
|  231  |  231  | 
|  232 private: |  232 private: | 
|  233     typedef skiagm::GM INHERITED; |  233     typedef skiagm::GM INHERITED; | 
|  234 }; |  234 }; | 
|  235  |  235  | 
 |  236 class BitmapRectRounding : public skiagm::GM { | 
 |  237     SkBitmap fBM; | 
 |  238  | 
 |  239 public: | 
 |  240     BitmapRectRounding() {} | 
 |  241  | 
 |  242 protected: | 
 |  243     SkString onShortName() SK_OVERRIDE { | 
 |  244         SkString str; | 
 |  245         str.printf("bitmaprect_rounding"); | 
 |  246         return str; | 
 |  247     } | 
 |  248  | 
 |  249     SkISize onISize() SK_OVERRIDE { | 
 |  250         return SkISize::Make(640, 480); | 
 |  251     } | 
 |  252  | 
 |  253     void onOnceBeforeDraw() SK_OVERRIDE { | 
 |  254         fBM.allocN32Pixels(10, 10); | 
 |  255         fBM.eraseColor(SK_ColorBLUE); | 
 |  256     } | 
 |  257  | 
 |  258     // This choice of coordinates and matrix land the bottom edge of the clip (a
     nd bitmap dst) | 
 |  259     // at exactly 1/2 pixel boundary. However, drawBitmapRect may lose precision
      along the way. | 
 |  260     // If it does, we may see a red-line at the bottom, instead of the bitmap ex
     actly matching | 
 |  261     // the clip (in which case we should see all blue). | 
 |  262     // The correct image should be all blue. | 
 |  263     void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 
 |  264         SkPaint paint; | 
 |  265         paint.setColor(SK_ColorRED); | 
 |  266  | 
 |  267         const SkRect r = SkRect::MakeXYWH(1, 1, 110, 114); | 
 |  268         canvas->scale(0.9f, 0.9f); | 
 |  269  | 
 |  270         // the drawRect shows the same problem as clipRect(r) followed by drawco
     lor(red) | 
 |  271         canvas->drawRect(r, paint); | 
 |  272         canvas->drawBitmapRect(fBM, NULL, r, NULL); | 
 |  273     } | 
 |  274      | 
 |  275 private: | 
 |  276     typedef skiagm::GM INHERITED; | 
 |  277 }; | 
 |  278  | 
|  236 ////////////////////////////////////////////////////////////////////////////// |  279 ////////////////////////////////////////////////////////////////////////////// | 
|  237  |  280  | 
|  238 static skiagm::GM* MyFactory0(void*) { return new DrawBitmapRect2(false); } |  281 static skiagm::GM* MyFactory0(void*) { return new DrawBitmapRect2(false); } | 
|  239 static skiagm::GM* MyFactory1(void*) { return new DrawBitmapRect2(true); } |  282 static skiagm::GM* MyFactory1(void*) { return new DrawBitmapRect2(true); } | 
|  240  |  283  | 
|  241 static skiagm::GM* MyFactory2(void*) { return new DrawBitmapRect3(); } |  284 static skiagm::GM* MyFactory2(void*) { return new DrawBitmapRect3(); } | 
|  242  |  285  | 
|  243 #ifndef SK_BUILD_FOR_ANDROID |  286 #ifndef SK_BUILD_FOR_ANDROID | 
|  244 static skiagm::GM* MyFactory3(void*) { return new DrawBitmapRect4(false); } |  287 static skiagm::GM* MyFactory3(void*) { return new DrawBitmapRect4(false); } | 
|  245 static skiagm::GM* MyFactory4(void*) { return new DrawBitmapRect4(true); } |  288 static skiagm::GM* MyFactory4(void*) { return new DrawBitmapRect4(true); } | 
|  246 #endif |  289 #endif | 
|  247  |  290  | 
|  248 static skiagm::GMRegistry reg0(MyFactory0); |  291 static skiagm::GMRegistry reg0(MyFactory0); | 
|  249 static skiagm::GMRegistry reg1(MyFactory1); |  292 static skiagm::GMRegistry reg1(MyFactory1); | 
|  250  |  293  | 
|  251 static skiagm::GMRegistry reg2(MyFactory2); |  294 static skiagm::GMRegistry reg2(MyFactory2); | 
|  252  |  295  | 
|  253 #ifndef SK_BUILD_FOR_ANDROID |  296 #ifndef SK_BUILD_FOR_ANDROID | 
|  254 static skiagm::GMRegistry reg3(MyFactory3); |  297 static skiagm::GMRegistry reg3(MyFactory3); | 
|  255 static skiagm::GMRegistry reg4(MyFactory4); |  298 static skiagm::GMRegistry reg4(MyFactory4); | 
|  256 #endif |  299 #endif | 
 |  300  | 
 |  301 DEF_GM( return new BitmapRectRounding; ) | 
| OLD | NEW |