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

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

Issue 873543002: More changes to SkPDFShader to eliminate multiple inheritance! (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 11 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
« src/pdf/SkPDFCanon.cpp ('K') | « 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 SkPDFShader::State* CreateOpaqueState() const; 498 SkPDFShader::State* CreateOpaqueState() const;
499 499
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 static void remove_from_canon(SkPDFShader* shader) { 508 ////////////////////////////////////////////////////////////////////////////////
509 SkAutoMutexAcquire lock(SkPDFCanon::GetShaderMutex()); 509
510 SkPDFCanon::GetCanon().removeShader(shader); 510 SkPDFFunctionShader::SkPDFFunctionShader(SkPDFShader::State* state)
511 : SkPDFDict("Pattern"), fShaderState(state) {}
512
513 void SkPDFFunctionShader::getResources(const SkTSet<SkPDFObject*>& known,
514 SkTSet<SkPDFObject*>* newr) {
515 GetResourcesHelper(&fResources, known, newr);
511 } 516 }
512 517
513 class SkPDFFunctionShader : public SkPDFDict, public SkPDFShader { 518 SkPDFFunctionShader::~SkPDFFunctionShader() {
514 SK_DECLARE_INST_COUNT(SkPDFFunctionShader) 519 SkAutoMutexAcquire lock(SkPDFCanon::GetShaderMutex());
515 public: 520 SkPDFCanon::GetCanon().removeFunctionShader(this);
516 static SkPDFObject* Create(SkAutoTDelete<SkPDFShader::State>*); 521 lock.release();
517 522 fResources.unrefAll();
518 virtual ~SkPDFFunctionShader() {
519 remove_from_canon(this);
520 fResources.unrefAll();
521 }
522
523 SkPDFObject* toPDFObject() SK_OVERRIDE { return this; }
524
525 void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects,
526 SkTSet<SkPDFObject*>* newResourceObjects) SK_OVERRIDE {
527 GetResourcesHelper(&fResources,
528 knownResourceObjects,
529 newResourceObjects);
530 }
531
532 private:
533 SkTDArray<SkPDFObject*> fResources;
534 explicit SkPDFFunctionShader(SkPDFShader::State* state)
535 : SkPDFDict("Pattern"), SkPDFShader(state) {}
536 typedef SkPDFDict INHERITED;
537 };
538
539 /**
540 * A shader for PDF gradients. This encapsulates the function shader
541 * inside a tiling pattern while providing a common pattern interface.
542 * The encapsulation allows the use of a SMask for transparency gradients.
543 */
544 class SkPDFAlphaFunctionShader : public SkPDFStream, public SkPDFShader {
545 public:
546 static SkPDFObject* Create(SkAutoTDelete<SkPDFShader::State>*);
547
548 virtual ~SkPDFAlphaFunctionShader() { remove_from_canon(this); }
549
550 SkPDFObject* toPDFObject() SK_OVERRIDE { return this; }
551
552 private:
553 explicit SkPDFAlphaFunctionShader(SkPDFShader::State* state);
554
555 static SkPDFGraphicState* CreateSMaskGraphicState(
556 const SkPDFShader::State&);
557
558 void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects,
559 SkTSet<SkPDFObject*>* newResourceObjects) SK_OVERRIDE {
560 fResourceDict->getReferencedResources(knownResourceObjects,
561 newResourceObjects,
562 true);
563 }
564
565 SkAutoTUnref<SkPDFObject> fColorShader;
566 SkAutoTUnref<SkPDFResourceDict> fResourceDict;
567 };
568
569 class SkPDFImageShader : public SkPDFStream, public SkPDFShader {
570 public:
571 static SkPDFObject* Create(SkAutoTDelete<SkPDFShader::State>*);
572
573 virtual ~SkPDFImageShader() {
574 remove_from_canon(this);
575 fResources.unrefAll();
576 }
577
578 SkPDFObject* toPDFObject() SK_OVERRIDE { return this; }
579
580 void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects,
581 SkTSet<SkPDFObject*>* newResourceObjects) SK_OVERRIDE {
582 GetResourcesHelper(&fResources.toArray(),
583 knownResourceObjects,
584 newResourceObjects);
585 }
586
587 private:
588 SkTSet<SkPDFObject*> fResources;
589 explicit SkPDFImageShader(SkPDFShader::State* state) : SkPDFShader(state) {}
590 };
591
592 SkPDFShader::SkPDFShader(SkPDFShader::State* s) : fShaderState(s) {}
593
594 SkPDFShader::~SkPDFShader() {}
595
596 bool SkPDFShader::equals(const SkPDFShader::State& state) const {
597 return state == *fShaderState.get();
598 } 523 }
599 524
600 // static 525 bool SkPDFFunctionShader::equals(const SkPDFShader::State& state) const {
601 SkPDFObject* SkPDFShader::GetPDFShaderByState( 526 return state == *fShaderState;
527 }
528
529 ////////////////////////////////////////////////////////////////////////////////
530
531 SkPDFAlphaFunctionShader::SkPDFAlphaFunctionShader(SkPDFShader::State* state)
532 : fShaderState(state) {}
533
534 bool SkPDFAlphaFunctionShader::equals(const SkPDFShader::State& state) const {
535 return state == *fShaderState;
536 }
537
538 SkPDFAlphaFunctionShader::~SkPDFAlphaFunctionShader() {
539 SkAutoMutexAcquire lock(SkPDFCanon::GetShaderMutex());
540 SkPDFCanon::GetCanon().removeAlphaShader(this);
541 }
542
543 void SkPDFAlphaFunctionShader::getResources(const SkTSet<SkPDFObject*>& known,
544 SkTSet<SkPDFObject*>* newr) {
545 fResourceDict->getReferencedResources(known, newr, true);
546 }
547
548 ////////////////////////////////////////////////////////////////////////////////
549
550 SkPDFImageShader::SkPDFImageShader(SkPDFShader::State* state)
551 : fShaderState(state) {}
552
553 bool SkPDFImageShader::equals(const SkPDFShader::State& state) const {
554 return state == *fShaderState;
555 }
556
557 SkPDFImageShader::~SkPDFImageShader() {
558 SkAutoMutexAcquire lock(SkPDFCanon::GetShaderMutex());
559 SkPDFCanon::GetCanon().removeImageShader(this);
560 lock.release();
561 fResources.unrefAll();
562 }
563
564 void SkPDFImageShader::getResources(const SkTSet<SkPDFObject*>& known,
565 SkTSet<SkPDFObject*>* newr) {
566 GetResourcesHelper(&fResources.toArray(), known, newr);
567 }
568
569 ////////////////////////////////////////////////////////////////////////////////
570
571 static SkPDFObject* get_pdf_shader_by_state(
602 SkAutoTDelete<SkPDFShader::State>* autoState) { 572 SkAutoTDelete<SkPDFShader::State>* autoState) {
603 const State& state = **autoState; 573 const SkPDFShader::State& state = **autoState;
604 if (state.fType == SkShader::kNone_GradientType && state.fImage.isNull()) { 574 if (state.fType == SkShader::kNone_GradientType && state.fImage.isNull()) {
605 // TODO(vandebo) This drops SKComposeShader on the floor. We could 575 // TODO(vandebo) This drops SKComposeShader on the floor. We could
606 // handle compose shader by pulling things up to a layer, drawing with 576 // handle compose shader by pulling things up to a layer, drawing with
607 // the first shader, applying the xfer mode and drawing again with the 577 // the first shader, applying the xfer mode and drawing again with the
608 // second shader, then applying the layer to the original drawing. 578 // second shader, then applying the layer to the original drawing.
609 return NULL; 579 return NULL;
610 } 580 } else if (state.fType == SkShader::kNone_GradientType) {
611 581 SkPDFObject* shader = SkPDFCanon::GetCanon().findImageShader(state);
612 SkPDFShader* pdfShader = SkPDFCanon::GetCanon().findShader(state); 582 return shader ? SkRef(shader) : SkPDFImageShader::Create(autoState);
613 if (pdfShader) {
614 return SkRef(pdfShader->toPDFObject());
615 }
616
617 // The PDFShader takes ownership of the shaderSate.
618 if (state.fType == SkShader::kNone_GradientType) {
619 return SkPDFImageShader::Create(autoState);
620 } else if (state.GradientHasAlpha()) { 583 } else if (state.GradientHasAlpha()) {
621 return SkPDFAlphaFunctionShader::Create(autoState); 584 SkPDFObject* shader = SkPDFCanon::GetCanon().findAlphaShader(state);
585 return shader ? SkRef(shader)
586 : SkPDFAlphaFunctionShader::Create(autoState);
622 } else { 587 } else {
623 return SkPDFFunctionShader::Create(autoState); 588 SkPDFObject* shader = SkPDFCanon::GetCanon().findFunctionShader(state);
589 return shader ? SkRef(shader) : SkPDFFunctionShader::Create(autoState);
624 } 590 }
625 } 591 }
626 592
627 // static 593 // static
628 SkPDFObject* SkPDFShader::GetPDFShader(const SkShader& shader, 594 SkPDFObject* SkPDFShader::GetPDFShader(const SkShader& shader,
629 const SkMatrix& matrix, 595 const SkMatrix& matrix,
630 const SkIRect& surfaceBBox, 596 const SkIRect& surfaceBBox,
631 SkScalar rasterScale) { 597 SkScalar rasterScale) {
598 // There is only one mutex becasue we don't know which one we'll need.
632 SkAutoMutexAcquire lock(SkPDFCanon::GetShaderMutex()); 599 SkAutoMutexAcquire lock(SkPDFCanon::GetShaderMutex());
633 SkAutoTDelete<SkPDFShader::State> state( 600 SkAutoTDelete<SkPDFShader::State> state(
634 SkNEW_ARGS(State, (shader, matrix, surfaceBBox, rasterScale))); 601 SkNEW_ARGS(State, (shader, matrix, surfaceBBox, rasterScale)));
635 return GetPDFShaderByState(&state); 602 return get_pdf_shader_by_state(&state);
636 } 603 }
637 604
638 static SkPDFResourceDict* get_gradient_resource_dict( 605 static SkPDFResourceDict* get_gradient_resource_dict(
639 SkPDFObject* functionShader, 606 SkPDFObject* functionShader,
640 SkPDFObject* gState) { 607 SkPDFObject* gState) {
641 SkPDFResourceDict* dict = new SkPDFResourceDict(); 608 SkPDFResourceDict* dict = new SkPDFResourceDict();
642 609
643 if (functionShader != NULL) { 610 if (functionShader != NULL) {
644 dict->insertResourceAsReference( 611 dict->insertResourceAsReference(
645 SkPDFResourceDict::kPattern_ResourceType, 0, functionShader); 612 SkPDFResourceDict::kPattern_ResourceType, 0, functionShader);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 SkPDFUtils::PaintPath(SkPaint::kFill_Style, SkPath::kEvenOdd_FillType, 654 SkPDFUtils::PaintPath(SkPaint::kFill_Style, SkPath::kEvenOdd_FillType,
688 &content); 655 &content);
689 656
690 return content.detachAsStream(); 657 return content.detachAsStream();
691 } 658 }
692 659
693 /** 660 /**
694 * Creates a ExtGState with the SMask set to the luminosityShader in 661 * Creates a ExtGState with the SMask set to the luminosityShader in
695 * luminosity mode. The shader pattern extends to the bbox. 662 * luminosity mode. The shader pattern extends to the bbox.
696 */ 663 */
697 SkPDFGraphicState* SkPDFAlphaFunctionShader::CreateSMaskGraphicState( 664 static SkPDFGraphicState* createsmask_graphic_state(
698 const SkPDFShader::State& state) { 665 const SkPDFShader::State& state) {
699 SkRect bbox; 666 SkRect bbox;
700 bbox.set(state.fBBox); 667 bbox.set(state.fBBox);
701 668
702 SkAutoTDelete<SkPDFShader::State> alphaToLuminosityState( 669 SkAutoTDelete<SkPDFShader::State> alphaToLuminosityState(
703 state.CreateAlphaToLuminosityState()); 670 state.CreateAlphaToLuminosityState());
704 SkAutoTUnref<SkPDFObject> luminosityShader( 671 SkAutoTUnref<SkPDFObject> luminosityShader(
705 SkPDFShader::GetPDFShaderByState(&alphaToLuminosityState)); 672 get_pdf_shader_by_state(&alphaToLuminosityState));
706 673
707 SkAutoTDelete<SkStream> alphaStream(create_pattern_fill_content(-1, bbox)); 674 SkAutoTDelete<SkStream> alphaStream(create_pattern_fill_content(-1, bbox));
708 675
709 SkAutoTUnref<SkPDFResourceDict> 676 SkAutoTUnref<SkPDFResourceDict>
710 resources(get_gradient_resource_dict(luminosityShader, NULL)); 677 resources(get_gradient_resource_dict(luminosityShader, NULL));
711 678
712 SkAutoTUnref<SkPDFFormXObject> alphaMask( 679 SkAutoTUnref<SkPDFFormXObject> alphaMask(
713 new SkPDFFormXObject(alphaStream.get(), bbox, resources.get())); 680 new SkPDFFormXObject(alphaStream.get(), bbox, resources.get()));
714 681
715 return SkPDFGraphicState::GetSMaskGraphicState( 682 return SkPDFGraphicState::GetSMaskGraphicState(
716 alphaMask.get(), false, 683 alphaMask.get(), false,
717 SkPDFGraphicState::kLuminosity_SMaskMode); 684 SkPDFGraphicState::kLuminosity_SMaskMode);
718 } 685 }
719 686
720 SkPDFObject* SkPDFAlphaFunctionShader::Create( 687 SkPDFAlphaFunctionShader* SkPDFAlphaFunctionShader::Create(
721 SkAutoTDelete<SkPDFShader::State>* autoState) { 688 SkAutoTDelete<SkPDFShader::State>* autoState) {
722 const SkPDFShader::State& state = **autoState; 689 const SkPDFShader::State& state = **autoState;
723 SkRect bbox; 690 SkRect bbox;
724 bbox.set(state.fBBox); 691 bbox.set(state.fBBox);
725 692
726 SkAutoTDelete<SkPDFShader::State> opaqueState(state.CreateOpaqueState()); 693 SkAutoTDelete<SkPDFShader::State> opaqueState(state.CreateOpaqueState());
727 694
728 SkPDFObject* colorShader = SkPDFShader::GetPDFShaderByState(&opaqueState); 695 SkPDFObject* colorShader = get_pdf_shader_by_state(&opaqueState);
729 if (!colorShader) { 696 if (!colorShader) {
730 return NULL; 697 return NULL;
731 } 698 }
732 699
733 // Create resource dict with alpha graphics state as G0 and 700 // Create resource dict with alpha graphics state as G0 and
734 // pattern shader as P0, then write content stream. 701 // pattern shader as P0, then write content stream.
735 SkAutoTUnref<SkPDFGraphicState> alphaGs( 702 SkAutoTUnref<SkPDFGraphicState> alphaGs(createsmask_graphic_state(state));
mtklein 2015/01/23 14:16:11 Let's add an _ between create and smask?
736 SkPDFAlphaFunctionShader::CreateSMaskGraphicState(state));
737 703
738 SkPDFAlphaFunctionShader* alphaFunctionShader = 704 SkPDFAlphaFunctionShader* alphaFunctionShader =
739 SkNEW_ARGS(SkPDFAlphaFunctionShader, (autoState->detach())); 705 SkNEW_ARGS(SkPDFAlphaFunctionShader, (autoState->detach()));
740 706
741 alphaFunctionShader->fColorShader.reset(colorShader); 707 alphaFunctionShader->fColorShader.reset(colorShader);
742 708
743 alphaFunctionShader->fResourceDict.reset(get_gradient_resource_dict( 709 alphaFunctionShader->fResourceDict.reset(get_gradient_resource_dict(
744 alphaFunctionShader->fColorShader.get(), alphaGs.get())); 710 alphaFunctionShader->fColorShader.get(), alphaGs.get()));
745 711
746 SkAutoTDelete<SkStream> colorStream( 712 SkAutoTDelete<SkStream> colorStream(
747 create_pattern_fill_content(0, bbox)); 713 create_pattern_fill_content(0, bbox));
748 alphaFunctionShader->setData(colorStream.get()); 714 alphaFunctionShader->setData(colorStream.get());
749 715
750 populate_tiling_pattern_dict(alphaFunctionShader, bbox, 716 populate_tiling_pattern_dict(alphaFunctionShader, bbox,
751 alphaFunctionShader->fResourceDict.get(), 717 alphaFunctionShader->fResourceDict.get(),
752 SkMatrix::I()); 718 SkMatrix::I());
753 SkPDFCanon::GetCanon().addShader(alphaFunctionShader); 719 SkPDFCanon::GetCanon().addAlphaShader(alphaFunctionShader);
754 return alphaFunctionShader; 720 return alphaFunctionShader;
755 } 721 }
756 722
757 SkPDFAlphaFunctionShader::SkPDFAlphaFunctionShader(SkPDFShader::State* state)
758 : SkPDFShader(state) {}
759
760 // Finds affine and persp such that in = affine * persp. 723 // Finds affine and persp such that in = affine * persp.
761 // but it returns the inverse of perspective matrix. 724 // but it returns the inverse of perspective matrix.
762 static bool split_perspective(const SkMatrix in, SkMatrix* affine, 725 static bool split_perspective(const SkMatrix in, SkMatrix* affine,
763 SkMatrix* perspectiveInverse) { 726 SkMatrix* perspectiveInverse) {
764 const SkScalar p2 = in[SkMatrix::kMPersp2]; 727 const SkScalar p2 = in[SkMatrix::kMPersp2];
765 728
766 if (SkScalarNearlyZero(p2)) { 729 if (SkScalarNearlyZero(p2)) {
767 return false; 730 return false;
768 } 731 }
769 732
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 SkPDFArray* domain) { 781 SkPDFArray* domain) {
819 SkAutoDataUnref funcData( 782 SkAutoDataUnref funcData(
820 SkData::NewWithCopy(psCode.c_str(), psCode.size())); 783 SkData::NewWithCopy(psCode.c_str(), psCode.size()));
821 SkPDFStream* result = SkNEW_ARGS(SkPDFStream, (funcData.get())); 784 SkPDFStream* result = SkNEW_ARGS(SkPDFStream, (funcData.get()));
822 result->insertInt("FunctionType", 4); 785 result->insertInt("FunctionType", 4);
823 result->insert("Domain", domain); 786 result->insert("Domain", domain);
824 result->insert("Range", rangeObject.get()); 787 result->insert("Range", rangeObject.get());
825 return result; 788 return result;
826 } 789 }
827 790
828 SkPDFObject* SkPDFFunctionShader::Create( 791 SkPDFFunctionShader* SkPDFFunctionShader::Create(
829 SkAutoTDelete<SkPDFShader::State>* autoState) { 792 SkAutoTDelete<SkPDFShader::State>* autoState) {
830 const SkPDFShader::State& state = **autoState; 793 const SkPDFShader::State& state = **autoState;
831 794
832 SkString (*codeFunction)(const SkShader::GradientInfo& info, 795 SkString (*codeFunction)(const SkShader::GradientInfo& info,
833 const SkMatrix& perspectiveRemover) = NULL; 796 const SkMatrix& perspectiveRemover) = NULL;
834 SkPoint transformPoints[2]; 797 SkPoint transformPoints[2];
835 798
836 // Depending on the type of the gradient, we want to transform the 799 // Depending on the type of the gradient, we want to transform the
837 // coordinate space in different ways. 800 // coordinate space in different ways.
838 const SkShader::GradientInfo* info = &state.fInfo; 801 const SkShader::GradientInfo* info = &state.fInfo;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 SkPDFFunctionShader* pdfFunctionShader = 910 SkPDFFunctionShader* pdfFunctionShader =
948 SkNEW_ARGS(SkPDFFunctionShader, (autoState->detach())); 911 SkNEW_ARGS(SkPDFFunctionShader, (autoState->detach()));
949 912
950 pdfFunctionShader->fResources.push(function); 913 pdfFunctionShader->fResources.push(function);
951 // Pass ownership to resource list. 914 // Pass ownership to resource list.
952 915
953 pdfFunctionShader->insertInt("PatternType", 2); 916 pdfFunctionShader->insertInt("PatternType", 2);
954 pdfFunctionShader->insert("Matrix", matrixArray.get()); 917 pdfFunctionShader->insert("Matrix", matrixArray.get());
955 pdfFunctionShader->insert("Shading", pdfShader.get()); 918 pdfFunctionShader->insert("Shading", pdfShader.get());
956 919
957 SkPDFCanon::GetCanon().addShader(pdfFunctionShader); 920 SkPDFCanon::GetCanon().addFunctionShader(pdfFunctionShader);
958 return pdfFunctionShader; 921 return pdfFunctionShader;
959 } 922 }
960 923
961 SkPDFObject* SkPDFImageShader::Create( 924 SkPDFImageShader* SkPDFImageShader::Create(
962 SkAutoTDelete<SkPDFShader::State>* autoState) { 925 SkAutoTDelete<SkPDFShader::State>* autoState) {
963 const SkPDFShader::State& state = **autoState; 926 const SkPDFShader::State& state = **autoState;
964 927
965 state.fImage.lockPixels(); 928 state.fImage.lockPixels();
966 929
967 // The image shader pattern cell will be drawn into a separate device 930 // The image shader pattern cell will be drawn into a separate device
968 // in pattern cell space (no scaling on the bitmap, though there may be 931 // in pattern cell space (no scaling on the bitmap, though there may be
969 // translations so that all content is in the device, coordinates > 0). 932 // translations so that all content is in the device, coordinates > 0).
970 933
971 // Map clip bounds to shader space to ensure the device is large enough 934 // Map clip bounds to shader space to ensure the device is large enough
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 1131
1169 SkPDFResourceDict* resourceDict = pattern.getResourceDict(); 1132 SkPDFResourceDict* resourceDict = pattern.getResourceDict();
1170 resourceDict->getReferencedResources(imageShader->fResources, 1133 resourceDict->getReferencedResources(imageShader->fResources,
1171 &imageShader->fResources, false); 1134 &imageShader->fResources, false);
1172 1135
1173 populate_tiling_pattern_dict(imageShader, patternBBox, 1136 populate_tiling_pattern_dict(imageShader, patternBBox,
1174 pattern.getResourceDict(), finalMatrix); 1137 pattern.getResourceDict(), finalMatrix);
1175 1138
1176 imageShader->fShaderState->fImage.unlockPixels(); 1139 imageShader->fShaderState->fImage.unlockPixels();
1177 1140
1178 SkPDFCanon::GetCanon().addShader(imageShader); 1141 SkPDFCanon::GetCanon().addImageShader(imageShader);
1179 return imageShader; 1142 return imageShader;
1180 } 1143 }
1181 1144
1182 bool SkPDFShader::State::operator==(const SkPDFShader::State& b) const { 1145 bool SkPDFShader::State::operator==(const SkPDFShader::State& b) const {
1183 if (fType != b.fType || 1146 if (fType != b.fType ||
1184 fCanvasTransform != b.fCanvasTransform || 1147 fCanvasTransform != b.fCanvasTransform ||
1185 fShaderTransform != b.fShaderTransform || 1148 fShaderTransform != b.fShaderTransform ||
1186 fBBox != b.fBBox) { 1149 fBBox != b.fBBox) {
1187 return false; 1150 return false;
1188 } 1151 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 return false; 1325 return false;
1363 } 1326 }
1364 1327
1365 void SkPDFShader::State::AllocateGradientInfoStorage() { 1328 void SkPDFShader::State::AllocateGradientInfoStorage() {
1366 fColorData.set(sk_malloc_throw( 1329 fColorData.set(sk_malloc_throw(
1367 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); 1330 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar))));
1368 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); 1331 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get());
1369 fInfo.fColorOffsets = 1332 fInfo.fColorOffsets =
1370 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); 1333 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount);
1371 } 1334 }
OLDNEW
« src/pdf/SkPDFCanon.cpp ('K') | « src/pdf/SkPDFShader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698