Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: src/pdf/SkPDFShader.cpp

Issue 348113002: Use SkMutex::assertHeld in SkPDFFont and SkPDFShader. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: AnotherPatchSet Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pdf/SkPDFFont.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "SkPDFShader.h" 10 #include "SkPDFShader.h"
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 SkPDFObject* SkPDFShader::GetPDFShader(const SkShader& shader, 652 SkPDFObject* SkPDFShader::GetPDFShader(const SkShader& shader,
653 const SkMatrix& matrix, 653 const SkMatrix& matrix,
654 const SkIRect& surfaceBBox) { 654 const SkIRect& surfaceBBox) {
655 SkAutoMutexAcquire lock(CanonicalShadersMutex()); 655 SkAutoMutexAcquire lock(CanonicalShadersMutex());
656 return GetPDFShaderByState( 656 return GetPDFShaderByState(
657 SkNEW_ARGS(State, (shader, matrix, surfaceBBox))); 657 SkNEW_ARGS(State, (shader, matrix, surfaceBBox)));
658 } 658 }
659 659
660 // static 660 // static
661 SkTDArray<SkPDFShader::ShaderCanonicalEntry>& SkPDFShader::CanonicalShaders() { 661 SkTDArray<SkPDFShader::ShaderCanonicalEntry>& SkPDFShader::CanonicalShaders() {
662 // This initialization is only thread safe with gcc. 662 SkPDFShader::CanonicalShadersMutex().assertHeld();
663 static SkTDArray<ShaderCanonicalEntry> gCanonicalShaders; 663 static SkTDArray<ShaderCanonicalEntry> gCanonicalShaders;
664 return gCanonicalShaders; 664 return gCanonicalShaders;
665 } 665 }
666 666
667 // static 667 // static
668 SkBaseMutex& SkPDFShader::CanonicalShadersMutex() { 668 SkBaseMutex& SkPDFShader::CanonicalShadersMutex() {
669 // This initialization is only thread safe with gcc or when
670 // POD-style mutex initialization is used.
671 SK_DECLARE_STATIC_MUTEX(gCanonicalShadersMutex); 669 SK_DECLARE_STATIC_MUTEX(gCanonicalShadersMutex);
672 return gCanonicalShadersMutex; 670 return gCanonicalShadersMutex;
673 } 671 }
674 672
675 // static 673 // static
676 SkPDFObject* SkPDFFunctionShader::RangeObject() { 674 SkPDFObject* SkPDFFunctionShader::RangeObject() {
677 // This initialization is only thread safe with gcc. 675 SkPDFShader::CanonicalShadersMutex().assertHeld();
678 static SkPDFArray* range = NULL; 676 static SkPDFArray* range = NULL;
679 // This method is only used with CanonicalShadersMutex, so it's safe to 677 // This method is only used with CanonicalShadersMutex, so it's safe to
680 // populate domain. 678 // populate domain.
681 if (range == NULL) { 679 if (range == NULL) {
682 range = new SkPDFArray; 680 range = new SkPDFArray;
683 range->reserve(6); 681 range->reserve(6);
684 range->appendInt(0); 682 range->appendInt(0);
685 range->appendInt(1); 683 range->appendInt(1);
686 range->appendInt(0); 684 range->appendInt(0);
687 range->appendInt(1); 685 range->appendInt(1);
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 return false; 1337 return false;
1340 } 1338 }
1341 1339
1342 void SkPDFShader::State::AllocateGradientInfoStorage() { 1340 void SkPDFShader::State::AllocateGradientInfoStorage() {
1343 fColorData.set(sk_malloc_throw( 1341 fColorData.set(sk_malloc_throw(
1344 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); 1342 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar))));
1345 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); 1343 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get());
1346 fInfo.fColorOffsets = 1344 fInfo.fColorOffsets =
1347 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); 1345 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount);
1348 } 1346 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFFont.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698