Skip to content

Commit f3a6b3e

Browse files
chinmaygardednfield
authored andcommitted
Document GN rules and make targets that cannot be built on the platform be no-ops. (flutter#70)
1 parent b3cbf05 commit f3a6b3e

File tree

5 files changed

+94
-34
lines changed

5 files changed

+94
-34
lines changed

impeller/compiler/BUILD.gn

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ impeller_component("compiler_lib") {
3030
]
3131
}
3232

33-
executable("impellerc") {
33+
impeller_component("impellerc") {
34+
target_type = "executable"
35+
3436
sources = [ "impellerc_main.cc" ]
3537

3638
deps = [ ":compiler_lib" ]

impeller/display_list/display_list_dispatcher.cc

+1-11
Original file line numberDiff line numberDiff line change
@@ -539,17 +539,7 @@ void DisplayListDispatcher::drawDisplayList(
539539
void DisplayListDispatcher::drawTextBlob(const sk_sp<SkTextBlob> blob,
540540
SkScalar x,
541541
SkScalar y) {
542-
if (!blob) {
543-
return;
544-
}
545-
546-
auto bounds = blob->bounds();
547-
bounds.fLeft += x;
548-
bounds.fTop += y;
549-
550-
impeller::Paint paint;
551-
paint.color = impeller::Color::Random().WithAlpha(0.2);
552-
canvas_.DrawRect(ToRect(bounds), paint);
542+
UNIMPLEMENTED;
553543
}
554544

555545
// |flutter::Dispatcher|

impeller/renderer/backend/metal/render_pass_mtl.mm

+6-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,6 @@ static bool Bind(PassBindingsCache& pass,
397397
fml::closure pop_debug_marker = [encoder]() { [encoder popDebugGroup]; };
398398
for (const auto& command : commands_) {
399399
if (command.index_count == 0u) {
400-
VALIDATION_LOG << "Zero index count in render pass command.";
401400
continue;
402401
}
403402

@@ -505,6 +504,12 @@ static bool Bind(PassBindingsCache& pass,
505504
}
506505
}
507506

507+
if (command.index_count == 0u) {
508+
// Essentially a no-op. Don't record the command but this is not necessary
509+
// an error either.
510+
return true;
511+
}
512+
508513
commands_.emplace_back(std::move(command));
509514
return true;
510515
}

impeller/renderer/renderer.h

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
#pragma once
66

7-
#include <dispatch/dispatch.h>
8-
97
#include <functional>
108
#include <memory>
119

impeller/tools/impeller.gni

+84-19
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,69 @@ import("//flutter/common/config.gni")
88
declare_args() {
99
# Whether playgrounds are enabled for unit tests.
1010
impeller_enable_playground = false
11+
12+
# Whether Impeller is supported on the platform.
13+
impeller_supports_platform = is_mac || is_ios
1114
}
1215

16+
# ------------------------------------------------------------------------------
17+
# @brief Define an Impeller component. Components are different
18+
# Impeller subsystems part of the umbrella framework.
19+
#
20+
# @param[optional] target_type The type of the component. This can be any of
21+
# the target types supported by GN. Defaults to
22+
# source_set. If Impeller is not supported on the
23+
# target platform, this target is a no-op.
24+
#
1325
template("impeller_component") {
14-
source_set(target_name) {
15-
forward_variables_from(invoker, "*")
16-
17-
if (!defined(invoker.public_configs)) {
18-
public_configs = []
26+
if (impeller_supports_platform) {
27+
target_type = "source_set"
28+
if (defined(invoker.target_type)) {
29+
target_type = invoker.target_type
1930
}
31+
target(target_type, target_name) {
32+
forward_variables_from(invoker, "*")
2033

21-
if (!defined(invoker.cflags_objc)) {
22-
cflags_objc = []
23-
}
34+
if (!defined(invoker.public_configs)) {
35+
public_configs = []
36+
}
2437

25-
if (!defined(invoker.cflags_objcc)) {
26-
cflags_objcc = []
27-
}
38+
public_configs += [ "//flutter/impeller:impeller_public_config" ]
2839

29-
if (!defined(invoker.deps)) {
30-
deps = []
31-
}
40+
if (!defined(invoker.cflags_objc)) {
41+
cflags_objc = []
42+
}
3243

33-
objc_warning_flags = [ "-Wno-unused-private-field" ]
44+
if (is_ios || is_mac) {
45+
cflags_objc += flutter_cflags_objc_arc
46+
}
3447

35-
cflags_objc += flutter_cflags_objc_arc + objc_warning_flags
36-
cflags_objcc += flutter_cflags_objcc_arc + objc_warning_flags
48+
if (!defined(invoker.cflags_objcc)) {
49+
cflags_objcc = []
50+
}
3751

38-
public_configs += [ "//flutter/impeller:impeller_public_config" ]
52+
if (is_ios || is_mac) {
53+
cflags_objcc += flutter_cflags_objcc_arc
54+
}
55+
}
56+
} else {
57+
group(target_name) {
58+
not_needed(invoker, "*")
59+
}
3960
}
4061
}
4162

63+
# ------------------------------------------------------------------------------
64+
# @brief Build a Metal Library. The output is a single file. Use
65+
# get_target_outputs to get its location on build.
66+
#
67+
# @param[required] name The name of the Metal library.
68+
#
69+
# @param[required] sources The GLSL (4.60) sources to compiled into the Metal
70+
# library.
71+
#
4272
template("metal_library") {
73+
assert(is_ios || is_mac)
4374
assert(defined(invoker.name), "Metal library name must be specified.")
4475
assert(defined(invoker.sources), "Metal source files must be specified.")
4576

@@ -94,7 +125,17 @@ template("metal_library") {
94125
}
95126
}
96127

97-
template("impeller_shaders") {
128+
# ------------------------------------------------------------------------------
129+
# @brief Build and reflect shader information. Reflected shader
130+
# information will be added to a generated source set along
131+
# with the shader contents.
132+
#
133+
# @param[required] name The name of the shader library.
134+
#
135+
# @param[required] sources The GLSL (4.60) sources to compiled into the shader
136+
# library.
137+
#
138+
template("impeller_shaders_real") {
98139
assert(defined(invoker.shaders), "Impeller shaders must be specified.")
99140
assert(defined(invoker.name), "Name of the shader library must be specified.")
100141

@@ -229,3 +270,27 @@ template("impeller_shaders") {
229270
]
230271
}
231272
}
273+
274+
# ------------------------------------------------------------------------------
275+
# @brief Builds the shader library from shader sources, generates
276+
# reflected shader information as source set, and, generates a
277+
# translation unit added as a source set that allows embedding
278+
# shaders into the final binary. On platforms where Impeller is
279+
# not supported, this is a no-op.
280+
#
281+
# @note For additional information about parameters, see
282+
# `impeller_shaders_real`
283+
#
284+
# @see impeller_shaders_real
285+
#
286+
template("impeller_shaders") {
287+
if (impeller_supports_platform) {
288+
impeller_shaders_real(target_name) {
289+
forward_variables_from(invoker, "*")
290+
}
291+
} else {
292+
group(target_name) {
293+
not_needed(invoker, "*")
294+
}
295+
}
296+
}

0 commit comments

Comments
 (0)