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 "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkConfig8888.h" | 9 #include "SkConfig8888.h" |
10 #include "SkDraw.h" | 10 #include "SkDraw.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 } else { | 315 } else { |
316 USE_DRAWBITMAP: | 316 USE_DRAWBITMAP: |
317 // We can go faster by just calling drawBitmap, which will concat the | 317 // We can go faster by just calling drawBitmap, which will concat the |
318 // matrix with the CTM, and try to call drawSprite if it can. If not, | 318 // matrix with the CTM, and try to call drawSprite if it can. If not, |
319 // it will make a shader and call drawRect, as we do below. | 319 // it will make a shader and call drawRect, as we do below. |
320 draw.drawBitmap(*bitmapPtr, matrix, dstPtr, paint); | 320 draw.drawBitmap(*bitmapPtr, matrix, dstPtr, paint); |
321 return; | 321 return; |
322 } | 322 } |
323 | 323 |
324 USE_SHADER: | 324 USE_SHADER: |
325 | |
326 // Since the shader need only live for our stack-frame, pass in a custom all ocator. This | |
327 // can save malloc calls, and signals to SkMakeBitmapShader to not try to co py the bitmap | |
328 // if its mutable, since that precaution is not needed (give the short lifet ime of the shader). | |
329 SkTBlitterAllocator allocator; | |
mtklein
2016/08/05 15:46:43
Perhaps as a follow up, I think this signal wants
f(malita)
2016/08/05 15:52:50
We already have ForceCopyMode for SkImageShader::M
reed1
2016/08/05 16:45:12
It is actually used to avoid mallocs when we alloc
| |
325 // construct a shader, so we can call drawRect with the dst | 330 // construct a shader, so we can call drawRect with the dst |
326 auto s = SkShader::MakeBitmapShader(*bitmapPtr, SkShader::kClamp_TileMode, | 331 auto s = SkMakeBitmapShader(*bitmapPtr, SkShader::kClamp_TileMode, SkShader: :kClamp_TileMode, |
327 SkShader::kClamp_TileMode, &matrix); | 332 &matrix, &allocator); |
328 if (!s) { | 333 if (!s) { |
329 return; | 334 return; |
330 } | 335 } |
331 | 336 |
332 SkPaint paintWithShader(paint); | 337 SkPaint paintWithShader(paint); |
333 paintWithShader.setStyle(SkPaint::kFill_Style); | 338 paintWithShader.setStyle(SkPaint::kFill_Style); |
334 paintWithShader.setShader(std::move(s)); | 339 paintWithShader.setShader(std::move(s)); |
335 | 340 |
336 // Call ourself, in case the subclass wanted to share this setup code | 341 // Call ourself, in case the subclass wanted to share this setup code |
337 // but handle the drawRect code themselves. | 342 // but handle the drawRect code themselves. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
434 paint.getRasterizer() || | 439 paint.getRasterizer() || |
435 paint.getPathEffect() || | 440 paint.getPathEffect() || |
436 paint.isFakeBoldText() || | 441 paint.isFakeBoldText() || |
437 paint.getStyle() != SkPaint::kFill_Style || | 442 paint.getStyle() != SkPaint::kFill_Style || |
438 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) | 443 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) |
439 { | 444 { |
440 return true; | 445 return true; |
441 } | 446 } |
442 return false; | 447 return false; |
443 } | 448 } |
OLD | NEW |