OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkDisplacementMapEffect.h" | 8 #include "SkDisplacementMapEffect.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 fYChannelSelector, | 328 fYChannelSelector, |
329 scale, | 329 scale, |
330 displTexture.get(), | 330 displTexture.get(), |
331 offsetMatrix, | 331 offsetMatrix, |
332 colorTexture.get(), | 332 colorTexture.get(), |
333 SkISize::Make(color->width(), color->h
eight()))); | 333 SkISize::Make(color->width(), color->h
eight()))); |
334 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 334 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
335 SkMatrix matrix; | 335 SkMatrix matrix; |
336 matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colo
rBounds.y())); | 336 matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colo
rBounds.y())); |
337 | 337 |
338 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::k
Approx, | 338 sk_sp<GrDrawContext> drawContext( |
339 bounds.width(),
bounds.height(), | 339 context->newDrawContext(SkBackingFit::kApprox, bounds.width(), bound
s.height(), |
340 kSkia8888_GrPix
elConfig)); | 340 kSkia8888_GrPixelConfig, sk_ref_sp(source->g
etColorSpace()))); |
341 if (!drawContext) { | 341 if (!drawContext) { |
342 return nullptr; | 342 return nullptr; |
343 } | 343 } |
344 | 344 |
345 drawContext->drawRect(GrNoClip(), paint, matrix, SkRect::Make(colorBound
s)); | 345 drawContext->drawRect(GrNoClip(), paint, matrix, SkRect::Make(colorBound
s)); |
346 | 346 |
347 offset->fX = bounds.left(); | 347 offset->fX = bounds.left(); |
348 offset->fY = bounds.top(); | 348 offset->fY = bounds.top(); |
349 // TODO: Get the colorSpace from the drawContext (once it has one) | |
350 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bound
s.height()), | 349 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bound
s.height()), |
351 kNeedNewImageUniqueID_SpecialImage, | 350 kNeedNewImageUniqueID_SpecialImage, |
352 drawContext->asTexture(), | 351 drawContext->asTexture(), |
353 sk_ref_sp(source->getColorSpace())); | 352 sk_ref_sp(drawContext->getColorSpace(
))); |
354 } | 353 } |
355 #endif | 354 #endif |
356 | 355 |
357 SkBitmap colorBM, displBM; | 356 SkBitmap colorBM, displBM; |
358 | 357 |
359 if (!color->getROPixels(&colorBM) || !displ->getROPixels(&displBM)) { | 358 if (!color->getROPixels(&colorBM) || !displ->getROPixels(&displBM)) { |
360 return nullptr; | 359 return nullptr; |
361 } | 360 } |
362 | 361 |
363 if ((colorBM.colorType() != kN32_SkColorType) || | 362 if ((colorBM.colorType() != kN32_SkColorType) || |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, | 618 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, |
620 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { | 619 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { |
621 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); | 620 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); |
622 | 621 |
623 uint32_t xKey = displacementMap.xChannelSelector(); | 622 uint32_t xKey = displacementMap.xChannelSelector(); |
624 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; | 623 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
625 | 624 |
626 b->add32(xKey | yKey); | 625 b->add32(xKey | yKey); |
627 } | 626 } |
628 #endif | 627 #endif |
OLD | NEW |