• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2019 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "ConfigBuilder.h"
16 
17 namespace android {
18 namespace automotive {
19 namespace computepipe {
20 namespace runner {
21 namespace engine {
22 
setDebugDisplayStream(int id)23 void ConfigBuilder::setDebugDisplayStream(int id) {
24     mDisplayStream = id;
25     mOutputConfig.emplace(id, 1);
26 }
27 
clientConfigEnablesDisplayStream()28 bool ConfigBuilder::clientConfigEnablesDisplayStream() {
29     return mConfigHasDisplayStream;
30 }
31 
updateInputConfigOption(int id)32 ConfigBuilder& ConfigBuilder::updateInputConfigOption(int id) {
33     mInputConfigId = id;
34     return *this;
35 }
36 
updateOutputStreamOption(int id,int maxInFlightPackets)37 ConfigBuilder& ConfigBuilder::updateOutputStreamOption(int id, int maxInFlightPackets) {
38     if (id == mDisplayStream) {
39         mConfigHasDisplayStream = true;
40     }
41     mOutputConfig.emplace(id, maxInFlightPackets);
42     return *this;
43 }
44 
updateTerminationOption(int id)45 ConfigBuilder& ConfigBuilder::updateTerminationOption(int id) {
46     mTerminationId = id;
47     return *this;
48 }
49 
updateOffloadOption(int id)50 ConfigBuilder& ConfigBuilder::updateOffloadOption(int id) {
51     mOffloadId = id;
52     return *this;
53 }
54 
updateOptionalConfig(std::string options)55 ConfigBuilder& ConfigBuilder::updateOptionalConfig(std::string options) {
56     mOptionalConfig = options;
57     return *this;
58 }
59 
updateProfilingType(proto::ProfilingType profilingType)60 ConfigBuilder& ConfigBuilder::updateProfilingType(proto::ProfilingType profilingType) {
61     mProfilingType = profilingType;
62     return *this;
63 }
64 
emitClientOptions()65 ClientConfig ConfigBuilder::emitClientOptions() {
66     return ClientConfig(mInputConfigId, mOffloadId, mTerminationId, mOutputConfig, mProfilingType,
67             mOptionalConfig);
68 }
69 
reset()70 ConfigBuilder& ConfigBuilder::reset() {
71     mInputConfigId = ClientConfig::kInvalidId;
72     mTerminationId = ClientConfig::kInvalidId;
73     mOffloadId = ClientConfig::kInvalidId;
74     mOutputConfig.clear();
75     mProfilingType = proto::ProfilingType::DISABLED;
76     if (mDisplayStream != ClientConfig::kInvalidId) {
77         mOutputConfig.emplace(mDisplayStream, 1);
78     }
79     mConfigHasDisplayStream = false;
80     return *this;
81 }
82 
83 }  // namespace engine
84 }  // namespace runner
85 }  // namespace computepipe
86 }  // namespace automotive
87 }  // namespace android
88