From fcf7458057f2b488f35d598aa230ffa752904641 Mon Sep 17 00:00:00 2001 From: George Wright Date: Thu, 13 Jan 2022 15:35:09 -0800 Subject: [PATCH] Move SoftwareCanvasProvider into its own source file (#30856) --- ci/licenses_golden/licenses_flutter | 1 + display_list/BUILD.gn | 1 + display_list/display_list_benchmarks.cc | 25 ------------ .../display_list_benchmarks_software.cc | 39 +++++++++++++++++++ 4 files changed, 41 insertions(+), 25 deletions(-) create mode 100644 display_list/display_list_benchmarks_software.cc diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 0ef87816feefb..06fd07c0f7a9e 100755 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -40,6 +40,7 @@ FILE: ../../../flutter/display_list/display_list_benchmarks.cc FILE: ../../../flutter/display_list/display_list_benchmarks.h FILE: ../../../flutter/display_list/display_list_benchmarks_gl.cc FILE: ../../../flutter/display_list/display_list_benchmarks_metal.cc +FILE: ../../../flutter/display_list/display_list_benchmarks_software.cc FILE: ../../../flutter/display_list/display_list_builder.cc FILE: ../../../flutter/display_list/display_list_builder.h FILE: ../../../flutter/display_list/display_list_canvas_dispatcher.cc diff --git a/display_list/BUILD.gn b/display_list/BUILD.gn index 88f957d33ccb4..e5ae8883fc34b 100644 --- a/display_list/BUILD.gn +++ b/display_list/BUILD.gn @@ -60,6 +60,7 @@ if (enable_unittests) { sources = [ "display_list_benchmarks.cc", "display_list_benchmarks.h", + "display_list_benchmarks_software.cc", ] deps = [ diff --git a/display_list/display_list_benchmarks.cc b/display_list/display_list_benchmarks.cc index 6fd39773ee015..1da387a26c370 100644 --- a/display_list/display_list_benchmarks.cc +++ b/display_list/display_list_benchmarks.cc @@ -11,29 +11,6 @@ namespace flutter { namespace testing { -class SoftwareCanvasProvider : public CanvasProvider { - public: - virtual ~SoftwareCanvasProvider() = default; - void InitializeSurface(const size_t width, const size_t height) override { - surface_ = SkSurface::MakeRasterN32Premul(width, height); - surface_->getCanvas()->clear(SK_ColorTRANSPARENT); - } - - sk_sp GetSurface() override { return surface_; } - - sk_sp MakeOffscreenSurface(const size_t width, - const size_t height) override { - auto surface = SkSurface::MakeRasterN32Premul(width, height); - surface->getCanvas()->clear(SK_ColorTRANSPARENT); - return surface; - } - - const std::string BackendName() override { return "Software"; } - - private: - sk_sp surface_; -}; - // Constants chosen to produce benchmark results in the region of 1-50ms constexpr size_t kLinesToDraw = 10000; constexpr size_t kRectsToDraw = 5000; @@ -1054,7 +1031,5 @@ void BM_DrawShadow(benchmark::State& state, canvas_provider->Snapshot(filename); } -RUN_DISPLAYLIST_BENCHMARKS(Software) - } // namespace testing } // namespace flutter diff --git a/display_list/display_list_benchmarks_software.cc b/display_list/display_list_benchmarks_software.cc new file mode 100644 index 0000000000000..b63d4a7a0a2e6 --- /dev/null +++ b/display_list/display_list_benchmarks_software.cc @@ -0,0 +1,39 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "flutter/display_list/display_list_benchmarks.h" +#include "flutter/display_list/display_list_builder.h" +#include "third_party/skia/include/core/SkPoint.h" +#include "third_party/skia/include/core/SkTextBlob.h" + +namespace flutter { +namespace testing { + +class SoftwareCanvasProvider : public CanvasProvider { + public: + virtual ~SoftwareCanvasProvider() = default; + void InitializeSurface(const size_t width, const size_t height) override { + surface_ = SkSurface::MakeRasterN32Premul(width, height); + surface_->getCanvas()->clear(SK_ColorTRANSPARENT); + } + + sk_sp GetSurface() override { return surface_; } + + sk_sp MakeOffscreenSurface(const size_t width, + const size_t height) override { + auto surface = SkSurface::MakeRasterN32Premul(width, height); + surface->getCanvas()->clear(SK_ColorTRANSPARENT); + return surface; + } + + const std::string BackendName() override { return "Software"; } + + private: + sk_sp surface_; +}; + +RUN_DISPLAYLIST_BENCHMARKS(Software) + +} // namespace testing +} // namespace flutter