forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement impeller::DisplayListDispatcher::drawTextBlob. (flutter#94)
- Loading branch information
1 parent
3235eac
commit f2d2351
Showing
20 changed files
with
323 additions
and
63 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
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,71 @@ | ||
// 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 "impeller/display_list/display_list_playground.h" | ||
|
||
#include "flutter/testing/testing.h" | ||
#include "impeller/aiks/aiks_context.h" | ||
#include "impeller/display_list/display_list_dispatcher.h" | ||
#include "third_party/skia/include/core/SkData.h" | ||
|
||
namespace impeller { | ||
|
||
DisplayListPlayground::DisplayListPlayground() = default; | ||
|
||
DisplayListPlayground::~DisplayListPlayground() = default; | ||
|
||
bool DisplayListPlayground::OpenPlaygroundHere( | ||
flutter::DisplayListBuilder& builder) { | ||
return OpenPlaygroundHere(builder.Build()); | ||
} | ||
|
||
bool DisplayListPlayground::OpenPlaygroundHere( | ||
sk_sp<flutter::DisplayList> list) { | ||
if (!Playground::is_enabled()) { | ||
return true; | ||
} | ||
|
||
if (!list) { | ||
return false; | ||
} | ||
|
||
DisplayListDispatcher dispatcher; | ||
list->Dispatch(dispatcher); | ||
auto picture = dispatcher.EndRecordingAsPicture(); | ||
|
||
AiksContext context(GetContext()); | ||
if (!context.IsValid()) { | ||
return false; | ||
} | ||
return Playground::OpenPlaygroundHere( | ||
[&picture, &context](RenderPass& pass) -> bool { | ||
return context.Render(picture, pass); | ||
}); | ||
} | ||
|
||
static sk_sp<SkData> OpenFixtureAsSkData(const char* fixture_name) { | ||
auto mapping = flutter::testing::OpenFixtureAsMapping(fixture_name); | ||
if (!mapping) { | ||
return nullptr; | ||
} | ||
return SkData::MakeWithProc( | ||
mapping->GetMapping(), mapping->GetSize(), | ||
[](const void* ptr, void* context) { | ||
delete reinterpret_cast<fml::Mapping*>(context); | ||
}, | ||
mapping.release()); | ||
} | ||
|
||
SkFont DisplayListPlayground::CreateTestFontOfSize(SkScalar scalar) { | ||
static constexpr const char* kTestFontFixture = "Roboto-Regular.ttf"; | ||
auto mapping = OpenFixtureAsSkData(kTestFontFixture); | ||
FML_CHECK(mapping); | ||
return SkFont{SkTypeface::MakeFromData(mapping), scalar}; | ||
} | ||
|
||
SkFont DisplayListPlayground::CreateTestFont() { | ||
return CreateTestFontOfSize(50); | ||
} | ||
|
||
} // namespace impeller |
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,33 @@ | ||
// 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. | ||
|
||
#pragma once | ||
|
||
#include "flutter/display_list/display_list.h" | ||
#include "flutter/display_list/display_list_builder.h" | ||
#include "flutter/fml/macros.h" | ||
#include "impeller/playground/playground.h" | ||
#include "third_party/skia/include/core/SkFont.h" | ||
|
||
namespace impeller { | ||
|
||
class DisplayListPlayground : public Playground { | ||
public: | ||
DisplayListPlayground(); | ||
|
||
~DisplayListPlayground(); | ||
|
||
bool OpenPlaygroundHere(flutter::DisplayListBuilder& builder); | ||
|
||
bool OpenPlaygroundHere(sk_sp<flutter::DisplayList> list); | ||
|
||
SkFont CreateTestFontOfSize(SkScalar scalar); | ||
|
||
SkFont CreateTestFont(); | ||
|
||
private: | ||
FML_DISALLOW_COPY_AND_ASSIGN(DisplayListPlayground); | ||
}; | ||
|
||
} // namespace impeller |
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
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
Oops, something went wrong.