forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move SoftwareCanvasProvider into its own source file (flutter#30856)
- Loading branch information
George Wright
authored
Jan 13, 2022
1 parent
4499797
commit fcf7458
Showing
4 changed files
with
41 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |