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

Side by Side Diff: src/core/SkBitmapDevice.cpp

Issue 2176193002: respect kFast_SrcRectConstraint by allowing shader access to entire bitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebased w/ new gm Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // needed (if the src was clipped). No check needed if src==null. 261 // needed (if the src was clipped). No check needed if src==null.
262 if (src) { 262 if (src) {
263 if (!bitmapBounds.contains(*src)) { 263 if (!bitmapBounds.contains(*src)) {
264 if (!tmpSrc.intersect(bitmapBounds)) { 264 if (!tmpSrc.intersect(bitmapBounds)) {
265 return; // nothing to draw 265 return; // nothing to draw
266 } 266 }
267 // recompute dst, based on the smaller tmpSrc 267 // recompute dst, based on the smaller tmpSrc
268 matrix.mapRect(&tmpDst, tmpSrc); 268 matrix.mapRect(&tmpDst, tmpSrc);
269 dstPtr = &tmpDst; 269 dstPtr = &tmpDst;
270 } 270 }
271 }
271 272
273 if (src && !src->contains(bitmapBounds) &&
274 SkCanvas::kFast_SrcRectConstraint == constraint &&
275 paint.getFilterQuality() != kNone_SkFilterQuality) {
276 // src is smaller than the bounds of the bitmap, and we are filtering, s o we don't know
277 // how much more of the bitmap we need, so we can't use extractSubset or drawBitmap,
278 // but we must use a shader w/ dst bounds (which can access all of the b itmap needed).
279 goto USE_SHADER;
280 }
281
282 if (src) {
272 // since we may need to clamp to the borders of the src rect within 283 // since we may need to clamp to the borders of the src rect within
273 // the bitmap, we extract a subset. 284 // the bitmap, we extract a subset.
274 const SkIRect srcIR = tmpSrc.roundOut(); 285 const SkIRect srcIR = tmpSrc.roundOut();
275 if(bitmap.pixelRef()->getTexture()) { 286 if(bitmap.pixelRef()->getTexture()) {
276 // Accelerated source canvas, don't use extractSubset but readPixels to get the subset. 287 // Accelerated source canvas, don't use extractSubset but readPixels to get the subset.
277 // This way, the pixels are copied in CPU memory instead of GPU memo ry. 288 // This way, the pixels are copied in CPU memory instead of GPU memo ry.
278 bitmap.pixelRef()->readPixels(&tmpBitmap, kN32_SkColorType, &srcIR); 289 bitmap.pixelRef()->readPixels(&tmpBitmap, kN32_SkColorType, &srcIR);
279 } else { 290 } else {
280 if (!bitmap.extractSubset(&tmpBitmap, srcIR)) { 291 if (!bitmap.extractSubset(&tmpBitmap, srcIR)) {
281 return; 292 return;
(...skipping 21 matching lines...) Expand all
303 } 314 }
304 } else { 315 } else {
305 USE_DRAWBITMAP: 316 USE_DRAWBITMAP:
306 // 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
307 // 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,
308 // 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.
309 draw.drawBitmap(*bitmapPtr, matrix, dstPtr, paint); 320 draw.drawBitmap(*bitmapPtr, matrix, dstPtr, paint);
310 return; 321 return;
311 } 322 }
312 323
324 USE_SHADER:
313 // construct a shader, so we can call drawRect with the dst 325 // construct a shader, so we can call drawRect with the dst
314 auto s = SkShader::MakeBitmapShader(*bitmapPtr, SkShader::kClamp_TileMode, 326 auto s = SkShader::MakeBitmapShader(*bitmapPtr, SkShader::kClamp_TileMode,
315 SkShader::kClamp_TileMode, &matrix); 327 SkShader::kClamp_TileMode, &matrix);
316 if (!s) { 328 if (!s) {
317 return; 329 return;
318 } 330 }
319 331
320 SkPaint paintWithShader(paint); 332 SkPaint paintWithShader(paint);
321 paintWithShader.setStyle(SkPaint::kFill_Style); 333 paintWithShader.setStyle(SkPaint::kFill_Style);
322 paintWithShader.setShader(std::move(s)); 334 paintWithShader.setShader(std::move(s));
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 paint.getRasterizer() || 434 paint.getRasterizer() ||
423 paint.getPathEffect() || 435 paint.getPathEffect() ||
424 paint.isFakeBoldText() || 436 paint.isFakeBoldText() ||
425 paint.getStyle() != SkPaint::kFill_Style || 437 paint.getStyle() != SkPaint::kFill_Style ||
426 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) 438 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode))
427 { 439 {
428 return true; 440 return true;
429 } 441 }
430 return false; 442 return false;
431 } 443 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698