OLD | NEW |
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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 SK_DECLARE_INST_COUNT(SkPDFFunctionShader) | 508 SK_DECLARE_INST_COUNT(SkPDFFunctionShader) |
509 public: | 509 public: |
510 explicit SkPDFFunctionShader(SkPDFShader::State* state); | 510 explicit SkPDFFunctionShader(SkPDFShader::State* state); |
511 virtual ~SkPDFFunctionShader() { | 511 virtual ~SkPDFFunctionShader() { |
512 if (isValid()) { | 512 if (isValid()) { |
513 RemoveShader(this); | 513 RemoveShader(this); |
514 } | 514 } |
515 fResources.unrefAll(); | 515 fResources.unrefAll(); |
516 } | 516 } |
517 | 517 |
518 virtual bool isValid() { return fResources.count() > 0; } | 518 virtual bool isValid() SK_OVERRIDE { return fResources.count() > 0; } |
519 | 519 |
520 void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects, | 520 void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects, |
521 SkTSet<SkPDFObject*>* newResourceObjects) { | 521 SkTSet<SkPDFObject*>* newResourceObjects) SK_OVERRIDE { |
522 GetResourcesHelper(&fResources, | 522 GetResourcesHelper(&fResources, |
523 knownResourceObjects, | 523 knownResourceObjects, |
524 newResourceObjects); | 524 newResourceObjects); |
525 } | 525 } |
526 | 526 |
527 private: | 527 private: |
528 static SkPDFObject* RangeObject(); | 528 static SkPDFObject* RangeObject(); |
529 | 529 |
530 SkTDArray<SkPDFObject*> fResources; | 530 SkTDArray<SkPDFObject*> fResources; |
531 SkAutoTDelete<const SkPDFShader::State> fState; | 531 SkAutoTDelete<const SkPDFShader::State> fState; |
532 | 532 |
533 SkPDFStream* makePSFunction(const SkString& psCode, SkPDFArray* domain); | 533 SkPDFStream* makePSFunction(const SkString& psCode, SkPDFArray* domain); |
534 typedef SkPDFDict INHERITED; | 534 typedef SkPDFDict INHERITED; |
535 }; | 535 }; |
536 | 536 |
537 /** | 537 /** |
538 * A shader for PDF gradients. This encapsulates the function shader | 538 * A shader for PDF gradients. This encapsulates the function shader |
539 * inside a tiling pattern while providing a common pattern interface. | 539 * inside a tiling pattern while providing a common pattern interface. |
540 * The encapsulation allows the use of a SMask for transparency gradients. | 540 * The encapsulation allows the use of a SMask for transparency gradients. |
541 */ | 541 */ |
542 class SkPDFAlphaFunctionShader : public SkPDFStream, public SkPDFShader { | 542 class SkPDFAlphaFunctionShader : public SkPDFStream, public SkPDFShader { |
543 public: | 543 public: |
544 explicit SkPDFAlphaFunctionShader(SkPDFShader::State* state); | 544 explicit SkPDFAlphaFunctionShader(SkPDFShader::State* state); |
545 virtual ~SkPDFAlphaFunctionShader() { | 545 virtual ~SkPDFAlphaFunctionShader() { |
546 if (isValid()) { | 546 if (isValid()) { |
547 RemoveShader(this); | 547 RemoveShader(this); |
548 } | 548 } |
549 } | 549 } |
550 | 550 |
551 virtual bool isValid() { | 551 virtual bool isValid() SK_OVERRIDE { |
552 return fColorShader.get() != NULL; | 552 return fColorShader.get() != NULL; |
553 } | 553 } |
554 | 554 |
555 private: | 555 private: |
556 SkAutoTDelete<const SkPDFShader::State> fState; | 556 SkAutoTDelete<const SkPDFShader::State> fState; |
557 | 557 |
558 SkPDFGraphicState* CreateSMaskGraphicState(); | 558 SkPDFGraphicState* CreateSMaskGraphicState(); |
559 | 559 |
560 void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects, | 560 void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects, |
561 SkTSet<SkPDFObject*>* newResourceObjects) { | 561 SkTSet<SkPDFObject*>* newResourceObjects) SK_OVERRIDE { |
562 fResourceDict->getReferencedResources(knownResourceObjects, | 562 fResourceDict->getReferencedResources(knownResourceObjects, |
563 newResourceObjects, | 563 newResourceObjects, |
564 true); | 564 true); |
565 } | 565 } |
566 | 566 |
567 SkAutoTUnref<SkPDFObject> fColorShader; | 567 SkAutoTUnref<SkPDFObject> fColorShader; |
568 SkAutoTUnref<SkPDFResourceDict> fResourceDict; | 568 SkAutoTUnref<SkPDFResourceDict> fResourceDict; |
569 }; | 569 }; |
570 | 570 |
571 class SkPDFImageShader : public SkPDFStream, public SkPDFShader { | 571 class SkPDFImageShader : public SkPDFStream, public SkPDFShader { |
572 public: | 572 public: |
573 explicit SkPDFImageShader(SkPDFShader::State* state); | 573 explicit SkPDFImageShader(SkPDFShader::State* state); |
574 virtual ~SkPDFImageShader() { | 574 virtual ~SkPDFImageShader() { |
575 if (isValid()) { | 575 if (isValid()) { |
576 RemoveShader(this); | 576 RemoveShader(this); |
577 } | 577 } |
578 fResources.unrefAll(); | 578 fResources.unrefAll(); |
579 } | 579 } |
580 | 580 |
581 virtual bool isValid() { return size() > 0; } | 581 virtual bool isValid() SK_OVERRIDE { return size() > 0; } |
582 | 582 |
583 void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects, | 583 void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects, |
584 SkTSet<SkPDFObject*>* newResourceObjects) { | 584 SkTSet<SkPDFObject*>* newResourceObjects) SK_OVERRIDE { |
585 GetResourcesHelper(&fResources.toArray(), | 585 GetResourcesHelper(&fResources.toArray(), |
586 knownResourceObjects, | 586 knownResourceObjects, |
587 newResourceObjects); | 587 newResourceObjects); |
588 } | 588 } |
589 | 589 |
590 private: | 590 private: |
591 SkTSet<SkPDFObject*> fResources; | 591 SkTSet<SkPDFObject*> fResources; |
592 SkAutoTDelete<const SkPDFShader::State> fState; | 592 SkAutoTDelete<const SkPDFShader::State> fState; |
593 }; | 593 }; |
594 | 594 |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1339 return false; | 1339 return false; |
1340 } | 1340 } |
1341 | 1341 |
1342 void SkPDFShader::State::AllocateGradientInfoStorage() { | 1342 void SkPDFShader::State::AllocateGradientInfoStorage() { |
1343 fColorData.set(sk_malloc_throw( | 1343 fColorData.set(sk_malloc_throw( |
1344 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); | 1344 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); |
1345 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); | 1345 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); |
1346 fInfo.fColorOffsets = | 1346 fInfo.fColorOffsets = |
1347 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); | 1347 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); |
1348 } | 1348 } |
OLD | NEW |