Commit 8ea2f214 authored by Juanmi Huertas's avatar Juanmi Huertas Committed by Commit Bot

Making Clear private and removing a last not-needed clear

Clear was not yet private as it was still being used by Canvas 2D
Layer Bridge.

Removing that usage now, and marking Clear as Private inside Canvas
Resource Provider.

Adding an explicit DidDraw to the creation of the Resource, as it has
been cleared on construction.

I am leaving a GetOrCreateResourceProvider in line 101 as it was called,
and that would, potentially, recreate the Resource.
It would be also a good follow-up to try to see if there is a way to
encapsulate the things DidDraw is doing here and in other places where
it is being called after the internal Clear of the CRP, to have it done
internally as well.

Bug: 1090081
Change-Id: I87a5b6d20a1d79606e1d986c484f2677edde2863
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2382612Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Commit-Queue: Juanmi Huertas <juanmihd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804237}
parent 3b2cdc9b
......@@ -97,10 +97,6 @@ Canvas2DLayerBridge::~Canvas2DLayerBridge() {
void Canvas2DLayerBridge::SetCanvasResourceHost(CanvasResourceHost* host) {
resource_host_ = host;
if (resource_host_ && GetOrCreateResourceProvider()) {
EnsureCleared();
}
}
void Canvas2DLayerBridge::ResetResourceProvider() {
......@@ -259,7 +255,10 @@ CanvasResourceProvider* Canvas2DLayerBridge::GetOrCreateResourceProvider() {
if (!resource_provider || !resource_provider->IsValid())
return nullptr;
EnsureCleared();
// Calling to DidDraw because GetOrCreateResourceProvider created a new
// provider and cleared it
// TODO crbug/1090081: Check possibility to move DidDraw inside Clear.
DidDraw(FloatRect(0.f, 0.f, size_.Width(), size_.Height()));
if (IsAccelerated() && !layer_) {
layer_ = cc::TextureLayer::CreateForMailbox(this);
......@@ -394,14 +393,6 @@ void Canvas2DLayerBridge::SkipQueuedDrawCommands() {
rate_limiter_->Reset();
}
void Canvas2DLayerBridge::EnsureCleared() {
if (cleared_)
return;
cleared_ = true;
ResourceProvider()->Clear();
DidDraw(FloatRect(0.f, 0.f, size_.Width(), size_.Height()));
}
void Canvas2DLayerBridge::ClearPendingRasterTimers() {
gpu::raster::RasterInterface* raster_interface = nullptr;
if (IsAccelerated() && SharedGpuContext::ContextProviderWrapper() &&
......
......@@ -177,7 +177,6 @@ class PLATFORM_EXPORT Canvas2DLayerBridge : public cc::TextureLayerClient {
void ResetResourceProvider();
void SkipQueuedDrawCommands();
void EnsureCleared();
// Check if the Raster Mode is GPU and if the GPU context is not lost
bool ShouldAccelerate() const;
......@@ -232,10 +231,6 @@ class PLATFORM_EXPORT Canvas2DLayerBridge : public cc::TextureLayerClient {
sk_sp<cc::PaintRecord> last_recording_;
// This tracks whether the canvas has been cleared once after
// this bridge was created.
bool cleared_ = false;
base::WeakPtrFactory<Canvas2DLayerBridge> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(Canvas2DLayerBridge);
......
......@@ -198,7 +198,7 @@ class PLATFORM_EXPORT CanvasResourceProvider
NOTREACHED();
return nullptr;
}
void Clear();
~CanvasResourceProvider() override;
base::WeakPtr<CanvasResourceProvider> CreateWeakPtr() {
......@@ -292,6 +292,8 @@ class PLATFORM_EXPORT CanvasResourceProvider
void EnsureSkiaCanvas();
void SetNeedsFlush() { needs_flush_ = true; }
void Clear();
base::WeakPtr<WebGraphicsContext3DProviderWrapper> context_provider_wrapper_;
base::WeakPtr<CanvasResourceDispatcher> resource_dispatcher_;
const IntSize size_;
......
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