Daniel Nicoara | 51a0a56 | 2016-12-08 16:48:20 -0500 | [diff] [blame] | 1 | /* |
| 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 Nicoara | 95a99a1 | 2017-03-21 15:30:45 -0400 | [diff] [blame^] | 17 | #include <android/frameworks/vr/composer/1.0/IVrComposerClient.h> |
Daniel Nicoara | 51a0a56 | 2016-12-08 16:48:20 -0500 | [diff] [blame] | 18 | #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 | |
| 25 | namespace android { |
| 26 | namespace dvr { |
| 27 | |
| 28 | using android::hardware::graphics::common::V1_0::PixelFormat; |
Daniel Nicoara | 95a99a1 | 2017-03-21 15:30:45 -0400 | [diff] [blame^] | 29 | using android::frameworks::vr::composer::V1_0::IVrComposerClient; |
Daniel Nicoara | 51a0a56 | 2016-12-08 16:48:20 -0500 | [diff] [blame] | 30 | |
| 31 | VrComposerClient::VrComposerClient(dvr::VrHwc& hal) |
| 32 | : ComposerClient(hal), mVrHal(hal) {} |
| 33 | |
| 34 | VrComposerClient::~VrComposerClient() {} |
| 35 | |
| 36 | std::unique_ptr<ComposerClient::CommandReader> |
| 37 | VrComposerClient::createCommandReader() { |
| 38 | return std::unique_ptr<CommandReader>(new VrCommandReader(*this)); |
| 39 | } |
| 40 | |
| 41 | VrComposerClient::VrCommandReader::VrCommandReader(VrComposerClient& client) |
| 42 | : CommandReader(client), mVrClient(client), mVrHal(client.mVrHal) {} |
| 43 | |
| 44 | VrComposerClient::VrCommandReader::~VrCommandReader() {} |
| 45 | |
| 46 | bool 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 | |
| 58 | bool 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 |