| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 The Android Open Source Project |
| 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 "SkBitmapSource.h" | 8 #include "SkBitmapSource.h" |
| 9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 if (NULL == device.get()) { | 72 if (NULL == device.get()) { |
| 73 return false; | 73 return false; |
| 74 } | 74 } |
| 75 | 75 |
| 76 SkCanvas canvas(device.get()); | 76 SkCanvas canvas(device.get()); |
| 77 SkPaint paint; | 77 SkPaint paint; |
| 78 | 78 |
| 79 // Subtract off the integer component of the translation (will be applied in
loc, below). | 79 // Subtract off the integer component of the translation (will be applied in
loc, below). |
| 80 dstRect.offset(-SkIntToScalar(dstIRect.fLeft), -SkIntToScalar(dstIRect.fTop)
); | 80 dstRect.offset(-SkIntToScalar(dstIRect.fLeft), -SkIntToScalar(dstIRect.fTop)
); |
| 81 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 81 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
| 82 // FIXME: this probably shouldn't be necessary, but drawBitmapRectToRect ass
erts | 82 // FIXME: this probably shouldn't be necessary, but drawBitmapRect asserts |
| 83 // None filtering when it's translate-only | 83 // None filtering when it's translate-only |
| 84 paint.setFilterQuality( | 84 paint.setFilterQuality( |
| 85 fSrcRect.width() == dstRect.width() && fSrcRect.height() == dstRect.heig
ht() ? | 85 fSrcRect.width() == dstRect.width() && fSrcRect.height() == dstRect.heig
ht() ? |
| 86 kNone_SkFilterQuality : fFilterQuality); | 86 kNone_SkFilterQuality : fFilterQuality); |
| 87 canvas.drawBitmapRectToRect(fBitmap, &fSrcRect, dstRect, &paint); | 87 canvas.drawBitmapRect(fBitmap, &fSrcRect, dstRect, &paint, SkCanvas::kStrict
_SrcRectConstraint); |
| 88 | 88 |
| 89 *result = device.get()->accessBitmap(false); | 89 *result = device.get()->accessBitmap(false); |
| 90 offset->fX = dstIRect.fLeft; | 90 offset->fX = dstIRect.fLeft; |
| 91 offset->fY = dstIRect.fTop; | 91 offset->fY = dstIRect.fTop; |
| 92 | 92 |
| 93 return true; | 93 return true; |
| 94 } | 94 } |
| 95 | 95 |
| 96 void SkBitmapSource::computeFastBounds(const SkRect&, SkRect* dst) const { | 96 void SkBitmapSource::computeFastBounds(const SkRect&, SkRect* dst) const { |
| 97 *dst = fDstRect; | 97 *dst = fDstRect; |
| 98 } | 98 } |
| 99 | 99 |
| 100 #ifndef SK_IGNORE_TO_STRING | 100 #ifndef SK_IGNORE_TO_STRING |
| 101 void SkBitmapSource::toString(SkString* str) const { | 101 void SkBitmapSource::toString(SkString* str) const { |
| 102 str->appendf("SkBitmapSource: ("); | 102 str->appendf("SkBitmapSource: ("); |
| 103 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", | 103 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", |
| 104 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m, | 104 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m, |
| 105 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); | 105 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); |
| 106 str->appendf("bitmap: (%d,%d)", | 106 str->appendf("bitmap: (%d,%d)", |
| 107 fBitmap.width(), fBitmap.height()); | 107 fBitmap.width(), fBitmap.height()); |
| 108 str->append(")"); | 108 str->append(")"); |
| 109 } | 109 } |
| 110 #endif | 110 #endif |
| OLD | NEW |