Flutter Engine
The Flutter Engine
embedder_resources.cc
Go to the documentation of this file.
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/runtime/embedder_resources.h"
6
7#include <cstring>
8
9#include "flutter/fml/logging.h"
10
11namespace flutter {
12
13using runtime::ResourcesEntry;
14
16 : resources_table_(resources_table) {}
17
19
20int EmbedderResources::ResourceLookup(const char* path, const char** resource) {
21 for (int i = 0; resources_table_[i].path_ != nullptr; i++) {
22 const ResourcesEntry& entry = resources_table_[i];
23 if (strcmp(path, entry.path_) == 0) {
24 *resource = entry.resource_;
25 FML_DCHECK(entry.length_ > 0);
26 return entry.length_;
27 }
28 }
29 return kNoSuchInstance;
30}
31
32const char* EmbedderResources::Path(int idx) {
33 FML_DCHECK(idx >= 0);
34 ResourcesEntry* entry = At(idx);
35 if (entry == nullptr) {
36 return nullptr;
37 }
38 FML_DCHECK(entry->path_ != nullptr);
39 return entry->path_;
40}
41
42ResourcesEntry* EmbedderResources::At(int idx) {
43 FML_DCHECK(idx >= 0);
44 for (int i = 0; resources_table_[i].path_ != nullptr; i++) {
45 if (idx == i) {
46 return &resources_table_[i];
47 }
48 }
49 return nullptr;
50}
51
52} // namespace flutter
static SkString resource(SkPDFResourceType type, int index)
const char * Path(int idx)
static const int kNoSuchInstance
int ResourceLookup(const char *path, const char **resource)
EmbedderResources(runtime::ResourcesEntry *resources_table)
#define FML_DCHECK(condition)
Definition: logging.h:103
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57