Commit 6d9c3390 authored by Teresa Kang's avatar Teresa Kang Committed by Commit Bot

RasterModeHint should not affect restore logic

With the logic that preserves acceleration regardless of the
RasterModeHint given in ShouldAccelerate, GetOrCreateResourceProvider
will try to create a gpu resource provider even if the hint is
kPreferCPU, in which case re-creation should try to happen through
Restore() first. The hint should not have an effect on whether or not
to use Restore().

Bug: 1090180
Change-Id: Ia87b081ef611021a4c94a7ac0232c380fca3a143
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2246788Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Reviewed-by: default avatarJuanmi Huertas <juanmihd@chromium.org>
Commit-Queue: Teresa Kang <teresakang@google.com>
Cr-Commit-Position: refs/heads/master@{#778976}
parent 7eb97887
...@@ -255,15 +255,23 @@ CanvasResourceProvider* Canvas2DLayerBridge::GetOrCreateResourceProvider( ...@@ -255,15 +255,23 @@ CanvasResourceProvider* Canvas2DLayerBridge::GetOrCreateResourceProvider(
return resource_provider; return resource_provider;
} }
if (layer_ && !IsHibernating() && hint == RasterModeHint::kPreferGPU && // Restore() is tried at most four times in two seconds to recreate the
acceleration_mode_ != kDisableAcceleration) { // ResourceProvider before the final attempt, in which a new
return nullptr; // re-creation will happen through restore() // Canvas2DLayerBridge is created along with its resource provider.
}
bool want_acceleration = ShouldAccelerate(hint); bool want_acceleration = ShouldAccelerate(hint);
RasterModeHint adjusted_hint = want_acceleration ? RasterModeHint::kPreferGPU RasterModeHint adjusted_hint = want_acceleration ? RasterModeHint::kPreferGPU
: RasterModeHint::kPreferCPU; : RasterModeHint::kPreferCPU;
// Re-creation will happen through Restore().
// If the Canvas2DLayerBridge has just been created, possibly due to failed
// attempts of Restore(), the layer would not exist, therefore, it will not
// fall through this clause to try Restore() again
if (layer_ && !IsHibernating() &&
adjusted_hint == RasterModeHint::kPreferGPU) {
return nullptr;
}
// We call GetOrCreateCanvasResourceProviderImpl directly here to prevent a // We call GetOrCreateCanvasResourceProviderImpl directly here to prevent a
// circular callstack from HTMLCanvasElement. // circular callstack from HTMLCanvasElement.
resource_provider = resource_provider =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment