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 bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, const S
kMatrix& ctm, | 19 bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, const S
kImageFilter::Context& ctx, |
20 SkBitmap* dst, SkIPoint* offset) const { | 20 SkBitmap* dst, SkIPoint* offset) const { |
21 SkBitmap source = src; | 21 SkBitmap source = src; |
22 SkImageFilter* input = getInput(0); | 22 SkImageFilter* input = getInput(0); |
23 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 23 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
24 if (input && !input->filterImage(proxy, src, ctm, &source, &srcOffset)) { | 24 if (input && !input->filterImage(proxy, src, ctx, &source, &srcOffset)) { |
25 return false; | 25 return false; |
26 } | 26 } |
27 | 27 |
28 SkRect dstRect; | 28 SkRect dstRect; |
29 ctm.mapRect(&dstRect, fDstRect); | 29 ctx.ctm().mapRect(&dstRect, fDstRect); |
30 SkIRect dstIRect; | 30 SkIRect dstIRect; |
31 dstRect.roundOut(&dstIRect); | 31 dstRect.roundOut(&dstIRect); |
32 int w = dstIRect.width(); | 32 int w = dstIRect.width(); |
33 int h = dstIRect.height(); | 33 int h = dstIRect.height(); |
34 if (!fSrcRect.width() || !fSrcRect.height() || !w || !h) { | 34 if (!fSrcRect.width() || !fSrcRect.height() || !w || !h) { |
35 return false; | 35 return false; |
36 } | 36 } |
37 | 37 |
38 SkRect srcRect; | 38 SkRect srcRect; |
39 ctm.mapRect(&srcRect, fSrcRect); | 39 ctx.ctm().mapRect(&srcRect, fSrcRect); |
40 SkIRect srcIRect; | 40 SkIRect srcIRect; |
41 srcRect.roundOut(&srcIRect); | 41 srcRect.roundOut(&srcIRect); |
42 srcIRect.offset(-srcOffset); | 42 srcIRect.offset(-srcOffset); |
43 SkBitmap subset; | 43 SkBitmap subset; |
44 SkIRect bounds; | 44 SkIRect bounds; |
45 source.getBounds(&bounds); | 45 source.getBounds(&bounds); |
46 | 46 |
47 if (!srcIRect.intersect(bounds)) { | 47 if (!srcIRect.intersect(bounds)) { |
48 offset->fX = offset->fY = 0; | 48 offset->fX = offset->fY = 0; |
49 return true; | 49 return true; |
(...skipping 29 matching lines...) Expand all Loading... |
79 buffer.readRect(&fSrcRect); | 79 buffer.readRect(&fSrcRect); |
80 buffer.readRect(&fDstRect); | 80 buffer.readRect(&fDstRect); |
81 buffer.validate(buffer.isValid() && SkIsValidRect(fSrcRect) && SkIsValidRect
(fDstRect)); | 81 buffer.validate(buffer.isValid() && SkIsValidRect(fSrcRect) && SkIsValidRect
(fDstRect)); |
82 } | 82 } |
83 | 83 |
84 void SkTileImageFilter::flatten(SkWriteBuffer& buffer) const { | 84 void SkTileImageFilter::flatten(SkWriteBuffer& buffer) const { |
85 this->INHERITED::flatten(buffer); | 85 this->INHERITED::flatten(buffer); |
86 buffer.writeRect(fSrcRect); | 86 buffer.writeRect(fSrcRect); |
87 buffer.writeRect(fDstRect); | 87 buffer.writeRect(fDstRect); |
88 } | 88 } |
OLD | NEW |