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 | |
| 20 | #include <string> |
| 21 | #include <vector> |
| 22 | |
| 23 | #include <android/hardware/graphics/composer/2.1/IComposer.h> |
| 24 | #include <utils/StrongPointer.h> |
| 25 | |
| 26 | namespace android { |
| 27 | |
| 28 | namespace Hwc2 { |
| 29 | |
| 30 | using android::hardware::graphics::allocator::V2_0::PixelFormat; |
| 31 | |
| 32 | using android::hardware::graphics::composer::V2_1::IComposer; |
| 33 | using android::hardware::graphics::composer::V2_1::IComposerCallback; |
| 34 | using android::hardware::graphics::composer::V2_1::Error; |
| 35 | using android::hardware::graphics::composer::V2_1::Display; |
| 36 | using android::hardware::graphics::composer::V2_1::Layer; |
| 37 | using android::hardware::graphics::composer::V2_1::Config; |
| 38 | |
| 39 | using android::hardware::graphics::composer::V2_1::ColorMode; |
| 40 | using android::hardware::graphics::composer::V2_1::Hdr; |
| 41 | using android::hardware::graphics::composer::V2_1::Dataspace; |
| 42 | using android::hardware::graphics::composer::V2_1::ColorTransform; |
| 43 | using android::hardware::graphics::composer::V2_1::Transform; |
| 44 | |
| 45 | // Composer is a wrapper to IComposer, a proxy to server-side composer. |
| 46 | class Composer { |
| 47 | public: |
| 48 | Composer(); |
| 49 | |
| 50 | std::vector<IComposer::Capability> getCapabilities() const; |
| 51 | std::string dumpDebugInfo() const; |
| 52 | |
| 53 | void registerCallback(const sp<IComposerCallback>& callback) const; |
| 54 | |
| 55 | uint32_t getMaxVirtualDisplayCount() const; |
| 56 | Error createVirtualDisplay(uint32_t width, uint32_t height, |
| 57 | PixelFormat& format, Display& display) const; |
| 58 | Error destroyVirtualDisplay(Display display) const; |
| 59 | |
| 60 | Error acceptDisplayChanges(Display display) const; |
| 61 | |
| 62 | Error createLayer(Display display, Layer& layer) const; |
| 63 | Error destroyLayer(Display display, Layer layer) const; |
| 64 | |
| 65 | Error getActiveConfig(Display display, Config& config) const; |
| 66 | Error getChangedCompositionTypes(Display display, |
| 67 | std::vector<Layer>& layers, |
| 68 | std::vector<IComposer::Composition>& types) const; |
| 69 | Error getColorModes(Display display, std::vector<ColorMode>& modes) const; |
| 70 | Error getDisplayAttribute(Display display, Config config, |
| 71 | IComposer::Attribute attribute, int32_t& value) const; |
| 72 | Error getDisplayConfigs(Display display, |
| 73 | std::vector<Config>& configs) const; |
| 74 | Error getDisplayName(Display display, std::string& name) const; |
| 75 | |
| 76 | Error getDisplayRequests(Display display, uint32_t& displayRequestMask, |
| 77 | std::vector<Layer>& layers, |
| 78 | std::vector<uint32_t>& layerRequestMasks) const; |
| 79 | |
| 80 | Error getDisplayType(Display display, IComposer::DisplayType& type) const; |
| 81 | Error getDozeSupport(Display display, bool& support) const; |
| 82 | Error getHdrCapabilities(Display display, std::vector<Hdr>& types, |
| 83 | float& maxLuminance, float& maxAverageLuminance, |
| 84 | float& minLuminance) const; |
| 85 | |
| 86 | Error getReleaseFences(Display display, std::vector<Layer>& layers, |
| 87 | std::vector<int>& releaseFences) const; |
| 88 | |
| 89 | Error presentDisplay(Display display, int& presentFence) const; |
| 90 | |
| 91 | Error setActiveConfig(Display display, Config config) const; |
| 92 | Error setClientTarget(Display display, const native_handle_t* target, |
| 93 | int acquireFence, Dataspace dataspace, |
| 94 | const std::vector<IComposer::Rect>& damage) const; |
| 95 | Error setColorMode(Display display, ColorMode mode) const; |
| 96 | Error setColorTransform(Display display, const float* matrix, |
| 97 | ColorTransform hint) const; |
| 98 | Error setOutputBuffer(Display display, const native_handle_t* buffer, |
| 99 | int releaseFence) const; |
| 100 | Error setPowerMode(Display display, IComposer::PowerMode mode) const; |
| 101 | Error setVsyncEnabled(Display display, IComposer::Vsync enabled) const; |
| 102 | |
| 103 | Error validateDisplay(Display display, uint32_t& numTypes, |
| 104 | uint32_t& numRequests) const; |
| 105 | |
| 106 | Error setCursorPosition(Display display, Layer layer, |
| 107 | int32_t x, int32_t y) const; |
| 108 | Error setLayerBuffer(Display display, Layer layer, |
| 109 | const native_handle_t* buffer, int acquireFence) const; |
| 110 | Error setLayerSurfaceDamage(Display display, Layer layer, |
| 111 | const std::vector<IComposer::Rect>& damage) const; |
| 112 | Error setLayerBlendMode(Display display, Layer layer, |
| 113 | IComposer::BlendMode mode) const; |
| 114 | Error setLayerColor(Display display, Layer layer, |
| 115 | const IComposer::Color& color) const; |
| 116 | Error setLayerCompositionType(Display display, Layer layer, |
| 117 | IComposer::Composition type) const; |
| 118 | Error setLayerDataspace(Display display, Layer layer, |
| 119 | Dataspace dataspace) const; |
| 120 | Error setLayerDisplayFrame(Display display, Layer layer, |
| 121 | const IComposer::Rect& frame) const; |
| 122 | Error setLayerPlaneAlpha(Display display, Layer layer, |
| 123 | float alpha) const; |
| 124 | Error setLayerSidebandStream(Display display, Layer layer, |
| 125 | const native_handle_t* stream) const; |
| 126 | Error setLayerSourceCrop(Display display, Layer layer, |
| 127 | const IComposer::FRect& crop) const; |
| 128 | Error setLayerTransform(Display display, Layer layer, |
| 129 | Transform transform) const; |
| 130 | Error setLayerVisibleRegion(Display display, Layer layer, |
| 131 | const std::vector<IComposer::Rect>& visible) const; |
| 132 | Error setLayerZOrder(Display display, Layer layer, uint32_t z) const; |
| 133 | |
| 134 | private: |
| 135 | sp<IComposer> mService; |
| 136 | }; |
| 137 | |
| 138 | } // namespace Hwc2 |
| 139 | |
| 140 | } // namespace android |
| 141 | |
| 142 | #endif // ANDROID_SF_COMPOSER_HAL_H |