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

Unified Diff: src/ports/SkFontHost_FreeType.cpp

Issue 2021923002: [Not for commit] Inject TRACE_EVENT to SkFontHost_FreeType.cpp Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_FreeType.cpp
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 2e0b8b6ee371abc703bd1c5db8bb336cceef9eda..ac73a7661cd5a9a1e6560cd2b6c7d07b801bf943 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -27,6 +27,8 @@
#include "SkTypes.h"
#include <memory>
+#include "base/trace_event/trace_event.h"
+
#if defined(SK_CAN_USE_DLOPEN)
#include <dlfcn.h>
#endif
@@ -58,6 +60,54 @@
//#define SK_FONTHOST_FREETYPE_RUNTIME_VERSION
//#define SK_GAMMA_APPLY_TO_A8
+class SkTracedAutoMutexAcquire : SkNoncopyable {
+public:
+ explicit SkTracedAutoMutexAcquire(SkBaseMutex& mutex) : fMutex(&mutex) {
+ SkASSERT(fMutex != nullptr);
+ {
+ TRACE_EVENT1("tzik", __PRETTY_FUNCTION__, "line", __LINE__);
+ mutex.acquire();
+ }
+ TRACE_EVENT_BEGIN0("tzik", "locked");
+ }
+
+ explicit SkTracedAutoMutexAcquire(SkBaseMutex* mutex) : fMutex(mutex) {
+ if (mutex) {
+ {
+ TRACE_EVENT1("tzik", __PRETTY_FUNCTION__, "line", __LINE__);
+ mutex->acquire();
+ }
+ TRACE_EVENT_BEGIN0("tzik", "locked");
+ }
+ }
+
+ /** If the mutex has not been released, release it now. */
+ ~SkTracedAutoMutexAcquire() {
+ if (fMutex) {
+ TRACE_EVENT_END0("tzik", "locked");
+ fMutex->release();
+ }
+ }
+
+ /** If the mutex has not been released, release it now. */
+ void release() {
+ if (fMutex) {
+ fMutex->release();
+ fMutex = nullptr;
+ }
+ }
+
+ /** Assert that we're holding the mutex. */
+ void assertHeld() {
+ SkASSERT(fMutex);
+ fMutex->assertHeld();
+ }
+
+private:
+ SkBaseMutex* fMutex;
+};
+
+
static bool isLCD(const SkScalerContext::Rec& rec) {
return SkMask::kLCD16_Format == rec.fMaskFormat;
}
@@ -687,7 +737,7 @@ void SkTypeface_FreeType::onFilterRec(SkScalerContextRec* rec) const {
if (isLCD(*rec)) {
// TODO: re-work so that FreeType is set-up and selected by the SkFontMgr.
- SkAutoMutexAcquire ama(gFTMutex);
+ SkTracedAutoMutexAcquire ama(gFTMutex);
ref_ft_library();
if (!gFTLibrary->isLCDSupported()) {
// If the runtime Freetype library doesn't support LCD, disable it here.
@@ -799,7 +849,7 @@ SkScalerContext_FreeType::SkScalerContext_FreeType(SkTypeface* typeface,
, fFTSize(nullptr)
, fStrikeIndex(-1)
{
- SkAutoMutexAcquire ac(gFTMutex);
+ SkTracedAutoMutexAcquire ac(gFTMutex);
if (!ref_ft_library()) {
sk_throw();
@@ -953,7 +1003,7 @@ SkScalerContext_FreeType::SkScalerContext_FreeType(SkTypeface* typeface,
}
SkScalerContext_FreeType::~SkScalerContext_FreeType() {
- SkAutoMutexAcquire ac(gFTMutex);
+ SkTracedAutoMutexAcquire ac(gFTMutex);
if (fFTSize != nullptr) {
FT_Done_Size(fFTSize);
@@ -990,12 +1040,12 @@ unsigned SkScalerContext_FreeType::generateGlyphCount() {
}
uint16_t SkScalerContext_FreeType::generateCharToGlyph(SkUnichar uni) {
- SkAutoMutexAcquire ac(gFTMutex);
+ SkTracedAutoMutexAcquire ac(gFTMutex);
return SkToU16(FT_Get_Char_Index( fFace, uni ));
}
SkUnichar SkScalerContext_FreeType::generateGlyphToChar(uint16_t glyph) {
- SkAutoMutexAcquire ac(gFTMutex);
+ SkTracedAutoMutexAcquire ac(gFTMutex);
// iterate through each cmap entry, looking for matching glyph indices
FT_UInt glyphIndex;
SkUnichar charCode = FT_Get_First_Char( fFace, &glyphIndex );
@@ -1019,7 +1069,7 @@ void SkScalerContext_FreeType::generateAdvance(SkGlyph* glyph) {
* which are very cheap to compute with some font formats...
*/
if (fDoLinearMetrics) {
- SkAutoMutexAcquire ac(gFTMutex);
+ SkTracedAutoMutexAcquire ac(gFTMutex);
if (this->setupSize()) {
glyph->zeroMetrics();
@@ -1123,7 +1173,7 @@ inline void scaleGlyphMetrics(SkGlyph& glyph, SkScalar scale) {
}
void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) {
- SkAutoMutexAcquire ac(gFTMutex);
+ SkTracedAutoMutexAcquire ac(gFTMutex);
glyph->fRsbDelta = 0;
glyph->fLsbDelta = 0;
@@ -1231,7 +1281,8 @@ static void clear_glyph_image(const SkGlyph& glyph) {
}
void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) {
- SkAutoMutexAcquire ac(gFTMutex);
+ TRACE_EVENT1("tzik", __PRETTY_FUNCTION__, "line", __LINE__);
+ SkTracedAutoMutexAcquire ac(gFTMutex);
if (this->setupSize()) {
clear_glyph_image(glyph);
@@ -1252,7 +1303,7 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) {
void SkScalerContext_FreeType::generatePath(const SkGlyph& glyph, SkPath* path) {
- SkAutoMutexAcquire ac(gFTMutex);
+ SkTracedAutoMutexAcquire ac(gFTMutex);
SkASSERT(path);
@@ -1293,7 +1344,7 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* metrics
return;
}
- SkAutoMutexAcquire ac(gFTMutex);
+ SkTracedAutoMutexAcquire ac(gFTMutex);
if (this->setupSize()) {
sk_bzero(metrics, sizeof(*metrics));
@@ -1648,7 +1699,7 @@ FT_Face SkTypeface_FreeType::Scanner::openFace(SkStream* stream, int ttcIndex,
}
bool SkTypeface_FreeType::Scanner::recognizedFont(SkStream* stream, int* numFaces) const {
- SkAutoMutexAcquire libraryLock(fLibraryMutex);
+ SkTracedAutoMutexAcquire libraryLock(fLibraryMutex);
FT_StreamRec streamRec;
FT_Face face = this->openFace(stream, -1, &streamRec);
@@ -1667,7 +1718,7 @@ bool SkTypeface_FreeType::Scanner::scanFont(
SkStream* stream, int ttcIndex,
SkString* name, SkFontStyle* style, bool* isFixedPitch, AxisDefinitions* axes) const
{
- SkAutoMutexAcquire libraryLock(fLibraryMutex);
+ SkTracedAutoMutexAcquire libraryLock(fLibraryMutex);
FT_StreamRec streamRec;
FT_Face face = this->openFace(stream, ttcIndex, &streamRec);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698