0

Remove SK_IGNORE_BLURRED_RRECT_OPT flag

In https://codereview.chromium.org/48623006/ Skia added an optimization
for blurring rounded rectangles (treating them as a ninepatch to
do less blurring and make the results cacheable). This saw up to an
80% reduction in time for rendering with the CPU backend in Skia's
benchmarks. However, due to differences in rendering between this
fast path and the existing path, it was not landed in Chromium and sat
unused here for 11+ years. It's been used in Android and all other
clients since then.

I addressed those rendering diffs [1][2][3] and this CL makes Chromium
use that fast path. This required setting up Chromium's discardable
memory cache (which Skia uses to cache masks and other things) because
in the new code path, Skia caches those blurred masks to save time
if there are, for example, multiple blurry rrects being drawn with 5px
border and the same sigma values.

There are still some very minor differences in appearance between the
two implementations, which I've addressed by rebasing and adding some
slight fuzzy tolerances, to make the tests less brittle for future
blur changes.

[1] http://review.skia.org/953496
[2] http://review.skia.org/953516
[3] https://crrev.com/c/6328778

Change-Id: I140844d24a9e31cb2bde4e25b6cb1cce1b812f67
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6335820
Commit-Queue: Kaylee Lubick <kjlubick@chromium.org>
Reviewed-by: Benoit Lize <lizeb@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Reviewed-by: Ashley Prasad <ashleydp@google.com>
Cr-Commit-Position: refs/heads/main@{#1432101}
This commit is contained in:
Kaylee Lubick
2025-03-13 07:41:12 -07:00
committed by Chromium LUCI CQ
parent 1d53cbe0fe
commit 4b79d0656e
23 changed files with 34 additions and 3 deletions

@ -48,6 +48,8 @@ void AshWebUITestSuite::Initialize() {
gl::GLSurfaceTestSupport::InitializeOneOff();
InitI18n();
base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_);
}
void AshWebUITestSuite::Shutdown() {

@ -5,6 +5,7 @@
#ifndef ASH_WEBUI_ASH_WEBUI_TEST_SUITE_H_
#define ASH_WEBUI_ASH_WEBUI_TEST_SUITE_H_
#include "base/test/test_discardable_memory_allocator.h"
#include "base/test/test_suite.h"
class AshWebUITestSuite : public base::TestSuite {
@ -20,6 +21,9 @@ class AshWebUITestSuite : public base::TestSuite {
// base::TestSuite:
void Initialize() override;
void Shutdown() override;
private:
base::TestDiscardableMemoryAllocator discardable_memory_allocator_;
};
#endif // ASH_WEBUI_ASH_WEBUI_TEST_SUITE_H_

@ -29,6 +29,10 @@ DiscardableMemoryAllocator* DiscardableMemoryAllocator::GetInstance() {
return g_discardable_allocator;
}
bool DiscardableMemoryAllocator::HasInstance() {
return g_discardable_allocator != nullptr;
}
std::unique_ptr<base::DiscardableMemory>
DiscardableMemoryAllocator::AllocateLockedDiscardableMemoryWithRetryOrDie(
size_t size,

@ -29,9 +29,12 @@ class BASE_EXPORT DiscardableMemoryAllocator {
virtual ~DiscardableMemoryAllocator() = default;
// Returns the allocator instance.
// Returns the allocator instance. Asserts if not already set.
static DiscardableMemoryAllocator* GetInstance();
// Returns true if the instance has been set.
static bool HasInstance();
// Sets the allocator instance. Can only be called once, e.g. on startup.
// Ownership of |instance| remains with the caller.
static void SetInstance(DiscardableMemoryAllocator* allocator);

@ -5,8 +5,11 @@
#include <memory>
#include "base/command_line.h"
#include "base/memory/discardable_memory_allocator.h"
#include "base/test/launcher/test_launcher.h"
#include "base/test/test_discardable_memory_allocator.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/ssl/https_upgrades_navigation_throttle.h"
#include "chrome/test/base/chrome_test_launcher.h"
#include "chrome/test/base/chrome_test_suite.h"
@ -71,6 +74,9 @@ class InteractiveUITestSuite : public ChromeTestSuite {
// Force the HTTPS-Upgrades timeout to zero.
HttpsUpgradesNavigationThrottle::set_timeout_for_testing(base::TimeDelta());
#endif
base::DiscardableMemoryAllocator::SetInstance(
&discardable_memory_allocator_);
}
void Shutdown() override {
@ -83,6 +89,7 @@ class InteractiveUITestSuite : public ChromeTestSuite {
#if BUILDFLAG(IS_WIN)
std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer_;
#endif
base::TestDiscardableMemoryAllocator discardable_memory_allocator_;
};
class InteractiveUITestLauncherDelegate : public ChromeTestLauncherDelegate {

@ -705,7 +705,9 @@ void BrowserMainLoop::PostCreateMainMessageLoop() {
// TODO(boliu): kSingleProcess check is a temporary workaround for
// in-process Android WebView. crbug.com/503724 tracks proper fix.
if (!parsed_command_line_->HasSwitch(switches::kSingleProcess)) {
// Also check to see if a discardable memory manager was set (e.g. unit tests)
if (!parsed_command_line_->HasSwitch(switches::kSingleProcess) &&
!base::DiscardableMemoryAllocator::HasInstance()) {
base::DiscardableMemoryAllocator::SetInstance(
discardable_memory::DiscardableSharedMemoryManager::Get());
}

@ -150,7 +150,6 @@ SK_API void SkDebugf_FileLine(const char* file,
// Temporarily enable new strike cache pinning logic, for staging.
#define SK_STRIKE_CACHE_DOESNT_AUTO_CHECK_PINNERS
#define SK_IGNORE_BLURRED_RRECT_OPT
#define SK_USE_DISCARDABLE_SCALEDIMAGECACHE
#define SK_ATTR_DEPRECATED SK_NOTHING_ARG1

Binary file not shown.

Before

(image error) Size: 9.5 KiB

After

(image error) Size: 9.5 KiB

@ -1,4 +1,5 @@
<!DOCTYPE html>
<meta name="fuzzy" content="maxDifference=0-2; totalPixels=0-100"/>
<style>
.bordered {
height: 150px;

Binary file not shown.

Before

(image error) Size: 7.1 KiB

After

(image error) Size: 7.2 KiB

@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<meta name="fuzzy" content="maxDifference=0-2; totalPixels=0-100"/>
<head>
<style type="text/css">
.box {

@ -1,3 +1,4 @@
<meta name="fuzzy" content="maxDifference=0-2; totalPixels=0-100"/>
<style>
span::selection { color: purple; }
div.roundedRect {

@ -1,3 +1,5 @@
<!DOCTYPE html>
<meta name="fuzzy" content="maxDifference=0-2; totalPixels=0-100"/>
<div style="
font-family: Lucida Grande;
font-weight: bold;

Binary file not shown.

Before

(image error) Size: 30 KiB

After

(image error) Size: 30 KiB

Binary file not shown.

Before

(image error) Size: 30 KiB

After

(image error) Size: 30 KiB

Binary file not shown.

Before

(image error) Size: 30 KiB

After

(image error) Size: 30 KiB

Binary file not shown.

Before

(image error) Size: 30 KiB

After

(image error) Size: 30 KiB

Binary file not shown.

Before

(image error) Size: 30 KiB

After

(image error) Size: 30 KiB

Binary file not shown.

Before

(image error) Size: 50 KiB

After

(image error) Size: 50 KiB

Binary file not shown.

Before

(image error) Size: 29 KiB

After

(image error) Size: 29 KiB

Binary file not shown.

Before

(image error) Size: 44 KiB

After

(image error) Size: 44 KiB

@ -6,6 +6,7 @@
#include "base/compiler_specific.h"
#include "base/functional/bind.h"
#include "base/memory/discardable_memory_allocator.h"
#include "base/path_service.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h"
@ -69,6 +70,8 @@ void ViewsTestSuite::Initialize() {
#if defined(USE_AURA)
InitializeEnv();
#endif
base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_);
}
void ViewsTestSuite::Shutdown() {

@ -6,6 +6,7 @@
#define UI_VIEWS_VIEWS_TEST_SUITE_H_
#include "base/memory/raw_ptr.h"
#include "base/test/test_discardable_memory_allocator.h"
#include "base/test/test_suite.h"
#include "build/build_config.h"
@ -49,6 +50,7 @@ class ViewsTestSuite : public base::TestSuite {
int argc_;
raw_ptr<char*> argv_;
base::TestDiscardableMemoryAllocator discardable_memory_allocator_;
};
} // namespace views