Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(726)

Side by Side Diff: src/core/SkDraw.cpp

Issue 263293005: add local-matrix to shader::context (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add/fix comments Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/core/SkCoreBlitters.h ('k') | src/core/SkPictureShader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // We can't call getTotalInverse(), because we explicitly don't want to look at the localmatrix
2407 // as our interators are intrinsically tied to the vertices, and nothing els e.
2408 SkMatrix ctmInv;
2409 if (!this->getCTM().invert(&ctmInv)) {
2410 return false;
2411 }
2412 fDstToUnit.setConcat(im, ctmInv);
2407 return true; 2413 return true;
2408 } 2414 }
2409 2415
2410 #include "SkColorPriv.h" 2416 #include "SkColorPriv.h"
2411 #include "SkComposeShader.h" 2417 #include "SkComposeShader.h"
2412 2418
2413 static int ScalarTo256(SkScalar v) { 2419 static int ScalarTo256(SkScalar v) {
2414 int scale = SkScalarToFixed(v) >> 8; 2420 int scale = SkScalarToFixed(v) >> 8;
2415 if (scale < 0) { 2421 if (scale < 0) {
2416 scale = 0; 2422 scale = 0;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
2549 // Abort early if we failed to create a shader context. 2555 // Abort early if we failed to create a shader context.
2550 if (blitter->isNullBlitter()) { 2556 if (blitter->isNullBlitter()) {
2551 return; 2557 return;
2552 } 2558 }
2553 2559
2554 // setup our state and function pointer for iterating triangles 2560 // setup our state and function pointer for iterating triangles
2555 VertState state(count, indices, indexCount); 2561 VertState state(count, indices, indexCount);
2556 VertState::Proc vertProc = state.chooseProc(vmode); 2562 VertState::Proc vertProc = state.chooseProc(vmode);
2557 2563
2558 if (NULL != textures || NULL != colors) { 2564 if (NULL != textures || NULL != colors) {
2559 SkMatrix tempM;
2560 SkMatrix savedLocalM;
2561 if (shader) {
2562 savedLocalM = shader->getLocalMatrix();
2563 }
2564
2565 while (vertProc(&state)) { 2565 while (vertProc(&state)) {
2566 if (NULL != textures) { 2566 if (NULL != textures) {
2567 SkMatrix tempM;
2567 if (texture_to_matrix(state, vertices, textures, &tempM)) { 2568 if (texture_to_matrix(state, vertices, textures, &tempM)) {
2568 tempM.postConcat(savedLocalM); 2569 SkShader::ContextRec rec(*fBitmap, p, *fMatrix);
2569 shader->setLocalMatrix(tempM); 2570 rec.fLocalMatrix = &tempM;
2570 if (!blitter->resetShaderContext(*fBitmap, p, *fMatrix)) { 2571 if (!blitter->resetShaderContext(rec)) {
2571 continue; 2572 continue;
2572 } 2573 }
2573 } 2574 }
2574 } 2575 }
2575 if (NULL != colors) { 2576 if (NULL != colors) {
2576 // Find the context for triShader. 2577 // Find the context for triShader.
2577 SkTriColorShader::TriColorShaderContext* triColorShaderContext; 2578 SkTriColorShader::TriColorShaderContext* triColorShaderContext;
2578 2579
2579 SkShader::Context* shaderContext = blitter->getShaderContext(); 2580 SkShader::Context* shaderContext = blitter->getShaderContext();
2580 SkASSERT(shaderContext); 2581 SkASSERT(shaderContext);
(...skipping 15 matching lines...) Expand all
2596 state.f0, state.f1, state.f2)) { 2597 state.f0, state.f1, state.f2)) {
2597 continue; 2598 continue;
2598 } 2599 }
2599 } 2600 }
2600 2601
2601 SkPoint tmp[] = { 2602 SkPoint tmp[] = {
2602 devVerts[state.f0], devVerts[state.f1], devVerts[state.f2] 2603 devVerts[state.f0], devVerts[state.f1], devVerts[state.f2]
2603 }; 2604 };
2604 SkScan::FillTriangle(tmp, *fRC, blitter.get()); 2605 SkScan::FillTriangle(tmp, *fRC, blitter.get());
2605 } 2606 }
2606
2607 // now restore the shader's original local matrix
2608 if (NULL != shader) {
2609 shader->setLocalMatrix(savedLocalM);
2610 }
2611 } else { 2607 } else {
2612 // no colors[] and no texture 2608 // no colors[] and no texture
2613 HairProc hairProc = ChooseHairProc(paint.isAntiAlias()); 2609 HairProc hairProc = ChooseHairProc(paint.isAntiAlias());
2614 const SkRasterClip& clip = *fRC; 2610 const SkRasterClip& clip = *fRC;
2615 while (vertProc(&state)) { 2611 while (vertProc(&state)) {
2616 hairProc(devVerts[state.f0], devVerts[state.f1], clip, blitter.get() ); 2612 hairProc(devVerts[state.f0], devVerts[state.f1], clip, blitter.get() );
2617 hairProc(devVerts[state.f1], devVerts[state.f2], clip, blitter.get() ); 2613 hairProc(devVerts[state.f1], devVerts[state.f2], clip, blitter.get() );
2618 hairProc(devVerts[state.f2], devVerts[state.f0], clip, blitter.get() ); 2614 hairProc(devVerts[state.f2], devVerts[state.f0], clip, blitter.get() );
2619 } 2615 }
2620 } 2616 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
2832 mask->fImage = SkMask::AllocImage(size); 2828 mask->fImage = SkMask::AllocImage(size);
2833 memset(mask->fImage, 0, mask->computeImageSize()); 2829 memset(mask->fImage, 0, mask->computeImageSize());
2834 } 2830 }
2835 2831
2836 if (SkMask::kJustComputeBounds_CreateMode != mode) { 2832 if (SkMask::kJustComputeBounds_CreateMode != mode) {
2837 draw_into_mask(*mask, devPath, style); 2833 draw_into_mask(*mask, devPath, style);
2838 } 2834 }
2839 2835
2840 return true; 2836 return true;
2841 } 2837 }
OLDNEW
« no previous file with comments | « src/core/SkCoreBlitters.h ('k') | src/core/SkPictureShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698