blob: acf0dac73476484e4e1bd26624d64062b803e8f4 [file] [log] [blame]
Daniel Nicoara51a0a562016-12-08 16:48:20 -05001/*
2 * Copyright 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Daniel Nicoara95a99a12017-03-21 15:30:45 -040017#include <android/frameworks/vr/composer/1.0/IVrComposerClient.h>
Daniel Nicoara51a0a562016-12-08 16:48:20 -050018#include <hardware/gralloc.h>
19#include <hardware/gralloc1.h>
20#include <log/log.h>
21
22#include "vr_hwc.h"
23#include "vr_composer_client.h"
24
25namespace android {
26namespace dvr {
27
28using android::hardware::graphics::common::V1_0::PixelFormat;
Daniel Nicoara95a99a12017-03-21 15:30:45 -040029using android::frameworks::vr::composer::V1_0::IVrComposerClient;
Daniel Nicoara51a0a562016-12-08 16:48:20 -050030
31VrComposerClient::VrComposerClient(dvr::VrHwc& hal)
32 : ComposerClient(hal), mVrHal(hal) {}
33
34VrComposerClient::~VrComposerClient() {}
35
36std::unique_ptr<ComposerClient::CommandReader>
37VrComposerClient::createCommandReader() {
38 return std::unique_ptr<CommandReader>(new VrCommandReader(*this));
39}
40
41VrComposerClient::VrCommandReader::VrCommandReader(VrComposerClient& client)
42 : CommandReader(client), mVrClient(client), mVrHal(client.mVrHal) {}
43
44VrComposerClient::VrCommandReader::~VrCommandReader() {}
45
46bool VrComposerClient::VrCommandReader::parseCommand(
47 IComposerClient::Command command, uint16_t length) {
48 IVrComposerClient::VrCommand vrCommand =
49 static_cast<IVrComposerClient::VrCommand>(command);
50 switch (vrCommand) {
51 case IVrComposerClient::VrCommand::SET_LAYER_INFO:
52 return parseSetLayerInfo(length);
53 default:
54 return CommandReader::parseCommand(command, length);
55 }
56}
57
58bool VrComposerClient::VrCommandReader::parseSetLayerInfo(uint16_t length) {
59 if (length != 2) {
60 return false;
61 }
62
63 auto err = mVrHal.setLayerInfo(mDisplay, mLayer, read(), read());
64 if (err != Error::NONE) {
65 mWriter.setError(getCommandLoc(), err);
66 }
67
68 return true;
69}
70
71} // namespace dvr
72} // namespace android