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

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

Issue 19977003: drawBitmap* cleanup (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Fixed bugs Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/device/xps/SkXPSDevice.cpp » ('j') | 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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
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 #include "SkDevice.h" 8 #include "SkDevice.h"
9 #include "SkDeviceProperties.h" 9 #include "SkDeviceProperties.h"
10 #include "SkDraw.h" 10 #include "SkDraw.h"
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 } 364 }
365 365
366 void SkDevice::drawPath(const SkDraw& draw, const SkPath& path, 366 void SkDevice::drawPath(const SkDraw& draw, const SkPath& path,
367 const SkPaint& paint, const SkMatrix* prePathMatrix, 367 const SkPaint& paint, const SkMatrix* prePathMatrix,
368 bool pathIsMutable) { 368 bool pathIsMutable) {
369 CHECK_FOR_NODRAW_ANNOTATION(paint); 369 CHECK_FOR_NODRAW_ANNOTATION(paint);
370 draw.drawPath(path, paint, prePathMatrix, pathIsMutable); 370 draw.drawPath(path, paint, prePathMatrix, pathIsMutable);
371 } 371 }
372 372
373 void SkDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, 373 void SkDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap,
374 const SkIRect* srcRect,
375 const SkMatrix& matrix, const SkPaint& paint) { 374 const SkMatrix& matrix, const SkPaint& paint) {
376 SkBitmap tmp; // storage if we need a subset of bitmap 375 draw.drawBitmap(bitmap, matrix, paint);
377 const SkBitmap* bitmapPtr = &bitmap;
378
379 if (srcRect) {
380 if (!bitmap.extractSubset(&tmp, *srcRect)) {
381 return; // extraction failed
382 }
383 bitmapPtr = &tmp;
384 }
385 draw.drawBitmap(*bitmapPtr, matrix, paint);
386 } 376 }
387 377
388 void SkDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, 378 void SkDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
389 const SkRect* src, const SkRect& dst, 379 const SkRect* src, const SkRect& dst,
390 const SkPaint& paint) { 380 const SkPaint& paint) {
391 SkMatrix matrix; 381 SkMatrix matrix;
392 SkRect bitmapBounds, tmpSrc, tmpDst; 382 SkRect bitmapBounds, tmpSrc, tmpDst;
393 SkBitmap tmpBitmap; 383 SkBitmap tmpBitmap;
394 384
395 bitmapBounds.isetWH(bitmap.width(), bitmap.height()); 385 bitmapBounds.isetWH(bitmap.width(), bitmap.height());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 extractedBitmapBounds.isetWH(bitmapPtr->width(), bitmapPtr->height()); 432 extractedBitmapBounds.isetWH(bitmapPtr->width(), bitmapPtr->height());
443 if (extractedBitmapBounds == tmpSrc) { 433 if (extractedBitmapBounds == tmpSrc) {
444 // no fractional part in src, we can just call drawBitmap 434 // no fractional part in src, we can just call drawBitmap
445 goto USE_DRAWBITMAP; 435 goto USE_DRAWBITMAP;
446 } 436 }
447 } else { 437 } else {
448 USE_DRAWBITMAP: 438 USE_DRAWBITMAP:
449 // We can go faster by just calling drawBitmap, which will concat the 439 // We can go faster by just calling drawBitmap, which will concat the
450 // matrix with the CTM, and try to call drawSprite if it can. If not, 440 // matrix with the CTM, and try to call drawSprite if it can. If not,
451 // it will make a shader and call drawRect, as we do below. 441 // it will make a shader and call drawRect, as we do below.
452 this->drawBitmap(draw, *bitmapPtr, NULL, matrix, paint); 442 this->drawBitmap(draw, *bitmapPtr, matrix, paint);
453 return; 443 return;
454 } 444 }
455 445
456 // construct a shader, so we can call drawRect with the dst 446 // construct a shader, so we can call drawRect with the dst
457 SkShader* s = SkShader::CreateBitmapShader(*bitmapPtr, 447 SkShader* s = SkShader::CreateBitmapShader(*bitmapPtr,
458 SkShader::kClamp_TileMode, 448 SkShader::kClamp_TileMode,
459 SkShader::kClamp_TileMode); 449 SkShader::kClamp_TileMode);
460 if (NULL == s) { 450 if (NULL == s) {
461 return; 451 return;
462 } 452 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 paint.getStyle() != SkPaint::kFill_Style || 523 paint.getStyle() != SkPaint::kFill_Style ||
534 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { 524 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) {
535 // turn off lcd 525 // turn off lcd
536 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; 526 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag;
537 flags->fHinting = paint.getHinting(); 527 flags->fHinting = paint.getHinting();
538 return true; 528 return true;
539 } 529 }
540 // we're cool with the paint as is 530 // we're cool with the paint as is
541 return false; 531 return false;
542 } 532 }
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/device/xps/SkXPSDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698