| OLD | NEW |
| 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 "SkTileImageFilter.h" | 8 #include "SkTileImageFilter.h" |
| 9 | 9 |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 return nullptr; | 48 return nullptr; |
| 49 } | 49 } |
| 50 | 50 |
| 51 SkRect dstRect; | 51 SkRect dstRect; |
| 52 ctx.ctm().mapRect(&dstRect, fDstRect); | 52 ctx.ctm().mapRect(&dstRect, fDstRect); |
| 53 if (!dstRect.intersect(SkRect::Make(ctx.clipBounds()))) { | 53 if (!dstRect.intersect(SkRect::Make(ctx.clipBounds()))) { |
| 54 return nullptr; | 54 return nullptr; |
| 55 } | 55 } |
| 56 | 56 |
| 57 const SkIRect dstIRect = dstRect.roundOut(); | 57 const SkIRect dstIRect = dstRect.roundOut(); |
| 58 int dstWidth = dstIRect.width(); | 58 if (!fSrcRect.width() || !fSrcRect.height() || !dstIRect.width() || !dstIRec
t.height()) { |
| 59 int dstHeight = dstIRect.height(); | |
| 60 if (!fSrcRect.width() || !fSrcRect.height() || !dstWidth || !dstHeight) { | |
| 61 return nullptr; | 59 return nullptr; |
| 62 } | 60 } |
| 63 | 61 |
| 64 SkRect srcRect; | 62 SkRect srcRect; |
| 65 ctx.ctm().mapRect(&srcRect, fSrcRect); | 63 ctx.ctm().mapRect(&srcRect, fSrcRect); |
| 66 SkIRect srcIRect; | 64 SkIRect srcIRect; |
| 67 srcRect.roundOut(&srcIRect); | 65 srcRect.roundOut(&srcIRect); |
| 68 srcIRect.offset(-inputOffset); | 66 srcIRect.offset(-inputOffset); |
| 69 const SkIRect inputBounds = SkIRect::MakeWH(input->width(), input->height())
; | 67 const SkIRect inputBounds = SkIRect::MakeWH(input->width(), input->height())
; |
| 70 | 68 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 95 | 93 |
| 96 input->draw(canvas, | 94 input->draw(canvas, |
| 97 SkIntToScalar(inputOffset.x()), SkIntToScalar(inputOffset.y(
)), | 95 SkIntToScalar(inputOffset.x()), SkIntToScalar(inputOffset.y(
)), |
| 98 &paint); | 96 &paint); |
| 99 | 97 |
| 100 subset = surf->makeImageSnapshot(); | 98 subset = surf->makeImageSnapshot(); |
| 101 } | 99 } |
| 102 SkASSERT(subset->width() == srcIRect.width()); | 100 SkASSERT(subset->width() == srcIRect.width()); |
| 103 SkASSERT(subset->height() == srcIRect.height()); | 101 SkASSERT(subset->height() == srcIRect.height()); |
| 104 | 102 |
| 105 const SkImageInfo info = SkImageInfo::MakeN32(dstWidth, dstHeight, kPremul_S
kAlphaType); | 103 sk_sp<SkSpecialSurface> surf(source->makeSurface(dstIRect)); |
| 106 | |
| 107 sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); | |
| 108 if (!surf) { | 104 if (!surf) { |
| 109 return nullptr; | 105 return nullptr; |
| 110 } | 106 } |
| 111 | 107 |
| 112 SkCanvas* canvas = surf->getCanvas(); | 108 SkCanvas* canvas = surf->getCanvas(); |
| 113 SkASSERT(canvas); | 109 SkASSERT(canvas); |
| 114 | 110 |
| 115 SkPaint paint; | 111 SkPaint paint; |
| 116 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 112 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
| 117 paint.setShader(subset->makeShader(SkShader::kRepeat_TileMode, SkShader::kRe
peat_TileMode)); | 113 paint.setShader(subset->makeShader(SkShader::kRepeat_TileMode, SkShader::kRe
peat_TileMode)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 str->appendf(" dst: %.2f %.2f %.2f %.2f", | 156 str->appendf(" dst: %.2f %.2f %.2f %.2f", |
| 161 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); | 157 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); |
| 162 if (this->getInput(0)) { | 158 if (this->getInput(0)) { |
| 163 str->appendf("input: ("); | 159 str->appendf("input: ("); |
| 164 this->getInput(0)->toString(str); | 160 this->getInput(0)->toString(str); |
| 165 str->appendf(")"); | 161 str->appendf(")"); |
| 166 } | 162 } |
| 167 str->append(")"); | 163 str->append(")"); |
| 168 } | 164 } |
| 169 #endif | 165 #endif |
| OLD | NEW |