| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkData.h" | 8 #include "SkData.h" |
| 9 #include "SkPDFFormXObject.h" | 9 #include "SkPDFFormXObject.h" |
| 10 #include "SkPDFGraphicState.h" | 10 #include "SkPDFGraphicState.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 return SkPDFDict::getOutputSize(catalog, indirect); | 81 return SkPDFDict::getOutputSize(catalog, indirect); |
| 82 } | 82 } |
| 83 | 83 |
| 84 // static | 84 // static |
| 85 SkTDArray<SkPDFGraphicState::GSCanonicalEntry>& SkPDFGraphicState::CanonicalPain
ts() { | 85 SkTDArray<SkPDFGraphicState::GSCanonicalEntry>& SkPDFGraphicState::CanonicalPain
ts() { |
| 86 CanonicalPaintsMutex().assertHeld(); | 86 CanonicalPaintsMutex().assertHeld(); |
| 87 static SkTDArray<SkPDFGraphicState::GSCanonicalEntry> gCanonicalPaints; | 87 static SkTDArray<SkPDFGraphicState::GSCanonicalEntry> gCanonicalPaints; |
| 88 return gCanonicalPaints; | 88 return gCanonicalPaints; |
| 89 } | 89 } |
| 90 | 90 |
| 91 SK_DECLARE_STATIC_MUTEX(gCanonicalPaintsMutex); |
| 91 // static | 92 // static |
| 92 SkBaseMutex& SkPDFGraphicState::CanonicalPaintsMutex() { | 93 SkBaseMutex& SkPDFGraphicState::CanonicalPaintsMutex() { |
| 93 SK_DECLARE_STATIC_MUTEX(gCanonicalPaintsMutex); | |
| 94 return gCanonicalPaintsMutex; | 94 return gCanonicalPaintsMutex; |
| 95 } | 95 } |
| 96 | 96 |
| 97 // static | 97 // static |
| 98 SkPDFGraphicState* SkPDFGraphicState::GetGraphicStateForPaint(const SkPaint& pai
nt) { | 98 SkPDFGraphicState* SkPDFGraphicState::GetGraphicStateForPaint(const SkPaint& pai
nt) { |
| 99 SkAutoMutexAcquire lock(CanonicalPaintsMutex()); | 99 SkAutoMutexAcquire lock(CanonicalPaintsMutex()); |
| 100 int index = Find(paint); | 100 int index = Find(paint); |
| 101 if (index >= 0) { | 101 if (index >= 0) { |
| 102 CanonicalPaints()[index].fGraphicState->ref(); | 102 CanonicalPaints()[index].fGraphicState->ref(); |
| 103 return CanonicalPaints()[index].fGraphicState; | 103 return CanonicalPaints()[index].fGraphicState; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 } | 278 } |
| 279 if (bXfermodeName < 0 || bXfermodeName > SkXfermode::kLastMode || | 279 if (bXfermodeName < 0 || bXfermodeName > SkXfermode::kLastMode || |
| 280 blend_mode_from_xfermode(bXfermodeName) == NULL) { | 280 blend_mode_from_xfermode(bXfermodeName) == NULL) { |
| 281 bXfermodeName = SkXfermode::kSrcOver_Mode; | 281 bXfermodeName = SkXfermode::kSrcOver_Mode; |
| 282 } | 282 } |
| 283 const char* bXfermodeString = blend_mode_from_xfermode(bXfermodeName); | 283 const char* bXfermodeString = blend_mode_from_xfermode(bXfermodeName); |
| 284 SkASSERT(bXfermodeString != NULL); | 284 SkASSERT(bXfermodeString != NULL); |
| 285 | 285 |
| 286 return strcmp(aXfermodeString, bXfermodeString) == 0; | 286 return strcmp(aXfermodeString, bXfermodeString) == 0; |
| 287 } | 287 } |
| OLD | NEW |