diff options
Diffstat (limited to 'gfx/thebes')
-rw-r--r-- | gfx/thebes/DeviceManagerDx.cpp | 70 | ||||
-rw-r--r-- | gfx/thebes/DeviceManagerDx.h | 2 | ||||
-rw-r--r-- | gfx/thebes/PrintTarget.cpp | 10 | ||||
-rw-r--r-- | gfx/thebes/gfxASurface.cpp | 19 | ||||
-rw-r--r-- | gfx/thebes/gfxASurface.h | 6 | ||||
-rw-r--r-- | gfx/thebes/gfxDWriteFonts.cpp | 2 | ||||
-rw-r--r-- | gfx/thebes/gfxFont.h | 4 | ||||
-rw-r--r-- | gfx/thebes/gfxFontEntry.cpp | 31 | ||||
-rw-r--r-- | gfx/thebes/gfxFontEntry.h | 13 | ||||
-rw-r--r-- | gfx/thebes/gfxPlatform.cpp | 7 | ||||
-rw-r--r-- | gfx/thebes/gfxPlatform.h | 2 | ||||
-rw-r--r-- | gfx/thebes/gfxUserFontSet.cpp | 11 | ||||
-rw-r--r-- | gfx/thebes/gfxUserFontSet.h | 4 | ||||
-rw-r--r-- | gfx/thebes/gfxUtils.cpp | 2 |
14 files changed, 52 insertions, 131 deletions
diff --git a/gfx/thebes/DeviceManagerDx.cpp b/gfx/thebes/DeviceManagerDx.cpp index 3a531e92ae..cfd1169e95 100644 --- a/gfx/thebes/DeviceManagerDx.cpp +++ b/gfx/thebes/DeviceManagerDx.cpp @@ -264,7 +264,7 @@ void DeviceManagerDx::UpdateMonitorInfo() { bool systemHdrEnabled = false; std::set<HMONITOR> hdrMonitors; - for (const auto& desc : GetOutputDescs()) { + for (const auto desc : EnumerateOutputs()) { if (ColorSpaceIsHDR(desc)) { systemHdrEnabled = true; hdrMonitors.emplace(desc.Monitor); @@ -279,72 +279,6 @@ void DeviceManagerDx::UpdateMonitorInfo() { } } -std::vector<DXGI_OUTPUT_DESC1> DeviceManagerDx::GetOutputDescs() { - std::vector<DXGI_OUTPUT_DESC1> outputDescs; - - nsModuleHandle dxgiModule(LoadLibrarySystem32(L"dxgi.dll")); - decltype(CreateDXGIFactory1)* createDXGIFactory1 = - (decltype(CreateDXGIFactory1)*)GetProcAddress(dxgiModule, - "CreateDXGIFactory1"); - if (!createDXGIFactory1) { - return outputDescs; - } - - RefPtr<IDXGIFactory1> dxgiFactory; - HRESULT hr = - createDXGIFactory1(__uuidof(IDXGIFactory1), getter_AddRefs(dxgiFactory)); - if (FAILED(hr)) { - gfxCriticalNoteOnce << "Failed to create DXGI factory: " << gfx::hexa(hr); - return outputDescs; - } - - for (UINT adapterIndex = 0;; adapterIndex++) { - RefPtr<IDXGIAdapter> adapter; - hr = dxgiFactory->EnumAdapters(adapterIndex, getter_AddRefs(adapter)); - if (hr == DXGI_ERROR_NOT_FOUND) { - break; - } - if (FAILED(hr)) { - MOZ_ASSERT_UNREACHABLE("unexpected to be called"); - gfxCriticalNoteOnce << "Failed to enumerate DXGI adapter: " - << gfx::hexa(hr); - break; - } - - for (UINT outputIndex = 0;; ++outputIndex) { - RefPtr<IDXGIOutput> output; - hr = adapter->EnumOutputs(outputIndex, getter_AddRefs(output)); - if (hr == DXGI_ERROR_NOT_FOUND) { - break; - } - if (FAILED(hr)) { - MOZ_ASSERT_UNREACHABLE("unexpected to be called"); - gfxCriticalNoteOnce << "Failed to enumulate DXGI output: " - << gfx::hexa(hr); - break; - } - - RefPtr<IDXGIOutput6> output6; - hr = output->QueryInterface(__uuidof(IDXGIOutput6), - getter_AddRefs(output6)); - if (FAILED(hr)) { - continue; - } - - DXGI_OUTPUT_DESC1 desc; - if (FAILED(output6->GetDesc1(&desc))) { - MOZ_ASSERT_UNREACHABLE("unexpected to be called"); - gfxCriticalNoteOnce << "Failed to get DXGI output descriptor"; - continue; - } - - outputDescs.push_back(std::move(desc)); - } - } - - return outputDescs; -} - bool DeviceManagerDx::SystemHDREnabled() { { MutexAutoLock lock(mDeviceLock); @@ -704,7 +638,7 @@ void DeviceManagerDx::CreateContentDevicesLocked() { // We should have been assigned a DeviceStatus from the parent process, // GPU process, or the same process if using in-process compositing. - MOZ_ASSERT(mDeviceStatus); + MOZ_RELEASE_ASSERT(mDeviceStatus); if (CreateContentDevice() == FeatureStatus::CrashedInHandler) { DisableD3D11AfterCrash(); diff --git a/gfx/thebes/DeviceManagerDx.h b/gfx/thebes/DeviceManagerDx.h index ee44447d23..9444c7f64d 100644 --- a/gfx/thebes/DeviceManagerDx.h +++ b/gfx/thebes/DeviceManagerDx.h @@ -185,8 +185,6 @@ class DeviceManagerDx final { bool GetAnyDeviceRemovedReason(DeviceResetReason* aOutReason) MOZ_REQUIRES(mDeviceLock); - std::vector<DXGI_OUTPUT_DESC1> GetOutputDescs(); - private: static StaticAutoPtr<DeviceManagerDx> sInstance; diff --git a/gfx/thebes/PrintTarget.cpp b/gfx/thebes/PrintTarget.cpp index 7ab6984d8d..beb6db0035 100644 --- a/gfx/thebes/PrintTarget.cpp +++ b/gfx/thebes/PrintTarget.cpp @@ -106,16 +106,6 @@ already_AddRefed<DrawTarget> PrintTarget::GetReferenceDrawTarget() { size.width, size.height); break; #endif -#ifdef CAIRO_HAS_QUARTZ_SURFACE - case CAIRO_SURFACE_TYPE_QUARTZ: - if (StaticPrefs::gfx_cairo_quartz_cg_layer_enabled()) { - similar = cairo_quartz_surface_create_cg_layer( - mCairoSurface, cairo_surface_get_content(mCairoSurface), - size.width, size.height); - break; - } - [[fallthrough]]; -#endif default: similar = cairo_surface_create_similar( mCairoSurface, cairo_surface_get_content(mCairoSurface), size.width, diff --git a/gfx/thebes/gfxASurface.cpp b/gfx/thebes/gfxASurface.cpp index f77c836fb9..d5c78d0938 100644 --- a/gfx/thebes/gfxASurface.cpp +++ b/gfx/thebes/gfxASurface.cpp @@ -248,25 +248,6 @@ void gfxASurface::Finish() { cairo_surface_finish(mSurface); } -already_AddRefed<gfxImageSurface> gfxASurface::CopyToARGB32ImageSurface() { - if (!mSurface || !mSurfaceValid) { - return nullptr; - } - - const IntSize size = GetSize(); - RefPtr<gfxImageSurface> imgSurface = - new gfxImageSurface(size, SurfaceFormat::A8R8G8B8_UINT32); - - RefPtr<DrawTarget> dt = gfxPlatform::CreateDrawTargetForSurface( - imgSurface, IntSize(size.width, size.height)); - RefPtr<SourceSurface> source = - gfxPlatform::GetSourceSurfaceForSurface(dt, this); - - dt->CopySurface(source, IntRect(0, 0, size.width, size.height), IntPoint()); - - return imgSurface.forget(); -} - int gfxASurface::CairoStatus() { if (!mSurfaceValid) return -1; diff --git a/gfx/thebes/gfxASurface.h b/gfx/thebes/gfxASurface.h index d2e6daf771..ee63f01aa2 100644 --- a/gfx/thebes/gfxASurface.h +++ b/gfx/thebes/gfxASurface.h @@ -80,12 +80,6 @@ class gfxASurface { */ virtual already_AddRefed<gfxImageSurface> GetAsImageSurface(); - /** - * Creates a new ARGB32 image surface with the same contents as this surface. - * Returns null on error. - */ - already_AddRefed<gfxImageSurface> CopyToARGB32ImageSurface(); - int CairoStatus(); static gfxContentType ContentFromFormat(gfxImageFormat format); diff --git a/gfx/thebes/gfxDWriteFonts.cpp b/gfx/thebes/gfxDWriteFonts.cpp index 0877d389bc..8510c3b7cc 100644 --- a/gfx/thebes/gfxDWriteFonts.cpp +++ b/gfx/thebes/gfxDWriteFonts.cpp @@ -276,12 +276,14 @@ void gfxDWriteFont::UpdateClearTypeVars() { gfxVars::SetSystemTextRenderingMode(renderingMode); } +#if 0 // Set cairo dwrite params in the parent process where it might still be // needed for printing. We use the validated pref int directly for rendering // mode, because a negative (i.e. not set) rendering mode is also used for // deciding on forcing GDI in cairo. cairo_dwrite_set_cleartype_params(gamma, enhancedContrast, clearTypeLevel, pixelGeometry, renderingModePref); +#endif } gfxFont* gfxDWriteFont::CopyWithAntialiasOption( diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h index f51c08ea82..fa6fd6a83f 100644 --- a/gfx/thebes/gfxFont.h +++ b/gfx/thebes/gfxFont.h @@ -1527,9 +1527,7 @@ class gfxFont { // and therefore needs us to use a mask for text-shadow even when // we're not actually blurring. bool AlwaysNeedsMaskForShadow() const { - return mFontEntry->TryGetColorGlyphs() || mFontEntry->TryGetSVGData(this) || - mFontEntry->HasFontTable(TRUETYPE_TAG('C', 'B', 'D', 'T')) || - mFontEntry->HasFontTable(TRUETYPE_TAG('s', 'b', 'i', 'x')); + return mFontEntry->AlwaysNeedsMaskForShadow(); } // whether a feature is supported by the font (limited to a small set diff --git a/gfx/thebes/gfxFontEntry.cpp b/gfx/thebes/gfxFontEntry.cpp index 7ff5f82a85..840ef8943f 100644 --- a/gfx/thebes/gfxFontEntry.cpp +++ b/gfx/thebes/gfxFontEntry.cpp @@ -79,6 +79,7 @@ gfxFontEntry::gfxFontEntry(const nsACString& aName, bool aIsStandardFace) mHasGraphiteTables(LazyFlag::Uninitialized), mHasGraphiteSpaceContextuals(LazyFlag::Uninitialized), mHasColorBitmapTable(LazyFlag::Uninitialized), + mNeedsMaskForShadow(LazyFlag::Uninitialized), mHasSpaceFeatures(SpaceFeatures::Uninitialized) { mTrakTable.exchange(kTrakTableUninitialized); memset(&mDefaultSubSpaceFeatures, 0, sizeof(mDefaultSubSpaceFeatures)); @@ -355,7 +356,7 @@ bool gfxFontEntry::TryGetSVGData(const gfxFont* aFont) { mSVGInitialized = true; } - if (GetSVGGlyphs()) { + if (GetSVGGlyphs() && aFont) { AutoWriteLock lock(mLock); if (!mFontsUsingSVGGlyphs.Contains(aFont)) { mFontsUsingSVGGlyphs.AppendElement(aFont); @@ -2171,21 +2172,29 @@ gfxFontEntry* gfxFontFamily::FindFont(const nsACString& aFontName, } void gfxFontFamily::ReadAllCMAPs(FontInfoData* aFontInfoData) { - AutoWriteLock lock(mLock); - FindStyleVariationsLocked(aFontInfoData); + AutoTArray<RefPtr<gfxFontEntry>, 16> faces; + { + AutoWriteLock lock(mLock); + FindStyleVariationsLocked(aFontInfoData); + faces.AppendElements(mAvailableFonts); + } - uint32_t i, numFonts = mAvailableFonts.Length(); - for (i = 0; i < numFonts; i++) { - gfxFontEntry* fe = mAvailableFonts[i]; + gfxSparseBitSet familyMap; + for (auto& face : faces) { // don't try to load cmaps for downloadable fonts not yet loaded - if (!fe || fe->mIsUserFontContainer) { + if (!face || face->mIsUserFontContainer) { continue; } - fe->ReadCMAP(aFontInfoData); - mFamilyCharacterMap.Union(*(fe->GetCharacterMap())); + face->ReadCMAP(aFontInfoData); + familyMap.Union(*(face->GetCharacterMap())); + } + + AutoWriteLock lock(mLock); + if (!mFamilyCharacterMapInitialized) { + familyMap.Compact(); + mFamilyCharacterMap = std::move(familyMap); + mFamilyCharacterMapInitialized = true; } - mFamilyCharacterMap.Compact(); - mFamilyCharacterMapInitialized = true; } void gfxFontFamily::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, diff --git a/gfx/thebes/gfxFontEntry.h b/gfx/thebes/gfxFontEntry.h index 364cf6c79e..82218d5611 100644 --- a/gfx/thebes/gfxFontEntry.h +++ b/gfx/thebes/gfxFontEntry.h @@ -273,6 +273,18 @@ class gfxFontEntry { return flag == LazyFlag::Yes; } + inline bool AlwaysNeedsMaskForShadow() { + LazyFlag flag = mNeedsMaskForShadow; + if (flag == LazyFlag::Uninitialized) { + flag = + TryGetColorGlyphs() || TryGetSVGData(nullptr) || HasColorBitmapTable() + ? LazyFlag::Yes + : LazyFlag::No; + mNeedsMaskForShadow = flag; + } + return flag == LazyFlag::Yes; + } + inline bool HasCmapTable() { if (!mCharacterMap && !mShmemCharacterMap) { ReadCMAP(); @@ -670,6 +682,7 @@ class gfxFontEntry { std::atomic<LazyFlag> mHasGraphiteTables; std::atomic<LazyFlag> mHasGraphiteSpaceContextuals; std::atomic<LazyFlag> mHasColorBitmapTable; + std::atomic<LazyFlag> mNeedsMaskForShadow; enum class SpaceFeatures : uint8_t { Uninitialized = 0xff, diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index ccc58213ef..ae0f3489fa 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -872,10 +872,9 @@ void gfxPlatform::Init() { StaticPrefs::webgl_disable_angle(), StaticPrefs::webgl_dxgl_enabled(), StaticPrefs::webgl_force_enabled(), StaticPrefs::webgl_msaa_force()); // Prefs that don't fit into any of the other sections - forcedPrefs.AppendPrintf("-T%d%d%d) ", + forcedPrefs.AppendPrintf("-T%d%d) ", StaticPrefs::gfx_android_rgb16_force_AtStartup(), - StaticPrefs::gfx_canvas_accelerated(), - StaticPrefs::layers_force_shmem_tiles_AtStartup()); + StaticPrefs::gfx_canvas_accelerated()); ScopedGfxFeatureReporter::AppNote(forcedPrefs); } @@ -2083,7 +2082,7 @@ Maybe<nsTArray<uint8_t>>& gfxPlatform::GetCMSOutputProfileData() { CMSMode GfxColorManagementMode() { const auto mode = StaticPrefs::gfx_color_management_mode(); - if (mode >= 0 && mode < UnderlyingValue(CMSMode::AllCount)) { + if (mode >= 0 && mode <= UnderlyingValue(CMSMode::_ENUM_MAX)) { return CMSMode(mode); } return CMSMode::Off; diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 452e7208b4..37d6ec9187 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -82,7 +82,7 @@ enum class CMSMode : int32_t { Off = 0, // No color management All = 1, // Color manage everything TaggedOnly = 2, // Color manage tagged Images Only - AllCount = 3 + _ENUM_MAX = TaggedOnly }; enum eGfxLog { diff --git a/gfx/thebes/gfxUserFontSet.cpp b/gfx/thebes/gfxUserFontSet.cpp index c761bd9227..f1cea3d914 100644 --- a/gfx/thebes/gfxUserFontSet.cpp +++ b/gfx/thebes/gfxUserFontSet.cpp @@ -469,7 +469,7 @@ void gfxUserFontEntry::DoLoadNextSrc(bool aIsContinue) { if (fe) { LOG(("userfonts (%p) [src %d] loaded local: (%s) for (%s) gen: %8.8x\n", fontSet.get(), mCurrentSrcIndex, currSrc.mLocalName.get(), - mFamilyName.get(), uint32_t(fontSet->mGeneration))); + mFamilyName.get(), uint32_t(fontSet->GetGeneration()))); fe->mFeatureSettings.AppendElements(mFeatureSettings); fe->mVariationSettings.AppendElements(mVariationSettings); fe->mLanguageOverride = mLanguageOverride; @@ -706,7 +706,6 @@ bool gfxUserFontEntry::LoadPlatformFont(uint32_t aSrcIndex, const uint8_t* aSanitizedFontData, uint32_t aSanitizedLength, nsTArray<OTSMessage>&& aMessages) { - MOZ_ASSERT(NS_IsMainThread()); RefPtr<gfxUserFontSet> fontSet = GetUserFontSet(); if (NS_WARN_IF(!fontSet)) { free((void*)aOriginalFontData); @@ -817,10 +816,14 @@ bool gfxUserFontEntry::LoadPlatformFont(uint32_t aSrcIndex, "(%p) gen: %8.8x compress: %d%%\n", fontSet.get(), aSrcIndex, mSrcList[aSrcIndex].mURI->GetSpecOrDefault().get(), mFamilyName.get(), - this, uint32_t(fontSet->mGeneration), fontCompressionRatio)); + this, uint32_t(fontSet->GetGeneration()), fontCompressionRatio)); mPlatformFontEntry = fe; SetLoadState(STATUS_LOADED); - gfxUserFontSet::UserFontCache::CacheFont(fe); + if (NS_IsMainThread()) { + // UserFontCache::CacheFont is not currently safe to call off-main-thread, + // so we only cache the font if this is a main-thread load. + gfxUserFontSet::UserFontCache::CacheFont(fe); + } } else { LOG(( "userfonts (%p) [src %d] failed uri: (%s) for (%s)" diff --git a/gfx/thebes/gfxUserFontSet.h b/gfx/thebes/gfxUserFontSet.h index 58cd2a077f..4dadea73b0 100644 --- a/gfx/thebes/gfxUserFontSet.h +++ b/gfx/thebes/gfxUserFontSet.h @@ -545,8 +545,8 @@ class gfxUserFontSet { // font families defined by @font-face rules nsRefPtrHashtable<nsCStringHashKey, gfxUserFontFamily> mFontFamilies; - uint64_t mGeneration; // bumped on any font load change - uint64_t mRebuildGeneration; // only bumped on rebuilds + mozilla::Atomic<uint64_t> mGeneration; // bumped on any font load change + uint64_t mRebuildGeneration; // only bumped on rebuilds // true when local names have been looked up, false otherwise bool mLocalRulesUsed; diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp index ad3ab14f8b..98e68ae862 100644 --- a/gfx/thebes/gfxUtils.cpp +++ b/gfx/thebes/gfxUtils.cpp @@ -1265,7 +1265,7 @@ nsresult gfxUtils::EncodeSourceSurface(SourceSurface* aSurface, nsCOMPtr<nsIClipboardHelper> clipboard( do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv)); if (clipboard) { - clipboard->CopyString(NS_ConvertASCIItoUTF16(dataURI)); + clipboard->CopyString(NS_ConvertASCIItoUTF16(dataURI), nullptr); } } return NS_OK; |