diff --git a/gfx/layers/PaintThread.cpp b/gfx/layers/PaintThread.cpp index e16add4ead05..c5758e97e30b 100644 --- a/gfx/layers/PaintThread.cpp +++ b/gfx/layers/PaintThread.cpp @@ -22,7 +22,7 @@ #include "mozilla/SyncRunnable.h" #include "nsIPropertyBag2.h" #include "nsServiceManagerUtils.h" -#include "prsystem.h" +#include "nsSystemInfo.h" // Uncomment the following line to dispatch sync runnables when // painting so that rasterization happens synchronously from @@ -156,7 +156,15 @@ PaintThread::AddRef() /* static */ int32_t PaintThread::CalculatePaintWorkerCount() { - int32_t cpuCores = PR_GetNumberOfProcessors(); + int32_t cpuCores = 1; + nsCOMPtr systemInfo = do_GetService(NS_SYSTEMINFO_CONTRACTID); + if (systemInfo) { + nsresult rv = systemInfo->GetPropertyAsInt32(NS_LITERAL_STRING("cpucores"), &cpuCores); + if (NS_FAILED(rv)) { + cpuCores = 1; + } + } + int32_t workerCount = gfxPrefs::LayersOMTPPaintWorkers(); // If not manually specified, default to (cpuCores * 3) / 4, and clamp diff --git a/gfx/skia/skia/src/ports/SkFontHost_cairo.cpp b/gfx/skia/skia/src/ports/SkFontHost_cairo.cpp index fcc2ae6e6a78..9869569fa6a8 100644 --- a/gfx/skia/skia/src/ports/SkFontHost_cairo.cpp +++ b/gfx/skia/skia/src/ports/SkFontHost_cairo.cpp @@ -13,7 +13,6 @@ #include "SkAdvancedTypefaceMetrics.h" #include "SkFDot6.h" -#include "SkMutex.h" #include "SkPath.h" #include "SkScalerContext.h" #include "SkTypefaceCache.h" @@ -170,8 +169,6 @@ static bool isAxisAligned(const SkScalerContextRec& rec) { bothZero(rec.fPost2x2[0][0], rec.fPost2x2[1][1])); } -SK_DECLARE_STATIC_MUTEX(gTypefaceMutex); - class SkCairoFTTypeface : public SkTypeface { public: virtual SkStreamAsset* onOpenStream(int*) const override { return nullptr; } @@ -272,19 +269,9 @@ public: } private: - - void internal_dispose() const override - { - SkAutoMutexAcquire lock(gTypefaceMutex); - internal_dispose_restore_refcnt_to_1(); - delete this; - } - ~SkCairoFTTypeface() { - if (cairo_font_face_get_user_data(fFontFace, &kSkTypefaceKey) == this) { - cairo_font_face_set_user_data(fFontFace, &kSkTypefaceKey, nullptr, nullptr); - } + cairo_font_face_set_user_data(fFontFace, &kSkTypefaceKey, nullptr, nullptr); cairo_font_face_destroy(fFontFace); #ifdef CAIRO_HAS_FC_FONT if (fPattern) { @@ -303,13 +290,12 @@ SkTypeface* SkCreateTypefaceFromCairoFTFontWithFontconfig(cairo_scaled_font_t* s SkASSERT(cairo_font_face_status(fontFace) == CAIRO_STATUS_SUCCESS); SkASSERT(cairo_font_face_get_type(fontFace) == CAIRO_FONT_TYPE_FT); - SkAutoMutexAcquire lock(gTypefaceMutex); - SkTypeface* typeface = reinterpret_cast(cairo_font_face_get_user_data(fontFace, &kSkTypefaceKey)); - if (typeface && typeface->getRefCnt() > 0) { + if (typeface) { typeface->ref(); } else { typeface = new SkCairoFTTypeface(fontFace, pattern); + SkTypefaceCache::Add(typeface); } return typeface;