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

Side by Side Diff: src/core/SkBitmapDevice.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 * 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 "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkConfig8888.h" 9 #include "SkConfig8888.h"
10 #include "SkDraw.h" 10 #include "SkDraw.h"
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 } else { 307 } else {
308 USE_DRAWBITMAP: 308 USE_DRAWBITMAP:
309 // We can go faster by just calling drawBitmap, which will concat the 309 // We can go faster by just calling drawBitmap, which will concat the
310 // matrix with the CTM, and try to call drawSprite if it can. If not, 310 // matrix with the CTM, and try to call drawSprite if it can. If not,
311 // it will make a shader and call drawRect, as we do below. 311 // it will make a shader and call drawRect, as we do below.
312 draw.drawBitmap(*bitmapPtr, matrix, dstPtr, paint); 312 draw.drawBitmap(*bitmapPtr, matrix, dstPtr, paint);
313 return; 313 return;
314 } 314 }
315 315
316 // construct a shader, so we can call drawRect with the dst 316 // construct a shader, so we can call drawRect with the dst
317 SkShader* s = SkShader::CreateBitmapShader(*bitmapPtr, 317 auto s = SkShader::MakeBitmapShader(*bitmapPtr, SkShader::kClamp_TileMode,
318 SkShader::kClamp_TileMode, 318 SkShader::kClamp_TileMode, &matrix);
319 SkShader::kClamp_TileMode, 319 if (!s) {
320 &matrix);
321 if (nullptr == s) {
322 return; 320 return;
323 } 321 }
324 322
325 SkPaint paintWithShader(paint); 323 SkPaint paintWithShader(paint);
326 paintWithShader.setStyle(SkPaint::kFill_Style); 324 paintWithShader.setStyle(SkPaint::kFill_Style);
327 paintWithShader.setShader(s)->unref(); 325 paintWithShader.setShader(s);
f(malita) 2016/03/08 15:50:35 setShader(std::move(s))
reed1 2016/03/08 20:17:15 Done.
328 326
329 // Call ourself, in case the subclass wanted to share this setup code 327 // Call ourself, in case the subclass wanted to share this setup code
330 // but handle the drawRect code themselves. 328 // but handle the drawRect code themselves.
331 this->drawRect(draw, *dstPtr, paintWithShader); 329 this->drawRect(draw, *dstPtr, paintWithShader);
332 } 330 }
333 331
334 void SkBitmapDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, 332 void SkBitmapDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
335 int x, int y, const SkPaint& paint) { 333 int x, int y, const SkPaint& paint) {
336 draw.drawSprite(bitmap, x, y, paint); 334 draw.drawSprite(bitmap, x, y, paint);
337 } 335 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 paint.getRasterizer() || 377 paint.getRasterizer() ||
380 paint.getPathEffect() || 378 paint.getPathEffect() ||
381 paint.isFakeBoldText() || 379 paint.isFakeBoldText() ||
382 paint.getStyle() != SkPaint::kFill_Style || 380 paint.getStyle() != SkPaint::kFill_Style ||
383 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) 381 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode))
384 { 382 {
385 return true; 383 return true;
386 } 384 }
387 return false; 385 return false;
388 } 386 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698