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

Side by Side Diff: src/pdf/SkPDFShader.cpp

Issue 944643002: PDF: Now threadsafe! (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: TODO=DONE Created 5 years, 10 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
« no previous file with comments | « src/pdf/SkPDFShader.h ('k') | no next file » | 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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkPDFShader.h" 10 #include "SkPDFShader.h"
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 bool GradientHasAlpha() const; 500 bool GradientHasAlpha() const;
501 501
502 private: 502 private:
503 State(const State& other); 503 State(const State& other);
504 State operator=(const State& rhs); 504 State operator=(const State& rhs);
505 void AllocateGradientInfoStorage(); 505 void AllocateGradientInfoStorage();
506 }; 506 };
507 507
508 //////////////////////////////////////////////////////////////////////////////// 508 ////////////////////////////////////////////////////////////////////////////////
509 509
510 SkPDFFunctionShader::SkPDFFunctionShader(SkPDFShader::State* state) 510 SkPDFFunctionShader::SkPDFFunctionShader(SkPDFCanon* canon,
511 : SkPDFDict("Pattern"), fShaderState(state) {} 511 SkPDFShader::State* state)
512 : SkPDFDict("Pattern"), fCanon(canon), fShaderState(state) {}
512 513
513 SkPDFFunctionShader::~SkPDFFunctionShader() { 514 SkPDFFunctionShader::~SkPDFFunctionShader() {
514 SkAutoMutexAcquire lock(SkPDFCanon::GetShaderMutex()); 515 fCanon->removeFunctionShader(this);
515 SkPDFCanon::GetCanon().removeFunctionShader(this);
516 lock.release();
517 fResources.unrefAll(); 516 fResources.unrefAll();
518 } 517 }
519 518
520 bool SkPDFFunctionShader::equals(const SkPDFShader::State& state) const { 519 bool SkPDFFunctionShader::equals(const SkPDFShader::State& state) const {
521 return state == *fShaderState; 520 return state == *fShaderState;
522 } 521 }
523 522
524 //////////////////////////////////////////////////////////////////////////////// 523 ////////////////////////////////////////////////////////////////////////////////
525 524
526 SkPDFAlphaFunctionShader::SkPDFAlphaFunctionShader(SkPDFShader::State* state) 525 SkPDFAlphaFunctionShader::SkPDFAlphaFunctionShader(SkPDFCanon* canon,
527 : fShaderState(state) {} 526 SkPDFShader::State* state)
527 : fCanon(canon), fShaderState(state) {}
528 528
529 bool SkPDFAlphaFunctionShader::equals(const SkPDFShader::State& state) const { 529 bool SkPDFAlphaFunctionShader::equals(const SkPDFShader::State& state) const {
530 return state == *fShaderState; 530 return state == *fShaderState;
531 } 531 }
532 532
533 SkPDFAlphaFunctionShader::~SkPDFAlphaFunctionShader() { 533 SkPDFAlphaFunctionShader::~SkPDFAlphaFunctionShader() {
534 SkAutoMutexAcquire lock(SkPDFCanon::GetShaderMutex()); 534 fCanon->removeAlphaShader(this);
535 SkPDFCanon::GetCanon().removeAlphaShader(this);
536 } 535 }
537 536
538 //////////////////////////////////////////////////////////////////////////////// 537 ////////////////////////////////////////////////////////////////////////////////
539 538
540 SkPDFImageShader::SkPDFImageShader(SkPDFShader::State* state) 539 SkPDFImageShader::SkPDFImageShader(SkPDFCanon* canon, SkPDFShader::State* state)
541 : fShaderState(state) {} 540 : fCanon(canon), fShaderState(state) {}
542 541
543 bool SkPDFImageShader::equals(const SkPDFShader::State& state) const { 542 bool SkPDFImageShader::equals(const SkPDFShader::State& state) const {
544 return state == *fShaderState; 543 return state == *fShaderState;
545 } 544 }
546 545
547 SkPDFImageShader::~SkPDFImageShader() { 546 SkPDFImageShader::~SkPDFImageShader() {
548 SkAutoMutexAcquire lock(SkPDFCanon::GetShaderMutex()); 547 fCanon->removeImageShader(this);
549 SkPDFCanon::GetCanon().removeImageShader(this);
550 lock.release();
551 fResources.unrefAll(); 548 fResources.unrefAll();
552 } 549 }
553 550
554 //////////////////////////////////////////////////////////////////////////////// 551 ////////////////////////////////////////////////////////////////////////////////
555 552
556 static SkPDFObject* get_pdf_shader_by_state( 553 static SkPDFObject* get_pdf_shader_by_state(
554 SkPDFCanon* canon,
555 SkScalar dpi,
557 SkAutoTDelete<SkPDFShader::State>* autoState) { 556 SkAutoTDelete<SkPDFShader::State>* autoState) {
558 const SkPDFShader::State& state = **autoState; 557 const SkPDFShader::State& state = **autoState;
559 if (state.fType == SkShader::kNone_GradientType && state.fImage.isNull()) { 558 if (state.fType == SkShader::kNone_GradientType && state.fImage.isNull()) {
560 // TODO(vandebo) This drops SKComposeShader on the floor. We could 559 // TODO(vandebo) This drops SKComposeShader on the floor. We could
561 // handle compose shader by pulling things up to a layer, drawing with 560 // handle compose shader by pulling things up to a layer, drawing with
562 // the first shader, applying the xfer mode and drawing again with the 561 // the first shader, applying the xfer mode and drawing again with the
563 // second shader, then applying the layer to the original drawing. 562 // second shader, then applying the layer to the original drawing.
564 return NULL; 563 return NULL;
565 } else if (state.fType == SkShader::kNone_GradientType) { 564 } else if (state.fType == SkShader::kNone_GradientType) {
566 SkPDFObject* shader = SkPDFCanon::GetCanon().findImageShader(state); 565 SkPDFObject* shader = canon->findImageShader(state);
567 return shader ? SkRef(shader) : SkPDFImageShader::Create(autoState); 566 return shader ? SkRef(shader)
567 : SkPDFImageShader::Create(canon, dpi, autoState);
568 } else if (state.GradientHasAlpha()) { 568 } else if (state.GradientHasAlpha()) {
569 SkPDFObject* shader = SkPDFCanon::GetCanon().findAlphaShader(state); 569 SkPDFObject* shader = canon->findAlphaShader(state);
570 return shader ? SkRef(shader) 570 return shader ? SkRef(shader)
571 : SkPDFAlphaFunctionShader::Create(autoState); 571 : SkPDFAlphaFunctionShader::Create(canon, dpi, autoState);
572 } else { 572 } else {
573 SkPDFObject* shader = SkPDFCanon::GetCanon().findFunctionShader(state); 573 SkPDFObject* shader = canon->findFunctionShader(state);
574 return shader ? SkRef(shader) : SkPDFFunctionShader::Create(autoState); 574 return shader ? SkRef(shader)
575 : SkPDFFunctionShader::Create(canon, autoState);
575 } 576 }
576 } 577 }
577 578
578 // static 579 // static
579 SkPDFObject* SkPDFShader::GetPDFShader(const SkShader& shader, 580 SkPDFObject* SkPDFShader::GetPDFShader(SkPDFCanon* canon,
581 SkScalar dpi,
582 const SkShader& shader,
580 const SkMatrix& matrix, 583 const SkMatrix& matrix,
581 const SkIRect& surfaceBBox, 584 const SkIRect& surfaceBBox,
582 SkScalar rasterScale) { 585 SkScalar rasterScale) {
583 // There is only one mutex becasue we don't know which one we'll need. 586 // There is only one mutex becasue we don't know which one we'll need.
584 SkAutoMutexAcquire lock(SkPDFCanon::GetShaderMutex());
585 SkAutoTDelete<SkPDFShader::State> state( 587 SkAutoTDelete<SkPDFShader::State> state(
586 SkNEW_ARGS(State, (shader, matrix, surfaceBBox, rasterScale))); 588 SkNEW_ARGS(State, (shader, matrix, surfaceBBox, rasterScale)));
587 return get_pdf_shader_by_state(&state); 589 return get_pdf_shader_by_state(canon, dpi, &state);
588 } 590 }
589 591
590 static SkPDFResourceDict* get_gradient_resource_dict( 592 static SkPDFResourceDict* get_gradient_resource_dict(
591 SkPDFObject* functionShader, 593 SkPDFObject* functionShader,
592 SkPDFObject* gState) { 594 SkPDFObject* gState) {
593 SkPDFResourceDict* dict = new SkPDFResourceDict(); 595 SkPDFResourceDict* dict = new SkPDFResourceDict();
594 596
595 if (functionShader != NULL) { 597 if (functionShader != NULL) {
596 dict->insertResourceAsReference( 598 dict->insertResourceAsReference(
597 SkPDFResourceDict::kPattern_ResourceType, 0, functionShader); 599 SkPDFResourceDict::kPattern_ResourceType, 0, functionShader);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 &content); 642 &content);
641 643
642 return content.detachAsStream(); 644 return content.detachAsStream();
643 } 645 }
644 646
645 /** 647 /**
646 * Creates a ExtGState with the SMask set to the luminosityShader in 648 * Creates a ExtGState with the SMask set to the luminosityShader in
647 * luminosity mode. The shader pattern extends to the bbox. 649 * luminosity mode. The shader pattern extends to the bbox.
648 */ 650 */
649 static SkPDFGraphicState* create_smask_graphic_state( 651 static SkPDFGraphicState* create_smask_graphic_state(
650 const SkPDFShader::State& state) { 652 SkPDFCanon* canon, SkScalar dpi, const SkPDFShader::State& state) {
651 SkRect bbox; 653 SkRect bbox;
652 bbox.set(state.fBBox); 654 bbox.set(state.fBBox);
653 655
654 SkAutoTDelete<SkPDFShader::State> alphaToLuminosityState( 656 SkAutoTDelete<SkPDFShader::State> alphaToLuminosityState(
655 state.CreateAlphaToLuminosityState()); 657 state.CreateAlphaToLuminosityState());
656 SkAutoTUnref<SkPDFObject> luminosityShader( 658 SkAutoTUnref<SkPDFObject> luminosityShader(
657 get_pdf_shader_by_state(&alphaToLuminosityState)); 659 get_pdf_shader_by_state(canon, dpi, &alphaToLuminosityState));
658 660
659 SkAutoTDelete<SkStream> alphaStream(create_pattern_fill_content(-1, bbox)); 661 SkAutoTDelete<SkStream> alphaStream(create_pattern_fill_content(-1, bbox));
660 662
661 SkAutoTUnref<SkPDFResourceDict> 663 SkAutoTUnref<SkPDFResourceDict>
662 resources(get_gradient_resource_dict(luminosityShader, NULL)); 664 resources(get_gradient_resource_dict(luminosityShader, NULL));
663 665
664 SkAutoTUnref<SkPDFFormXObject> alphaMask( 666 SkAutoTUnref<SkPDFFormXObject> alphaMask(
665 new SkPDFFormXObject(alphaStream.get(), bbox, resources.get())); 667 new SkPDFFormXObject(alphaStream.get(), bbox, resources.get()));
666 668
667 return SkPDFGraphicState::GetSMaskGraphicState( 669 return SkPDFGraphicState::GetSMaskGraphicState(
668 alphaMask.get(), false, 670 alphaMask.get(), false,
669 SkPDFGraphicState::kLuminosity_SMaskMode); 671 SkPDFGraphicState::kLuminosity_SMaskMode);
670 } 672 }
671 673
672 SkPDFAlphaFunctionShader* SkPDFAlphaFunctionShader::Create( 674 SkPDFAlphaFunctionShader* SkPDFAlphaFunctionShader::Create(
675 SkPDFCanon* canon,
676 SkScalar dpi,
673 SkAutoTDelete<SkPDFShader::State>* autoState) { 677 SkAutoTDelete<SkPDFShader::State>* autoState) {
674 const SkPDFShader::State& state = **autoState; 678 const SkPDFShader::State& state = **autoState;
675 SkRect bbox; 679 SkRect bbox;
676 bbox.set(state.fBBox); 680 bbox.set(state.fBBox);
677 681
678 SkAutoTDelete<SkPDFShader::State> opaqueState(state.CreateOpaqueState()); 682 SkAutoTDelete<SkPDFShader::State> opaqueState(state.CreateOpaqueState());
679 683
680 SkPDFObject* colorShader = get_pdf_shader_by_state(&opaqueState); 684 SkPDFObject* colorShader =
685 get_pdf_shader_by_state(canon, dpi, &opaqueState);
681 if (!colorShader) { 686 if (!colorShader) {
682 return NULL; 687 return NULL;
683 } 688 }
684 689
685 // Create resource dict with alpha graphics state as G0 and 690 // Create resource dict with alpha graphics state as G0 and
686 // pattern shader as P0, then write content stream. 691 // pattern shader as P0, then write content stream.
687 SkAutoTUnref<SkPDFGraphicState> alphaGs(create_smask_graphic_state(state)); 692 SkAutoTUnref<SkPDFGraphicState> alphaGs(
693 create_smask_graphic_state(canon, dpi, state));
688 694
689 SkPDFAlphaFunctionShader* alphaFunctionShader = 695 SkPDFAlphaFunctionShader* alphaFunctionShader =
690 SkNEW_ARGS(SkPDFAlphaFunctionShader, (autoState->detach())); 696 SkNEW_ARGS(SkPDFAlphaFunctionShader, (canon, autoState->detach()));
691 697
692 alphaFunctionShader->fColorShader.reset(colorShader); 698 alphaFunctionShader->fColorShader.reset(colorShader);
693 699
694 alphaFunctionShader->fResourceDict.reset(get_gradient_resource_dict( 700 alphaFunctionShader->fResourceDict.reset(get_gradient_resource_dict(
695 alphaFunctionShader->fColorShader.get(), alphaGs.get())); 701 alphaFunctionShader->fColorShader.get(), alphaGs.get()));
696 702
697 SkAutoTDelete<SkStream> colorStream( 703 SkAutoTDelete<SkStream> colorStream(
698 create_pattern_fill_content(0, bbox)); 704 create_pattern_fill_content(0, bbox));
699 alphaFunctionShader->setData(colorStream.get()); 705 alphaFunctionShader->setData(colorStream.get());
700 706
701 populate_tiling_pattern_dict(alphaFunctionShader, bbox, 707 populate_tiling_pattern_dict(alphaFunctionShader, bbox,
702 alphaFunctionShader->fResourceDict.get(), 708 alphaFunctionShader->fResourceDict.get(),
703 SkMatrix::I()); 709 SkMatrix::I());
704 SkPDFCanon::GetCanon().addAlphaShader(alphaFunctionShader); 710 canon->addAlphaShader(alphaFunctionShader);
705 return alphaFunctionShader; 711 return alphaFunctionShader;
706 } 712 }
707 713
708 // Finds affine and persp such that in = affine * persp. 714 // Finds affine and persp such that in = affine * persp.
709 // but it returns the inverse of perspective matrix. 715 // but it returns the inverse of perspective matrix.
710 static bool split_perspective(const SkMatrix in, SkMatrix* affine, 716 static bool split_perspective(const SkMatrix in, SkMatrix* affine,
711 SkMatrix* perspectiveInverse) { 717 SkMatrix* perspectiveInverse) {
712 const SkScalar p2 = in[SkMatrix::kMPersp2]; 718 const SkScalar p2 = in[SkMatrix::kMPersp2];
713 719
714 if (SkScalarNearlyZero(p2)) { 720 if (SkScalarNearlyZero(p2)) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 SkAutoDataUnref funcData( 773 SkAutoDataUnref funcData(
768 SkData::NewWithCopy(psCode.c_str(), psCode.size())); 774 SkData::NewWithCopy(psCode.c_str(), psCode.size()));
769 SkPDFStream* result = SkNEW_ARGS(SkPDFStream, (funcData.get())); 775 SkPDFStream* result = SkNEW_ARGS(SkPDFStream, (funcData.get()));
770 result->insertInt("FunctionType", 4); 776 result->insertInt("FunctionType", 4);
771 result->insert("Domain", domain); 777 result->insert("Domain", domain);
772 result->insert("Range", rangeObject.get()); 778 result->insert("Range", rangeObject.get());
773 return result; 779 return result;
774 } 780 }
775 781
776 SkPDFFunctionShader* SkPDFFunctionShader::Create( 782 SkPDFFunctionShader* SkPDFFunctionShader::Create(
777 SkAutoTDelete<SkPDFShader::State>* autoState) { 783 SkPDFCanon* canon, SkAutoTDelete<SkPDFShader::State>* autoState) {
778 const SkPDFShader::State& state = **autoState; 784 const SkPDFShader::State& state = **autoState;
779 785
780 SkString (*codeFunction)(const SkShader::GradientInfo& info, 786 SkString (*codeFunction)(const SkShader::GradientInfo& info,
781 const SkMatrix& perspectiveRemover) = NULL; 787 const SkMatrix& perspectiveRemover) = NULL;
782 SkPoint transformPoints[2]; 788 SkPoint transformPoints[2];
783 789
784 // Depending on the type of the gradient, we want to transform the 790 // Depending on the type of the gradient, we want to transform the
785 // coordinate space in different ways. 791 // coordinate space in different ways.
786 const SkShader::GradientInfo* info = &state.fInfo; 792 const SkShader::GradientInfo* info = &state.fInfo;
787 transformPoints[0] = info->fPoint[0]; 793 transformPoints[0] = info->fPoint[0];
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 pdfShader->insertName("ColorSpace", "DeviceRGB"); 892 pdfShader->insertName("ColorSpace", "DeviceRGB");
887 pdfShader->insert("Domain", domain.get()); 893 pdfShader->insert("Domain", domain.get());
888 894
889 SkPDFStream* function = make_ps_function(functionCode, domain.get()); 895 SkPDFStream* function = make_ps_function(functionCode, domain.get());
890 pdfShader->insert("Function", new SkPDFObjRef(function))->unref(); 896 pdfShader->insert("Function", new SkPDFObjRef(function))->unref();
891 897
892 SkAutoTUnref<SkPDFArray> matrixArray( 898 SkAutoTUnref<SkPDFArray> matrixArray(
893 SkPDFUtils::MatrixToArray(finalMatrix)); 899 SkPDFUtils::MatrixToArray(finalMatrix));
894 900
895 SkPDFFunctionShader* pdfFunctionShader = 901 SkPDFFunctionShader* pdfFunctionShader =
896 SkNEW_ARGS(SkPDFFunctionShader, (autoState->detach())); 902 SkNEW_ARGS(SkPDFFunctionShader, (canon, autoState->detach()));
897 903
898 pdfFunctionShader->fResources.push(function); 904 pdfFunctionShader->fResources.push(function);
899 // Pass ownership to resource list. 905 // Pass ownership to resource list.
900 906
901 pdfFunctionShader->insertInt("PatternType", 2); 907 pdfFunctionShader->insertInt("PatternType", 2);
902 pdfFunctionShader->insert("Matrix", matrixArray.get()); 908 pdfFunctionShader->insert("Matrix", matrixArray.get());
903 pdfFunctionShader->insert("Shading", pdfShader.get()); 909 pdfFunctionShader->insert("Shading", pdfShader.get());
904 910
905 SkPDFCanon::GetCanon().addFunctionShader(pdfFunctionShader); 911 canon->addFunctionShader(pdfFunctionShader);
906 return pdfFunctionShader; 912 return pdfFunctionShader;
907 } 913 }
908 914
909 SkPDFImageShader* SkPDFImageShader::Create( 915 SkPDFImageShader* SkPDFImageShader::Create(
916 SkPDFCanon* canon,
917 SkScalar dpi,
910 SkAutoTDelete<SkPDFShader::State>* autoState) { 918 SkAutoTDelete<SkPDFShader::State>* autoState) {
911 const SkPDFShader::State& state = **autoState; 919 const SkPDFShader::State& state = **autoState;
912 920
913 state.fImage.lockPixels(); 921 state.fImage.lockPixels();
914 922
915 // The image shader pattern cell will be drawn into a separate device 923 // The image shader pattern cell will be drawn into a separate device
916 // in pattern cell space (no scaling on the bitmap, though there may be 924 // in pattern cell space (no scaling on the bitmap, though there may be
917 // translations so that all content is in the device, coordinates > 0). 925 // translations so that all content is in the device, coordinates > 0).
918 926
919 // Map clip bounds to shader space to ensure the device is large enough 927 // Map clip bounds to shader space to ensure the device is large enough
(...skipping 18 matching lines...) Expand all
938 tileModes[0] = state.fImageTileModes[0]; 946 tileModes[0] = state.fImageTileModes[0];
939 tileModes[1] = state.fImageTileModes[1]; 947 tileModes[1] = state.fImageTileModes[1];
940 if (tileModes[0] != SkShader::kClamp_TileMode || 948 if (tileModes[0] != SkShader::kClamp_TileMode ||
941 tileModes[1] != SkShader::kClamp_TileMode) { 949 tileModes[1] != SkShader::kClamp_TileMode) {
942 deviceBounds.join(bitmapBounds); 950 deviceBounds.join(bitmapBounds);
943 } 951 }
944 952
945 SkISize size = SkISize::Make(SkScalarRoundToInt(deviceBounds.width()), 953 SkISize size = SkISize::Make(SkScalarRoundToInt(deviceBounds.width()),
946 SkScalarRoundToInt(deviceBounds.height())); 954 SkScalarRoundToInt(deviceBounds.height()));
947 SkAutoTUnref<SkPDFDevice> patternDevice( 955 SkAutoTUnref<SkPDFDevice> patternDevice(
948 SkPDFDevice::CreateUnflipped(size, 72.0f, NULL)); 956 SkPDFDevice::CreateUnflipped(size, dpi, canon));
949 SkCanvas canvas(patternDevice.get()); 957 SkCanvas canvas(patternDevice.get());
950 958
951 SkRect patternBBox; 959 SkRect patternBBox;
952 image->getBounds(&patternBBox); 960 image->getBounds(&patternBBox);
953 961
954 // Translate the canvas so that the bitmap origin is at (0, 0). 962 // Translate the canvas so that the bitmap origin is at (0, 0).
955 canvas.translate(-deviceBounds.left(), -deviceBounds.top()); 963 canvas.translate(-deviceBounds.left(), -deviceBounds.top());
956 patternBBox.offset(-deviceBounds.left(), -deviceBounds.top()); 964 patternBBox.offset(-deviceBounds.left(), -deviceBounds.top());
957 // Undo the translation in the final matrix 965 // Undo the translation in the final matrix
958 finalMatrix.preTranslate(deviceBounds.left(), deviceBounds.top()); 966 finalMatrix.preTranslate(deviceBounds.left(), deviceBounds.top());
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 drawBitmapMatrix(&canvas, bottom, bottomMatrix); 1108 drawBitmapMatrix(&canvas, bottom, bottomMatrix);
1101 } 1109 }
1102 patternBBox.fBottom = deviceBounds.height(); 1110 patternBBox.fBottom = deviceBounds.height();
1103 } 1111 }
1104 } 1112 }
1105 1113
1106 // Put the canvas into the pattern stream (fContent). 1114 // Put the canvas into the pattern stream (fContent).
1107 SkAutoTDelete<SkStream> content(patternDevice->content()); 1115 SkAutoTDelete<SkStream> content(patternDevice->content());
1108 1116
1109 SkPDFImageShader* imageShader = 1117 SkPDFImageShader* imageShader =
1110 SkNEW_ARGS(SkPDFImageShader, (autoState->detach())); 1118 SkNEW_ARGS(SkPDFImageShader, (canon, autoState->detach()));
1111 imageShader->setData(content.get()); 1119 imageShader->setData(content.get());
1112 1120
1113 populate_tiling_pattern_dict(imageShader, 1121 populate_tiling_pattern_dict(imageShader, patternBBox,
1114 patternBBox, 1122 patternDevice->getResourceDict(), finalMatrix);
1115 patternDevice->getResourceDict(),
1116 finalMatrix);
1117 1123
1118 imageShader->fShaderState->fImage.unlockPixels(); 1124 imageShader->fShaderState->fImage.unlockPixels();
1119 1125
1120 SkPDFCanon::GetCanon().addImageShader(imageShader); 1126 canon->addImageShader(imageShader);
1121 return imageShader; 1127 return imageShader;
1122 } 1128 }
1123 1129
1124 bool SkPDFShader::State::operator==(const SkPDFShader::State& b) const { 1130 bool SkPDFShader::State::operator==(const SkPDFShader::State& b) const {
1125 if (fType != b.fType || 1131 if (fType != b.fType ||
1126 fCanvasTransform != b.fCanvasTransform || 1132 fCanvasTransform != b.fCanvasTransform ||
1127 fShaderTransform != b.fShaderTransform || 1133 fShaderTransform != b.fShaderTransform ||
1128 fBBox != b.fBBox) { 1134 fBBox != b.fBBox) {
1129 return false; 1135 return false;
1130 } 1136 }
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 return false; 1319 return false;
1314 } 1320 }
1315 1321
1316 void SkPDFShader::State::AllocateGradientInfoStorage() { 1322 void SkPDFShader::State::AllocateGradientInfoStorage() {
1317 fColorData.set(sk_malloc_throw( 1323 fColorData.set(sk_malloc_throw(
1318 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); 1324 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar))));
1319 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); 1325 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get());
1320 fInfo.fColorOffsets = 1326 fInfo.fColorOffsets =
1321 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); 1327 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount);
1322 } 1328 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFShader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698