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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 if (!colorTexture || !displTexture) { | 316 if (!colorTexture || !displTexture) { |
317 return nullptr; | 317 return nullptr; |
318 } | 318 } |
319 | 319 |
320 GrSurfaceDesc desc; | 320 GrSurfaceDesc desc; |
321 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 321 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
322 desc.fWidth = bounds.width(); | 322 desc.fWidth = bounds.width(); |
323 desc.fHeight = bounds.height(); | 323 desc.fHeight = bounds.height(); |
324 desc.fConfig = kSkia8888_GrPixelConfig; | 324 desc.fConfig = kSkia8888_GrPixelConfig; |
325 | 325 |
326 SkAutoTUnref<GrTexture> dst(context->textureProvider()->createApproxText
ure(desc)); | 326 sk_sp<GrTexture> dst(context->textureProvider()->createApproxTexture(des
c)); |
327 if (!dst) { | 327 if (!dst) { |
328 return nullptr; | 328 return nullptr; |
329 } | 329 } |
330 | 330 |
331 GrPaint paint; | 331 GrPaint paint; |
332 SkMatrix offsetMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(displ
Texture.get()); | 332 SkMatrix offsetMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(displ
Texture.get()); |
333 offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displOffset.fX)
, | 333 offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displOffset.fX)
, |
334 SkIntToScalar(colorOffset.fY - displOffset.fY)
); | 334 SkIntToScalar(colorOffset.fY - displOffset.fY)
); |
335 | 335 |
336 paint.addColorFragmentProcessor( | 336 paint.addColorFragmentProcessor( |
(...skipping 13 matching lines...) Expand all Loading... |
350 if (!drawContext) { | 350 if (!drawContext) { |
351 return nullptr; | 351 return nullptr; |
352 } | 352 } |
353 | 353 |
354 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(co
lorBounds)); | 354 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(co
lorBounds)); |
355 | 355 |
356 offset->fX = bounds.left(); | 356 offset->fX = bounds.left(); |
357 offset->fY = bounds.top(); | 357 offset->fY = bounds.top(); |
358 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bound
s.height()), | 358 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bound
s.height()), |
359 kNeedNewImageUniqueID_SpecialImage, | 359 kNeedNewImageUniqueID_SpecialImage, |
360 dst); | 360 std::move(dst)); |
361 } | 361 } |
362 #endif | 362 #endif |
363 | 363 |
364 SkBitmap colorBM, displBM; | 364 SkBitmap colorBM, displBM; |
365 | 365 |
366 if (!color->getROPixels(&colorBM) || !displ->getROPixels(&displBM)) { | 366 if (!color->getROPixels(&colorBM) || !displ->getROPixels(&displBM)) { |
367 return nullptr; | 367 return nullptr; |
368 } | 368 } |
369 | 369 |
370 if ((colorBM.colorType() != kN32_SkColorType) || | 370 if ((colorBM.colorType() != kN32_SkColorType) || |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, | 626 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, |
627 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { | 627 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { |
628 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); | 628 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); |
629 | 629 |
630 uint32_t xKey = displacementMap.xChannelSelector(); | 630 uint32_t xKey = displacementMap.xChannelSelector(); |
631 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; | 631 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
632 | 632 |
633 b->add32(xKey | yKey); | 633 b->add32(xKey | yKey); |
634 } | 634 } |
635 #endif | 635 #endif |
OLD | NEW |