Chromium Code Reviews| 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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 GrTexture* color = colorBM.getTexture(); | 407 GrTexture* color = colorBM.getTexture(); |
| 408 GrTexture* displacement = displacementBM.getTexture(); | 408 GrTexture* displacement = displacementBM.getTexture(); |
| 409 GrContext* context = color->getContext(); | 409 GrContext* context = color->getContext(); |
| 410 | 410 |
| 411 GrTextureDesc desc; | 411 GrTextureDesc desc; |
| 412 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; | 412 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; |
| 413 desc.fWidth = bounds.width(); | 413 desc.fWidth = bounds.width(); |
| 414 desc.fHeight = bounds.height(); | 414 desc.fHeight = bounds.height(); |
| 415 desc.fConfig = kSkia8888_GrPixelConfig; | 415 desc.fConfig = kSkia8888_GrPixelConfig; |
| 416 | 416 |
| 417 GrAutoScratchTexture ast(context, desc); | 417 SkAutoTUnref<GrTexture> dst( |
| 418 if (NULL == ast.texture()) { | 418 context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); |
|
robertphillips
2014/10/09 17:19:50
if (!dst) {
return false;
}
?
bsalomon
2014/10/13 15:42:01
Done.
| |
| 419 return false; | |
| 420 } | |
| 421 SkAutoTUnref<GrTexture> dst(ast.detach()); | |
| 422 | 419 |
| 423 GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); | 420 GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); |
| 424 | 421 |
| 425 SkVector scale = SkVector::Make(fScale, fScale); | 422 SkVector scale = SkVector::Make(fScale, fScale); |
| 426 ctx.ctm().mapVectors(&scale, 1); | 423 ctx.ctm().mapVectors(&scale, 1); |
| 427 | 424 |
| 428 GrPaint paint; | 425 GrPaint paint; |
| 429 SkMatrix offsetMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(displacem ent); | 426 SkMatrix offsetMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(displacem ent); |
| 430 offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset. fX), | 427 offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset. fX), |
| 431 SkIntToScalar(colorOffset.fY - displacementOffset. fY)); | 428 SkIntToScalar(colorOffset.fY - displacementOffset. fY)); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 632 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, | 629 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, |
| 633 const GrGLCaps&, GrProcessorKeyBuilder* b ) { | 630 const GrGLCaps&, GrProcessorKeyBuilder* b ) { |
| 634 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>(); | 631 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>(); |
| 635 | 632 |
| 636 uint32_t xKey = displacementMap.xChannelSelector(); | 633 uint32_t xKey = displacementMap.xChannelSelector(); |
| 637 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s; | 634 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s; |
| 638 | 635 |
| 639 b->add32(xKey | yKey); | 636 b->add32(xKey | yKey); |
| 640 } | 637 } |
| 641 #endif | 638 #endif |
| OLD | NEW |