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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 // src is smaller than the bounds of the bitmap, and we are filtering, s
o we don't know | 274 // src is smaller than the bounds of the bitmap, and we are filtering, s
o we don't know |
275 // how much more of the bitmap we need, so we can't use extractSubset or
drawBitmap, | 275 // how much more of the bitmap we need, so we can't use extractSubset or
drawBitmap, |
276 // but we must use a shader w/ dst bounds (which can access all of the b
itmap needed). | 276 // but we must use a shader w/ dst bounds (which can access all of the b
itmap needed). |
277 goto USE_SHADER; | 277 goto USE_SHADER; |
278 } | 278 } |
279 | 279 |
280 if (src) { | 280 if (src) { |
281 // since we may need to clamp to the borders of the src rect within | 281 // since we may need to clamp to the borders of the src rect within |
282 // the bitmap, we extract a subset. | 282 // the bitmap, we extract a subset. |
283 const SkIRect srcIR = tmpSrc.roundOut(); | 283 const SkIRect srcIR = tmpSrc.roundOut(); |
284 if(bitmap.pixelRef()->getTexture()) { | 284 if (!bitmap.extractSubset(&tmpBitmap, srcIR)) { |
285 // Accelerated source canvas, don't use extractSubset but readPixels
to get the subset. | 285 return; |
286 // This way, the pixels are copied in CPU memory instead of GPU memo
ry. | |
287 bitmap.pixelRef()->readPixels(&tmpBitmap, kN32_SkColorType, &srcIR); | |
288 } else { | |
289 if (!bitmap.extractSubset(&tmpBitmap, srcIR)) { | |
290 return; | |
291 } | |
292 } | 286 } |
293 bitmapPtr = &tmpBitmap; | 287 bitmapPtr = &tmpBitmap; |
294 | 288 |
295 // Since we did an extract, we need to adjust the matrix accordingly | 289 // Since we did an extract, we need to adjust the matrix accordingly |
296 SkScalar dx = 0, dy = 0; | 290 SkScalar dx = 0, dy = 0; |
297 if (srcIR.fLeft > 0) { | 291 if (srcIR.fLeft > 0) { |
298 dx = SkIntToScalar(srcIR.fLeft); | 292 dx = SkIntToScalar(srcIR.fLeft); |
299 } | 293 } |
300 if (srcIR.fTop > 0) { | 294 if (srcIR.fTop > 0) { |
301 dy = SkIntToScalar(srcIR.fTop); | 295 dy = SkIntToScalar(srcIR.fTop); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 paint.getRasterizer() || | 433 paint.getRasterizer() || |
440 paint.getPathEffect() || | 434 paint.getPathEffect() || |
441 paint.isFakeBoldText() || | 435 paint.isFakeBoldText() || |
442 paint.getStyle() != SkPaint::kFill_Style || | 436 paint.getStyle() != SkPaint::kFill_Style || |
443 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) | 437 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) |
444 { | 438 { |
445 return true; | 439 return true; |
446 } | 440 } |
447 return false; | 441 return false; |
448 } | 442 } |
OLD | NEW |