mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Wire up asset resolution.
This commit is contained in:
parent
e452fab337
commit
afc94fa9c4
@ -4,12 +4,17 @@
|
||||
|
||||
import("//flutter/common/config.gni")
|
||||
import("//flutter/impeller/tools/metal/metal_library.gni")
|
||||
import("//flutter/testing/testing.gni")
|
||||
|
||||
metal_library("impeller_host_shaders") {
|
||||
name = "impeller_host"
|
||||
sources = [ "shaders.metal" ]
|
||||
}
|
||||
|
||||
test_fixtures("impeller_host_fixtures") {
|
||||
fixtures = [ "assets/ColorMap.png" ]
|
||||
}
|
||||
|
||||
executable("host") {
|
||||
cflags_objc = flutter_cflags_objc_arc
|
||||
cflags_objcc = flutter_cflags_objcc_arc
|
||||
@ -20,6 +25,8 @@ executable("host") {
|
||||
|
||||
sources = [
|
||||
"ShaderTypes.h",
|
||||
"assets_location.cc",
|
||||
"assets_location.h",
|
||||
"impeller_host_view_controller.h",
|
||||
"impeller_host_view_controller.mm",
|
||||
"impeller_renderer.h",
|
||||
@ -38,6 +45,7 @@ executable("host") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
":impeller_host_fixtures",
|
||||
":impeller_host_shaders",
|
||||
"//flutter/fml",
|
||||
"//flutter/impeller/impeller",
|
||||
|
||||
BIN
engine/src/flutter/impeller/host/assets/ColorMap.png
Normal file
BIN
engine/src/flutter/impeller/host/assets/ColorMap.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
31
engine/src/flutter/impeller/host/assets_location.cc
Normal file
31
engine/src/flutter/impeller/host/assets_location.cc
Normal file
@ -0,0 +1,31 @@
|
||||
// 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/impeller/host/assets_location.h"
|
||||
|
||||
#include "flutter/fml/paths.h"
|
||||
|
||||
namespace flutter::testing {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// @brief Returns the directory containing the test fixture for the target
|
||||
/// if this target has fixtures configured. If there are no
|
||||
/// fixtures, this is a link error. If you see a linker error on
|
||||
/// this symbol, the unit-test target needs to depend on a
|
||||
/// `test_fixtures` target.
|
||||
///
|
||||
/// @return The fixtures path.
|
||||
///
|
||||
const char* GetFixturesPath();
|
||||
|
||||
} // namespace flutter::testing
|
||||
|
||||
namespace impeller {
|
||||
|
||||
std::string GetAssetLocation(const char* asset_path) {
|
||||
return fml::paths::JoinPaths(
|
||||
{flutter::testing::GetFixturesPath(), std::string{asset_path}});
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
11
engine/src/flutter/impeller/host/assets_location.h
Normal file
11
engine/src/flutter/impeller/host/assets_location.h
Normal file
@ -0,0 +1,11 @@
|
||||
// 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 <string>
|
||||
|
||||
namespace impeller {
|
||||
|
||||
std::string GetAssetLocation(const char* asset_path);
|
||||
|
||||
} // namespace impeller
|
||||
@ -5,6 +5,7 @@
|
||||
#import <ModelIO/ModelIO.h>
|
||||
#import <simd/simd.h>
|
||||
|
||||
#import "assets_location.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
#import "impeller_renderer.h"
|
||||
#import "shaders_location.h"
|
||||
@ -178,9 +179,11 @@ static const size_t kAlignedUniformsSize = (sizeof(Uniforms) & ~0xFF) + 0x100;
|
||||
MTKTextureLoaderOptionTextureStorageMode : @(MTLStorageModePrivate)
|
||||
};
|
||||
|
||||
_colorMap = [textureLoader newTextureWithName:@"ColorMap"
|
||||
scaleFactor:1.0
|
||||
bundle:nil
|
||||
auto color_map_data = [NSData
|
||||
dataWithContentsOfFile:@(impeller::GetAssetLocation("ColorMap.png")
|
||||
.c_str())];
|
||||
|
||||
_colorMap = [textureLoader newTextureWithData:color_map_data
|
||||
options:textureLoaderOptions
|
||||
error:&error];
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user