OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkLazyPtr.h" | 8 #include "SkLazyPtr.h" |
9 #include "SkPDFCanon.h" | 9 #include "SkPDFCanon.h" |
10 #include "SkPDFFont.h" | 10 #include "SkPDFFont.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 //////////////////////////////////////////////////////////////////////////////// | 32 //////////////////////////////////////////////////////////////////////////////// |
33 | 33 |
34 static void assert_mutex_held(const SkPDFCanon* canon, SkBaseMutex& mutex) { | 34 static void assert_mutex_held(const SkPDFCanon* canon, SkBaseMutex& mutex) { |
35 if (canon == singleton.get()) { | 35 if (canon == singleton.get()) { |
36 mutex.assertHeld(); | 36 mutex.assertHeld(); |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 template <class T> T* assert_ptr(T* p) { SkASSERT(p); return p; } | 40 template <class T> T* assert_ptr(T* p) { SkASSERT(p); return p; } |
41 | 41 |
42 // TODO(halcanary): add this method to SkTDArray. | |
43 template <typename T> | 42 template <typename T> |
44 bool remove_item(SkTDArray<T>* array, const T& elem) { | 43 bool remove_item(SkTDArray<T>* array, const T& elem) { |
45 int i = array->find(elem); | 44 int i = array->find(elem); |
46 if (i >= 0) { | 45 if (i >= 0) { |
47 array->removeShuffle(i); | 46 array->removeShuffle(i); |
48 return true; | 47 return true; |
49 } | 48 } |
50 return false; | 49 return false; |
51 } | 50 } |
52 | 51 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 161 |
163 void SkPDFCanon::addGraphicState(SkPDFGraphicState* state) { | 162 void SkPDFCanon::addGraphicState(SkPDFGraphicState* state) { |
164 assert_mutex_held(this, gSkPDFCanonPaintMutex); | 163 assert_mutex_held(this, gSkPDFCanonPaintMutex); |
165 fGraphicStateRecords.push(assert_ptr(state)); | 164 fGraphicStateRecords.push(assert_ptr(state)); |
166 } | 165 } |
167 | 166 |
168 void SkPDFCanon::removeGraphicState(SkPDFGraphicState* pdfGraphicState) { | 167 void SkPDFCanon::removeGraphicState(SkPDFGraphicState* pdfGraphicState) { |
169 assert_mutex_held(this, gSkPDFCanonPaintMutex); | 168 assert_mutex_held(this, gSkPDFCanonPaintMutex); |
170 SkAssertResult(remove_item(&fGraphicStateRecords, pdfGraphicState)); | 169 SkAssertResult(remove_item(&fGraphicStateRecords, pdfGraphicState)); |
171 } | 170 } |
OLD | NEW |