| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 | 10 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 SkRect src = SkRect::MakeXYWH(1, 1, | 110 SkRect src = SkRect::MakeXYWH(1, 1, |
| 111 kSmallTextureSize-2, | 111 kSmallTextureSize-2, |
| 112 kSmallTextureSize-2); | 112 kSmallTextureSize-2); |
| 113 SkRect dst = SkRect::MakeXYWH(10, 10, 100, 100); | 113 SkRect dst = SkRect::MakeXYWH(10, 10, 100, 100); |
| 114 | 114 |
| 115 // first draw without bleeding | 115 // first draw without bleeding |
| 116 canvas->drawBitmapRectToRect(fBitmapSmall, &src, dst, &paint); | 116 canvas->drawBitmapRectToRect(fBitmapSmall, &src, dst, &paint); |
| 117 | 117 |
| 118 // then draw with bleeding | 118 // then draw with bleeding |
| 119 dst = SkRect::MakeXYWH(120, 10, 100, 100); | 119 dst = SkRect::MakeXYWH(120, 10, 100, 100); |
| 120 canvas->drawBitmapRectToRect(fBitmapSmall, &src, dst, &paint); | 120 canvas->drawBitmapRectToRect(fBitmapSmall, &src, dst, &paint, |
| 121 SkCanvas::kBleed_DrawBitmapRectFlag); |
| 121 | 122 |
| 122 // Next test out the GPU's tiling of large textures | 123 // Next test out the GPU's tiling of large textures |
| 123 | 124 |
| 124 // first draw almost the whole thing | 125 // first draw almost the whole thing |
| 125 src = SkRect::MakeXYWH(1, 1, | 126 src = SkRect::MakeXYWH(1, 1, |
| 126 SkIntToScalar(fBitmapBig.width()-2), | 127 SkIntToScalar(fBitmapBig.width()-2), |
| 127 SkIntToScalar(fBitmapBig.height()-2)); | 128 SkIntToScalar(fBitmapBig.height()-2)); |
| 128 dst = SkRect::MakeXYWH(10, 120, 100, 100); | 129 dst = SkRect::MakeXYWH(10, 120, 100, 100); |
| 129 | 130 |
| 130 // first without bleeding | 131 // first without bleeding |
| 131 canvas->drawBitmapRectToRect(fBitmapBig, &src, dst, &paint); | 132 canvas->drawBitmapRectToRect(fBitmapBig, &src, dst, &paint); |
| 132 | 133 |
| 133 // then with bleeding | 134 // then with bleeding |
| 134 dst = SkRect::MakeXYWH(120, 120, 100, 100); | 135 dst = SkRect::MakeXYWH(120, 120, 100, 100); |
| 135 canvas->drawBitmapRectToRect(fBitmapBig, &src, dst, &paint); | 136 canvas->drawBitmapRectToRect(fBitmapBig, &src, dst, &paint, |
| 137 SkCanvas::kBleed_DrawBitmapRectFlag); |
| 136 | 138 |
| 137 // next draw ~1/4 of the bitmap | 139 // next draw ~1/4 of the bitmap |
| 138 src = SkRect::MakeXYWH(1, 1, | 140 src = SkRect::MakeXYWH(1, 1, |
| 139 SkIntToScalar(fBitmapBig.width()/2-1), | 141 SkIntToScalar(fBitmapBig.width()/2-1), |
| 140 SkIntToScalar(fBitmapBig.height()/2-1)); | 142 SkIntToScalar(fBitmapBig.height()/2-1)); |
| 141 dst = SkRect::MakeXYWH(10, 230, 100, 100); | 143 dst = SkRect::MakeXYWH(10, 230, 100, 100); |
| 142 | 144 |
| 143 // first without bleeding | 145 // first without bleeding |
| 144 canvas->drawBitmapRectToRect(fBitmapBig, &src, dst, &paint); | 146 canvas->drawBitmapRectToRect(fBitmapBig, &src, dst, &paint); |
| 145 | 147 |
| 146 // then with bleeding | 148 // then with bleeding |
| 147 dst = SkRect::MakeXYWH(120, 230, 100, 100); | 149 dst = SkRect::MakeXYWH(120, 230, 100, 100); |
| 148 canvas->drawBitmapRectToRect(fBitmapBig, &src, dst, &paint); | 150 canvas->drawBitmapRectToRect(fBitmapBig, &src, dst, &paint, |
| 151 SkCanvas::kBleed_DrawBitmapRectFlag); |
| 149 | 152 |
| 150 #if SK_SUPPORT_GPU | 153 #if SK_SUPPORT_GPU |
| 151 if (NULL != ctx) { | 154 if (NULL != ctx) { |
| 152 ctx->setMaxTextureSizeOverride(oldMaxTextureSize); | 155 ctx->setMaxTextureSizeOverride(oldMaxTextureSize); |
| 153 } | 156 } |
| 154 #endif | 157 #endif |
| 155 } | 158 } |
| 156 | 159 |
| 157 private: | 160 private: |
| 158 static const int kWidth = 230; | 161 static const int kWidth = 230; |
| 159 static const int kHeight = 340; | 162 static const int kHeight = 340; |
| 160 | 163 |
| 161 static const int kSmallTextureSize = 4; | 164 static const int kSmallTextureSize = 4; |
| 162 static const int kMaxTextureSize = 32; | 165 static const int kMaxTextureSize = 32; |
| 163 | 166 |
| 164 SkBitmap fBitmapSmall; | 167 SkBitmap fBitmapSmall; |
| 165 SkBitmap fBitmapBig; | 168 SkBitmap fBitmapBig; |
| 166 | 169 |
| 167 typedef GM INHERITED; | 170 typedef GM INHERITED; |
| 168 }; | 171 }; |
| 169 | 172 |
| 170 DEF_GM( return new BleedGM(); ) | 173 DEF_GM( return new BleedGM(); ) |
| OLD | NEW |