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 "SkLightingImageFilter.h" | 8 #include "SkLightingImageFilter.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 SkASSERT(inputTexture); | 408 SkASSERT(inputTexture); |
409 | 409 |
410 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kAppr
ox, | 410 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kAppr
ox, |
411 offsetBounds.width(
), | 411 offsetBounds.width(
), |
412 offsetBounds.height
(), | 412 offsetBounds.height
(), |
413 kRGBA_8888_GrPixelC
onfig)); | 413 kRGBA_8888_GrPixelC
onfig)); |
414 if (!drawContext) { | 414 if (!drawContext) { |
415 return nullptr; | 415 return nullptr; |
416 } | 416 } |
417 | 417 |
418 SkRect dstRect = SkRect::MakeWH(SkIntToScalar(offsetBounds.width()), | 418 const SkIRect& dstRect = SkIRect::MakeWH(offsetBounds.width(), offsetBounds.
height()); |
419 SkIntToScalar(offsetBounds.height())); | |
420 | 419 |
421 // setup new clip | 420 // setup new clip |
422 GrClip clip(dstRect); | 421 GrFixedClip clip(dstRect); |
423 | 422 |
424 const SkIRect inputBounds = SkIRect::MakeWH(input->width(), input->height())
; | 423 const SkIRect inputBounds = SkIRect::MakeWH(input->width(), input->height())
; |
425 SkRect topLeft = SkRect::MakeXYWH(0, 0, 1, 1); | 424 SkRect topLeft = SkRect::MakeXYWH(0, 0, 1, 1); |
426 SkRect top = SkRect::MakeXYWH(1, 0, dstRect.width() - 2, 1); | 425 SkRect top = SkRect::MakeXYWH(1, 0, dstRect.width() - 2, 1); |
427 SkRect topRight = SkRect::MakeXYWH(dstRect.width() - 1, 0, 1, 1); | 426 SkRect topRight = SkRect::MakeXYWH(dstRect.width() - 1, 0, 1, 1); |
428 SkRect left = SkRect::MakeXYWH(0, 1, 1, dstRect.height() - 2); | 427 SkRect left = SkRect::MakeXYWH(0, 1, 1, dstRect.height() - 2); |
429 SkRect interior = dstRect.makeInset(1, 1); | 428 SkRect interior = SkRect::Make(dstRect.makeInset(1, 1)); |
430 SkRect right = SkRect::MakeXYWH(dstRect.width() - 1, 1, 1, dstRect.height()
- 2); | 429 SkRect right = SkRect::MakeXYWH(dstRect.width() - 1, 1, 1, dstRect.height()
- 2); |
431 SkRect bottomLeft = SkRect::MakeXYWH(0, dstRect.height() - 1, 1, 1); | 430 SkRect bottomLeft = SkRect::MakeXYWH(0, dstRect.height() - 1, 1, 1); |
432 SkRect bottom = SkRect::MakeXYWH(1, dstRect.height() - 1, dstRect.width() -
2, 1); | 431 SkRect bottom = SkRect::MakeXYWH(1, dstRect.height() - 1, dstRect.width() -
2, 1); |
433 SkRect bottomRight = SkRect::MakeXYWH(dstRect.width() - 1, dstRect.height()
- 1, 1, 1); | 432 SkRect bottomRight = SkRect::MakeXYWH(dstRect.width() - 1, dstRect.height()
- 1, 1, 1); |
434 | 433 |
435 const SkIRect* pSrcBounds = inputBounds.contains(offsetBounds) ? nullptr : &
inputBounds; | 434 const SkIRect* pSrcBounds = inputBounds.contains(offsetBounds) ? nullptr : &
inputBounds; |
436 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, topLeft, | 435 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, topLeft, |
437 kTopLeft_BoundaryMode, pSrcBounds, offsetBounds); | 436 kTopLeft_BoundaryMode, pSrcBounds, offsetBounds); |
438 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, top, kTo
p_BoundaryMode, | 437 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, top, kTo
p_BoundaryMode, |
439 pSrcBounds, offsetBounds); | 438 pSrcBounds, offsetBounds); |
(...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2163 | 2162 |
2164 fragBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); | 2163 fragBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); |
2165 } | 2164 } |
2166 | 2165 |
2167 #endif | 2166 #endif |
2168 | 2167 |
2169 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) | 2168 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) |
2170 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) | 2169 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) |
2171 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) | 2170 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) |
2172 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 2171 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |