Bug 1182665 - Add gfxPlatform::GetScreenSize() and use nsIScreen for gfxPlatform::GetScreenDepth() r=nical

This commit is contained in:
James Willcox 2015-08-26 17:37:48 -05:00
parent c469bfe59a
commit 365b1b0164
10 changed files with 30 additions and 75 deletions

View File

@ -100,13 +100,7 @@ gfxAndroidPlatform::gfxAndroidPlatform()
RegisterStrongMemoryReporter(new FreetypeReporter());
nsCOMPtr<nsIScreenManager> screenMgr = do_GetService("@mozilla.org/gfx/screenmanager;1");
nsCOMPtr<nsIScreen> screen;
screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
mScreenDepth = 24;
screen->GetColorDepth(&mScreenDepth);
mOffscreenFormat = mScreenDepth == 16
mOffscreenFormat = GetScreenDepth() == 16
? gfxImageFormat::RGB16_565
: gfxImageFormat::RGB24;
@ -418,12 +412,6 @@ gfxAndroidPlatform::RequiresLinearZoom()
return gfxPlatform::RequiresLinearZoom();
}
int
gfxAndroidPlatform::GetScreenDepth() const
{
return mScreenDepth;
}
bool
gfxAndroidPlatform::UseAcceleratedSkiaCanvas()
{

View File

@ -80,8 +80,6 @@ public:
FT_Library GetFTLibrary();
virtual int GetScreenDepth() const;
virtual bool CanRenderContentToDataSurface() const override {
return true;
}

View File

@ -514,6 +514,7 @@ gfxPlatform::Init()
InitLayersAccelerationPrefs();
InitLayersIPC();
gPlatform->PopulateScreenInfo();
gPlatform->ComputeTileSize();
nsresult rv;
@ -1063,6 +1064,22 @@ gfxPlatform::ComputeTileSize()
SetTileSize(w, h);
}
void
gfxPlatform::PopulateScreenInfo()
{
nsCOMPtr<nsIScreenManager> manager = do_GetService("@mozilla.org/gfx/screenmanager;1");
MOZ_ASSERT(manager, "failed to get nsIScreenManager");
nsCOMPtr<nsIScreen> screen;
manager->GetPrimaryScreen(getter_AddRefs(screen));
MOZ_ASSERT(screen, "failed to get primary screen");
screen->GetColorDepth(&mScreenDepth);
int left, top;
screen->GetRect(&left, &top, &mScreenSize.width, &mScreenSize.height);
}
bool
gfxPlatform::SupportsAzureContentForDrawTarget(DrawTarget* aTarget)
{
@ -2093,13 +2110,6 @@ gfxPlatform::GetLog(eGfxLog aWhichLog)
return nullptr;
}
int
gfxPlatform::GetScreenDepth() const
{
NS_WARNING("GetScreenDepth not implemented on this platform -- returning 0!");
return 0;
}
mozilla::gfx::SurfaceFormat
gfxPlatform::Optimal2DFormatForContent(gfxContentType aContent)
{

View File

@ -568,7 +568,8 @@ public:
*/
static PRLogModuleInfo* GetLog(eGfxLog aWhichLog);
virtual int GetScreenDepth() const;
int GetScreenDepth() const { return mScreenDepth; }
mozilla::gfx::IntSize GetScreenSize() const { return mScreenSize; }
/**
* Return the layer debugging options to use browser-wide.
@ -777,6 +778,11 @@ private:
*/
void ComputeTileSize();
/**
* This uses nsIScreenManager to determine the screen size and color depth
*/
void PopulateScreenInfo();
nsRefPtr<gfxASurface> mScreenReferenceSurface;
nsTArray<uint32_t> mCJKPrefLangs;
nsCOMPtr<nsIObserver> mSRGBOverrideObserver;
@ -804,6 +810,9 @@ private:
// Backend that we are compositing with. NONE, if no compositor has been
// created yet.
mozilla::layers::LayersBackend mCompositorBackend;
int32_t mScreenDepth;
mozilla::gfx::IntSize mScreenSize;
};
#endif /* GFX_PLATFORM_H */

View File

@ -363,24 +363,6 @@ gfxPlatformGtk::GetOffscreenFormat()
return gfxImageFormat::RGB24;
}
static int sDepth = 0;
int
gfxPlatformGtk::GetScreenDepth() const
{
if (!sDepth) {
GdkScreen *screen = gdk_screen_get_default();
if (screen) {
sDepth = gdk_visual_get_depth(gdk_visual_get_system());
} else {
sDepth = 24;
}
}
return sDepth;
}
void
gfxPlatformGtk::GetPlatformCMSOutputProfile(void *&mem, size_t &size)
{

View File

@ -122,8 +122,6 @@ public:
virtual gfxImageFormat GetOffscreenFormat() override;
virtual int GetScreenDepth() const override;
bool SupportsApzWheelInput() const override {
return true;
}

View File

@ -53,8 +53,8 @@ gfxQtPlatform::gfxQtPlatform()
if (!sFontconfigUtils)
sFontconfigUtils = gfxFontconfigUtils::GetFontconfigUtils();
mScreenDepth = qApp->primaryScreen()->depth();
if (mScreenDepth == 16) {
int32_t depth = GetScreenDepth();
if (depth == 16) {
sOffscreenFormat = gfxImageFormat::RGB16_565;
}
uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);
@ -195,12 +195,6 @@ gfxQtPlatform::GetOffscreenFormat()
return sOffscreenFormat;
}
int
gfxQtPlatform::GetScreenDepth() const
{
return mScreenDepth;
}
already_AddRefed<ScaledFont>
gfxQtPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont* aFont)
{

View File

@ -82,8 +82,6 @@ public:
static Screen* GetXScreen(QWindow* aWindow = 0);
#endif
virtual int GetScreenDepth() const override;
bool AccelerateLayersByDefault() override {
return true;
}

View File

@ -1592,26 +1592,6 @@ gfxWindowsPlatform::IsOptimus()
return knowIsOptimus;
}
int
gfxWindowsPlatform::GetScreenDepth() const
{
// if the system doesn't have all displays with the same
// pixel format, just return 24 and move on with life.
if (!GetSystemMetrics(SM_SAMEDISPLAYFORMAT))
return 24;
HDC hdc = GetDC(nullptr);
if (!hdc)
return 24;
int depth = GetDeviceCaps(hdc, BITSPIXEL) *
GetDeviceCaps(hdc, PLANES);
ReleaseDC(nullptr, hdc);
return depth;
}
IDXGIAdapter1*
gfxWindowsPlatform::GetDXGIAdapter()
{

View File

@ -140,8 +140,6 @@ public:
RENDER_MODE_MAX
};
int GetScreenDepth() const;
RenderMode GetRenderMode() { return mRenderMode; }
void SetRenderMode(RenderMode rmode) { mRenderMode = rmode; }