Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 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 "SkDraw.h" | 8 #include "SkDraw.h" |
| 9 #include "SkBlitter.h" | 9 #include "SkBlitter.h" |
| 10 #include "SkBounder.h" | 10 #include "SkBounder.h" |
| (...skipping 2385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2396 m.reset(); | 2396 m.reset(); |
| 2397 m.set(0, pts[index1].fX - pts[index0].fX); | 2397 m.set(0, pts[index1].fX - pts[index0].fX); |
| 2398 m.set(1, pts[index2].fX - pts[index0].fX); | 2398 m.set(1, pts[index2].fX - pts[index0].fX); |
| 2399 m.set(2, pts[index0].fX); | 2399 m.set(2, pts[index0].fX); |
| 2400 m.set(3, pts[index1].fY - pts[index0].fY); | 2400 m.set(3, pts[index1].fY - pts[index0].fY); |
| 2401 m.set(4, pts[index2].fY - pts[index0].fY); | 2401 m.set(4, pts[index2].fY - pts[index0].fY); |
| 2402 m.set(5, pts[index0].fY); | 2402 m.set(5, pts[index0].fY); |
| 2403 if (!m.invert(&im)) { | 2403 if (!m.invert(&im)) { |
| 2404 return false; | 2404 return false; |
| 2405 } | 2405 } |
| 2406 fDstToUnit.setConcat(im, this->getTotalInverse()); | 2406 SkMatrix ctmInv; |
| 2407 if (!this->getCTM().invert(&ctmInv)) { | |
| 2408 return false; | |
| 2409 } | |
| 2410 fDstToUnit.setConcat(im, ctmInv); | |
| 2407 return true; | 2411 return true; |
| 2408 } | 2412 } |
| 2409 | 2413 |
| 2410 #include "SkColorPriv.h" | 2414 #include "SkColorPriv.h" |
| 2411 #include "SkComposeShader.h" | 2415 #include "SkComposeShader.h" |
| 2412 | 2416 |
| 2413 static int ScalarTo256(SkScalar v) { | 2417 static int ScalarTo256(SkScalar v) { |
| 2414 int scale = SkScalarToFixed(v) >> 8; | 2418 int scale = SkScalarToFixed(v) >> 8; |
| 2415 if (scale < 0) { | 2419 if (scale < 0) { |
| 2416 scale = 0; | 2420 scale = 0; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2549 // Abort early if we failed to create a shader context. | 2553 // Abort early if we failed to create a shader context. |
| 2550 if (blitter->isNullBlitter()) { | 2554 if (blitter->isNullBlitter()) { |
| 2551 return; | 2555 return; |
| 2552 } | 2556 } |
| 2553 | 2557 |
| 2554 // setup our state and function pointer for iterating triangles | 2558 // setup our state and function pointer for iterating triangles |
| 2555 VertState state(count, indices, indexCount); | 2559 VertState state(count, indices, indexCount); |
| 2556 VertState::Proc vertProc = state.chooseProc(vmode); | 2560 VertState::Proc vertProc = state.chooseProc(vmode); |
| 2557 | 2561 |
| 2558 if (NULL != textures || NULL != colors) { | 2562 if (NULL != textures || NULL != colors) { |
| 2559 SkMatrix tempM; | |
| 2560 SkMatrix savedLocalM; | |
| 2561 if (shader) { | |
| 2562 savedLocalM = shader->getLocalMatrix(); | |
| 2563 } | |
| 2564 | |
| 2565 while (vertProc(&state)) { | 2563 while (vertProc(&state)) { |
| 2566 if (NULL != textures) { | 2564 if (NULL != textures) { |
| 2565 SkMatrix tempM; | |
| 2567 if (texture_to_matrix(state, vertices, textures, &tempM)) { | 2566 if (texture_to_matrix(state, vertices, textures, &tempM)) { |
| 2568 tempM.postConcat(savedLocalM); | 2567 SkShader::ContextRec rec(*fBitmap, p, *fMatrix); |
| 2569 shader->setLocalMatrix(tempM); | 2568 rec.fLocalMatrix = &tempM; |
| 2570 if (!blitter->resetShaderContext(*fBitmap, p, *fMatrix)) { | 2569 if (!blitter->resetShaderContext(rec)) { |
|
Dominik Grewe
2014/05/06 13:48:51
'shader->setLocalMatrix()' is changing the LM of t
reed1
2014/05/06 14:07:58
Correct, but composeshader forwards that LM to its
| |
| 2571 continue; | 2570 continue; |
| 2572 } | 2571 } |
| 2573 } | 2572 } |
| 2574 } | 2573 } |
| 2575 if (NULL != colors) { | 2574 if (NULL != colors) { |
| 2576 // Find the context for triShader. | 2575 // Find the context for triShader. |
| 2577 SkTriColorShader::TriColorShaderContext* triColorShaderContext; | 2576 SkTriColorShader::TriColorShaderContext* triColorShaderContext; |
| 2578 | 2577 |
| 2579 SkShader::Context* shaderContext = blitter->getShaderContext(); | 2578 SkShader::Context* shaderContext = blitter->getShaderContext(); |
| 2580 SkASSERT(shaderContext); | 2579 SkASSERT(shaderContext); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 2596 state.f0, state.f1, state.f2)) { | 2595 state.f0, state.f1, state.f2)) { |
| 2597 continue; | 2596 continue; |
| 2598 } | 2597 } |
| 2599 } | 2598 } |
| 2600 | 2599 |
| 2601 SkPoint tmp[] = { | 2600 SkPoint tmp[] = { |
| 2602 devVerts[state.f0], devVerts[state.f1], devVerts[state.f2] | 2601 devVerts[state.f0], devVerts[state.f1], devVerts[state.f2] |
| 2603 }; | 2602 }; |
| 2604 SkScan::FillTriangle(tmp, *fRC, blitter.get()); | 2603 SkScan::FillTriangle(tmp, *fRC, blitter.get()); |
| 2605 } | 2604 } |
| 2606 | |
| 2607 // now restore the shader's original local matrix | |
| 2608 if (NULL != shader) { | |
| 2609 shader->setLocalMatrix(savedLocalM); | |
| 2610 } | |
| 2611 } else { | 2605 } else { |
| 2612 // no colors[] and no texture | 2606 // no colors[] and no texture |
| 2613 HairProc hairProc = ChooseHairProc(paint.isAntiAlias()); | 2607 HairProc hairProc = ChooseHairProc(paint.isAntiAlias()); |
| 2614 const SkRasterClip& clip = *fRC; | 2608 const SkRasterClip& clip = *fRC; |
| 2615 while (vertProc(&state)) { | 2609 while (vertProc(&state)) { |
| 2616 hairProc(devVerts[state.f0], devVerts[state.f1], clip, blitter.get() ); | 2610 hairProc(devVerts[state.f0], devVerts[state.f1], clip, blitter.get() ); |
| 2617 hairProc(devVerts[state.f1], devVerts[state.f2], clip, blitter.get() ); | 2611 hairProc(devVerts[state.f1], devVerts[state.f2], clip, blitter.get() ); |
| 2618 hairProc(devVerts[state.f2], devVerts[state.f0], clip, blitter.get() ); | 2612 hairProc(devVerts[state.f2], devVerts[state.f0], clip, blitter.get() ); |
| 2619 } | 2613 } |
| 2620 } | 2614 } |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2832 mask->fImage = SkMask::AllocImage(size); | 2826 mask->fImage = SkMask::AllocImage(size); |
| 2833 memset(mask->fImage, 0, mask->computeImageSize()); | 2827 memset(mask->fImage, 0, mask->computeImageSize()); |
| 2834 } | 2828 } |
| 2835 | 2829 |
| 2836 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2830 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
| 2837 draw_into_mask(*mask, devPath, style); | 2831 draw_into_mask(*mask, devPath, style); |
| 2838 } | 2832 } |
| 2839 | 2833 |
| 2840 return true; | 2834 return true; |
| 2841 } | 2835 } |
| OLD | NEW |