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 #include "SkReadBuffer.h" | 9 #include "SkReadBuffer.h" |
10 #include "SkWriteBuffer.h" | 10 #include "SkWriteBuffer.h" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 GrTexture* displacement = displacementBM.getTexture(); | 382 GrTexture* displacement = displacementBM.getTexture(); |
383 GrContext* context = color->getContext(); | 383 GrContext* context = color->getContext(); |
384 | 384 |
385 GrTextureDesc desc; | 385 GrTextureDesc desc; |
386 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; | 386 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; |
387 desc.fWidth = bounds.width(); | 387 desc.fWidth = bounds.width(); |
388 desc.fHeight = bounds.height(); | 388 desc.fHeight = bounds.height(); |
389 desc.fConfig = kSkia8888_GrPixelConfig; | 389 desc.fConfig = kSkia8888_GrPixelConfig; |
390 | 390 |
391 GrAutoScratchTexture ast(context, desc); | 391 GrAutoScratchTexture ast(context, desc); |
| 392 if (NULL == ast.texture()) { |
| 393 return false; |
| 394 } |
392 SkAutoTUnref<GrTexture> dst(ast.detach()); | 395 SkAutoTUnref<GrTexture> dst(ast.detach()); |
393 | 396 |
394 GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); | 397 GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); |
395 | 398 |
396 SkVector scale = SkVector::Make(fScale, fScale); | 399 SkVector scale = SkVector::Make(fScale, fScale); |
397 ctx.ctm().mapVectors(&scale, 1); | 400 ctx.ctm().mapVectors(&scale, 1); |
398 | 401 |
399 GrPaint paint; | 402 GrPaint paint; |
400 SkMatrix offsetMatrix = GrEffect::MakeDivByTextureWHMatrix(displacement); | 403 SkMatrix offsetMatrix = GrEffect::MakeDivByTextureWHMatrix(displacement); |
401 offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset.
fX), | 404 offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset.
fX), |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 const GrGLCaps&, GrEffectKeyBuilder* b) { | 607 const GrGLCaps&, GrEffectKeyBuilder* b) { |
605 const GrDisplacementMapEffect& displacementMap = | 608 const GrDisplacementMapEffect& displacementMap = |
606 drawEffect.castEffect<GrDisplacementMapEffect>(); | 609 drawEffect.castEffect<GrDisplacementMapEffect>(); |
607 | 610 |
608 uint32_t xKey = displacementMap.xChannelSelector(); | 611 uint32_t xKey = displacementMap.xChannelSelector(); |
609 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; | 612 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
610 | 613 |
611 b->add32(xKey | yKey); | 614 b->add32(xKey | yKey); |
612 } | 615 } |
613 #endif | 616 #endif |
OLD | NEW |