Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move SoftwareCanvasProvider into its own source file #30856

Merged
merged 2 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions display_list/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ if (enable_unittests) {
sources = [
"display_list_benchmarks.cc",
"display_list_benchmarks.h",
"display_list_benchmarks_software.cc",
]

deps = [
Expand Down
25 changes: 0 additions & 25 deletions display_list/display_list_benchmarks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<SkSurface> GetSurface() override { return surface_; }

sk_sp<SkSurface> 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<SkSurface> surface_;
};

// Constants chosen to produce benchmark results in the region of 1-50ms
constexpr size_t kLinesToDraw = 10000;
constexpr size_t kRectsToDraw = 5000;
Expand Down Expand Up @@ -1054,7 +1031,5 @@ void BM_DrawShadow(benchmark::State& state,
canvas_provider->Snapshot(filename);
}

RUN_DISPLAYLIST_BENCHMARKS(Software)

} // namespace testing
} // namespace flutter
39 changes: 39 additions & 0 deletions display_list/display_list_benchmarks_software.cc
Original file line number Diff line number Diff line change
@@ -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<SkSurface> GetSurface() override { return surface_; }

sk_sp<SkSurface> 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<SkSurface> surface_;
};

RUN_DISPLAYLIST_BENCHMARKS(Software)

} // namespace testing
} // namespace flutter