| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 | 63 |
| 64 SkCanvas canvas(device.get()); | 64 SkCanvas canvas(device.get()); |
| 65 SkPaint paint; | 65 SkPaint paint; |
| 66 | 66 |
| 67 // Subtract off the integer component of the translation (will be applied in
loc, below). | 67 // Subtract off the integer component of the translation (will be applied in
loc, below). |
| 68 dstRect.offset(-SkIntToScalar(dstIRect.fLeft), -SkIntToScalar(dstIRect.fTop)
); | 68 dstRect.offset(-SkIntToScalar(dstIRect.fLeft), -SkIntToScalar(dstIRect.fTop)
); |
| 69 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 69 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
| 70 // FIXME: this probably shouldn't be necessary, but drawBitmapRectToRect ass
erts | 70 // FIXME: this probably shouldn't be necessary, but drawBitmapRectToRect ass
erts |
| 71 // None filtering when it's translate-only | 71 // None filtering when it's translate-only |
| 72 paint.setFilterLevel( | 72 paint.setFilterQuality( |
| 73 fSrcRect.width() == dstRect.width() && fSrcRect.height() == dstRect.heig
ht() ? | 73 fSrcRect.width() == dstRect.width() && fSrcRect.height() == dstRect.heig
ht() ? |
| 74 SkPaint::kNone_FilterLevel : SkPaint::kHigh_FilterLevel); | 74 kNone_SkFilterQuality : kHigh_SkFilterQuality); |
| 75 canvas.drawBitmapRectToRect(fBitmap, &fSrcRect, dstRect, &paint); | 75 canvas.drawBitmapRectToRect(fBitmap, &fSrcRect, dstRect, &paint); |
| 76 | 76 |
| 77 *result = device.get()->accessBitmap(false); | 77 *result = device.get()->accessBitmap(false); |
| 78 offset->fX = dstIRect.fLeft; | 78 offset->fX = dstIRect.fLeft; |
| 79 offset->fY = dstIRect.fTop; | 79 offset->fY = dstIRect.fTop; |
| 80 return true; | 80 return true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void SkBitmapSource::computeFastBounds(const SkRect&, SkRect* dst) const { | 83 void SkBitmapSource::computeFastBounds(const SkRect&, SkRect* dst) const { |
| 84 *dst = fDstRect; | 84 *dst = fDstRect; |
| 85 } | 85 } |
| 86 | 86 |
| 87 #ifndef SK_IGNORE_TO_STRING | 87 #ifndef SK_IGNORE_TO_STRING |
| 88 void SkBitmapSource::toString(SkString* str) const { | 88 void SkBitmapSource::toString(SkString* str) const { |
| 89 str->appendf("SkBitmapSource: ("); | 89 str->appendf("SkBitmapSource: ("); |
| 90 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", | 90 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", |
| 91 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m, | 91 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m, |
| 92 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); | 92 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); |
| 93 str->appendf("bitmap: (%d,%d)", | 93 str->appendf("bitmap: (%d,%d)", |
| 94 fBitmap.width(), fBitmap.height()); | 94 fBitmap.width(), fBitmap.height()); |
| 95 str->append(")"); | 95 str->append(")"); |
| 96 } | 96 } |
| 97 #endif | 97 #endif |
| OLD | NEW |