OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkPaintImageFilter.h" | 8 #include "SkPaintImageFilter.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 SkIPoint* offset) const { | 38 SkIPoint* offset) const { |
39 SkIRect bounds; | 39 SkIRect bounds; |
40 const SkIRect srcBounds = SkIRect::MakeWH(source->width(), source->height())
; | 40 const SkIRect srcBounds = SkIRect::MakeWH(source->width(), source->height())
; |
41 if (!this->applyCropRect(ctx, srcBounds, &bounds)) { | 41 if (!this->applyCropRect(ctx, srcBounds, &bounds)) { |
42 return nullptr; | 42 return nullptr; |
43 } | 43 } |
44 | 44 |
45 SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(), | 45 SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(), |
46 kPremul_SkAlphaType); | 46 kPremul_SkAlphaType); |
47 | 47 |
48 SkAutoTUnref<SkSpecialSurface> surf(source->newSurface(info)); | 48 sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); |
49 if (!surf) { | 49 if (!surf) { |
50 return nullptr; | 50 return nullptr; |
51 } | 51 } |
52 | 52 |
53 SkCanvas* canvas = surf->getCanvas(); | 53 SkCanvas* canvas = surf->getCanvas(); |
54 SkASSERT(canvas); | 54 SkASSERT(canvas); |
55 | 55 |
56 canvas->clear(0x0); | 56 canvas->clear(0x0); |
57 | 57 |
58 SkMatrix matrix(ctx.ctm()); | 58 SkMatrix matrix(ctx.ctm()); |
59 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to
p())); | 59 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to
p())); |
60 SkRect rect = SkRect::MakeIWH(bounds.width(), bounds.height()); | 60 SkRect rect = SkRect::MakeIWH(bounds.width(), bounds.height()); |
61 SkMatrix inverse; | 61 SkMatrix inverse; |
62 if (matrix.invert(&inverse)) { | 62 if (matrix.invert(&inverse)) { |
63 inverse.mapRect(&rect); | 63 inverse.mapRect(&rect); |
64 } | 64 } |
65 canvas->setMatrix(matrix); | 65 canvas->setMatrix(matrix); |
66 canvas->drawRect(rect, fPaint); | 66 canvas->drawRect(rect, fPaint); |
67 | 67 |
68 offset->fX = bounds.fLeft; | 68 offset->fX = bounds.fLeft; |
69 offset->fY = bounds.fTop; | 69 offset->fY = bounds.fTop; |
70 return surf->newImageSnapshot(); | 70 return surf->makeImageSnapshot().release(); |
71 } | 71 } |
72 | 72 |
73 bool SkPaintImageFilter::canComputeFastBounds() const { | 73 bool SkPaintImageFilter::canComputeFastBounds() const { |
74 // http:skbug.com/4627: "make computeFastBounds and onFilterBounds() CropRec
t-aware" | 74 // http:skbug.com/4627: "make computeFastBounds and onFilterBounds() CropRec
t-aware" |
75 // computeFastBounds() doesn't currently take the crop rect into account, | 75 // computeFastBounds() doesn't currently take the crop rect into account, |
76 // so we can't compute it. If a full crop rect is set, we should return true
here. | 76 // so we can't compute it. If a full crop rect is set, we should return true
here. |
77 return false; | 77 return false; |
78 } | 78 } |
79 | 79 |
80 #ifndef SK_IGNORE_TO_STRING | 80 #ifndef SK_IGNORE_TO_STRING |
81 void SkPaintImageFilter::toString(SkString* str) const { | 81 void SkPaintImageFilter::toString(SkString* str) const { |
82 str->appendf("SkPaintImageFilter: ("); | 82 str->appendf("SkPaintImageFilter: ("); |
83 str->append(")"); | 83 str->append(")"); |
84 } | 84 } |
85 #endif | 85 #endif |
OLD | NEW |