| 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 "SkPDFBitmap.h" |
| 9 #include "SkPDFCanon.h" | 10 #include "SkPDFCanon.h" |
| 10 #include "SkPDFFont.h" | 11 #include "SkPDFFont.h" |
| 11 #include "SkPDFGraphicState.h" | 12 #include "SkPDFGraphicState.h" |
| 12 #include "SkPDFShader.h" | 13 #include "SkPDFShader.h" |
| 13 | 14 |
| 14 //////////////////////////////////////////////////////////////////////////////// | 15 //////////////////////////////////////////////////////////////////////////////// |
| 15 | 16 |
| 16 SK_DECLARE_STATIC_MUTEX(gSkPDFCanonFontMutex); | 17 SK_DECLARE_STATIC_MUTEX(gSkPDFCanonFontMutex); |
| 17 SK_DECLARE_STATIC_MUTEX(gSkPDFCanonShaderMutex); | 18 SK_DECLARE_STATIC_MUTEX(gSkPDFCanonShaderMutex); |
| 18 SK_DECLARE_STATIC_MUTEX(gSkPDFCanonPaintMutex); | 19 SK_DECLARE_STATIC_MUTEX(gSkPDFCanonPaintMutex); |
| 20 SK_DECLARE_STATIC_MUTEX(gSkPDFCanonBitmapMutex); |
| 19 | 21 |
| 20 SkBaseMutex& SkPDFCanon::GetFontMutex() { return gSkPDFCanonFontMutex; } | 22 SkBaseMutex& SkPDFCanon::GetFontMutex() { return gSkPDFCanonFontMutex; } |
| 21 SkBaseMutex& SkPDFCanon::GetShaderMutex() { return gSkPDFCanonShaderMutex; } | 23 SkBaseMutex& SkPDFCanon::GetShaderMutex() { return gSkPDFCanonShaderMutex; } |
| 22 SkBaseMutex& SkPDFCanon::GetPaintMutex() { return gSkPDFCanonPaintMutex; } | 24 SkBaseMutex& SkPDFCanon::GetPaintMutex() { return gSkPDFCanonPaintMutex; } |
| 25 SkBaseMutex& SkPDFCanon::GetBitmapMutex() { return gSkPDFCanonBitmapMutex; } |
| 23 | 26 |
| 24 SkPDFCanon::SkPDFCanon() {} | 27 SkPDFCanon::SkPDFCanon() {} |
| 25 | 28 |
| 26 SkPDFCanon::~SkPDFCanon() {} | 29 SkPDFCanon::~SkPDFCanon() {} |
| 27 | 30 |
| 28 SK_DECLARE_STATIC_LAZY_PTR(SkPDFCanon, singleton); | 31 SK_DECLARE_STATIC_LAZY_PTR(SkPDFCanon, singleton); |
| 29 | 32 |
| 30 SkPDFCanon& SkPDFCanon::GetCanon() { return *singleton.get(); } | 33 SkPDFCanon& SkPDFCanon::GetCanon() { return *singleton.get(); } |
| 31 | 34 |
| 32 //////////////////////////////////////////////////////////////////////////////// | 35 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 164 |
| 162 void SkPDFCanon::addGraphicState(SkPDFGraphicState* state) { | 165 void SkPDFCanon::addGraphicState(SkPDFGraphicState* state) { |
| 163 assert_mutex_held(this, gSkPDFCanonPaintMutex); | 166 assert_mutex_held(this, gSkPDFCanonPaintMutex); |
| 164 fGraphicStateRecords.push(assert_ptr(state)); | 167 fGraphicStateRecords.push(assert_ptr(state)); |
| 165 } | 168 } |
| 166 | 169 |
| 167 void SkPDFCanon::removeGraphicState(SkPDFGraphicState* pdfGraphicState) { | 170 void SkPDFCanon::removeGraphicState(SkPDFGraphicState* pdfGraphicState) { |
| 168 assert_mutex_held(this, gSkPDFCanonPaintMutex); | 171 assert_mutex_held(this, gSkPDFCanonPaintMutex); |
| 169 SkAssertResult(remove_item(&fGraphicStateRecords, pdfGraphicState)); | 172 SkAssertResult(remove_item(&fGraphicStateRecords, pdfGraphicState)); |
| 170 } | 173 } |
| 174 |
| 175 //////////////////////////////////////////////////////////////////////////////// |
| 176 |
| 177 SkPDFBitmap* SkPDFCanon::findBitmap(const SkBitmap& bm) const { |
| 178 assert_mutex_held(this, gSkPDFCanonBitmapMutex); |
| 179 return find_item(fBitmapRecords, bm); |
| 180 } |
| 181 |
| 182 void SkPDFCanon::addBitmap(SkPDFBitmap* pdfBitmap) { |
| 183 assert_mutex_held(this, gSkPDFCanonBitmapMutex); |
| 184 fBitmapRecords.push(assert_ptr(pdfBitmap)); |
| 185 } |
| 186 |
| 187 void SkPDFCanon::removeBitmap(SkPDFBitmap* pdfBitmap) { |
| 188 assert_mutex_held(this, gSkPDFCanonBitmapMutex); |
| 189 SkAssertResult(remove_item(&fBitmapRecords, pdfBitmap)); |
| 190 } |
| OLD | NEW |