| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkImageSource.h" | 8 #include "SkImageSource.h" |
| 9 | 9 |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 SkCanvas* canvas = surf->getCanvas(); | 101 SkCanvas* canvas = surf->getCanvas(); |
| 102 SkASSERT(canvas); | 102 SkASSERT(canvas); |
| 103 | 103 |
| 104 // TODO: it seems like this clear shouldn't be necessary (see skbug.com/5075
) | 104 // TODO: it seems like this clear shouldn't be necessary (see skbug.com/5075
) |
| 105 canvas->clear(0x0); | 105 canvas->clear(0x0); |
| 106 | 106 |
| 107 SkPaint paint; | 107 SkPaint paint; |
| 108 | 108 |
| 109 // Subtract off the integer component of the translation (will be applied in
offset, below). | 109 // Subtract off the integer component of the translation (will be applied in
offset, below). |
| 110 dstRect.offset(-SkIntToScalar(dstIRect.fLeft), -SkIntToScalar(dstIRect.fTop)
); | 110 dstRect.offset(-SkIntToScalar(dstIRect.fLeft), -SkIntToScalar(dstIRect.fTop)
); |
| 111 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 111 paint.setBlendMode(SkBlendMode::kSrc); |
| 112 // FIXME: this probably shouldn't be necessary, but drawImageRect asserts | 112 // FIXME: this probably shouldn't be necessary, but drawImageRect asserts |
| 113 // None filtering when it's translate-only | 113 // None filtering when it's translate-only |
| 114 paint.setFilterQuality( | 114 paint.setFilterQuality( |
| 115 fSrcRect.width() == dstRect.width() && fSrcRect.height() == dstRect.heig
ht() ? | 115 fSrcRect.width() == dstRect.width() && fSrcRect.height() == dstRect.heig
ht() ? |
| 116 kNone_SkFilterQuality : fFilterQuality); | 116 kNone_SkFilterQuality : fFilterQuality); |
| 117 canvas->drawImageRect(fImage.get(), fSrcRect, dstRect, &paint, | 117 canvas->drawImageRect(fImage.get(), fSrcRect, dstRect, &paint, |
| 118 SkCanvas::kStrict_SrcRectConstraint); | 118 SkCanvas::kStrict_SrcRectConstraint); |
| 119 | 119 |
| 120 offset->fX = dstIRect.fLeft; | 120 offset->fX = dstIRect.fLeft; |
| 121 offset->fY = dstIRect.fTop; | 121 offset->fY = dstIRect.fTop; |
| 122 return surf->makeImageSnapshot(); | 122 return surf->makeImageSnapshot(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 SkRect SkImageSource::computeFastBounds(const SkRect& src) const { | 125 SkRect SkImageSource::computeFastBounds(const SkRect& src) const { |
| 126 return fDstRect; | 126 return fDstRect; |
| 127 } | 127 } |
| 128 | 128 |
| 129 #ifndef SK_IGNORE_TO_STRING | 129 #ifndef SK_IGNORE_TO_STRING |
| 130 void SkImageSource::toString(SkString* str) const { | 130 void SkImageSource::toString(SkString* str) const { |
| 131 str->appendf("SkImageSource: ("); | 131 str->appendf("SkImageSource: ("); |
| 132 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", | 132 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", |
| 133 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m, | 133 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m, |
| 134 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); | 134 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); |
| 135 str->appendf("image: (%d,%d)", | 135 str->appendf("image: (%d,%d)", |
| 136 fImage->width(), fImage->height()); | 136 fImage->width(), fImage->height()); |
| 137 str->append(")"); | 137 str->append(")"); |
| 138 } | 138 } |
| 139 #endif | 139 #endif |
| OLD | NEW |