Commit 90617fab authored by Kai Ninomiya's avatar Kai Ninomiya Committed by Commit Bot

Set filter quality on WebGPU CC layers

This changes the default filtering from nearest to bilinear, to match
other canvases.
The filter quality gets passed through from CSS's image-rendering.

Bug: 852089
Change-Id: I704c91940bd495a55a1afe29600dff9cec448b8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2161869Reviewed-by: default avatarAustin Eng <enga@chromium.org>
Reviewed-by: default avatarCorentin Wallez <cwallez@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#762030}
parent a4c42132
...@@ -62,6 +62,15 @@ cc::Layer* GPUCanvasContext::CcLayer() const { ...@@ -62,6 +62,15 @@ cc::Layer* GPUCanvasContext::CcLayer() const {
return nullptr; return nullptr;
} }
void GPUCanvasContext::SetFilterQuality(SkFilterQuality filter_quality) {
if (filter_quality != filter_quality_) {
filter_quality_ = filter_quality;
if (swapchain_) {
swapchain_->SetFilterQuality(filter_quality);
}
}
}
// gpu_canvas_context.idl // gpu_canvas_context.idl
GPUSwapChain* GPUCanvasContext::configureSwapChain( GPUSwapChain* GPUCanvasContext::configureSwapChain(
const GPUSwapChainDescriptor* descriptor) { const GPUSwapChainDescriptor* descriptor) {
...@@ -76,7 +85,8 @@ GPUSwapChain* GPUCanvasContext::configureSwapChain( ...@@ -76,7 +85,8 @@ GPUSwapChain* GPUCanvasContext::configureSwapChain(
// destroy all its resources (and produce errors when used). // destroy all its resources (and produce errors when used).
swapchain_->Neuter(); swapchain_->Neuter();
} }
swapchain_ = MakeGarbageCollected<GPUSwapChain>(this, descriptor); swapchain_ =
MakeGarbageCollected<GPUSwapChain>(this, descriptor, filter_quality_);
return swapchain_; return swapchain_;
} }
......
...@@ -55,7 +55,7 @@ class GPUCanvasContext : public CanvasRenderingContext { ...@@ -55,7 +55,7 @@ class GPUCanvasContext : public CanvasRenderingContext {
bool IsAccelerated() const final { return true; } bool IsAccelerated() const final { return true; }
bool IsOriginTopLeft() const final { return true; } bool IsOriginTopLeft() const final { return true; }
bool Is3d() const final { return true; } bool Is3d() const final { return true; }
void SetFilterQuality(SkFilterQuality) final {} void SetFilterQuality(SkFilterQuality) override;
bool IsPaintable() const final { return true; } bool IsPaintable() const final { return true; }
int ExternallyAllocatedBufferCountPerPixel() final { return 1; } int ExternallyAllocatedBufferCountPerPixel() final { return 1; }
void Stop() final; void Stop() final;
...@@ -68,6 +68,7 @@ class GPUCanvasContext : public CanvasRenderingContext { ...@@ -68,6 +68,7 @@ class GPUCanvasContext : public CanvasRenderingContext {
private: private:
DISALLOW_COPY_AND_ASSIGN(GPUCanvasContext); DISALLOW_COPY_AND_ASSIGN(GPUCanvasContext);
SkFilterQuality filter_quality_ = kLow_SkFilterQuality;
Member<GPUSwapChain> swapchain_; Member<GPUSwapChain> swapchain_;
bool stopped_ = false; bool stopped_ = false;
}; };
......
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
namespace blink { namespace blink {
GPUSwapChain::GPUSwapChain(GPUCanvasContext* context, GPUSwapChain::GPUSwapChain(GPUCanvasContext* context,
const GPUSwapChainDescriptor* descriptor) const GPUSwapChainDescriptor* descriptor,
SkFilterQuality filter_quality)
: DawnObjectBase(descriptor->device()->GetDawnControlClient()), : DawnObjectBase(descriptor->device()->GetDawnControlClient()),
device_(descriptor->device()), device_(descriptor->device()),
context_(context), context_(context),
...@@ -23,6 +24,7 @@ GPUSwapChain::GPUSwapChain(GPUCanvasContext* context, ...@@ -23,6 +24,7 @@ GPUSwapChain::GPUSwapChain(GPUCanvasContext* context,
swap_buffers_ = base::AdoptRef(new WebGPUSwapBufferProvider( swap_buffers_ = base::AdoptRef(new WebGPUSwapBufferProvider(
this, GetDawnControlClient(), device_->GetClientID(), usage_, this, GetDawnControlClient(), device_->GetClientID(), usage_,
AsDawnEnum<WGPUTextureFormat>(descriptor->format()))); AsDawnEnum<WGPUTextureFormat>(descriptor->format())));
swap_buffers_->SetFilterQuality(filter_quality);
} }
GPUSwapChain::~GPUSwapChain() { GPUSwapChain::~GPUSwapChain() {
...@@ -51,6 +53,13 @@ cc::Layer* GPUSwapChain::CcLayer() { ...@@ -51,6 +53,13 @@ cc::Layer* GPUSwapChain::CcLayer() {
return swap_buffers_->CcLayer(); return swap_buffers_->CcLayer();
} }
void GPUSwapChain::SetFilterQuality(SkFilterQuality filter_quality) {
DCHECK(swap_buffers_);
if (swap_buffers_) {
swap_buffers_->SetFilterQuality(filter_quality);
}
}
// gpu_swap_chain.idl // gpu_swap_chain.idl
GPUTexture* GPUSwapChain::getCurrentTexture() { GPUTexture* GPUSwapChain::getCurrentTexture() {
if (!swap_buffers_) { if (!swap_buffers_) {
......
...@@ -26,13 +26,15 @@ class GPUSwapChain : public ScriptWrappable, ...@@ -26,13 +26,15 @@ class GPUSwapChain : public ScriptWrappable,
public: public:
explicit GPUSwapChain(GPUCanvasContext* context, explicit GPUSwapChain(GPUCanvasContext* context,
const GPUSwapChainDescriptor* descriptor); const GPUSwapChainDescriptor* descriptor,
SkFilterQuality filter_quality);
~GPUSwapChain() override; ~GPUSwapChain() override;
void Trace(Visitor* visitor) override; void Trace(Visitor* visitor) override;
void Neuter(); void Neuter();
cc::Layer* CcLayer(); cc::Layer* CcLayer();
void SetFilterQuality(SkFilterQuality);
// gpu_swap_chain.idl // gpu_swap_chain.idl
GPUTexture* getCurrentTexture(); GPUTexture* getCurrentTexture();
......
...@@ -43,7 +43,7 @@ WebGPUSwapBufferProvider::WebGPUSwapBufferProvider( ...@@ -43,7 +43,7 @@ WebGPUSwapBufferProvider::WebGPUSwapBufferProvider(
layer_->SetIsDrawable(true); layer_->SetIsDrawable(true);
layer_->SetBlendBackgroundColor(false); layer_->SetBlendBackgroundColor(false);
layer_->SetNearestNeighbor(true); layer_->SetNearestNeighbor(false);
layer_->SetFlipped(false); layer_->SetFlipped(false);
// TODO(cwallez@chromium.org): These flags aren't taken into account when the // TODO(cwallez@chromium.org): These flags aren't taken into account when the
// layer is promoted to an overlay. Make sure we have fallback / emulation // layer is promoted to an overlay. Make sure we have fallback / emulation
...@@ -61,6 +61,13 @@ cc::Layer* WebGPUSwapBufferProvider::CcLayer() { ...@@ -61,6 +61,13 @@ cc::Layer* WebGPUSwapBufferProvider::CcLayer() {
return layer_.get(); return layer_.get();
} }
void WebGPUSwapBufferProvider::SetFilterQuality(
SkFilterQuality filter_quality) {
if (layer_) {
layer_->SetNearestNeighbor(filter_quality == kNone_SkFilterQuality);
}
}
void WebGPUSwapBufferProvider::Neuter() { void WebGPUSwapBufferProvider::Neuter() {
if (neutered_) { if (neutered_) {
return; return;
......
...@@ -41,6 +41,7 @@ class PLATFORM_EXPORT WebGPUSwapBufferProvider ...@@ -41,6 +41,7 @@ class PLATFORM_EXPORT WebGPUSwapBufferProvider
~WebGPUSwapBufferProvider() override; ~WebGPUSwapBufferProvider() override;
cc::Layer* CcLayer(); cc::Layer* CcLayer();
void SetFilterQuality(SkFilterQuality);
void Neuter(); void Neuter();
WGPUTexture GetNewTexture(const IntSize& size); WGPUTexture GetNewTexture(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