Skip to content

Commit fcf7458

Browse files
author
George Wright
authored
Move SoftwareCanvasProvider into its own source file (flutter#30856)
1 parent 4499797 commit fcf7458

File tree

4 files changed

+41
-25
lines changed

4 files changed

+41
-25
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ FILE: ../../../flutter/display_list/display_list_benchmarks.cc
4040
FILE: ../../../flutter/display_list/display_list_benchmarks.h
4141
FILE: ../../../flutter/display_list/display_list_benchmarks_gl.cc
4242
FILE: ../../../flutter/display_list/display_list_benchmarks_metal.cc
43+
FILE: ../../../flutter/display_list/display_list_benchmarks_software.cc
4344
FILE: ../../../flutter/display_list/display_list_builder.cc
4445
FILE: ../../../flutter/display_list/display_list_builder.h
4546
FILE: ../../../flutter/display_list/display_list_canvas_dispatcher.cc

display_list/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ if (enable_unittests) {
6060
sources = [
6161
"display_list_benchmarks.cc",
6262
"display_list_benchmarks.h",
63+
"display_list_benchmarks_software.cc",
6364
]
6465

6566
deps = [

display_list/display_list_benchmarks.cc

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,6 @@
1111
namespace flutter {
1212
namespace testing {
1313

14-
class SoftwareCanvasProvider : public CanvasProvider {
15-
public:
16-
virtual ~SoftwareCanvasProvider() = default;
17-
void InitializeSurface(const size_t width, const size_t height) override {
18-
surface_ = SkSurface::MakeRasterN32Premul(width, height);
19-
surface_->getCanvas()->clear(SK_ColorTRANSPARENT);
20-
}
21-
22-
sk_sp<SkSurface> GetSurface() override { return surface_; }
23-
24-
sk_sp<SkSurface> MakeOffscreenSurface(const size_t width,
25-
const size_t height) override {
26-
auto surface = SkSurface::MakeRasterN32Premul(width, height);
27-
surface->getCanvas()->clear(SK_ColorTRANSPARENT);
28-
return surface;
29-
}
30-
31-
const std::string BackendName() override { return "Software"; }
32-
33-
private:
34-
sk_sp<SkSurface> surface_;
35-
};
36-
3714
// Constants chosen to produce benchmark results in the region of 1-50ms
3815
constexpr size_t kLinesToDraw = 10000;
3916
constexpr size_t kRectsToDraw = 5000;
@@ -1054,7 +1031,5 @@ void BM_DrawShadow(benchmark::State& state,
10541031
canvas_provider->Snapshot(filename);
10551032
}
10561033

1057-
RUN_DISPLAYLIST_BENCHMARKS(Software)
1058-
10591034
} // namespace testing
10601035
} // namespace flutter
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "flutter/display_list/display_list_benchmarks.h"
6+
#include "flutter/display_list/display_list_builder.h"
7+
#include "third_party/skia/include/core/SkPoint.h"
8+
#include "third_party/skia/include/core/SkTextBlob.h"
9+
10+
namespace flutter {
11+
namespace testing {
12+
13+
class SoftwareCanvasProvider : public CanvasProvider {
14+
public:
15+
virtual ~SoftwareCanvasProvider() = default;
16+
void InitializeSurface(const size_t width, const size_t height) override {
17+
surface_ = SkSurface::MakeRasterN32Premul(width, height);
18+
surface_->getCanvas()->clear(SK_ColorTRANSPARENT);
19+
}
20+
21+
sk_sp<SkSurface> GetSurface() override { return surface_; }
22+
23+
sk_sp<SkSurface> MakeOffscreenSurface(const size_t width,
24+
const size_t height) override {
25+
auto surface = SkSurface::MakeRasterN32Premul(width, height);
26+
surface->getCanvas()->clear(SK_ColorTRANSPARENT);
27+
return surface;
28+
}
29+
30+
const std::string BackendName() override { return "Software"; }
31+
32+
private:
33+
sk_sp<SkSurface> surface_;
34+
};
35+
36+
RUN_DISPLAYLIST_BENCHMARKS(Software)
37+
38+
} // namespace testing
39+
} // namespace flutter

0 commit comments

Comments
 (0)