Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: src/utils/SkNinePatch.cpp

Issue 1772463002: use Make instead of Create to return a shared shader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: partial update of skia call-sites Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
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 8
9 9
10 #include "SkNinePatch.h" 10 #include "SkNinePatch.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 229 }
230 } 230 }
231 fillRow(verts, texs, vy, ty, bounds, xDivs, numXDivs, 231 fillRow(verts, texs, vy, ty, bounds, xDivs, numXDivs,
232 stretchX, bitmap.width()); 232 stretchX, bitmap.width());
233 verts += numXDivs + 2; 233 verts += numXDivs + 2;
234 texs += numXDivs + 2; 234 texs += numXDivs + 2;
235 } 235 }
236 fillRow(verts, texs, bounds.fBottom, SkIntToScalar(bitmap.height()), 236 fillRow(verts, texs, bounds.fBottom, SkIntToScalar(bitmap.height()),
237 bounds, xDivs, numXDivs, stretchX, bitmap.width()); 237 bounds, xDivs, numXDivs, stretchX, bitmap.width());
238 238
239 SkShader* shader = SkShader::CreateBitmapShader(bitmap,
240 SkShader::kClamp_TileMode,
241 SkShader::kClamp_TileMode);
242 SkPaint p; 239 SkPaint p;
243 if (paint) { 240 if (paint) {
244 p = *paint; 241 p = *paint;
245 } 242 }
246 p.setShader(shader)->unref(); 243 p.setShader(SkShader::MakeBitmapShader(bitmap,
244 SkShader::kClamp_TileMode,
245 SkShader::kClamp_TileMode));
247 canvas->drawVertices(SkCanvas::kTriangles_VertexMode, vCount, 246 canvas->drawVertices(SkCanvas::kTriangles_VertexMode, vCount,
248 mesh.fVerts, mesh.fTexs, mesh.fColors, nullptr, 247 mesh.fVerts, mesh.fTexs, mesh.fColors, nullptr,
249 mesh.fIndices, indexCount, p); 248 mesh.fIndices, indexCount, p);
250 } 249 }
251 250
252 /////////////////////////////////////////////////////////////////////////////// 251 ///////////////////////////////////////////////////////////////////////////////
253 252
254 static void drawNineViaRects(SkCanvas* canvas, const SkRect& dst, 253 static void drawNineViaRects(SkCanvas* canvas, const SkRect& dst,
255 const SkBitmap& bitmap, const SkIRect& margins, 254 const SkBitmap& bitmap, const SkIRect& margins,
256 const SkPaint* paint) { 255 const SkPaint* paint) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 (margins.fTop + margins.fBottom); 325 (margins.fTop + margins.fBottom);
327 yDivs[1] = yDivs[0]; 326 yDivs[1] = yDivs[0];
328 } 327 }
329 328
330 SkNinePatch::DrawMesh(canvas, bounds, bitmap, 329 SkNinePatch::DrawMesh(canvas, bounds, bitmap,
331 xDivs, 2, yDivs, 2, paint); 330 xDivs, 2, yDivs, 2, paint);
332 } else { 331 } else {
333 drawNineViaRects(canvas, bounds, bitmap, margins, paint); 332 drawNineViaRects(canvas, bounds, bitmap, margins, paint);
334 } 333 }
335 } 334 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698