Chromium Code Reviews| 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 #ifndef SkPDFShader_DEFINED | 10 #ifndef SkPDFShader_DEFINED |
| 11 #define SkPDFShader_DEFINED | 11 #define SkPDFShader_DEFINED |
| 12 | 12 |
| 13 #include "SkPDFStream.h" | 13 #include "SkPDFStream.h" |
| 14 #include "SkPDFTypes.h" | 14 #include "SkPDFTypes.h" |
| 15 #include "SkMatrix.h" | 15 #include "SkMatrix.h" |
| 16 #include "SkRefCnt.h" | 16 #include "SkRefCnt.h" |
| 17 #include "SkShader.h" | 17 #include "SkShader.h" |
| 18 | 18 |
| 19 class SkObjRef; | 19 class SkObjRef; |
| 20 class SkPDFCatalog; | 20 class SkPDFCatalog; |
| 21 | 21 |
| 22 /** \class SkPDFShader | 22 /** \class SkPDFShader |
| 23 | 23 |
| 24 In PDF parlance, this is a pattern, used in place of a color when the | 24 In PDF parlance, this is a pattern, used in place of a color when the |
| 25 pattern color space is selected. | 25 pattern color space is selected. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 class SkPDFShaderState; | |
| 29 | |
| 28 class SkPDFShader { | 30 class SkPDFShader { |
| 29 public: | 31 public: |
| 30 /** Get the PDF shader for the passed SkShader. If the SkShader is | 32 /** Get the PDF shader for the passed SkShader. If the SkShader is |
| 31 * invalid in some way, returns NULL. The reference count of | 33 * invalid in some way, returns NULL. The reference count of |
| 32 * the object is incremented and it is the caller's responsibility to | 34 * the object is incremented and it is the caller's responsibility to |
| 33 * unreference it when done. This is needed to accommodate the weak | 35 * unreference it when done. This is needed to accommodate the weak |
| 34 * reference pattern used when the returned object is new and has no | 36 * reference pattern used when the returned object is new and has no |
| 35 * other references. | 37 * other references. |
| 36 * @param shader The SkShader to emulate. | 38 * @param shader The SkShader to emulate. |
| 37 * @param matrix The current transform. (PDF shaders are absolutely | 39 * @param matrix The current transform. (PDF shaders are absolutely |
| 38 * positioned, relative to where the page is drawn.) | 40 * positioned, relative to where the page is drawn.) |
| 39 * @param surfceBBox The bounding box of the drawing surface (with matrix | 41 * @param surfceBBox The bounding box of the drawing surface (with matrix |
| 40 * already applied). | 42 * already applied). |
| 41 */ | 43 */ |
| 42 static SkPDFObject* GetPDFShader(const SkShader& shader, | 44 static SkPDFObject* GetPDFShader(const SkShader& shader, |
| 43 const SkMatrix& matrix, | 45 const SkMatrix& matrix, |
| 44 const SkIRect& surfaceBBox); | 46 const SkIRect& surfaceBBox); |
| 45 | 47 |
| 48 const SkPDFShaderState& pdfShaderState() const; | |
|
mtklein
2015/01/20 21:59:52
I am very skeptical about the number of "pdf"s in
hal.canary
2015/01/21 17:07:51
Done.
| |
| 49 | |
| 50 bool equals(const SkPDFShaderState&) const; | |
| 51 | |
| 46 protected: | 52 protected: |
| 47 class State; | 53 SkAutoTDelete<const SkPDFShaderState> fPDFShaderState; |
| 48 | |
| 49 class ShaderCanonicalEntry { | |
| 50 public: | |
| 51 ShaderCanonicalEntry(SkPDFObject* pdfShader, const State* state); | |
| 52 bool operator==(const ShaderCanonicalEntry& b) const; | |
| 53 | |
| 54 SkPDFObject* fPDFShader; | |
| 55 const State* fState; | |
| 56 }; | |
| 57 // This should be made a hash table if performance is a problem. | |
| 58 static SkTDArray<ShaderCanonicalEntry>& CanonicalShaders(); | |
| 59 static SkBaseMutex& CanonicalShadersMutex(); | |
| 60 | 54 |
| 61 // This is an internal method. | 55 // This is an internal method. |
| 62 // CanonicalShadersMutex() should already be acquired. | 56 // CanonicalShadersMutex() should already be acquired. |
| 63 // This also takes ownership of shaderState. | 57 // This also takes ownership of shaderState. |
| 64 static SkPDFObject* GetPDFShaderByState(State* shaderState); | 58 static SkPDFObject* GetPDFShaderByState(SkPDFShaderState* shaderState); |
| 65 static void RemoveShader(SkPDFObject* shader); | 59 static void RemoveShader(SkPDFObject* shader); |
| 66 | 60 |
| 67 SkPDFShader(); | 61 SkPDFShader(const SkPDFShaderState* state); |
| 68 virtual ~SkPDFShader() {}; | 62 |
| 63 virtual ~SkPDFShader(); | |
| 69 | 64 |
| 70 virtual bool isValid() = 0; | 65 virtual bool isValid() = 0; |
| 66 virtual SkPDFObject* toPDFObject() = 0; | |
| 71 }; | 67 }; |
| 72 | 68 |
| 73 #endif | 69 #endif |
| OLD | NEW |