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 SkShader* s = SkShader::CreateBitmapShader(bm, SkShader::kClamp_TileMode
, | 169 paint->setShader(SkShader::MakeBitmapShader(bm, SkShader::kClamp_TileMod
e, |
170 SkShader::kClamp_TileMode); | 170 SkShader::kClamp_TileMode)); |
171 paint->setShader(s)->unref(); | |
172 | |
173 } | 171 } |
174 | 172 |
175 void draw(SkCanvas* canvas, SkPaint* paint) { | 173 void draw(SkCanvas* canvas, SkPaint* paint) { |
176 canvas->drawVertices(SkCanvas::kTriangleFan_VertexMode, 4, fPts, fPts, | 174 canvas->drawVertices(SkCanvas::kTriangleFan_VertexMode, 4, fPts, fPts, |
177 nullptr, nullptr, nullptr, 0, *paint); | 175 nullptr, nullptr, nullptr, 0, *paint); |
178 } | 176 } |
179 }; | 177 }; |
180 | 178 |
181 #include "SkImageEncoder.h" | 179 #include "SkImageEncoder.h" |
182 static void save_bm(const SkBitmap& bm, const char name[]) { | 180 static void save_bm(const SkBitmap& bm, const char name[]) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 } | 253 } |
256 } | 254 } |
257 } | 255 } |
258 } | 256 } |
259 } | 257 } |
260 | 258 |
261 DEF_TEST(BlitRow, reporter) { | 259 DEF_TEST(BlitRow, reporter) { |
262 test_00_FF(reporter); | 260 test_00_FF(reporter); |
263 test_diagonal(reporter); | 261 test_diagonal(reporter); |
264 } | 262 } |
OLD | NEW |