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 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkDevice.h" | 11 #include "SkDevice.h" |
12 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
13 #include "SkWriteBuffer.h" | 13 #include "SkWriteBuffer.h" |
14 #include "SkMatrix.h" | 14 #include "SkMatrix.h" |
15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
16 #include "SkShader.h" | 16 #include "SkShader.h" |
17 #include "SkValidationUtils.h" | 17 #include "SkValidationUtils.h" |
18 | 18 |
19 SkTileImageFilter* SkTileImageFilter::Create(const SkRect& srcRect, const SkRect
& dstRect, | 19 SkTileImageFilter* SkTileImageFilter::Create(const SkRect& srcRect, const SkRect
& dstRect, |
20 SkImageFilter* input) { | 20 SkImageFilter* input) { |
21 if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) { | 21 if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) { |
22 return NULL; | 22 return nullptr; |
23 } | 23 } |
24 return new SkTileImageFilter(srcRect, dstRect, input); | 24 return new SkTileImageFilter(srcRect, dstRect, input); |
25 } | 25 } |
26 | 26 |
27 bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, | 27 bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, |
28 const Context& ctx, | 28 const Context& ctx, |
29 SkBitmap* dst, SkIPoint* offset) const { | 29 SkBitmap* dst, SkIPoint* offset) const { |
30 SkBitmap source = src; | 30 SkBitmap source = src; |
31 SkImageFilter* input = getInput(0); | 31 SkImageFilter* input = getInput(0); |
32 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 32 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
(...skipping 20 matching lines...) Expand all Loading... |
53 source.getBounds(&bounds); | 53 source.getBounds(&bounds); |
54 | 54 |
55 if (!srcIRect.intersect(bounds)) { | 55 if (!srcIRect.intersect(bounds)) { |
56 offset->fX = offset->fY = 0; | 56 offset->fX = offset->fY = 0; |
57 return true; | 57 return true; |
58 } else if (!source.extractSubset(&subset, srcIRect)) { | 58 } else if (!source.extractSubset(&subset, srcIRect)) { |
59 return false; | 59 return false; |
60 } | 60 } |
61 | 61 |
62 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(w, h)); | 62 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(w, h)); |
63 if (NULL == device.get()) { | 63 if (nullptr == device.get()) { |
64 return false; | 64 return false; |
65 } | 65 } |
66 SkCanvas canvas(device); | 66 SkCanvas canvas(device); |
67 SkPaint paint; | 67 SkPaint paint; |
68 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 68 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
69 | 69 |
70 SkMatrix shaderMatrix; | 70 SkMatrix shaderMatrix; |
71 shaderMatrix.setTranslate(SkIntToScalar(srcOffset.fX), | 71 shaderMatrix.setTranslate(SkIntToScalar(srcOffset.fX), |
72 SkIntToScalar(srcOffset.fY)); | 72 SkIntToScalar(srcOffset.fY)); |
73 SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(subset, | 73 SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(subset, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 str->appendf(" dst: %.2f %.2f %.2f %.2f", | 121 str->appendf(" dst: %.2f %.2f %.2f %.2f", |
122 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); | 122 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); |
123 if (this->getInput(0)) { | 123 if (this->getInput(0)) { |
124 str->appendf("input: ("); | 124 str->appendf("input: ("); |
125 this->getInput(0)->toString(str); | 125 this->getInput(0)->toString(str); |
126 str->appendf(")"); | 126 str->appendf(")"); |
127 } | 127 } |
128 str->append(")"); | 128 str->append(")"); |
129 } | 129 } |
130 #endif | 130 #endif |
OLD | NEW |