| 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 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 * positioned, relative to where the page is drawn.) | 38 * positioned, relative to where the page is drawn.) |
| 39 * @param surfceBBox The bounding box of the drawing surface (with matrix | 39 * @param surfceBBox The bounding box of the drawing surface (with matrix |
| 40 * already applied). | 40 * already applied). |
| 41 * @param rasterScale Additional scale to be applied for early rasterizatio
n. | 41 * @param rasterScale Additional scale to be applied for early rasterizatio
n. |
| 42 */ | 42 */ |
| 43 static SkPDFObject* GetPDFShader(const SkShader& shader, | 43 static SkPDFObject* GetPDFShader(const SkShader& shader, |
| 44 const SkMatrix& matrix, | 44 const SkMatrix& matrix, |
| 45 const SkIRect& surfaceBBox, | 45 const SkIRect& surfaceBBox, |
| 46 SkScalar rasterScale); | 46 SkScalar rasterScale); |
| 47 | 47 |
| 48 class State; |
| 49 bool equals(const SkPDFShader::State&) const; |
| 50 |
| 48 protected: | 51 protected: |
| 49 class State; | 52 SkAutoTDelete<const State> fShaderState; |
| 50 | |
| 51 class ShaderCanonicalEntry { | |
| 52 public: | |
| 53 ShaderCanonicalEntry(SkPDFObject* pdfShader, const State* state); | |
| 54 bool operator==(const ShaderCanonicalEntry& b) const; | |
| 55 | |
| 56 SkPDFObject* fPDFShader; | |
| 57 const State* fState; | |
| 58 }; | |
| 59 // This should be made a hash table if performance is a problem. | |
| 60 static SkTDArray<ShaderCanonicalEntry>& CanonicalShaders(); | |
| 61 static SkBaseMutex& CanonicalShadersMutex(); | |
| 62 | 53 |
| 63 // This is an internal method. | 54 // This is an internal method. |
| 64 // CanonicalShadersMutex() should already be acquired. | 55 // CanonicalShadersMutex() should already be acquired. |
| 65 // This also takes ownership of shaderState. | 56 // This also takes ownership of shaderState. |
| 66 static SkPDFObject* GetPDFShaderByState(State* shaderState); | 57 static SkPDFObject* GetPDFShaderByState(State* shaderState); |
| 67 static void RemoveShader(SkPDFObject* shader); | 58 static SkPDFObject* AddToCanonIfValid(SkPDFShader*); |
| 59 static void RemoveFromCanonIfValid(SkPDFShader*); |
| 68 | 60 |
| 69 SkPDFShader(); | 61 SkPDFShader(State*); |
| 70 virtual ~SkPDFShader() {}; | 62 virtual ~SkPDFShader(); |
| 71 | 63 |
| 72 virtual bool isValid() = 0; | 64 virtual bool isValid() = 0; |
| 65 virtual SkPDFObject* toPDFObject() = 0; |
| 73 }; | 66 }; |
| 74 | 67 |
| 75 #endif | 68 #endif |
| OLD | NEW |