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 "SkOffsetImageFilter.h" | 8 #include "SkOffsetImageFilter.h" |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 offset->fY = srcOffset.fY + SkScalarRoundToInt(vec.fY); | 42 offset->fY = srcOffset.fY + SkScalarRoundToInt(vec.fY); |
43 return input; | 43 return input; |
44 } else { | 44 } else { |
45 SkIRect bounds; | 45 SkIRect bounds; |
46 SkIRect srcBounds = SkIRect::MakeWH(input->width(), input->height()); | 46 SkIRect srcBounds = SkIRect::MakeWH(input->width(), input->height()); |
47 srcBounds.offset(srcOffset); | 47 srcBounds.offset(srcOffset); |
48 if (!this->applyCropRect(ctx, srcBounds, &bounds)) { | 48 if (!this->applyCropRect(ctx, srcBounds, &bounds)) { |
49 return nullptr; | 49 return nullptr; |
50 } | 50 } |
51 | 51 |
52 sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(),
bounds.size())); | 52 SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(), |
| 53 kPremul_SkAlphaType); |
| 54 sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); |
53 if (!surf) { | 55 if (!surf) { |
54 return nullptr; | 56 return nullptr; |
55 } | 57 } |
56 | 58 |
57 SkCanvas* canvas = surf->getCanvas(); | 59 SkCanvas* canvas = surf->getCanvas(); |
58 SkASSERT(canvas); | 60 SkASSERT(canvas); |
59 | 61 |
60 // TODO: it seems like this clear shouldn't be necessary (see skbug.com/
5075) | 62 // TODO: it seems like this clear shouldn't be necessary (see skbug.com/
5075) |
61 canvas->clear(0x0); | 63 canvas->clear(0x0); |
62 | 64 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 void SkOffsetImageFilter::toString(SkString* str) const { | 115 void SkOffsetImageFilter::toString(SkString* str) const { |
114 str->appendf("SkOffsetImageFilter: ("); | 116 str->appendf("SkOffsetImageFilter: ("); |
115 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY); | 117 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY); |
116 str->append("input: ("); | 118 str->append("input: ("); |
117 if (this->getInput(0)) { | 119 if (this->getInput(0)) { |
118 this->getInput(0)->toString(str); | 120 this->getInput(0)->toString(str); |
119 } | 121 } |
120 str->append("))"); | 122 str->append("))"); |
121 } | 123 } |
122 #endif | 124 #endif |
OLD | NEW |