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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 492 |
493 bool GradientHasAlpha() const; | 493 bool GradientHasAlpha() const; |
494 | 494 |
495 private: | 495 private: |
496 State(const State& other); | 496 State(const State& other); |
497 State operator=(const State& rhs); | 497 State operator=(const State& rhs); |
498 void AllocateGradientInfoStorage(); | 498 void AllocateGradientInfoStorage(); |
499 }; | 499 }; |
500 | 500 |
501 class SkPDFFunctionShader : public SkPDFDict, public SkPDFShader { | 501 class SkPDFFunctionShader : public SkPDFDict, public SkPDFShader { |
| 502 SK_DECLARE_INST_COUNT(SkPDFFunctionShader) |
502 public: | 503 public: |
503 explicit SkPDFFunctionShader(SkPDFShader::State* state); | 504 explicit SkPDFFunctionShader(SkPDFShader::State* state); |
504 virtual ~SkPDFFunctionShader() { | 505 virtual ~SkPDFFunctionShader() { |
505 if (isValid()) { | 506 if (isValid()) { |
506 RemoveShader(this); | 507 RemoveShader(this); |
507 } | 508 } |
508 fResources.unrefAll(); | 509 fResources.unrefAll(); |
509 } | 510 } |
510 | 511 |
511 virtual bool isValid() { return fResources.count() > 0; } | 512 virtual bool isValid() { return fResources.count() > 0; } |
512 | 513 |
513 void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects, | 514 void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects, |
514 SkTSet<SkPDFObject*>* newResourceObjects) { | 515 SkTSet<SkPDFObject*>* newResourceObjects) { |
515 GetResourcesHelper(&fResources, | 516 GetResourcesHelper(&fResources, |
516 knownResourceObjects, | 517 knownResourceObjects, |
517 newResourceObjects); | 518 newResourceObjects); |
518 } | 519 } |
519 | 520 |
520 private: | 521 private: |
521 static SkPDFObject* RangeObject(); | 522 static SkPDFObject* RangeObject(); |
522 | 523 |
523 SkTDArray<SkPDFObject*> fResources; | 524 SkTDArray<SkPDFObject*> fResources; |
524 SkAutoTDelete<const SkPDFShader::State> fState; | 525 SkAutoTDelete<const SkPDFShader::State> fState; |
525 | 526 |
526 SkPDFStream* makePSFunction(const SkString& psCode, SkPDFArray* domain); | 527 SkPDFStream* makePSFunction(const SkString& psCode, SkPDFArray* domain); |
| 528 typedef SkPDFDict INHERITED; |
527 }; | 529 }; |
528 | 530 |
529 /** | 531 /** |
530 * A shader for PDF gradients. This encapsulates the function shader | 532 * A shader for PDF gradients. This encapsulates the function shader |
531 * inside a tiling pattern while providing a common pattern interface. | 533 * inside a tiling pattern while providing a common pattern interface. |
532 * The encapsulation allows the use of a SMask for transparency gradients. | 534 * The encapsulation allows the use of a SMask for transparency gradients. |
533 */ | 535 */ |
534 class SkPDFAlphaFunctionShader : public SkPDFStream, public SkPDFShader { | 536 class SkPDFAlphaFunctionShader : public SkPDFStream, public SkPDFShader { |
535 public: | 537 public: |
536 explicit SkPDFAlphaFunctionShader(SkPDFShader::State* state); | 538 explicit SkPDFAlphaFunctionShader(SkPDFShader::State* state); |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 return false; | 1339 return false; |
1338 } | 1340 } |
1339 | 1341 |
1340 void SkPDFShader::State::AllocateGradientInfoStorage() { | 1342 void SkPDFShader::State::AllocateGradientInfoStorage() { |
1341 fColorData.set(sk_malloc_throw( | 1343 fColorData.set(sk_malloc_throw( |
1342 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); | 1344 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); |
1343 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); | 1345 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); |
1344 fInfo.fColorOffsets = | 1346 fInfo.fColorOffsets = |
1345 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); | 1347 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); |
1346 } | 1348 } |
OLD | NEW |