mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-11 21:58:41 +02:00
Bug 1249640: Part 2 gfxPlatform simplification when it comes to accelerated canvas, using the new blocking. r=gw280
This commit is contained in:
parent
c2c7011ac5
commit
1498964285
5 changed files with 31 additions and 28 deletions
|
|
@ -795,10 +795,16 @@ CanvasDrawObserver::FrameEnd()
|
||||||
// If we don't have enough data, don't bother changing...
|
// If we don't have enough data, don't bother changing...
|
||||||
if (mGPUPreferredCalls > mMinCallsBeforeDecision ||
|
if (mGPUPreferredCalls > mMinCallsBeforeDecision ||
|
||||||
mSoftwarePreferredCalls > mMinCallsBeforeDecision) {
|
mSoftwarePreferredCalls > mMinCallsBeforeDecision) {
|
||||||
|
CanvasRenderingContext2D::RenderingMode switchToMode;
|
||||||
if (mGPUPreferredCalls >= mSoftwarePreferredCalls) {
|
if (mGPUPreferredCalls >= mSoftwarePreferredCalls) {
|
||||||
mCanvasContext->SwitchRenderingMode(CanvasRenderingContext2D::RenderingMode::OpenGLBackendMode);
|
switchToMode = CanvasRenderingContext2D::RenderingMode::OpenGLBackendMode;
|
||||||
} else {
|
} else {
|
||||||
mCanvasContext->SwitchRenderingMode(CanvasRenderingContext2D::RenderingMode::SoftwareBackendMode);
|
switchToMode = CanvasRenderingContext2D::RenderingMode::SoftwareBackendMode;
|
||||||
|
}
|
||||||
|
if (switchToMode != mCanvasContext->mRenderingMode) {
|
||||||
|
if (!mCanvasContext->SwitchRenderingMode(switchToMode)) {
|
||||||
|
gfxDebug() << "Canvas acceleration failed mode switch to " << switchToMode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -968,12 +974,10 @@ CanvasRenderingContext2D::CanvasRenderingContext2D()
|
||||||
sNumLivingContexts++;
|
sNumLivingContexts++;
|
||||||
|
|
||||||
// The default is to use OpenGL mode
|
// The default is to use OpenGL mode
|
||||||
if (!gfxPlatform::GetPlatform()->UseAcceleratedSkiaCanvas()) {
|
if (gfxPlatform::GetPlatform()->UseAcceleratedCanvas()) {
|
||||||
mRenderingMode = RenderingMode::SoftwareBackendMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gfxPlatform::GetPlatform()->HaveChoiceOfHWAndSWCanvas()) {
|
|
||||||
mDrawObserver = new CanvasDrawObserver(this);
|
mDrawObserver = new CanvasDrawObserver(this);
|
||||||
|
} else {
|
||||||
|
mRenderingMode = RenderingMode::SoftwareBackendMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1208,8 +1212,7 @@ bool CanvasRenderingContext2D::SwitchRenderingMode(RenderingMode aRenderingMode)
|
||||||
#ifdef USE_SKIA_GPU
|
#ifdef USE_SKIA_GPU
|
||||||
// Do not attempt to switch into GL mode if the platform doesn't allow it.
|
// Do not attempt to switch into GL mode if the platform doesn't allow it.
|
||||||
if ((aRenderingMode == RenderingMode::OpenGLBackendMode) &&
|
if ((aRenderingMode == RenderingMode::OpenGLBackendMode) &&
|
||||||
(!gfxPlatform::GetPlatform()->HaveChoiceOfHWAndSWCanvas() ||
|
!gfxPlatform::GetPlatform()->UseAcceleratedCanvas()) {
|
||||||
!gfxPlatform::GetPlatform()->UseAcceleratedSkiaCanvas())) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1416,7 +1419,7 @@ CanvasRenderingContext2D::EnsureTarget(RenderingMode aRenderingMode)
|
||||||
|
|
||||||
if (layerManager) {
|
if (layerManager) {
|
||||||
if (mode == RenderingMode::OpenGLBackendMode &&
|
if (mode == RenderingMode::OpenGLBackendMode &&
|
||||||
gfxPlatform::GetPlatform()->UseAcceleratedSkiaCanvas() &&
|
gfxPlatform::GetPlatform()->UseAcceleratedCanvas() &&
|
||||||
CheckSizeForSkiaGL(size)) {
|
CheckSizeForSkiaGL(size)) {
|
||||||
DemoteOldestContextIfNecessary();
|
DemoteOldestContextIfNecessary();
|
||||||
mBufferProvider = nullptr;
|
mBufferProvider = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ function IsAcceleratedSkia() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var props = Cc["@mozilla.org/gfx/info;1"].getService(SpecialPowers.Ci.nsIGfxInfo).getInfo();
|
var props = Cc["@mozilla.org/gfx/info;1"].getService(SpecialPowers.Ci.nsIGfxInfo).getInfo();
|
||||||
enabled = props.AzureCanvasBackend == "skia" && props.AzureSkiaAccelerated;
|
enabled = props.AzureCanvasBackend == "skia" && props.AzureCanvasAccelerated;
|
||||||
} catch(e) { }
|
} catch(e) { }
|
||||||
|
|
||||||
return enabled;
|
return enabled;
|
||||||
|
|
|
||||||
|
|
@ -1207,22 +1207,24 @@ gfxPlatform::SupportsAzureContentForDrawTarget(DrawTarget* aTarget)
|
||||||
return SupportsAzureContentForType(aTarget->GetBackendType());
|
return SupportsAzureContentForType(aTarget->GetBackendType());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool gfxPlatform::UseAcceleratedCanvas()
|
||||||
gfxPlatform::UseAcceleratedSkiaCanvas()
|
|
||||||
{
|
{
|
||||||
return gfxPrefs::CanvasAzureAccelerated() &&
|
// Allow acceleration on Skia if the preference is set, unless it's blocked
|
||||||
mPreferredCanvasBackend == BackendType::SKIA;
|
if (mPreferredCanvasBackend == BackendType::SKIA && gfxPrefs::CanvasAzureAccelerated()) {
|
||||||
}
|
nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
|
||||||
|
int32_t status;
|
||||||
bool gfxPlatform::HaveChoiceOfHWAndSWCanvas()
|
return !gfxInfo ||
|
||||||
{
|
(NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_CANVAS2D_ACCELERATION,
|
||||||
return mPreferredCanvasBackend == BackendType::SKIA;
|
&status)) &&
|
||||||
|
status == nsIGfxInfo::FEATURE_STATUS_OK);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gfxPlatform::InitializeSkiaCacheLimits()
|
gfxPlatform::InitializeSkiaCacheLimits()
|
||||||
{
|
{
|
||||||
if (UseAcceleratedSkiaCanvas()) {
|
if (UseAcceleratedCanvas()) {
|
||||||
#ifdef USE_SKIA_GPU
|
#ifdef USE_SKIA_GPU
|
||||||
bool usingDynamicCache = gfxPrefs::CanvasSkiaGLDynamicCache();
|
bool usingDynamicCache = gfxPrefs::CanvasSkiaGLDynamicCache();
|
||||||
int cacheItemLimit = gfxPrefs::CanvasSkiaGLCacheItems();
|
int cacheItemLimit = gfxPrefs::CanvasSkiaGLCacheItems();
|
||||||
|
|
@ -1254,7 +1256,7 @@ SkiaGLGlue*
|
||||||
gfxPlatform::GetSkiaGLGlue()
|
gfxPlatform::GetSkiaGLGlue()
|
||||||
{
|
{
|
||||||
#ifdef USE_SKIA_GPU
|
#ifdef USE_SKIA_GPU
|
||||||
if (!gfxPlatform::GetPlatform()->UseAcceleratedSkiaCanvas()) {
|
if (!UseAcceleratedCanvas()) {
|
||||||
gfxCriticalNote << "Accelerated Skia canvas is disabled";
|
gfxCriticalNote << "Accelerated Skia canvas is disabled";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -252,15 +252,13 @@ public:
|
||||||
return BackendTypeBit(aType) & mContentBackendBitmask;
|
return BackendTypeBit(aType) & mContentBackendBitmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This function lets us know if the current preferences/platform
|
/// This function also lets us know if the current preferences/platform
|
||||||
/// combination allows for both accelerated and not accelerated canvas
|
/// combination allows for both accelerated and not accelerated canvas
|
||||||
/// implementations. If it does, and other relevant preferences are
|
/// implementations. If it does, and other relevant preferences are
|
||||||
/// asking for it, we will examine the commands in the first few seconds
|
/// asking for it, we will examine the commands in the first few seconds
|
||||||
/// of the canvas usage, and potentially change to accelerated or
|
/// of the canvas usage, and potentially change to accelerated or
|
||||||
/// non-accelerated canvas.
|
/// non-accelerated canvas.
|
||||||
virtual bool HaveChoiceOfHWAndSWCanvas();
|
virtual bool UseAcceleratedCanvas();
|
||||||
|
|
||||||
virtual bool UseAcceleratedSkiaCanvas();
|
|
||||||
virtual void InitializeSkiaCacheLimits();
|
virtual void InitializeSkiaCacheLimits();
|
||||||
|
|
||||||
/// These should be used instead of directly accessing the preference,
|
/// These should be used instead of directly accessing the preference,
|
||||||
|
|
@ -271,7 +269,7 @@ public:
|
||||||
|
|
||||||
virtual void GetAzureBackendInfo(mozilla::widget::InfoObject &aObj) {
|
virtual void GetAzureBackendInfo(mozilla::widget::InfoObject &aObj) {
|
||||||
aObj.DefineProperty("AzureCanvasBackend", GetBackendName(mPreferredCanvasBackend));
|
aObj.DefineProperty("AzureCanvasBackend", GetBackendName(mPreferredCanvasBackend));
|
||||||
aObj.DefineProperty("AzureSkiaAccelerated", UseAcceleratedSkiaCanvas());
|
aObj.DefineProperty("AzureCanvasAccelerated", UseAcceleratedCanvas());
|
||||||
aObj.DefineProperty("AzureFallbackCanvasBackend", GetBackendName(mFallbackCanvasBackend));
|
aObj.DefineProperty("AzureFallbackCanvasBackend", GetBackendName(mFallbackCanvasBackend));
|
||||||
aObj.DefineProperty("AzureContentBackend", GetBackendName(mContentBackend));
|
aObj.DefineProperty("AzureContentBackend", GetBackendName(mContentBackend));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -654,7 +654,7 @@ function BuildConditionSandbox(aURL) {
|
||||||
sandbox.azureQuartz = info.AzureCanvasBackend == "quartz";
|
sandbox.azureQuartz = info.AzureCanvasBackend == "quartz";
|
||||||
sandbox.azureSkia = info.AzureCanvasBackend == "skia";
|
sandbox.azureSkia = info.AzureCanvasBackend == "skia";
|
||||||
sandbox.skiaContent = info.AzureContentBackend == "skia";
|
sandbox.skiaContent = info.AzureContentBackend == "skia";
|
||||||
sandbox.azureSkiaGL = info.AzureSkiaAccelerated; // FIXME: assumes GL right now
|
sandbox.azureSkiaGL = info.AzureCanvasAccelerated; // FIXME: assumes GL right now
|
||||||
// true if we are using the same Azure backend for rendering canvas and content
|
// true if we are using the same Azure backend for rendering canvas and content
|
||||||
sandbox.contentSameGfxBackendAsCanvas = info.AzureContentBackend == info.AzureCanvasBackend
|
sandbox.contentSameGfxBackendAsCanvas = info.AzureContentBackend == info.AzureCanvasBackend
|
||||||
|| (info.AzureContentBackend == "none" && info.AzureCanvasBackend == "cairo");
|
|| (info.AzureContentBackend == "none" && info.AzureCanvasBackend == "cairo");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue