OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkImageSource.h" | 8 #include "SkImageSource.h" |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 sk_sp<SkSpecialImage> SkImageSource::onFilterImage(SkSpecialImage* source, const
Context& ctx, | 80 sk_sp<SkSpecialImage> SkImageSource::onFilterImage(SkSpecialImage* source, const
Context& ctx, |
81 SkIPoint* offset) const { | 81 SkIPoint* offset) const { |
82 SkRect dstRect; | 82 SkRect dstRect; |
83 ctx.ctm().mapRect(&dstRect, fDstRect); | 83 ctx.ctm().mapRect(&dstRect, fDstRect); |
84 | 84 |
85 SkRect bounds = SkRect::MakeIWH(fImage->width(), fImage->height()); | 85 SkRect bounds = SkRect::MakeIWH(fImage->width(), fImage->height()); |
86 if (fSrcRect == bounds && dstRect == bounds) { | 86 if (fSrcRect == bounds && dstRect == bounds) { |
87 // No regions cropped out or resized; return entire image. | 87 // No regions cropped out or resized; return entire image. |
88 offset->fX = offset->fY = 0; | 88 offset->fX = offset->fY = 0; |
89 return SkSpecialImage::MakeFromImage(source->internal_getProxy(), | 89 return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(fImage->width(), fI
mage->height()), |
90 SkIRect::MakeWH(fImage->width(), fI
mage->height()), | |
91 fImage, | 90 fImage, |
92 &source->props()); | 91 &source->props()); |
93 } | 92 } |
94 | 93 |
95 const SkIRect dstIRect = dstRect.roundOut(); | 94 const SkIRect dstIRect = dstRect.roundOut(); |
96 | 95 |
97 // SRGBTODO: Propagate SkColorType? | 96 // SRGBTODO: Propagate SkColorType? |
98 const SkImageInfo info = SkImageInfo::MakeN32(dstIRect.width(), dstIRect.hei
ght(), | 97 const SkImageInfo info = SkImageInfo::MakeN32(dstIRect.width(), dstIRect.hei
ght(), |
99 kPremul_SkAlphaType); | 98 kPremul_SkAlphaType); |
100 | 99 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 void SkImageSource::toString(SkString* str) const { | 134 void SkImageSource::toString(SkString* str) const { |
136 str->appendf("SkImageSource: ("); | 135 str->appendf("SkImageSource: ("); |
137 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", | 136 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", |
138 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m, | 137 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m, |
139 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); | 138 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); |
140 str->appendf("image: (%d,%d)", | 139 str->appendf("image: (%d,%d)", |
141 fImage->width(), fImage->height()); | 140 fImage->width(), fImage->height()); |
142 str->append(")"); | 141 str->append(")"); |
143 } | 142 } |
144 #endif | 143 #endif |
OLD | NEW |