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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkMagnifierImageFilter.h" | 9 #include "SkMagnifierImageFilter.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 225 } |
226 | 226 |
227 void GrMagnifierEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ | 227 void GrMagnifierEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ |
228 this->updateInvariantOutputForModulation(inout); | 228 this->updateInvariantOutputForModulation(inout); |
229 } | 229 } |
230 | 230 |
231 #endif | 231 #endif |
232 | 232 |
233 //////////////////////////////////////////////////////////////////////////////// | 233 //////////////////////////////////////////////////////////////////////////////// |
234 | 234 |
235 SkImageFilter* SkMagnifierImageFilter::Create(const SkRect& srcRect, SkScalar in
set, | 235 sk_sp<SkImageFilter> SkMagnifierImageFilter::Make(const SkRect& srcRect, SkScala
r inset, |
236 SkImageFilter* input) { | 236 sk_sp<SkImageFilter> input) { |
237 | 237 |
238 if (!SkScalarIsFinite(inset) || !SkIsValidRect(srcRect)) { | 238 if (!SkScalarIsFinite(inset) || !SkIsValidRect(srcRect)) { |
239 return nullptr; | 239 return nullptr; |
240 } | 240 } |
241 // Negative numbers in src rect are not supported | 241 // Negative numbers in src rect are not supported |
242 if (srcRect.fLeft < 0 || srcRect.fTop < 0) { | 242 if (srcRect.fLeft < 0 || srcRect.fTop < 0) { |
243 return nullptr; | 243 return nullptr; |
244 } | 244 } |
245 return new SkMagnifierImageFilter(srcRect, inset, input); | 245 return sk_sp<SkImageFilter>(new SkMagnifierImageFilter(srcRect, inset, std::
move(input))); |
246 } | 246 } |
247 | 247 |
248 | 248 |
249 SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar i
nset, | 249 SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar i
nset, |
250 SkImageFilter* input) | 250 sk_sp<SkImageFilter> input) |
251 : INHERITED(1, &input), fSrcRect(srcRect), fInset(inset) { | 251 : INHERITED(&input, 1, nullptr) |
| 252 , fSrcRect(srcRect) |
| 253 , fInset(inset) { |
252 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0); | 254 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0); |
253 } | 255 } |
254 | 256 |
255 #if SK_SUPPORT_GPU | 257 #if SK_SUPPORT_GPU |
256 bool SkMagnifierImageFilter::asFragmentProcessor(GrFragmentProcessor** fp, | 258 bool SkMagnifierImageFilter::asFragmentProcessor(GrFragmentProcessor** fp, |
257 GrTexture* texture, const SkMat
rix&, | 259 GrTexture* texture, const SkMat
rix&, |
258 const SkIRect&bounds) const { | 260 const SkIRect&bounds) const { |
259 if (fp) { | 261 if (fp) { |
260 SkScalar yOffset = texture->origin() == kTopLeft_GrSurfaceOrigin ? fSrcR
ect.y() : | 262 SkScalar yOffset = texture->origin() == kTopLeft_GrSurfaceOrigin ? fSrcR
ect.y() : |
261 texture->height() - fSrcRect.height() * texture->height() / bounds.he
ight() | 263 texture->height() - fSrcRect.height() * texture->height() / bounds.he
ight() |
(...skipping 16 matching lines...) Expand all Loading... |
278 bounds.height() * invInset); | 280 bounds.height() * invInset); |
279 } | 281 } |
280 return true; | 282 return true; |
281 } | 283 } |
282 #endif | 284 #endif |
283 | 285 |
284 sk_sp<SkFlattenable> SkMagnifierImageFilter::CreateProc(SkReadBuffer& buffer) { | 286 sk_sp<SkFlattenable> SkMagnifierImageFilter::CreateProc(SkReadBuffer& buffer) { |
285 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 287 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
286 SkRect src; | 288 SkRect src; |
287 buffer.readRect(&src); | 289 buffer.readRect(&src); |
288 return sk_sp<SkFlattenable>(Create(src, buffer.readScalar(), common.getInput
(0).get())); | 290 return Make(src, buffer.readScalar(), common.getInput(0)); |
289 } | 291 } |
290 | 292 |
291 void SkMagnifierImageFilter::flatten(SkWriteBuffer& buffer) const { | 293 void SkMagnifierImageFilter::flatten(SkWriteBuffer& buffer) const { |
292 this->INHERITED::flatten(buffer); | 294 this->INHERITED::flatten(buffer); |
293 buffer.writeRect(fSrcRect); | 295 buffer.writeRect(fSrcRect); |
294 buffer.writeScalar(fInset); | 296 buffer.writeScalar(fInset); |
295 } | 297 } |
296 | 298 |
297 bool SkMagnifierImageFilter::onFilterImageDeprecated(Proxy* proxy, const SkBitma
p& src, | 299 bool SkMagnifierImageFilter::onFilterImageDeprecated(Proxy* proxy, const SkBitma
p& src, |
298 const Context&, SkBitmap* d
st, | 300 const Context&, SkBitmap* d
st, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 | 367 |
366 #ifndef SK_IGNORE_TO_STRING | 368 #ifndef SK_IGNORE_TO_STRING |
367 void SkMagnifierImageFilter::toString(SkString* str) const { | 369 void SkMagnifierImageFilter::toString(SkString* str) const { |
368 str->appendf("SkMagnifierImageFilter: ("); | 370 str->appendf("SkMagnifierImageFilter: ("); |
369 str->appendf("src: (%f,%f,%f,%f) ", | 371 str->appendf("src: (%f,%f,%f,%f) ", |
370 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m); | 372 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m); |
371 str->appendf("inset: %f", fInset); | 373 str->appendf("inset: %f", fInset); |
372 str->append(")"); | 374 str->append(")"); |
373 } | 375 } |
374 #endif | 376 #endif |
OLD | NEW |