| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [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 |  | 
|  | 17 | #ifndef ANDROID_SF_COMPOSER_HAL_H | 
|  | 18 | #define ANDROID_SF_COMPOSER_HAL_H | 
|  | 19 |  | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 20 | #include <memory> | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 21 | #include <string> | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 22 | #include <unordered_map> | 
|  | 23 | #include <utility> | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 24 | #include <vector> | 
|  | 25 |  | 
| Daniel Nicoara | 1f42e3a | 2017-04-10 13:27:32 -0400 | [diff] [blame] | 26 | #include <android/frameworks/vr/composer/1.0/IVrComposerClient.h> | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 27 | #include <android/hardware/graphics/composer/2.1/IComposer.h> | 
|  | 28 | #include <utils/StrongPointer.h> | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 29 | #include <IComposerCommandBuffer.h> | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 30 |  | 
|  | 31 | namespace android { | 
|  | 32 |  | 
|  | 33 | namespace Hwc2 { | 
|  | 34 |  | 
| Daniel Nicoara | 1f42e3a | 2017-04-10 13:27:32 -0400 | [diff] [blame] | 35 | using android::frameworks::vr::composer::V1_0::IVrComposerClient; | 
|  | 36 |  | 
| Chia-I Wu | 5901fda | 2016-11-17 10:26:37 +0800 | [diff] [blame] | 37 | using android::hardware::graphics::common::V1_0::ColorMode; | 
|  | 38 | using android::hardware::graphics::common::V1_0::ColorTransform; | 
|  | 39 | using android::hardware::graphics::common::V1_0::Dataspace; | 
|  | 40 | using android::hardware::graphics::common::V1_0::Hdr; | 
|  | 41 | using android::hardware::graphics::common::V1_0::PixelFormat; | 
|  | 42 | using android::hardware::graphics::common::V1_0::Transform; | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 43 |  | 
|  | 44 | using android::hardware::graphics::composer::V2_1::IComposer; | 
|  | 45 | using android::hardware::graphics::composer::V2_1::IComposerCallback; | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 46 | using android::hardware::graphics::composer::V2_1::IComposerClient; | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 47 | using android::hardware::graphics::composer::V2_1::Error; | 
|  | 48 | using android::hardware::graphics::composer::V2_1::Display; | 
|  | 49 | using android::hardware::graphics::composer::V2_1::Layer; | 
|  | 50 | using android::hardware::graphics::composer::V2_1::Config; | 
|  | 51 |  | 
| Daniel Nicoara | 3c9cbd4 | 2017-01-17 12:04:06 -0500 | [diff] [blame] | 52 | using android::hardware::graphics::composer::V2_1::CommandWriterBase; | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 53 | using android::hardware::graphics::composer::V2_1::CommandReaderBase; | 
|  | 54 |  | 
|  | 55 | using android::hardware::kSynchronizedReadWrite; | 
|  | 56 | using android::hardware::MessageQueue; | 
|  | 57 | using android::hardware::MQDescriptorSync; | 
|  | 58 | using android::hardware::hidl_vec; | 
|  | 59 | using android::hardware::hidl_handle; | 
|  | 60 |  | 
|  | 61 | class CommandReader : public CommandReaderBase { | 
|  | 62 | public: | 
|  | 63 | ~CommandReader(); | 
|  | 64 |  | 
|  | 65 | // Parse and execute commands from the command queue.  The commands are | 
|  | 66 | // actually return values from the server and will be saved in ReturnData. | 
|  | 67 | Error parse(); | 
|  | 68 |  | 
|  | 69 | // Get and clear saved errors. | 
|  | 70 | struct CommandError { | 
|  | 71 | uint32_t location; | 
|  | 72 | Error error; | 
|  | 73 | }; | 
|  | 74 | std::vector<CommandError> takeErrors(); | 
|  | 75 |  | 
| Chia-I Wu | 67e376d | 2016-12-19 11:36:22 +0800 | [diff] [blame] | 76 | bool hasChanges(Display display, uint32_t* outNumChangedCompositionTypes, | 
|  | 77 | uint32_t* outNumLayerRequestMasks) const; | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 78 |  | 
|  | 79 | // Get and clear saved changed composition types. | 
|  | 80 | void takeChangedCompositionTypes(Display display, | 
| Chia-I Wu | 67e376d | 2016-12-19 11:36:22 +0800 | [diff] [blame] | 81 | std::vector<Layer>* outLayers, | 
|  | 82 | std::vector<IComposerClient::Composition>* outTypes); | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 83 |  | 
|  | 84 | // Get and clear saved display requests. | 
|  | 85 | void takeDisplayRequests(Display display, | 
| Chia-I Wu | 67e376d | 2016-12-19 11:36:22 +0800 | [diff] [blame] | 86 | uint32_t* outDisplayRequestMask, std::vector<Layer>* outLayers, | 
|  | 87 | std::vector<uint32_t>* outLayerRequestMasks); | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 88 |  | 
|  | 89 | // Get and clear saved release fences. | 
| Chia-I Wu | 67e376d | 2016-12-19 11:36:22 +0800 | [diff] [blame] | 90 | void takeReleaseFences(Display display, std::vector<Layer>* outLayers, | 
|  | 91 | std::vector<int>* outReleaseFences); | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 92 |  | 
|  | 93 | // Get and clear saved present fence. | 
| Chia-I Wu | 67e376d | 2016-12-19 11:36:22 +0800 | [diff] [blame] | 94 | void takePresentFence(Display display, int* outPresentFence); | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 95 |  | 
| Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 96 | // Get what stage succeeded during PresentOrValidate: Present or Validate | 
|  | 97 | void takePresentOrValidateStage(Display display, uint32_t * state); | 
|  | 98 |  | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 99 | private: | 
|  | 100 | void resetData(); | 
|  | 101 |  | 
|  | 102 | bool parseSelectDisplay(uint16_t length); | 
|  | 103 | bool parseSetError(uint16_t length); | 
|  | 104 | bool parseSetChangedCompositionTypes(uint16_t length); | 
|  | 105 | bool parseSetDisplayRequests(uint16_t length); | 
|  | 106 | bool parseSetPresentFence(uint16_t length); | 
|  | 107 | bool parseSetReleaseFences(uint16_t length); | 
| Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 108 | bool parseSetPresentOrValidateDisplayResult(uint16_t length); | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 109 |  | 
|  | 110 | struct ReturnData { | 
|  | 111 | uint32_t displayRequests = 0; | 
|  | 112 |  | 
|  | 113 | std::vector<Layer> changedLayers; | 
|  | 114 | std::vector<IComposerClient::Composition> compositionTypes; | 
|  | 115 |  | 
|  | 116 | std::vector<Layer> requestedLayers; | 
|  | 117 | std::vector<uint32_t> requestMasks; | 
|  | 118 |  | 
|  | 119 | int presentFence = -1; | 
|  | 120 |  | 
|  | 121 | std::vector<Layer> releasedLayers; | 
|  | 122 | std::vector<int> releaseFences; | 
| Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 123 |  | 
|  | 124 | uint32_t presentOrValidateState; | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 125 | }; | 
|  | 126 |  | 
|  | 127 | std::vector<CommandError> mErrors; | 
|  | 128 | std::unordered_map<Display, ReturnData> mReturnData; | 
|  | 129 |  | 
|  | 130 | // When SELECT_DISPLAY is parsed, this is updated to point to the | 
|  | 131 | // display's return data in mReturnData.  We use it to avoid repeated | 
|  | 132 | // map lookups. | 
|  | 133 | ReturnData* mCurrentReturnData; | 
|  | 134 | }; | 
|  | 135 |  | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 136 | // Composer is a wrapper to IComposer, a proxy to server-side composer. | 
|  | 137 | class Composer { | 
|  | 138 | public: | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 139 | Composer(const std::string& serviceName); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 140 |  | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 141 | std::vector<IComposer::Capability> getCapabilities(); | 
|  | 142 | std::string dumpDebugInfo(); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 143 |  | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 144 | void registerCallback(const sp<IComposerCallback>& callback); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 145 |  | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 146 | // Returns true if the connected composer service is running in a remote | 
|  | 147 | // process, false otherwise. This will return false if the service is | 
|  | 148 | // configured in passthrough mode, for example. | 
|  | 149 | bool isRemote(); | 
|  | 150 |  | 
| Steven Thomas | 0af4b9f | 2017-04-26 14:34:01 -0700 | [diff] [blame] | 151 | // Reset all pending commands in the command buffer. Useful if you want to | 
|  | 152 | // skip a frame but have already queued some commands. | 
|  | 153 | void resetCommands(); | 
|  | 154 |  | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 155 | uint32_t getMaxVirtualDisplayCount(); | 
| Hendrik Wagenaar | 87670ff | 2017-02-01 12:10:46 -0800 | [diff] [blame] | 156 | bool isUsingVrComposer() const { return mIsUsingVrComposer; } | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 157 | Error createVirtualDisplay(uint32_t width, uint32_t height, | 
| Chia-I Wu | 67e376d | 2016-12-19 11:36:22 +0800 | [diff] [blame] | 158 | PixelFormat* format, Display* outDisplay); | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 159 | Error destroyVirtualDisplay(Display display); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 160 |  | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 161 | Error acceptDisplayChanges(Display display); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 162 |  | 
| Chia-I Wu | 67e376d | 2016-12-19 11:36:22 +0800 | [diff] [blame] | 163 | Error createLayer(Display display, Layer* outLayer); | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 164 | Error destroyLayer(Display display, Layer layer); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 165 |  | 
| Chia-I Wu | 67e376d | 2016-12-19 11:36:22 +0800 | [diff] [blame] | 166 | Error getActiveConfig(Display display, Config* outConfig); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 167 | Error getChangedCompositionTypes(Display display, | 
| Chia-I Wu | 67e376d | 2016-12-19 11:36:22 +0800 | [diff] [blame] | 168 | std::vector<Layer>* outLayers, | 
|  | 169 | std::vector<IComposerClient::Composition>* outTypes); | 
|  | 170 | Error getColorModes(Display display, std::vector<ColorMode>* outModes); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 171 | Error getDisplayAttribute(Display display, Config config, | 
| Chia-I Wu | 67e376d | 2016-12-19 11:36:22 +0800 | [diff] [blame] | 172 | IComposerClient::Attribute attribute, int32_t* outValue); | 
|  | 173 | Error getDisplayConfigs(Display display, std::vector<Config>* outConfigs); | 
|  | 174 | Error getDisplayName(Display display, std::string* outName); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 175 |  | 
| Chia-I Wu | 67e376d | 2016-12-19 11:36:22 +0800 | [diff] [blame] | 176 | Error getDisplayRequests(Display display, uint32_t* outDisplayRequestMask, | 
|  | 177 | std::vector<Layer>* outLayers, | 
|  | 178 | std::vector<uint32_t>* outLayerRequestMasks); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 179 |  | 
| Chia-I Wu | 67e376d | 2016-12-19 11:36:22 +0800 | [diff] [blame] | 180 | Error getDisplayType(Display display, | 
|  | 181 | IComposerClient::DisplayType* outType); | 
|  | 182 | Error getDozeSupport(Display display, bool* outSupport); | 
|  | 183 | Error getHdrCapabilities(Display display, std::vector<Hdr>* outTypes, | 
|  | 184 | float* outMaxLuminance, float* outMaxAverageLuminance, | 
|  | 185 | float* outMinLuminance); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 186 |  | 
| Chia-I Wu | 67e376d | 2016-12-19 11:36:22 +0800 | [diff] [blame] | 187 | Error getReleaseFences(Display display, std::vector<Layer>* outLayers, | 
|  | 188 | std::vector<int>* outReleaseFences); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 189 |  | 
| Chia-I Wu | 67e376d | 2016-12-19 11:36:22 +0800 | [diff] [blame] | 190 | Error presentDisplay(Display display, int* outPresentFence); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 191 |  | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 192 | Error setActiveConfig(Display display, Config config); | 
| Chia-I Wu | 06d63de | 2017-01-04 14:58:51 +0800 | [diff] [blame] | 193 |  | 
|  | 194 | /* | 
|  | 195 | * The composer caches client targets internally.  When target is nullptr, | 
|  | 196 | * the composer uses slot to look up the client target from its cache. | 
|  | 197 | * When target is not nullptr, the cache is updated with the new target. | 
|  | 198 | */ | 
|  | 199 | Error setClientTarget(Display display, uint32_t slot, | 
| Daniel Nicoara | 1f42e3a | 2017-04-10 13:27:32 -0400 | [diff] [blame] | 200 | const sp<GraphicBuffer>& target, | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 201 | int acquireFence, Dataspace dataspace, | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 202 | const std::vector<IComposerClient::Rect>& damage); | 
|  | 203 | Error setColorMode(Display display, ColorMode mode); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 204 | Error setColorTransform(Display display, const float* matrix, | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 205 | ColorTransform hint); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 206 | Error setOutputBuffer(Display display, const native_handle_t* buffer, | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 207 | int releaseFence); | 
|  | 208 | Error setPowerMode(Display display, IComposerClient::PowerMode mode); | 
|  | 209 | Error setVsyncEnabled(Display display, IComposerClient::Vsync enabled); | 
|  | 210 |  | 
|  | 211 | Error setClientTargetSlotCount(Display display); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 212 |  | 
| Chia-I Wu | 67e376d | 2016-12-19 11:36:22 +0800 | [diff] [blame] | 213 | Error validateDisplay(Display display, uint32_t* outNumTypes, | 
|  | 214 | uint32_t* outNumRequests); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 215 |  | 
| Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 216 | Error presentOrValidateDisplay(Display display, uint32_t* outNumTypes, | 
|  | 217 | uint32_t* outNumRequests, | 
|  | 218 | int* outPresentFence, | 
|  | 219 | uint32_t* state); | 
|  | 220 |  | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 221 | Error setCursorPosition(Display display, Layer layer, | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 222 | int32_t x, int32_t y); | 
| Chia-I Wu | 06d63de | 2017-01-04 14:58:51 +0800 | [diff] [blame] | 223 | /* see setClientTarget for the purpose of slot */ | 
|  | 224 | Error setLayerBuffer(Display display, Layer layer, uint32_t slot, | 
| Daniel Nicoara | 1f42e3a | 2017-04-10 13:27:32 -0400 | [diff] [blame] | 225 | const sp<GraphicBuffer>& buffer, int acquireFence); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 226 | Error setLayerSurfaceDamage(Display display, Layer layer, | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 227 | const std::vector<IComposerClient::Rect>& damage); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 228 | Error setLayerBlendMode(Display display, Layer layer, | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 229 | IComposerClient::BlendMode mode); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 230 | Error setLayerColor(Display display, Layer layer, | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 231 | const IComposerClient::Color& color); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 232 | Error setLayerCompositionType(Display display, Layer layer, | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 233 | IComposerClient::Composition type); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 234 | Error setLayerDataspace(Display display, Layer layer, | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 235 | Dataspace dataspace); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 236 | Error setLayerDisplayFrame(Display display, Layer layer, | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 237 | const IComposerClient::Rect& frame); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 238 | Error setLayerPlaneAlpha(Display display, Layer layer, | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 239 | float alpha); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 240 | Error setLayerSidebandStream(Display display, Layer layer, | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 241 | const native_handle_t* stream); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 242 | Error setLayerSourceCrop(Display display, Layer layer, | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 243 | const IComposerClient::FRect& crop); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 244 | Error setLayerTransform(Display display, Layer layer, | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 245 | Transform transform); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 246 | Error setLayerVisibleRegion(Display display, Layer layer, | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 247 | const std::vector<IComposerClient::Rect>& visible); | 
|  | 248 | Error setLayerZOrder(Display display, Layer layer, uint32_t z); | 
| Daniel Nicoara | 2f5f8a5 | 2016-12-20 16:11:58 -0500 | [diff] [blame] | 249 | Error setLayerInfo(Display display, Layer layer, uint32_t type, | 
|  | 250 | uint32_t appId); | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 251 | private: | 
| Daniel Nicoara | 2f5f8a5 | 2016-12-20 16:11:58 -0500 | [diff] [blame] | 252 | class CommandWriter : public CommandWriterBase { | 
|  | 253 | public: | 
|  | 254 | CommandWriter(uint32_t initialMaxSize); | 
|  | 255 | ~CommandWriter() override; | 
|  | 256 |  | 
|  | 257 | void setLayerInfo(uint32_t type, uint32_t appId); | 
| Daniel Nicoara | 1f42e3a | 2017-04-10 13:27:32 -0400 | [diff] [blame] | 258 | void setClientTargetMetadata( | 
|  | 259 | const IVrComposerClient::BufferMetadata& metadata); | 
|  | 260 | void setLayerBufferMetadata( | 
|  | 261 | const IVrComposerClient::BufferMetadata& metadata); | 
|  | 262 |  | 
|  | 263 | private: | 
|  | 264 | void writeBufferMetadata( | 
|  | 265 | const IVrComposerClient::BufferMetadata& metadata); | 
| Daniel Nicoara | 2f5f8a5 | 2016-12-20 16:11:58 -0500 | [diff] [blame] | 266 | }; | 
|  | 267 |  | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 268 | // Many public functions above simply write a command into the command | 
|  | 269 | // queue to batch the calls.  validateDisplay and presentDisplay will call | 
|  | 270 | // this function to execute the command queue. | 
|  | 271 | Error execute(); | 
|  | 272 |  | 
|  | 273 | sp<IComposer> mComposer; | 
|  | 274 | sp<IComposerClient> mClient; | 
|  | 275 |  | 
|  | 276 | // 64KiB minus a small space for metadata such as read/write pointers | 
|  | 277 | static constexpr size_t kWriterInitialSize = | 
|  | 278 | 64 * 1024 / sizeof(uint32_t) - 16; | 
| Daniel Nicoara | 2f5f8a5 | 2016-12-20 16:11:58 -0500 | [diff] [blame] | 279 | CommandWriter mWriter; | 
| Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 280 | CommandReader mReader; | 
| Daniel Nicoara | 2f5f8a5 | 2016-12-20 16:11:58 -0500 | [diff] [blame] | 281 |  | 
| Hendrik Wagenaar | 87670ff | 2017-02-01 12:10:46 -0800 | [diff] [blame] | 282 | // When true, the we attach to the vr_hwcomposer service instead of the | 
|  | 283 | // hwcomposer. This allows us to redirect surfaces to 3d surfaces in vr. | 
|  | 284 | const bool mIsUsingVrComposer; | 
| Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 285 | }; | 
|  | 286 |  | 
|  | 287 | } // namespace Hwc2 | 
|  | 288 |  | 
|  | 289 | } // namespace android | 
|  | 290 |  | 
|  | 291 | #endif // ANDROID_SF_COMPOSER_HAL_H |