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