Bug 1356218 - Fix nsDeviceContext::GetDepth to use the information from the correct monitor. r=jfkthame

MozReview-Commit-ID: BQpm6y3Ayo4

--HG--
extra : rebase_source : c798db446d28c0621d38fb65a5345300ace8cca7
This commit is contained in:
Masatoshi Kimura 2017-04-14 20:50:13 +09:00
parent df6ee97f6a
commit 48a997a3cb
2 changed files with 10 additions and 8 deletions

View File

@ -28,7 +28,6 @@
#include "nsIObserver.h" // for nsIObserver, etc
#include "nsIObserverService.h" // for nsIObserverService
#include "nsIScreen.h" // for nsIScreen
#include "nsIScreenManager.h" // for nsIScreenManager
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
#include "nsISupportsUtils.h" // for NS_ADDREF, NS_RELEASE
#include "nsIWidget.h" // for nsIWidget, NS_NATIVE_WINDOW
@ -38,10 +37,12 @@
#include "nsTArray.h" // for nsTArray, nsTArray_Impl
#include "nsThreadUtils.h" // for NS_IsMainThread
#include "mozilla/gfx/Logging.h"
#include "mozilla/widget/ScreenManager.h" // for ScreenManager
using namespace mozilla;
using namespace mozilla::gfx;
using mozilla::services::GetObserverService;
using mozilla::widget::ScreenManager;
class nsFontCache final : public nsIObserver
{
@ -190,7 +191,7 @@ nsFontCache::Flush()
}
nsDeviceContext::nsDeviceContext()
: mWidth(0), mHeight(0), mDepth(0),
: mWidth(0), mHeight(0),
mAppUnitsPerDevPixel(-1), mAppUnitsPerDevPixelAtUnitFullZoom(-1),
mAppUnitsPerPhysicalInch(-1),
mFullZoom(1.0f), mPrintingScale(1.0f)
@ -399,13 +400,15 @@ nsDeviceContext::CreateRenderingContextCommon(bool aWantReferenceContext)
nsresult
nsDeviceContext::GetDepth(uint32_t& aDepth)
{
if (mDepth == 0 && mScreenManager) {
nsCOMPtr<nsIScreen> primaryScreen;
mScreenManager->GetPrimaryScreen(getter_AddRefs(primaryScreen));
primaryScreen->GetColorDepth(reinterpret_cast<int32_t *>(&mDepth));
nsCOMPtr<nsIScreen> screen;
FindScreen(getter_AddRefs(screen));
if (!screen) {
ScreenManager& screenManager = ScreenManager::GetSingleton();
screenManager.GetPrimaryScreen(getter_AddRefs(screen));
MOZ_ASSERT(screen);
}
screen->GetColorDepth(reinterpret_cast<int32_t *>(&aDepth));
aDepth = mDepth;
return NS_OK;
}

View File

@ -294,7 +294,6 @@ private:
nscoord mWidth;
nscoord mHeight;
uint32_t mDepth;
int32_t mAppUnitsPerDevPixel;
int32_t mAppUnitsPerDevPixelAtUnitFullZoom;
int32_t mAppUnitsPerPhysicalInch;