mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
Introduce ComposerBase interface to allow custom Hwc implementations
Decouples the ComposerClient code which deals with parsing the command buffer messages sent by SurfaceFlinger from the Hwc code that handles the commands. Bug: 33297270 Test: Compiled and verified on device that hwcomposer-2-1 service can start correctly. SurfaceFlinger can connect to the service and the system boots up. Also verified SurfaceFlinger runs correctly without hwcomposer-2-1. Change-Id: I43357306caea57d262735f4756c379ba9d0138cd
This commit is contained in:
@@ -1,7 +1,28 @@
|
||||
cc_library_static {
|
||||
name: "libhwcomposer-client",
|
||||
export_include_dirs: ["."],
|
||||
srcs: ["ComposerClient.cpp"],
|
||||
cppflags: ["-DBINDERIZED"],
|
||||
shared_libs: [
|
||||
"android.hardware.graphics.allocator@2.0",
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"libfmq",
|
||||
"libhardware",
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libhwbinder",
|
||||
"liblog",
|
||||
"libsync",
|
||||
"libutils",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library_shared {
|
||||
name: "android.hardware.graphics.composer@2.1-impl",
|
||||
relative_install_path: "hw",
|
||||
srcs: ["Hwc.cpp", "HwcClient.cpp"],
|
||||
srcs: ["Hwc.cpp", "ComposerClient.cpp"],
|
||||
shared_libs: [
|
||||
"android.hardware.graphics.allocator@2.0",
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
@@ -21,10 +42,13 @@ cc_library_shared {
|
||||
cc_binary {
|
||||
name: "android.hardware.graphics.composer@2.1-service",
|
||||
relative_install_path: "hw",
|
||||
srcs: ["service.cpp", "Hwc.cpp", "HwcClient.cpp"],
|
||||
srcs: ["service.cpp", "Hwc.cpp"],
|
||||
cppflags: ["-DBINDERIZED"],
|
||||
init_rc: ["android.hardware.graphics.composer@2.1-service.rc"],
|
||||
|
||||
static_libs: [
|
||||
"libhwcomposer-client",
|
||||
],
|
||||
shared_libs: [
|
||||
"android.hardware.graphics.allocator@2.0",
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
|
||||
130
graphics/composer/2.1/default/ComposerBase.h
Normal file
130
graphics/composer/2.1/default/ComposerBase.h
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_GRAPHICS_COMPOSER_V2_1_COMPOSER_BASE_H
|
||||
#define ANDROID_HARDWARE_GRAPHICS_COMPOSER_V2_1_COMPOSER_BASE_H
|
||||
|
||||
#include <android/hardware/graphics/composer/2.1/IComposer.h>
|
||||
#include <hardware/hwcomposer2.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace graphics {
|
||||
namespace composer {
|
||||
namespace V2_1 {
|
||||
namespace implementation {
|
||||
|
||||
using android::hardware::graphics::common::V1_0::PixelFormat;
|
||||
using android::hardware::graphics::common::V1_0::Transform;
|
||||
using android::hardware::graphics::common::V1_0::Dataspace;
|
||||
using android::hardware::graphics::common::V1_0::ColorMode;
|
||||
using android::hardware::graphics::common::V1_0::ColorTransform;
|
||||
using android::hardware::graphics::common::V1_0::Hdr;
|
||||
|
||||
class ComposerBase {
|
||||
public:
|
||||
virtual ~ComposerBase() {};
|
||||
|
||||
virtual void removeClient() = 0;
|
||||
virtual void enableCallback(bool enable) = 0;
|
||||
virtual uint32_t getMaxVirtualDisplayCount() = 0;
|
||||
virtual Error createVirtualDisplay(uint32_t width, uint32_t height,
|
||||
PixelFormat* format, Display* outDisplay) = 0;
|
||||
virtual Error destroyVirtualDisplay(Display display) = 0;
|
||||
virtual Error createLayer(Display display, Layer* outLayer) = 0;
|
||||
virtual Error destroyLayer(Display display, Layer layer) = 0;
|
||||
|
||||
virtual Error getActiveConfig(Display display, Config* outConfig) = 0;
|
||||
virtual Error getClientTargetSupport(Display display,
|
||||
uint32_t width, uint32_t height,
|
||||
PixelFormat format, Dataspace dataspace) = 0;
|
||||
virtual Error getColorModes(Display display,
|
||||
hidl_vec<ColorMode>* outModes) = 0;
|
||||
virtual Error getDisplayAttribute(Display display, Config config,
|
||||
IComposerClient::Attribute attribute, int32_t* outValue) = 0;
|
||||
virtual Error getDisplayConfigs(Display display,
|
||||
hidl_vec<Config>* outConfigs) = 0;
|
||||
virtual Error getDisplayName(Display display, hidl_string* outName) = 0;
|
||||
virtual Error getDisplayType(Display display,
|
||||
IComposerClient::DisplayType* outType) = 0;
|
||||
virtual Error getDozeSupport(Display display, bool* outSupport) = 0;
|
||||
virtual Error getHdrCapabilities(Display display, hidl_vec<Hdr>* outTypes,
|
||||
float* outMaxLuminance, float* outMaxAverageLuminance,
|
||||
float* outMinLuminance) = 0;
|
||||
|
||||
virtual Error setActiveConfig(Display display, Config config) = 0;
|
||||
virtual Error setColorMode(Display display, ColorMode mode) = 0;
|
||||
virtual Error setPowerMode(Display display,
|
||||
IComposerClient::PowerMode mode) = 0;
|
||||
virtual Error setVsyncEnabled(Display display,
|
||||
IComposerClient::Vsync enabled) = 0;
|
||||
|
||||
virtual Error setColorTransform(Display display, const float* matrix,
|
||||
int32_t hint) = 0;
|
||||
virtual Error setClientTarget(Display display, buffer_handle_t target,
|
||||
int32_t acquireFence, int32_t dataspace,
|
||||
const std::vector<hwc_rect_t>& damage) = 0;
|
||||
virtual Error setOutputBuffer(Display display, buffer_handle_t buffer,
|
||||
int32_t releaseFence) = 0;
|
||||
virtual Error validateDisplay(Display display,
|
||||
std::vector<Layer>* outChangedLayers,
|
||||
std::vector<IComposerClient::Composition>* outCompositionTypes,
|
||||
uint32_t* outDisplayRequestMask,
|
||||
std::vector<Layer>* outRequestedLayers,
|
||||
std::vector<uint32_t>* outRequestMasks) = 0;
|
||||
virtual Error acceptDisplayChanges(Display display) = 0;
|
||||
virtual Error presentDisplay(Display display, int32_t* outPresentFence,
|
||||
std::vector<Layer>* outLayers,
|
||||
std::vector<int32_t>* outReleaseFences) = 0;
|
||||
|
||||
virtual Error setLayerCursorPosition(Display display, Layer layer,
|
||||
int32_t x, int32_t y) = 0;
|
||||
virtual Error setLayerBuffer(Display display, Layer layer,
|
||||
buffer_handle_t buffer, int32_t acquireFence) = 0;
|
||||
virtual Error setLayerSurfaceDamage(Display display, Layer layer,
|
||||
const std::vector<hwc_rect_t>& damage) = 0;
|
||||
virtual Error setLayerBlendMode(Display display, Layer layer,
|
||||
int32_t mode) = 0;
|
||||
virtual Error setLayerColor(Display display, Layer layer,
|
||||
IComposerClient::Color color) = 0;
|
||||
virtual Error setLayerCompositionType(Display display, Layer layer,
|
||||
int32_t type) = 0;
|
||||
virtual Error setLayerDataspace(Display display, Layer layer,
|
||||
int32_t dataspace) = 0;
|
||||
virtual Error setLayerDisplayFrame(Display display, Layer layer,
|
||||
const hwc_rect_t& frame) = 0;
|
||||
virtual Error setLayerPlaneAlpha(Display display, Layer layer,
|
||||
float alpha) = 0;
|
||||
virtual Error setLayerSidebandStream(Display display, Layer layer,
|
||||
buffer_handle_t stream) = 0;
|
||||
virtual Error setLayerSourceCrop(Display display, Layer layer,
|
||||
const hwc_frect_t& crop) = 0;
|
||||
virtual Error setLayerTransform(Display display, Layer layer,
|
||||
int32_t transform) = 0;
|
||||
virtual Error setLayerVisibleRegion(Display display, Layer layer,
|
||||
const std::vector<hwc_rect_t>& visible) = 0;
|
||||
virtual Error setLayerZOrder(Display display, Layer layer,
|
||||
uint32_t z) = 0;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_1
|
||||
} // namespace composer
|
||||
} // namespace graphics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_GRAPHICS_COMPOSER_V2_1_COMPOSER_BASE_H
|
||||
@@ -20,8 +20,8 @@
|
||||
#include <hardware/gralloc1.h>
|
||||
#include <log/log.h>
|
||||
|
||||
#include "ComposerClient.h"
|
||||
#include "Hwc.h"
|
||||
#include "HwcClient.h"
|
||||
#include "IComposerCommandBuffer.h"
|
||||
|
||||
namespace android {
|
||||
@@ -230,15 +230,12 @@ void BufferClone::clear()
|
||||
}
|
||||
}
|
||||
|
||||
HwcClient::HwcClient(HwcHal& hal)
|
||||
: mHal(hal), mReader(*this), mWriter(kWriterInitialSize)
|
||||
ComposerClient::ComposerClient(ComposerBase& hal)
|
||||
: mHal(hal), mWriter(kWriterInitialSize)
|
||||
{
|
||||
if (!sHandleImporter.initialize()) {
|
||||
LOG_ALWAYS_FATAL("failed to initialize handle importer");
|
||||
}
|
||||
}
|
||||
|
||||
HwcClient::~HwcClient()
|
||||
ComposerClient::~ComposerClient()
|
||||
{
|
||||
mHal.enableCallback(false);
|
||||
mHal.removeClient();
|
||||
@@ -264,7 +261,15 @@ HwcClient::~HwcClient()
|
||||
sHandleImporter.cleanup();
|
||||
}
|
||||
|
||||
void HwcClient::onHotplug(Display display,
|
||||
void ComposerClient::initialize()
|
||||
{
|
||||
mReader = createCommandReader();
|
||||
if (!sHandleImporter.initialize()) {
|
||||
LOG_ALWAYS_FATAL("failed to initialize handle importer");
|
||||
}
|
||||
}
|
||||
|
||||
void ComposerClient::onHotplug(Display display,
|
||||
IComposerCallback::Connection connected)
|
||||
{
|
||||
{
|
||||
@@ -280,17 +285,18 @@ void HwcClient::onHotplug(Display display,
|
||||
mCallback->onHotplug(display, connected);
|
||||
}
|
||||
|
||||
void HwcClient::onRefresh(Display display)
|
||||
void ComposerClient::onRefresh(Display display)
|
||||
{
|
||||
mCallback->onRefresh(display);
|
||||
}
|
||||
|
||||
void HwcClient::onVsync(Display display, int64_t timestamp)
|
||||
void ComposerClient::onVsync(Display display, int64_t timestamp)
|
||||
{
|
||||
mCallback->onVsync(display, timestamp);
|
||||
}
|
||||
|
||||
Return<void> HwcClient::registerCallback(const sp<IComposerCallback>& callback)
|
||||
Return<void> ComposerClient::registerCallback(
|
||||
const sp<IComposerCallback>& callback)
|
||||
{
|
||||
// no locking as we require this function to be called only once
|
||||
mCallback = callback;
|
||||
@@ -299,13 +305,13 @@ Return<void> HwcClient::registerCallback(const sp<IComposerCallback>& callback)
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<uint32_t> HwcClient::getMaxVirtualDisplayCount()
|
||||
Return<uint32_t> ComposerClient::getMaxVirtualDisplayCount()
|
||||
{
|
||||
return mHal.getMaxVirtualDisplayCount();
|
||||
}
|
||||
|
||||
Return<void> HwcClient::createVirtualDisplay(uint32_t width, uint32_t height,
|
||||
PixelFormat formatHint, uint32_t outputBufferSlotCount,
|
||||
Return<void> ComposerClient::createVirtualDisplay(uint32_t width,
|
||||
uint32_t height, PixelFormat formatHint, uint32_t outputBufferSlotCount,
|
||||
createVirtualDisplay_cb hidl_cb)
|
||||
{
|
||||
Display display = 0;
|
||||
@@ -322,7 +328,7 @@ Return<void> HwcClient::createVirtualDisplay(uint32_t width, uint32_t height,
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<Error> HwcClient::destroyVirtualDisplay(Display display)
|
||||
Return<Error> ComposerClient::destroyVirtualDisplay(Display display)
|
||||
{
|
||||
Error err = mHal.destroyVirtualDisplay(display);
|
||||
if (err == Error::NONE) {
|
||||
@@ -334,8 +340,8 @@ Return<Error> HwcClient::destroyVirtualDisplay(Display display)
|
||||
return err;
|
||||
}
|
||||
|
||||
Return<void> HwcClient::createLayer(Display display, uint32_t bufferSlotCount,
|
||||
createLayer_cb hidl_cb)
|
||||
Return<void> ComposerClient::createLayer(Display display,
|
||||
uint32_t bufferSlotCount, createLayer_cb hidl_cb)
|
||||
{
|
||||
Layer layer = 0;
|
||||
Error err = mHal.createLayer(display, &layer);
|
||||
@@ -351,7 +357,7 @@ Return<void> HwcClient::createLayer(Display display, uint32_t bufferSlotCount,
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<Error> HwcClient::destroyLayer(Display display, Layer layer)
|
||||
Return<Error> ComposerClient::destroyLayer(Display display, Layer layer)
|
||||
{
|
||||
Error err = mHal.destroyLayer(display, layer);
|
||||
if (err == Error::NONE) {
|
||||
@@ -364,7 +370,7 @@ Return<Error> HwcClient::destroyLayer(Display display, Layer layer)
|
||||
return err;
|
||||
}
|
||||
|
||||
Return<void> HwcClient::getActiveConfig(Display display,
|
||||
Return<void> ComposerClient::getActiveConfig(Display display,
|
||||
getActiveConfig_cb hidl_cb)
|
||||
{
|
||||
Config config = 0;
|
||||
@@ -374,7 +380,7 @@ Return<void> HwcClient::getActiveConfig(Display display,
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<Error> HwcClient::getClientTargetSupport(Display display,
|
||||
Return<Error> ComposerClient::getClientTargetSupport(Display display,
|
||||
uint32_t width, uint32_t height,
|
||||
PixelFormat format, Dataspace dataspace)
|
||||
{
|
||||
@@ -383,7 +389,8 @@ Return<Error> HwcClient::getClientTargetSupport(Display display,
|
||||
return err;
|
||||
}
|
||||
|
||||
Return<void> HwcClient::getColorModes(Display display, getColorModes_cb hidl_cb)
|
||||
Return<void> ComposerClient::getColorModes(Display display,
|
||||
getColorModes_cb hidl_cb)
|
||||
{
|
||||
hidl_vec<ColorMode> modes;
|
||||
Error err = mHal.getColorModes(display, &modes);
|
||||
@@ -392,7 +399,7 @@ Return<void> HwcClient::getColorModes(Display display, getColorModes_cb hidl_cb)
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> HwcClient::getDisplayAttribute(Display display,
|
||||
Return<void> ComposerClient::getDisplayAttribute(Display display,
|
||||
Config config, Attribute attribute,
|
||||
getDisplayAttribute_cb hidl_cb)
|
||||
{
|
||||
@@ -403,7 +410,7 @@ Return<void> HwcClient::getDisplayAttribute(Display display,
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> HwcClient::getDisplayConfigs(Display display,
|
||||
Return<void> ComposerClient::getDisplayConfigs(Display display,
|
||||
getDisplayConfigs_cb hidl_cb)
|
||||
{
|
||||
hidl_vec<Config> configs;
|
||||
@@ -413,7 +420,7 @@ Return<void> HwcClient::getDisplayConfigs(Display display,
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> HwcClient::getDisplayName(Display display,
|
||||
Return<void> ComposerClient::getDisplayName(Display display,
|
||||
getDisplayName_cb hidl_cb)
|
||||
{
|
||||
hidl_string name;
|
||||
@@ -423,7 +430,7 @@ Return<void> HwcClient::getDisplayName(Display display,
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> HwcClient::getDisplayType(Display display,
|
||||
Return<void> ComposerClient::getDisplayType(Display display,
|
||||
getDisplayType_cb hidl_cb)
|
||||
{
|
||||
DisplayType type = DisplayType::INVALID;
|
||||
@@ -433,7 +440,7 @@ Return<void> HwcClient::getDisplayType(Display display,
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> HwcClient::getDozeSupport(Display display,
|
||||
Return<void> ComposerClient::getDozeSupport(Display display,
|
||||
getDozeSupport_cb hidl_cb)
|
||||
{
|
||||
bool support = false;
|
||||
@@ -443,7 +450,7 @@ Return<void> HwcClient::getDozeSupport(Display display,
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> HwcClient::getHdrCapabilities(Display display,
|
||||
Return<void> ComposerClient::getHdrCapabilities(Display display,
|
||||
getHdrCapabilities_cb hidl_cb)
|
||||
{
|
||||
hidl_vec<Hdr> types;
|
||||
@@ -457,7 +464,7 @@ Return<void> HwcClient::getHdrCapabilities(Display display,
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<Error> HwcClient::setClientTargetSlotCount(Display display,
|
||||
Return<Error> ComposerClient::setClientTargetSlotCount(Display display,
|
||||
uint32_t clientTargetSlotCount)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mDisplayDataMutex);
|
||||
@@ -472,39 +479,39 @@ Return<Error> HwcClient::setClientTargetSlotCount(Display display,
|
||||
return Error::NONE;
|
||||
}
|
||||
|
||||
Return<Error> HwcClient::setActiveConfig(Display display, Config config)
|
||||
Return<Error> ComposerClient::setActiveConfig(Display display, Config config)
|
||||
{
|
||||
Error err = mHal.setActiveConfig(display, config);
|
||||
return err;
|
||||
}
|
||||
|
||||
Return<Error> HwcClient::setColorMode(Display display, ColorMode mode)
|
||||
Return<Error> ComposerClient::setColorMode(Display display, ColorMode mode)
|
||||
{
|
||||
Error err = mHal.setColorMode(display, mode);
|
||||
return err;
|
||||
}
|
||||
|
||||
Return<Error> HwcClient::setPowerMode(Display display, PowerMode mode)
|
||||
Return<Error> ComposerClient::setPowerMode(Display display, PowerMode mode)
|
||||
{
|
||||
Error err = mHal.setPowerMode(display, mode);
|
||||
return err;
|
||||
}
|
||||
|
||||
Return<Error> HwcClient::setVsyncEnabled(Display display, Vsync enabled)
|
||||
Return<Error> ComposerClient::setVsyncEnabled(Display display, Vsync enabled)
|
||||
{
|
||||
Error err = mHal.setVsyncEnabled(display, enabled);
|
||||
return err;
|
||||
}
|
||||
|
||||
Return<Error> HwcClient::setInputCommandQueue(
|
||||
Return<Error> ComposerClient::setInputCommandQueue(
|
||||
const MQDescriptorSync<uint32_t>& descriptor)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mCommandMutex);
|
||||
return mReader.setMQDescriptor(descriptor) ?
|
||||
return mReader->setMQDescriptor(descriptor) ?
|
||||
Error::NONE : Error::NO_RESOURCES;
|
||||
}
|
||||
|
||||
Return<void> HwcClient::getOutputCommandQueue(
|
||||
Return<void> ComposerClient::getOutputCommandQueue(
|
||||
getOutputCommandQueue_cb hidl_cb)
|
||||
{
|
||||
// no locking as we require this function to be called inside
|
||||
@@ -520,7 +527,7 @@ Return<void> HwcClient::getOutputCommandQueue(
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> HwcClient::executeCommands(uint32_t inLength,
|
||||
Return<void> ComposerClient::executeCommands(uint32_t inLength,
|
||||
const hidl_vec<hidl_handle>& inHandles,
|
||||
executeCommands_cb hidl_cb)
|
||||
{
|
||||
@@ -530,12 +537,12 @@ Return<void> HwcClient::executeCommands(uint32_t inLength,
|
||||
uint32_t outLength = 0;
|
||||
hidl_vec<hidl_handle> outHandles;
|
||||
|
||||
if (!mReader.readQueue(inLength, inHandles)) {
|
||||
if (!mReader->readQueue(inLength, inHandles)) {
|
||||
hidl_cb(Error::BAD_PARAMETER, outChanged, outLength, outHandles);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Error err = mReader.parse();
|
||||
Error err = mReader->parse();
|
||||
if (err == Error::NONE &&
|
||||
!mWriter.writeQueue(&outChanged, &outLength, &outHandles)) {
|
||||
err = Error::NO_RESOURCES;
|
||||
@@ -543,18 +550,29 @@ Return<void> HwcClient::executeCommands(uint32_t inLength,
|
||||
|
||||
hidl_cb(err, outChanged, outLength, outHandles);
|
||||
|
||||
mReader.reset();
|
||||
mReader->reset();
|
||||
mWriter.reset();
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
HwcClient::CommandReader::CommandReader(HwcClient& client)
|
||||
std::unique_ptr<ComposerClient::CommandReader>
|
||||
ComposerClient::createCommandReader()
|
||||
{
|
||||
return std::unique_ptr<ComposerClient::CommandReader>(
|
||||
new CommandReader(*this));
|
||||
}
|
||||
|
||||
ComposerClient::CommandReader::CommandReader(ComposerClient& client)
|
||||
: mClient(client), mHal(client.mHal), mWriter(client.mWriter)
|
||||
{
|
||||
}
|
||||
|
||||
Error HwcClient::CommandReader::parse()
|
||||
ComposerClient::CommandReader::~CommandReader()
|
||||
{
|
||||
}
|
||||
|
||||
Error ComposerClient::CommandReader::parse()
|
||||
{
|
||||
IComposerClient::Command command;
|
||||
uint16_t length = 0;
|
||||
@@ -564,79 +582,7 @@ Error HwcClient::CommandReader::parse()
|
||||
break;
|
||||
}
|
||||
|
||||
bool parsed = false;
|
||||
switch (command) {
|
||||
case IComposerClient::Command::SELECT_DISPLAY:
|
||||
parsed = parseSelectDisplay(length);
|
||||
break;
|
||||
case IComposerClient::Command::SELECT_LAYER:
|
||||
parsed = parseSelectLayer(length);
|
||||
break;
|
||||
case IComposerClient::Command::SET_COLOR_TRANSFORM:
|
||||
parsed = parseSetColorTransform(length);
|
||||
break;
|
||||
case IComposerClient::Command::SET_CLIENT_TARGET:
|
||||
parsed = parseSetClientTarget(length);
|
||||
break;
|
||||
case IComposerClient::Command::SET_OUTPUT_BUFFER:
|
||||
parsed = parseSetOutputBuffer(length);
|
||||
break;
|
||||
case IComposerClient::Command::VALIDATE_DISPLAY:
|
||||
parsed = parseValidateDisplay(length);
|
||||
break;
|
||||
case IComposerClient::Command::ACCEPT_DISPLAY_CHANGES:
|
||||
parsed = parseAcceptDisplayChanges(length);
|
||||
break;
|
||||
case IComposerClient::Command::PRESENT_DISPLAY:
|
||||
parsed = parsePresentDisplay(length);
|
||||
break;
|
||||
case IComposerClient::Command::SET_LAYER_CURSOR_POSITION:
|
||||
parsed = parseSetLayerCursorPosition(length);
|
||||
break;
|
||||
case IComposerClient::Command::SET_LAYER_BUFFER:
|
||||
parsed = parseSetLayerBuffer(length);
|
||||
break;
|
||||
case IComposerClient::Command::SET_LAYER_SURFACE_DAMAGE:
|
||||
parsed = parseSetLayerSurfaceDamage(length);
|
||||
break;
|
||||
case IComposerClient::Command::SET_LAYER_BLEND_MODE:
|
||||
parsed = parseSetLayerBlendMode(length);
|
||||
break;
|
||||
case IComposerClient::Command::SET_LAYER_COLOR:
|
||||
parsed = parseSetLayerColor(length);
|
||||
break;
|
||||
case IComposerClient::Command::SET_LAYER_COMPOSITION_TYPE:
|
||||
parsed = parseSetLayerCompositionType(length);
|
||||
break;
|
||||
case IComposerClient::Command::SET_LAYER_DATASPACE:
|
||||
parsed = parseSetLayerDataspace(length);
|
||||
break;
|
||||
case IComposerClient::Command::SET_LAYER_DISPLAY_FRAME:
|
||||
parsed = parseSetLayerDisplayFrame(length);
|
||||
break;
|
||||
case IComposerClient::Command::SET_LAYER_PLANE_ALPHA:
|
||||
parsed = parseSetLayerPlaneAlpha(length);
|
||||
break;
|
||||
case IComposerClient::Command::SET_LAYER_SIDEBAND_STREAM:
|
||||
parsed = parseSetLayerSidebandStream(length);
|
||||
break;
|
||||
case IComposerClient::Command::SET_LAYER_SOURCE_CROP:
|
||||
parsed = parseSetLayerSourceCrop(length);
|
||||
break;
|
||||
case IComposerClient::Command::SET_LAYER_TRANSFORM:
|
||||
parsed = parseSetLayerTransform(length);
|
||||
break;
|
||||
case IComposerClient::Command::SET_LAYER_VISIBLE_REGION:
|
||||
parsed = parseSetLayerVisibleRegion(length);
|
||||
break;
|
||||
case IComposerClient::Command::SET_LAYER_Z_ORDER:
|
||||
parsed = parseSetLayerZOrder(length);
|
||||
break;
|
||||
default:
|
||||
parsed = false;
|
||||
break;
|
||||
}
|
||||
|
||||
bool parsed = parseCommand(command, length);
|
||||
endCommand();
|
||||
|
||||
if (!parsed) {
|
||||
@@ -649,7 +595,59 @@ Error HwcClient::CommandReader::parse()
|
||||
return (isEmpty()) ? Error::NONE : Error::BAD_PARAMETER;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSelectDisplay(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseCommand(
|
||||
IComposerClient::Command command, uint16_t length) {
|
||||
switch (command) {
|
||||
case IComposerClient::Command::SELECT_DISPLAY:
|
||||
return parseSelectDisplay(length);
|
||||
case IComposerClient::Command::SELECT_LAYER:
|
||||
return parseSelectLayer(length);
|
||||
case IComposerClient::Command::SET_COLOR_TRANSFORM:
|
||||
return parseSetColorTransform(length);
|
||||
case IComposerClient::Command::SET_CLIENT_TARGET:
|
||||
return parseSetClientTarget(length);
|
||||
case IComposerClient::Command::SET_OUTPUT_BUFFER:
|
||||
return parseSetOutputBuffer(length);
|
||||
case IComposerClient::Command::VALIDATE_DISPLAY:
|
||||
return parseValidateDisplay(length);
|
||||
case IComposerClient::Command::ACCEPT_DISPLAY_CHANGES:
|
||||
return parseAcceptDisplayChanges(length);
|
||||
case IComposerClient::Command::PRESENT_DISPLAY:
|
||||
return parsePresentDisplay(length);
|
||||
case IComposerClient::Command::SET_LAYER_CURSOR_POSITION:
|
||||
return parseSetLayerCursorPosition(length);
|
||||
case IComposerClient::Command::SET_LAYER_BUFFER:
|
||||
return parseSetLayerBuffer(length);
|
||||
case IComposerClient::Command::SET_LAYER_SURFACE_DAMAGE:
|
||||
return parseSetLayerSurfaceDamage(length);
|
||||
case IComposerClient::Command::SET_LAYER_BLEND_MODE:
|
||||
return parseSetLayerBlendMode(length);
|
||||
case IComposerClient::Command::SET_LAYER_COLOR:
|
||||
return parseSetLayerColor(length);
|
||||
case IComposerClient::Command::SET_LAYER_COMPOSITION_TYPE:
|
||||
return parseSetLayerCompositionType(length);
|
||||
case IComposerClient::Command::SET_LAYER_DATASPACE:
|
||||
return parseSetLayerDataspace(length);
|
||||
case IComposerClient::Command::SET_LAYER_DISPLAY_FRAME:
|
||||
return parseSetLayerDisplayFrame(length);
|
||||
case IComposerClient::Command::SET_LAYER_PLANE_ALPHA:
|
||||
return parseSetLayerPlaneAlpha(length);
|
||||
case IComposerClient::Command::SET_LAYER_SIDEBAND_STREAM:
|
||||
return parseSetLayerSidebandStream(length);
|
||||
case IComposerClient::Command::SET_LAYER_SOURCE_CROP:
|
||||
return parseSetLayerSourceCrop(length);
|
||||
case IComposerClient::Command::SET_LAYER_TRANSFORM:
|
||||
return parseSetLayerTransform(length);
|
||||
case IComposerClient::Command::SET_LAYER_VISIBLE_REGION:
|
||||
return parseSetLayerVisibleRegion(length);
|
||||
case IComposerClient::Command::SET_LAYER_Z_ORDER:
|
||||
return parseSetLayerZOrder(length);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ComposerClient::CommandReader::parseSelectDisplay(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kSelectDisplayLength) {
|
||||
return false;
|
||||
@@ -661,7 +659,7 @@ bool HwcClient::CommandReader::parseSelectDisplay(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSelectLayer(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSelectLayer(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kSelectLayerLength) {
|
||||
return false;
|
||||
@@ -672,7 +670,7 @@ bool HwcClient::CommandReader::parseSelectLayer(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSetColorTransform(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSetColorTransform(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kSetColorTransformLength) {
|
||||
return false;
|
||||
@@ -692,7 +690,7 @@ bool HwcClient::CommandReader::parseSetColorTransform(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSetClientTarget(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSetClientTarget(uint16_t length)
|
||||
{
|
||||
// 4 parameters followed by N rectangles
|
||||
if ((length - 4) % 4 != 0) {
|
||||
@@ -720,7 +718,7 @@ bool HwcClient::CommandReader::parseSetClientTarget(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSetOutputBuffer(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSetOutputBuffer(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kSetOutputBufferLength) {
|
||||
return false;
|
||||
@@ -744,7 +742,7 @@ bool HwcClient::CommandReader::parseSetOutputBuffer(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseValidateDisplay(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseValidateDisplay(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kValidateDisplayLength) {
|
||||
return false;
|
||||
@@ -771,7 +769,7 @@ bool HwcClient::CommandReader::parseValidateDisplay(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseAcceptDisplayChanges(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseAcceptDisplayChanges(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kAcceptDisplayChangesLength) {
|
||||
return false;
|
||||
@@ -785,7 +783,7 @@ bool HwcClient::CommandReader::parseAcceptDisplayChanges(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parsePresentDisplay(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parsePresentDisplay(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kPresentDisplayLength) {
|
||||
return false;
|
||||
@@ -805,7 +803,7 @@ bool HwcClient::CommandReader::parsePresentDisplay(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSetLayerCursorPosition(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSetLayerCursorPosition(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kSetLayerCursorPositionLength) {
|
||||
return false;
|
||||
@@ -820,7 +818,7 @@ bool HwcClient::CommandReader::parseSetLayerCursorPosition(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSetLayerBuffer(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSetLayerBuffer(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kSetLayerBufferLength) {
|
||||
return false;
|
||||
@@ -844,7 +842,7 @@ bool HwcClient::CommandReader::parseSetLayerBuffer(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSetLayerSurfaceDamage(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSetLayerSurfaceDamage(uint16_t length)
|
||||
{
|
||||
// N rectangles
|
||||
if (length % 4 != 0) {
|
||||
@@ -860,7 +858,7 @@ bool HwcClient::CommandReader::parseSetLayerSurfaceDamage(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSetLayerBlendMode(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSetLayerBlendMode(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kSetLayerBlendModeLength) {
|
||||
return false;
|
||||
@@ -874,7 +872,7 @@ bool HwcClient::CommandReader::parseSetLayerBlendMode(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSetLayerColor(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSetLayerColor(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kSetLayerColorLength) {
|
||||
return false;
|
||||
@@ -888,7 +886,8 @@ bool HwcClient::CommandReader::parseSetLayerColor(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSetLayerCompositionType(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSetLayerCompositionType(
|
||||
uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kSetLayerCompositionTypeLength) {
|
||||
return false;
|
||||
@@ -902,7 +901,7 @@ bool HwcClient::CommandReader::parseSetLayerCompositionType(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSetLayerDataspace(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSetLayerDataspace(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kSetLayerDataspaceLength) {
|
||||
return false;
|
||||
@@ -916,7 +915,7 @@ bool HwcClient::CommandReader::parseSetLayerDataspace(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSetLayerDisplayFrame(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSetLayerDisplayFrame(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kSetLayerDisplayFrameLength) {
|
||||
return false;
|
||||
@@ -930,7 +929,7 @@ bool HwcClient::CommandReader::parseSetLayerDisplayFrame(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSetLayerPlaneAlpha(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSetLayerPlaneAlpha(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kSetLayerPlaneAlphaLength) {
|
||||
return false;
|
||||
@@ -944,7 +943,7 @@ bool HwcClient::CommandReader::parseSetLayerPlaneAlpha(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSetLayerSidebandStream(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSetLayerSidebandStream(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kSetLayerSidebandStreamLength) {
|
||||
return false;
|
||||
@@ -963,7 +962,7 @@ bool HwcClient::CommandReader::parseSetLayerSidebandStream(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSetLayerSourceCrop(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSetLayerSourceCrop(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kSetLayerSourceCropLength) {
|
||||
return false;
|
||||
@@ -977,7 +976,7 @@ bool HwcClient::CommandReader::parseSetLayerSourceCrop(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSetLayerTransform(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSetLayerTransform(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kSetLayerTransformLength) {
|
||||
return false;
|
||||
@@ -991,7 +990,7 @@ bool HwcClient::CommandReader::parseSetLayerTransform(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSetLayerVisibleRegion(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSetLayerVisibleRegion(uint16_t length)
|
||||
{
|
||||
// N rectangles
|
||||
if (length % 4 != 0) {
|
||||
@@ -1007,7 +1006,7 @@ bool HwcClient::CommandReader::parseSetLayerVisibleRegion(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HwcClient::CommandReader::parseSetLayerZOrder(uint16_t length)
|
||||
bool ComposerClient::CommandReader::parseSetLayerZOrder(uint16_t length)
|
||||
{
|
||||
if (length != CommandWriterBase::kSetLayerZOrderLength) {
|
||||
return false;
|
||||
@@ -1021,7 +1020,7 @@ bool HwcClient::CommandReader::parseSetLayerZOrder(uint16_t length)
|
||||
return true;
|
||||
}
|
||||
|
||||
hwc_rect_t HwcClient::CommandReader::readRect()
|
||||
hwc_rect_t ComposerClient::CommandReader::readRect()
|
||||
{
|
||||
return hwc_rect_t{
|
||||
readSigned(),
|
||||
@@ -1031,7 +1030,7 @@ hwc_rect_t HwcClient::CommandReader::readRect()
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<hwc_rect_t> HwcClient::CommandReader::readRegion(size_t count)
|
||||
std::vector<hwc_rect_t> ComposerClient::CommandReader::readRegion(size_t count)
|
||||
{
|
||||
std::vector<hwc_rect_t> region;
|
||||
region.reserve(count);
|
||||
@@ -1043,7 +1042,7 @@ std::vector<hwc_rect_t> HwcClient::CommandReader::readRegion(size_t count)
|
||||
return region;
|
||||
}
|
||||
|
||||
hwc_frect_t HwcClient::CommandReader::readFRect()
|
||||
hwc_frect_t ComposerClient::CommandReader::readFRect()
|
||||
{
|
||||
return hwc_frect_t{
|
||||
readFloat(),
|
||||
@@ -1053,8 +1052,8 @@ hwc_frect_t HwcClient::CommandReader::readFRect()
|
||||
};
|
||||
}
|
||||
|
||||
Error HwcClient::CommandReader::lookupBuffer(BufferCache cache, uint32_t slot,
|
||||
bool useCache, buffer_handle_t& handle)
|
||||
Error ComposerClient::CommandReader::lookupBuffer(BufferCache cache,
|
||||
uint32_t slot, bool useCache, buffer_handle_t& handle)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mClient.mDisplayDataMutex);
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_GRAPHICS_COMPOSER_V2_1_HWC_CLIENT_H
|
||||
#define ANDROID_HARDWARE_GRAPHICS_COMPOSER_V2_1_HWC_CLIENT_H
|
||||
#ifndef ANDROID_HARDWARE_GRAPHICS_COMPOSER_V2_1_COMPOSER_CLIENT_H
|
||||
#define ANDROID_HARDWARE_GRAPHICS_COMPOSER_V2_1_COMPOSER_CLIENT_H
|
||||
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
@@ -50,10 +50,12 @@ private:
|
||||
buffer_handle_t mHandle;
|
||||
};
|
||||
|
||||
class HwcClient : public IComposerClient {
|
||||
class ComposerClient : public IComposerClient {
|
||||
public:
|
||||
HwcClient(HwcHal& hal);
|
||||
virtual ~HwcClient();
|
||||
ComposerClient(ComposerBase& hal);
|
||||
virtual ~ComposerClient();
|
||||
|
||||
void initialize();
|
||||
|
||||
void onHotplug(Display display, IComposerCallback::Connection connected);
|
||||
void onRefresh(Display display);
|
||||
@@ -104,7 +106,7 @@ public:
|
||||
const hidl_vec<hidl_handle>& inHandles,
|
||||
executeCommands_cb hidl_cb) override;
|
||||
|
||||
private:
|
||||
protected:
|
||||
struct LayerBuffers {
|
||||
std::vector<BufferClone> Buffers;
|
||||
BufferClone SidebandStream;
|
||||
@@ -123,10 +125,15 @@ private:
|
||||
|
||||
class CommandReader : public CommandReaderBase {
|
||||
public:
|
||||
CommandReader(HwcClient& client);
|
||||
CommandReader(ComposerClient& client);
|
||||
virtual ~CommandReader();
|
||||
|
||||
Error parse();
|
||||
|
||||
private:
|
||||
protected:
|
||||
virtual bool parseCommand(IComposerClient::Command command,
|
||||
uint16_t length);
|
||||
|
||||
bool parseSelectDisplay(uint16_t length);
|
||||
bool parseSelectLayer(uint16_t length);
|
||||
bool parseSetColorTransform(uint16_t length);
|
||||
@@ -169,21 +176,23 @@ private:
|
||||
0, false, handle);
|
||||
}
|
||||
|
||||
HwcClient& mClient;
|
||||
HwcHal& mHal;
|
||||
ComposerClient& mClient;
|
||||
ComposerBase& mHal;
|
||||
CommandWriterBase& mWriter;
|
||||
|
||||
Display mDisplay;
|
||||
Layer mLayer;
|
||||
};
|
||||
|
||||
HwcHal& mHal;
|
||||
virtual std::unique_ptr<CommandReader> createCommandReader();
|
||||
|
||||
ComposerBase& mHal;
|
||||
|
||||
// 64KiB minus a small space for metadata such as read/write pointers
|
||||
static constexpr size_t kWriterInitialSize =
|
||||
64 * 1024 / sizeof(uint32_t) - 16;
|
||||
std::mutex mCommandMutex;
|
||||
CommandReader mReader;
|
||||
std::unique_ptr<CommandReader> mReader;
|
||||
CommandWriterBase mWriter;
|
||||
|
||||
sp<IComposerCallback> mCallback;
|
||||
@@ -199,4 +208,4 @@ private:
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_GRAPHICS_COMPOSER_V2_1_HWC_CLIENT_H
|
||||
#endif // ANDROID_HARDWARE_GRAPHICS_COMPOSER_V2_1_COMPOSER_CLIENT_H
|
||||
@@ -20,8 +20,8 @@
|
||||
|
||||
#include <log/log.h>
|
||||
|
||||
#include "ComposerClient.h"
|
||||
#include "Hwc.h"
|
||||
#include "HwcClient.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
@@ -184,14 +184,15 @@ Return<void> HwcHal::dumpDebugInfo(dumpDebugInfo_cb hidl_cb)
|
||||
Return<void> HwcHal::createClient(createClient_cb hidl_cb)
|
||||
{
|
||||
Error err = Error::NONE;
|
||||
sp<HwcClient> client;
|
||||
sp<ComposerClient> client;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mClientMutex);
|
||||
|
||||
// only one client is allowed
|
||||
if (mClient == nullptr) {
|
||||
client = new HwcClient(*this);
|
||||
client = new ComposerClient(*this);
|
||||
client->initialize();
|
||||
mClient = client;
|
||||
} else {
|
||||
err = Error::NO_RESOURCES;
|
||||
@@ -203,7 +204,7 @@ Return<void> HwcHal::createClient(createClient_cb hidl_cb)
|
||||
return Void();
|
||||
}
|
||||
|
||||
sp<HwcClient> HwcHal::getClient()
|
||||
sp<ComposerClient> HwcHal::getClient()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mClientMutex);
|
||||
return (mClient != nullptr) ? mClient.promote() : nullptr;
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include <android/hardware/graphics/composer/2.1/IComposer.h>
|
||||
#include <hardware/hwcomposer2.h>
|
||||
|
||||
#include "ComposerBase.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace graphics {
|
||||
@@ -38,96 +40,101 @@ using android::hardware::graphics::common::V1_0::ColorMode;
|
||||
using android::hardware::graphics::common::V1_0::ColorTransform;
|
||||
using android::hardware::graphics::common::V1_0::Hdr;
|
||||
|
||||
class HwcClient;
|
||||
class ComposerClient;
|
||||
|
||||
class HwcHal : public IComposer {
|
||||
class HwcHal : public IComposer, public ComposerBase {
|
||||
public:
|
||||
HwcHal(const hw_module_t* module);
|
||||
virtual ~HwcHal();
|
||||
|
||||
bool hasCapability(Capability capability) const;
|
||||
|
||||
// IComposer interface
|
||||
Return<void> getCapabilities(getCapabilities_cb hidl_cb) override;
|
||||
Return<void> dumpDebugInfo(dumpDebugInfo_cb hidl_cb) override;
|
||||
Return<void> createClient(createClient_cb hidl_cb) override;
|
||||
|
||||
bool hasCapability(Capability capability) const;
|
||||
|
||||
void removeClient();
|
||||
|
||||
void enableCallback(bool enable);
|
||||
|
||||
uint32_t getMaxVirtualDisplayCount();
|
||||
// ComposerBase interface
|
||||
void removeClient() override;
|
||||
void enableCallback(bool enable) override;
|
||||
uint32_t getMaxVirtualDisplayCount() override;
|
||||
Error createVirtualDisplay(uint32_t width, uint32_t height,
|
||||
PixelFormat* format, Display* outDisplay);
|
||||
Error destroyVirtualDisplay(Display display);
|
||||
PixelFormat* format, Display* outDisplay) override;
|
||||
Error destroyVirtualDisplay(Display display) override;
|
||||
|
||||
Error createLayer(Display display, Layer* outLayer);
|
||||
Error destroyLayer(Display display, Layer layer);
|
||||
Error createLayer(Display display, Layer* outLayer) override;
|
||||
Error destroyLayer(Display display, Layer layer) override;
|
||||
|
||||
Error getActiveConfig(Display display, Config* outConfig);
|
||||
Error getActiveConfig(Display display, Config* outConfig) override;
|
||||
Error getClientTargetSupport(Display display,
|
||||
uint32_t width, uint32_t height,
|
||||
PixelFormat format, Dataspace dataspace);
|
||||
Error getColorModes(Display display, hidl_vec<ColorMode>* outModes);
|
||||
PixelFormat format, Dataspace dataspace) override;
|
||||
Error getColorModes(Display display,
|
||||
hidl_vec<ColorMode>* outModes) override;
|
||||
Error getDisplayAttribute(Display display, Config config,
|
||||
IComposerClient::Attribute attribute, int32_t* outValue);
|
||||
Error getDisplayConfigs(Display display, hidl_vec<Config>* outConfigs);
|
||||
Error getDisplayName(Display display, hidl_string* outName);
|
||||
IComposerClient::Attribute attribute, int32_t* outValue) override;
|
||||
Error getDisplayConfigs(Display display,
|
||||
hidl_vec<Config>* outConfigs) override;
|
||||
Error getDisplayName(Display display, hidl_string* outName) override;
|
||||
Error getDisplayType(Display display,
|
||||
IComposerClient::DisplayType* outType);
|
||||
Error getDozeSupport(Display display, bool* outSupport);
|
||||
IComposerClient::DisplayType* outType) override;
|
||||
Error getDozeSupport(Display display, bool* outSupport) override;
|
||||
Error getHdrCapabilities(Display display, hidl_vec<Hdr>* outTypes,
|
||||
float* outMaxLuminance, float* outMaxAverageLuminance,
|
||||
float* outMinLuminance);
|
||||
float* outMinLuminance) override;
|
||||
|
||||
Error setActiveConfig(Display display, Config config);
|
||||
Error setColorMode(Display display, ColorMode mode);
|
||||
Error setPowerMode(Display display, IComposerClient::PowerMode mode);
|
||||
Error setVsyncEnabled(Display display, IComposerClient::Vsync enabled);
|
||||
Error setActiveConfig(Display display, Config config) override;
|
||||
Error setColorMode(Display display, ColorMode mode) override;
|
||||
Error setPowerMode(Display display,
|
||||
IComposerClient::PowerMode mode) override;
|
||||
Error setVsyncEnabled(Display display,
|
||||
IComposerClient::Vsync enabled) override;
|
||||
|
||||
Error setColorTransform(Display display, const float* matrix,
|
||||
int32_t hint);
|
||||
int32_t hint) override;
|
||||
Error setClientTarget(Display display, buffer_handle_t target,
|
||||
int32_t acquireFence, int32_t dataspace,
|
||||
const std::vector<hwc_rect_t>& damage);
|
||||
const std::vector<hwc_rect_t>& damage) override;
|
||||
Error setOutputBuffer(Display display, buffer_handle_t buffer,
|
||||
int32_t releaseFence);
|
||||
int32_t releaseFence) override;
|
||||
Error validateDisplay(Display display,
|
||||
std::vector<Layer>* outChangedLayers,
|
||||
std::vector<IComposerClient::Composition>* outCompositionTypes,
|
||||
uint32_t* outDisplayRequestMask,
|
||||
std::vector<Layer>* outRequestedLayers,
|
||||
std::vector<uint32_t>* outRequestMasks);
|
||||
Error acceptDisplayChanges(Display display);
|
||||
std::vector<uint32_t>* outRequestMasks) override;
|
||||
Error acceptDisplayChanges(Display display) override;
|
||||
Error presentDisplay(Display display, int32_t* outPresentFence,
|
||||
std::vector<Layer>* outLayers,
|
||||
std::vector<int32_t>* outReleaseFences);
|
||||
std::vector<int32_t>* outReleaseFences) override;
|
||||
|
||||
Error setLayerCursorPosition(Display display, Layer layer,
|
||||
int32_t x, int32_t y);
|
||||
int32_t x, int32_t y) override;
|
||||
Error setLayerBuffer(Display display, Layer layer,
|
||||
buffer_handle_t buffer, int32_t acquireFence);
|
||||
buffer_handle_t buffer, int32_t acquireFence) override;
|
||||
Error setLayerSurfaceDamage(Display display, Layer layer,
|
||||
const std::vector<hwc_rect_t>& damage);
|
||||
Error setLayerBlendMode(Display display, Layer layer, int32_t mode);
|
||||
const std::vector<hwc_rect_t>& damage) override;
|
||||
Error setLayerBlendMode(Display display, Layer layer,
|
||||
int32_t mode) override;
|
||||
Error setLayerColor(Display display, Layer layer,
|
||||
IComposerClient::Color color);
|
||||
IComposerClient::Color color) override;
|
||||
Error setLayerCompositionType(Display display, Layer layer,
|
||||
int32_t type);
|
||||
int32_t type) override;
|
||||
Error setLayerDataspace(Display display, Layer layer,
|
||||
int32_t dataspace);
|
||||
int32_t dataspace) override;
|
||||
Error setLayerDisplayFrame(Display display, Layer layer,
|
||||
const hwc_rect_t& frame);
|
||||
Error setLayerPlaneAlpha(Display display, Layer layer, float alpha);
|
||||
const hwc_rect_t& frame) override;
|
||||
Error setLayerPlaneAlpha(Display display, Layer layer,
|
||||
float alpha) override;
|
||||
Error setLayerSidebandStream(Display display, Layer layer,
|
||||
buffer_handle_t stream);
|
||||
buffer_handle_t stream) override;
|
||||
Error setLayerSourceCrop(Display display, Layer layer,
|
||||
const hwc_frect_t& crop);
|
||||
const hwc_frect_t& crop) override;
|
||||
Error setLayerTransform(Display display, Layer layer,
|
||||
int32_t transform);
|
||||
int32_t transform) override;
|
||||
Error setLayerVisibleRegion(Display display, Layer layer,
|
||||
const std::vector<hwc_rect_t>& visible);
|
||||
Error setLayerZOrder(Display display, Layer layer, uint32_t z);
|
||||
const std::vector<hwc_rect_t>& visible) override;
|
||||
Error setLayerZOrder(Display display, Layer layer, uint32_t z) override;
|
||||
|
||||
private:
|
||||
void initCapabilities();
|
||||
@@ -136,7 +143,7 @@ private:
|
||||
void initDispatch(hwc2_function_descriptor_t desc, T* outPfn);
|
||||
void initDispatch();
|
||||
|
||||
sp<HwcClient> getClient();
|
||||
sp<ComposerClient> getClient();
|
||||
|
||||
static void hotplugHook(hwc2_callback_data_t callbackData,
|
||||
hwc2_display_t display, int32_t connected);
|
||||
@@ -196,7 +203,7 @@ private:
|
||||
} mDispatch;
|
||||
|
||||
std::mutex mClientMutex;
|
||||
wp<HwcClient> mClient;
|
||||
wp<ComposerClient> mClient;
|
||||
};
|
||||
|
||||
extern "C" IComposer* HIDL_FETCH_IComposer(const char* name);
|
||||
|
||||
Reference in New Issue
Block a user