OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 struct Mesh { | 159 struct Mesh { |
160 SkPoint fPts[4]; | 160 SkPoint fPts[4]; |
161 | 161 |
162 Mesh(const SkBitmap& bm, SkPaint* paint) { | 162 Mesh(const SkBitmap& bm, SkPaint* paint) { |
163 const SkScalar w = SkIntToScalar(bm.width()); | 163 const SkScalar w = SkIntToScalar(bm.width()); |
164 const SkScalar h = SkIntToScalar(bm.height()); | 164 const SkScalar h = SkIntToScalar(bm.height()); |
165 fPts[0].set(0, 0); | 165 fPts[0].set(0, 0); |
166 fPts[1].set(w, 0); | 166 fPts[1].set(w, 0); |
167 fPts[2].set(w, h); | 167 fPts[2].set(w, h); |
168 fPts[3].set(0, h); | 168 fPts[3].set(0, h); |
169 paint->setShader(SkShader::MakeBitmapShader(bm, SkShader::kClamp_TileMod
e, | 169 SkShader* s = SkShader::CreateBitmapShader(bm, SkShader::kClamp_TileMode
, |
170 SkShader::kClamp_TileMode)); | 170 SkShader::kClamp_TileMode); |
| 171 paint->setShader(s)->unref(); |
| 172 |
171 } | 173 } |
172 | 174 |
173 void draw(SkCanvas* canvas, SkPaint* paint) { | 175 void draw(SkCanvas* canvas, SkPaint* paint) { |
174 canvas->drawVertices(SkCanvas::kTriangleFan_VertexMode, 4, fPts, fPts, | 176 canvas->drawVertices(SkCanvas::kTriangleFan_VertexMode, 4, fPts, fPts, |
175 nullptr, nullptr, nullptr, 0, *paint); | 177 nullptr, nullptr, nullptr, 0, *paint); |
176 } | 178 } |
177 }; | 179 }; |
178 | 180 |
179 #include "SkImageEncoder.h" | 181 #include "SkImageEncoder.h" |
180 static void save_bm(const SkBitmap& bm, const char name[]) { | 182 static void save_bm(const SkBitmap& bm, const char name[]) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 } | 255 } |
254 } | 256 } |
255 } | 257 } |
256 } | 258 } |
257 } | 259 } |
258 | 260 |
259 DEF_TEST(BlitRow, reporter) { | 261 DEF_TEST(BlitRow, reporter) { |
260 test_00_FF(reporter); | 262 test_00_FF(reporter); |
261 test_diagonal(reporter); | 263 test_diagonal(reporter); |
262 } | 264 } |
OLD | NEW |