[Composer] Create place holder for Composer 2.4.
Create place holder for composer 2.4. Minor: Extend DisplayCapability to include protected contents. BUG: 135929065 Test: build Change-Id: I9dbdb21f4a69027bedd95cd54e9c3c652bbe9006
This commit is contained in:
parent
55bfb0cfeb
commit
781d0bbe3b
23 changed files with 1188 additions and 0 deletions
24
graphics/composer/2.4/Android.bp
Normal file
24
graphics/composer/2.4/Android.bp
Normal file
|
@ -0,0 +1,24 @@
|
|||
// This file is autogenerated by hidl-gen -Landroidbp.
|
||||
|
||||
hidl_interface {
|
||||
name: "android.hardware.graphics.composer@2.4",
|
||||
root: "android.hardware",
|
||||
vndk: {
|
||||
// TODO(b/135929065) enable once we are ready to use.
|
||||
enabled: false,
|
||||
},
|
||||
srcs: [
|
||||
"IComposer.hal",
|
||||
"IComposerClient.hal",
|
||||
],
|
||||
interfaces: [
|
||||
"android.hardware.graphics.common@1.0",
|
||||
"android.hardware.graphics.common@1.1",
|
||||
"android.hardware.graphics.common@1.2",
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
"android.hardware.graphics.composer@2.2",
|
||||
"android.hardware.graphics.composer@2.3",
|
||||
"android.hidl.base@1.0",
|
||||
],
|
||||
gen_java: false,
|
||||
}
|
34
graphics/composer/2.4/IComposer.hal
Normal file
34
graphics/composer/2.4/IComposer.hal
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2019 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.
|
||||
*/
|
||||
|
||||
package android.hardware.graphics.composer@2.4;
|
||||
|
||||
import IComposerClient;
|
||||
|
||||
import @2.1::Error;
|
||||
import @2.3::IComposer;
|
||||
|
||||
interface IComposer extends @2.3::IComposer {
|
||||
|
||||
/**
|
||||
* Creates a v2.4 client of the composer. Supersedes @2.3::createClient.
|
||||
*
|
||||
* @return error is NONE upon success. Otherwise,
|
||||
* NO_RESOURCES when the client could not be created.
|
||||
* @return client is the newly created client.
|
||||
*/
|
||||
createClient_2_4() generates (Error error, IComposerClient client);
|
||||
};
|
51
graphics/composer/2.4/IComposerClient.hal
Normal file
51
graphics/composer/2.4/IComposerClient.hal
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright 2019 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.
|
||||
*/
|
||||
|
||||
package android.hardware.graphics.composer@2.4;
|
||||
|
||||
import @2.1::Display;
|
||||
import @2.1::Error;
|
||||
import @2.3::IComposerClient;
|
||||
|
||||
interface IComposerClient extends @2.3::IComposerClient {
|
||||
|
||||
/**
|
||||
* Required capabilities which are supported by the display. The
|
||||
* particular set of supported capabilities for a given display may be
|
||||
* retrieved using getDisplayCapabilities.
|
||||
*/
|
||||
enum DisplayCapability : uint32_t {
|
||||
/**
|
||||
* Indicates that the display supports protected contents.
|
||||
* When returned, hardware composer must be able to accept client target
|
||||
* with protected buffers.
|
||||
*/
|
||||
PROTECTED_CONTENTS = 4,
|
||||
};
|
||||
|
||||
/**
|
||||
* Provides a list of supported capabilities (as described in the
|
||||
* definition of DisplayCapability above). This list must not change after
|
||||
* initialization.
|
||||
*
|
||||
* @return error is NONE upon success. Otherwise,
|
||||
* BAD_DISPLAY when an invalid display handle was passed in.
|
||||
* @return capabilities is a list of supported capabilities.
|
||||
*/
|
||||
getDisplayCapabilities_2_4(Display display)
|
||||
generates (Error error,
|
||||
vec<DisplayCapability> capabilities);
|
||||
};
|
47
graphics/composer/2.4/default/Android.bp
Normal file
47
graphics/composer/2.4/default/Android.bp
Normal file
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// Copyright 2019 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.
|
||||
//
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.graphics.composer@2.4-service",
|
||||
defaults: ["hidl_defaults"],
|
||||
vendor: true,
|
||||
relative_install_path: "hw",
|
||||
srcs: ["service.cpp"],
|
||||
init_rc: ["android.hardware.graphics.composer@2.4-service.rc"],
|
||||
header_libs: [
|
||||
"android.hardware.graphics.composer@2.4-passthrough",
|
||||
],
|
||||
shared_libs: [
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
"android.hardware.graphics.composer@2.2",
|
||||
"android.hardware.graphics.composer@2.3",
|
||||
"android.hardware.graphics.composer@2.4",
|
||||
"android.hardware.graphics.mapper@2.0",
|
||||
"android.hardware.graphics.mapper@3.0",
|
||||
"libbase",
|
||||
"libbinder",
|
||||
"libcutils",
|
||||
"libfmq",
|
||||
"libhardware",
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libhwc2on1adapter",
|
||||
"libhwc2onfbadapter",
|
||||
"liblog",
|
||||
"libsync",
|
||||
"libutils",
|
||||
],
|
||||
}
|
4
graphics/composer/2.4/default/OWNERS
Normal file
4
graphics/composer/2.4/default/OWNERS
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Graphics team
|
||||
lpy@google.com
|
||||
stoza@google.com
|
||||
vhau@google.com
|
|
@ -0,0 +1,7 @@
|
|||
service vendor.hwcomposer-2-4 /vendor/bin/hw/android.hardware.graphics.composer@2.4-service
|
||||
class hal animation
|
||||
user system
|
||||
group graphics drmrpc
|
||||
capabilities SYS_NICE
|
||||
onrestart restart surfaceflinger
|
||||
writepid /dev/cpuset/system-background/tasks
|
55
graphics/composer/2.4/default/service.cpp
Normal file
55
graphics/composer/2.4/default/service.cpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright 2019 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.
|
||||
*/
|
||||
|
||||
#include <sched.h>
|
||||
|
||||
#include <android/hardware/graphics/composer/2.4/IComposer.h>
|
||||
#include <binder/ProcessState.h>
|
||||
#include <composer-passthrough/2.4/HwcLoader.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
|
||||
using android::hardware::graphics::composer::V2_4::IComposer;
|
||||
using android::hardware::graphics::composer::V2_4::passthrough::HwcLoader;
|
||||
|
||||
int main() {
|
||||
// the conventional HAL might start binder services
|
||||
android::ProcessState::initWithDriver("/dev/vndbinder");
|
||||
android::ProcessState::self()->setThreadPoolMaxThreadCount(4);
|
||||
android::ProcessState::self()->startThreadPool();
|
||||
|
||||
// same as SF main thread
|
||||
struct sched_param param = {0};
|
||||
param.sched_priority = 2;
|
||||
if (sched_setscheduler(0, SCHED_FIFO | SCHED_RESET_ON_FORK, ¶m) != 0) {
|
||||
ALOGE("Couldn't set SCHED_FIFO: %d", errno);
|
||||
}
|
||||
|
||||
android::hardware::configureRpcThreadpool(4, true /* will join */);
|
||||
|
||||
android::sp<IComposer> composer = HwcLoader::load();
|
||||
if (composer == nullptr) {
|
||||
return 1;
|
||||
}
|
||||
if (composer->registerAsService() != android::NO_ERROR) {
|
||||
ALOGE("failed to register service");
|
||||
return 1;
|
||||
}
|
||||
|
||||
android::hardware::joinRpcThreadpool();
|
||||
|
||||
ALOGE("service is terminating");
|
||||
return 1;
|
||||
}
|
4
graphics/composer/2.4/utils/OWNERS
Normal file
4
graphics/composer/2.4/utils/OWNERS
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Graphics team
|
||||
lpy@google.com
|
||||
stoza@google.com
|
||||
vhau@google.com
|
18
graphics/composer/2.4/utils/command-buffer/Android.bp
Normal file
18
graphics/composer/2.4/utils/command-buffer/Android.bp
Normal file
|
@ -0,0 +1,18 @@
|
|||
cc_library_headers {
|
||||
name: "android.hardware.graphics.composer@2.4-command-buffer",
|
||||
defaults: ["hidl_defaults"],
|
||||
vendor_available: true,
|
||||
shared_libs: [
|
||||
"android.hardware.graphics.composer@2.4",
|
||||
],
|
||||
export_shared_lib_headers: [
|
||||
"android.hardware.graphics.composer@2.4",
|
||||
],
|
||||
header_libs: [
|
||||
"android.hardware.graphics.composer@2.3-command-buffer",
|
||||
],
|
||||
export_header_lib_headers: [
|
||||
"android.hardware.graphics.composer@2.3-command-buffer",
|
||||
],
|
||||
export_include_dirs: ["include"],
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2019 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef LOG_TAG
|
||||
#warn "ComposerCommandBuffer.h included without LOG_TAG"
|
||||
#endif
|
||||
|
||||
#undef LOG_NDEBUG
|
||||
#define LOG_NDEBUG 0
|
||||
|
||||
#include <android/hardware/graphics/composer/2.4/IComposer.h>
|
||||
#include <android/hardware/graphics/composer/2.4/IComposerClient.h>
|
||||
#include <composer-command-buffer/2.3/ComposerCommandBuffer.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace graphics {
|
||||
namespace composer {
|
||||
namespace V2_4 {
|
||||
|
||||
using android::hardware::MessageQueue;
|
||||
using android::hardware::graphics::composer::V2_1::Error;
|
||||
using android::hardware::graphics::composer::V2_4::IComposerClient;
|
||||
|
||||
// This class helps build a command queue. Note that all sizes/lengths are in
|
||||
// units of uint32_t's.
|
||||
class CommandWriterBase : public V2_3::CommandWriterBase {
|
||||
public:
|
||||
CommandWriterBase(uint32_t initialMaxSize) : V2_3::CommandWriterBase(initialMaxSize) {}
|
||||
};
|
||||
|
||||
// This class helps parse a command queue. Note that all sizes/lengths are in
|
||||
// units of uint32_t's.
|
||||
class CommandReaderBase : public V2_3::CommandReaderBase {
|
||||
public:
|
||||
CommandReaderBase() : V2_3::CommandReaderBase(){};
|
||||
};
|
||||
|
||||
} // namespace V2_4
|
||||
} // namespace composer
|
||||
} // namespace graphics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
36
graphics/composer/2.4/utils/hal/Android.bp
Normal file
36
graphics/composer/2.4/utils/hal/Android.bp
Normal file
|
@ -0,0 +1,36 @@
|
|||
//
|
||||
// Copyright 2019 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.
|
||||
//
|
||||
|
||||
cc_library_headers {
|
||||
name: "android.hardware.graphics.composer@2.4-hal",
|
||||
defaults: ["hidl_defaults"],
|
||||
vendor_available: true,
|
||||
shared_libs: [
|
||||
"android.hardware.graphics.composer@2.4",
|
||||
],
|
||||
export_shared_lib_headers: [
|
||||
"android.hardware.graphics.composer@2.4",
|
||||
],
|
||||
header_libs: [
|
||||
"android.hardware.graphics.composer@2.3-hal",
|
||||
"android.hardware.graphics.composer@2.3-command-buffer",
|
||||
],
|
||||
export_header_lib_headers: [
|
||||
"android.hardware.graphics.composer@2.3-hal",
|
||||
"android.hardware.graphics.composer@2.3-command-buffer",
|
||||
],
|
||||
export_include_dirs: ["include"],
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* Copyright 2019 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef LOG_TAG
|
||||
#warning "Composer.h included without LOG_TAG"
|
||||
#endif
|
||||
|
||||
#include <android/hardware/graphics/composer/2.4/IComposer.h>
|
||||
#include <composer-hal/2.3/Composer.h>
|
||||
#include <composer-hal/2.4/ComposerClient.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace graphics {
|
||||
namespace composer {
|
||||
namespace V2_4 {
|
||||
namespace hal {
|
||||
|
||||
namespace detail {
|
||||
|
||||
// ComposerImpl implements V2_*::IComposer on top of V2_*::ComposerHal
|
||||
template <typename Interface, typename Hal>
|
||||
class ComposerImpl : public V2_3::hal::detail::ComposerImpl<Interface, Hal> {
|
||||
public:
|
||||
static std::unique_ptr<ComposerImpl> create(std::unique_ptr<Hal> hal) {
|
||||
return std::make_unique<ComposerImpl>(std::move(hal));
|
||||
}
|
||||
|
||||
explicit ComposerImpl(std::unique_ptr<Hal> hal) : BaseType2_3(std::move(hal)) {}
|
||||
|
||||
// IComposer 2.4 interface
|
||||
|
||||
Return<void> createClient_2_4(IComposer::createClient_2_4_cb hidl_cb) override {
|
||||
std::unique_lock<std::mutex> lock(mClientMutex);
|
||||
if (!waitForClientDestroyedLocked(lock)) {
|
||||
hidl_cb(Error::NO_RESOURCES, nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
sp<ComposerClient> client = ComposerClient::create(mHal.get()).release();
|
||||
if (!client) {
|
||||
hidl_cb(Error::NO_RESOURCES, nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
auto clientDestroyed = [this]() { onClientDestroyed(); };
|
||||
client->setOnClientDestroyed(clientDestroyed);
|
||||
|
||||
mClient = client;
|
||||
hidl_cb(Error::NONE, client);
|
||||
return Void();
|
||||
}
|
||||
|
||||
private:
|
||||
using BaseType2_3 = V2_3::hal::detail::ComposerImpl<Interface, Hal>;
|
||||
using BaseType2_1 = V2_1::hal::detail::ComposerImpl<Interface, Hal>;
|
||||
|
||||
using BaseType2_1::mClient;
|
||||
using BaseType2_1::mClientMutex;
|
||||
using BaseType2_1::mHal;
|
||||
using BaseType2_1::onClientDestroyed;
|
||||
using BaseType2_1::waitForClientDestroyedLocked;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
using Composer = detail::ComposerImpl<IComposer, ComposerHal>;
|
||||
|
||||
} // namespace hal
|
||||
} // namespace V2_4
|
||||
} // namespace composer
|
||||
} // namespace graphics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright 2019 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef LOG_TAG
|
||||
#warning "ComposerClient.h included without LOG_TAG"
|
||||
#endif
|
||||
|
||||
#include <android/hardware/graphics/composer/2.4/IComposerClient.h>
|
||||
#include <composer-hal/2.4/ComposerHal.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace graphics {
|
||||
namespace composer {
|
||||
namespace V2_4 {
|
||||
namespace hal {
|
||||
|
||||
namespace detail {
|
||||
|
||||
// ComposerClientImpl implements V2_*::IComposerClient on top of V2_*::ComposerHal
|
||||
template <typename Interface, typename Hal>
|
||||
class ComposerClientImpl : public V2_3::hal::detail::ComposerClientImpl<Interface, Hal> {
|
||||
public:
|
||||
ComposerClientImpl(Hal* hal) : BaseType2_3(hal) {}
|
||||
|
||||
Return<void> getDisplayCapabilities_2_4(
|
||||
Display display, IComposerClient::getDisplayCapabilities_2_4_cb hidl_cb) override {
|
||||
std::vector<IComposerClient::DisplayCapability> capabilities;
|
||||
Error error = mHal->getDisplayCapabilities_2_4(display, &capabilities);
|
||||
hidl_cb(error, capabilities);
|
||||
return Void();
|
||||
}
|
||||
|
||||
static std::unique_ptr<ComposerClientImpl> create(Hal* hal) {
|
||||
auto client = std::make_unique<ComposerClientImpl>(hal);
|
||||
return client->init() ? std::move(client) : nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
using BaseType2_3 = V2_3::hal::detail::ComposerClientImpl<Interface, Hal>;
|
||||
using BaseType2_1 = V2_1::hal::detail::ComposerClientImpl<Interface, Hal>;
|
||||
using BaseType2_1::mHal;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
using ComposerClient = detail::ComposerClientImpl<IComposerClient, ComposerHal>;
|
||||
|
||||
} // namespace hal
|
||||
} // namespace V2_4
|
||||
} // namespace composer
|
||||
} // namespace graphics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright 2018 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <composer-hal/2.3/ComposerHal.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace graphics {
|
||||
namespace composer {
|
||||
namespace V2_4 {
|
||||
namespace hal {
|
||||
|
||||
using common::V1_1::RenderIntent;
|
||||
using common::V1_2::ColorMode;
|
||||
using common::V1_2::Dataspace;
|
||||
using common::V1_2::Hdr;
|
||||
using common::V1_2::PixelFormat;
|
||||
using V2_1::Display;
|
||||
using V2_1::Error;
|
||||
using V2_1::Layer;
|
||||
|
||||
class ComposerHal : public V2_3::hal::ComposerHal {
|
||||
public:
|
||||
virtual Error getDisplayCapabilities_2_4(
|
||||
Display display, std::vector<IComposerClient::DisplayCapability>* outCapabilities) = 0;
|
||||
};
|
||||
|
||||
} // namespace hal
|
||||
} // namespace V2_4
|
||||
} // namespace composer
|
||||
} // namespace graphics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
30
graphics/composer/2.4/utils/passthrough/Android.bp
Normal file
30
graphics/composer/2.4/utils/passthrough/Android.bp
Normal file
|
@ -0,0 +1,30 @@
|
|||
//
|
||||
// Copyright 2019 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.
|
||||
//
|
||||
|
||||
cc_library_headers {
|
||||
name: "android.hardware.graphics.composer@2.4-passthrough",
|
||||
defaults: ["hidl_defaults"],
|
||||
vendor: true,
|
||||
header_libs: [
|
||||
"android.hardware.graphics.composer@2.3-passthrough",
|
||||
"android.hardware.graphics.composer@2.4-hal",
|
||||
],
|
||||
export_header_lib_headers: [
|
||||
"android.hardware.graphics.composer@2.3-passthrough",
|
||||
"android.hardware.graphics.composer@2.4-hal",
|
||||
],
|
||||
export_include_dirs: ["include"],
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright 2019 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef LOG_TAG
|
||||
#warning "HwcHal.h included without LOG_TAG"
|
||||
#endif
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <composer-hal/2.4/ComposerHal.h>
|
||||
#include <composer-passthrough/2.3/HwcHal.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace graphics {
|
||||
namespace composer {
|
||||
namespace V2_4 {
|
||||
namespace passthrough {
|
||||
|
||||
namespace detail {
|
||||
|
||||
using common::V1_1::RenderIntent;
|
||||
using common::V1_2::ColorMode;
|
||||
using common::V1_2::Dataspace;
|
||||
using common::V1_2::Hdr;
|
||||
using common::V1_2::PixelFormat;
|
||||
using V2_1::Display;
|
||||
using V2_1::Error;
|
||||
|
||||
// HwcHalImpl implements V2_*::hal::ComposerHal on top of hwcomposer2
|
||||
template <typename Hal>
|
||||
class HwcHalImpl : public V2_3::passthrough::detail::HwcHalImpl<Hal> {
|
||||
public:
|
||||
Error getDisplayCapabilities_2_4(
|
||||
Display display,
|
||||
std::vector<IComposerClient::DisplayCapability>* outCapabilities) override {
|
||||
std::vector<V2_3::IComposerClient::DisplayCapability> capabilities;
|
||||
Error error = BaseType2_3::getDisplayCapabilities(display, &capabilities);
|
||||
if (error != Error::NONE) {
|
||||
return error;
|
||||
}
|
||||
outCapabilities->clear();
|
||||
outCapabilities->reserve(capabilities.size());
|
||||
for (auto capability : capabilities) {
|
||||
outCapabilities->push_back(static_cast<IComposerClient::DisplayCapability>(capability));
|
||||
}
|
||||
return Error::NONE;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool initDispatch() override {
|
||||
if (!BaseType2_3::initDispatch()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
using BaseType2_1 = V2_1::passthrough::detail::HwcHalImpl<Hal>;
|
||||
using BaseType2_3 = V2_3::passthrough::detail::HwcHalImpl<Hal>;
|
||||
using BaseType2_1::mDevice;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
using HwcHal = detail::HwcHalImpl<hal::ComposerHal>;
|
||||
|
||||
} // namespace passthrough
|
||||
} // namespace V2_4
|
||||
} // namespace composer
|
||||
} // namespace graphics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright 2019 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef LOG_TAG
|
||||
#warning "HwcLoader.h included without LOG_TAG"
|
||||
#endif
|
||||
|
||||
#include <composer-hal/2.4/Composer.h>
|
||||
#include <composer-hal/2.4/ComposerHal.h>
|
||||
#include <composer-passthrough/2.3/HwcLoader.h>
|
||||
#include <composer-passthrough/2.4/HwcHal.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace graphics {
|
||||
namespace composer {
|
||||
namespace V2_4 {
|
||||
namespace passthrough {
|
||||
|
||||
class HwcLoader : public V2_3::passthrough::HwcLoader {
|
||||
public:
|
||||
static IComposer* load() {
|
||||
const hw_module_t* module = loadModule();
|
||||
if (!module) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto hal = createHalWithAdapter(module);
|
||||
if (!hal) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return createComposer(std::move(hal)).release();
|
||||
}
|
||||
|
||||
// create a ComposerHal instance
|
||||
static std::unique_ptr<hal::ComposerHal> createHal(const hw_module_t* module) {
|
||||
auto hal = std::make_unique<HwcHal>();
|
||||
return hal->initWithModule(module) ? std::move(hal) : nullptr;
|
||||
}
|
||||
|
||||
// create a ComposerHal instance, insert an adapter if necessary
|
||||
static std::unique_ptr<hal::ComposerHal> createHalWithAdapter(const hw_module_t* module) {
|
||||
bool adapted;
|
||||
hwc2_device_t* device = openDeviceWithAdapter(module, &adapted);
|
||||
if (!device) {
|
||||
return nullptr;
|
||||
}
|
||||
auto hal = std::make_unique<HwcHal>();
|
||||
return hal->initWithDevice(std::move(device), !adapted) ? std::move(hal) : nullptr;
|
||||
}
|
||||
|
||||
// create an IComposer instance
|
||||
static std::unique_ptr<IComposer> createComposer(std::unique_ptr<hal::ComposerHal> hal) {
|
||||
return hal::Composer::create(std::move(hal));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace passthrough
|
||||
} // namespace V2_4
|
||||
} // namespace composer
|
||||
} // namespace graphics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
42
graphics/composer/2.4/utils/vts/Android.bp
Normal file
42
graphics/composer/2.4/utils/vts/Android.bp
Normal file
|
@ -0,0 +1,42 @@
|
|||
//
|
||||
// Copyright 2019 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.
|
||||
//
|
||||
|
||||
cc_library_static {
|
||||
name: "android.hardware.graphics.composer@2.4-vts",
|
||||
defaults: ["hidl_defaults"],
|
||||
srcs: [
|
||||
"ComposerVts.cpp",
|
||||
],
|
||||
static_libs: [
|
||||
"VtsHalHidlTargetTestBase",
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
"android.hardware.graphics.composer@2.2",
|
||||
"android.hardware.graphics.composer@2.3-vts",
|
||||
"android.hardware.graphics.composer@2.3",
|
||||
"android.hardware.graphics.composer@2.4",
|
||||
],
|
||||
header_libs: [
|
||||
"android.hardware.graphics.composer@2.1-command-buffer",
|
||||
"android.hardware.graphics.composer@2.2-command-buffer",
|
||||
"android.hardware.graphics.composer@2.3-command-buffer",
|
||||
],
|
||||
cflags: [
|
||||
"-O0",
|
||||
"-g",
|
||||
"-DLOG_TAG=\"ComposerVts\"",
|
||||
],
|
||||
export_include_dirs: ["include"],
|
||||
}
|
69
graphics/composer/2.4/utils/vts/ComposerVts.cpp
Normal file
69
graphics/composer/2.4/utils/vts/ComposerVts.cpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright 2019 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.
|
||||
*/
|
||||
|
||||
#include <composer-vts/2.4/ComposerVts.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace graphics {
|
||||
namespace composer {
|
||||
namespace V2_4 {
|
||||
namespace vts {
|
||||
|
||||
using V2_1::Error;
|
||||
|
||||
Composer::Composer() : Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>()) {}
|
||||
|
||||
Composer::Composer(const std::string& name)
|
||||
: Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>(name)) {}
|
||||
|
||||
Composer::Composer(const sp<IComposer>& composer)
|
||||
: V2_3::vts::Composer(composer), mComposer(composer) {}
|
||||
|
||||
std::unique_ptr<ComposerClient> Composer::createClient() {
|
||||
std::unique_ptr<ComposerClient> client;
|
||||
mComposer->createClient_2_4([&client](const auto& tmpError, const auto& tmpClient) {
|
||||
ASSERT_EQ(Error::NONE, tmpError) << "failed to create client";
|
||||
client = std::make_unique<ComposerClient>(tmpClient);
|
||||
});
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
sp<IComposerClient> ComposerClient::getRaw() const {
|
||||
return mClient;
|
||||
}
|
||||
|
||||
Error ComposerClient::getDisplayCapabilities(
|
||||
Display display, std::vector<IComposerClient::DisplayCapability>* outCapabilities) {
|
||||
std::vector<IComposerClient::DisplayCapability> capabilities;
|
||||
Error error = Error::NONE;
|
||||
mClient->getDisplayCapabilities_2_4(display,
|
||||
[&](const auto& tmpError, const auto& tmpCapabilities) {
|
||||
error = tmpError;
|
||||
*outCapabilities = tmpCapabilities;
|
||||
});
|
||||
return error;
|
||||
}
|
||||
|
||||
} // namespace vts
|
||||
} // namespace V2_4
|
||||
} // namespace composer
|
||||
} // namespace graphics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright 2019 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <android/hardware/graphics/composer/2.4/IComposer.h>
|
||||
#include <android/hardware/graphics/composer/2.4/IComposerClient.h>
|
||||
#include <composer-vts/2.3/ComposerVts.h>
|
||||
#include <utils/StrongPointer.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace graphics {
|
||||
namespace composer {
|
||||
namespace V2_4 {
|
||||
namespace vts {
|
||||
|
||||
using common::V1_1::RenderIntent;
|
||||
using common::V1_2::ColorMode;
|
||||
using common::V1_2::Dataspace;
|
||||
using common::V1_2::Hdr;
|
||||
using common::V1_2::PixelFormat;
|
||||
using V2_1::Display;
|
||||
using V2_1::Error;
|
||||
using V2_4::IComposer;
|
||||
using V2_4::IComposerClient;
|
||||
|
||||
class ComposerClient;
|
||||
|
||||
// A wrapper to IComposer.
|
||||
class Composer : public V2_3::vts::Composer {
|
||||
public:
|
||||
Composer();
|
||||
explicit Composer(const std::string& name);
|
||||
|
||||
std::unique_ptr<ComposerClient> createClient();
|
||||
|
||||
protected:
|
||||
explicit Composer(const sp<IComposer>& composer);
|
||||
|
||||
private:
|
||||
const sp<IComposer> mComposer;
|
||||
};
|
||||
|
||||
// A wrapper to IComposerClient.
|
||||
class ComposerClient : public V2_3::vts::ComposerClient {
|
||||
public:
|
||||
explicit ComposerClient(const sp<IComposerClient>& client)
|
||||
: V2_3::vts::ComposerClient(client), mClient(client) {}
|
||||
|
||||
sp<IComposerClient> getRaw() const;
|
||||
|
||||
Error getDisplayCapabilities(
|
||||
Display display,
|
||||
std::vector<IComposerClient::DisplayCapability>* outDisplayCapabilities);
|
||||
|
||||
private:
|
||||
const sp<IComposerClient> mClient;
|
||||
};
|
||||
|
||||
} // namespace vts
|
||||
} // namespace V2_4
|
||||
} // namespace composer
|
||||
} // namespace graphics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
48
graphics/composer/2.4/vts/functional/Android.bp
Normal file
48
graphics/composer/2.4/vts/functional/Android.bp
Normal file
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// Copyright 2019 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.
|
||||
//
|
||||
|
||||
cc_test {
|
||||
name: "VtsHalGraphicsComposerV2_4TargetTest",
|
||||
defaults: ["VtsHalTargetTestDefaults"],
|
||||
srcs: ["VtsHalGraphicsComposerV2_4TargetTest.cpp"],
|
||||
|
||||
// TODO(b/64437680): Assume these libs are always available on the device.
|
||||
shared_libs: [
|
||||
"libfmq",
|
||||
"libhidltransport",
|
||||
"libsync",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.graphics.allocator@2.0",
|
||||
"android.hardware.graphics.composer@2.1",
|
||||
"android.hardware.graphics.composer@2.1-vts",
|
||||
"android.hardware.graphics.composer@2.2",
|
||||
"android.hardware.graphics.composer@2.2-vts",
|
||||
"android.hardware.graphics.composer@2.3",
|
||||
"android.hardware.graphics.composer@2.3-vts",
|
||||
"android.hardware.graphics.composer@2.4",
|
||||
"android.hardware.graphics.composer@2.4-vts",
|
||||
"android.hardware.graphics.mapper@2.0",
|
||||
"android.hardware.graphics.mapper@2.0-vts",
|
||||
"android.hardware.graphics.mapper@2.1",
|
||||
],
|
||||
header_libs: [
|
||||
"android.hardware.graphics.composer@2.1-command-buffer",
|
||||
"android.hardware.graphics.composer@2.2-command-buffer",
|
||||
"android.hardware.graphics.composer@2.3-command-buffer",
|
||||
"android.hardware.graphics.composer@2.4-command-buffer",
|
||||
],
|
||||
}
|
8
graphics/composer/2.4/vts/functional/OWNERS
Normal file
8
graphics/composer/2.4/vts/functional/OWNERS
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Graphics team
|
||||
lpy@google.com
|
||||
stoza@google.com
|
||||
vhau@google.com
|
||||
|
||||
# VTS team
|
||||
yim@google.com
|
||||
zhuoyao@google.com
|
|
@ -0,0 +1,197 @@
|
|||
/*
|
||||
* Copyright 2019 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "graphics_composer_hidl_hal_test@2.4"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android/hardware/graphics/mapper/2.0/IMapper.h>
|
||||
#include <composer-command-buffer/2.4/ComposerCommandBuffer.h>
|
||||
#include <composer-vts/2.1/GraphicsComposerCallback.h>
|
||||
#include <composer-vts/2.1/TestCommandReader.h>
|
||||
#include <composer-vts/2.4/ComposerVts.h>
|
||||
#include <mapper-vts/2.0/MapperVts.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace graphics {
|
||||
namespace composer {
|
||||
namespace V2_4 {
|
||||
namespace vts {
|
||||
namespace {
|
||||
|
||||
using common::V1_0::BufferUsage;
|
||||
using common::V1_1::RenderIntent;
|
||||
using common::V1_2::ColorMode;
|
||||
using common::V1_2::Dataspace;
|
||||
using common::V1_2::PixelFormat;
|
||||
using mapper::V2_0::IMapper;
|
||||
using mapper::V2_0::vts::Gralloc;
|
||||
|
||||
// Test environment for graphics.composer
|
||||
class GraphicsComposerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
public:
|
||||
// get the test environment singleton
|
||||
static GraphicsComposerHidlEnvironment* Instance() {
|
||||
static GraphicsComposerHidlEnvironment* instance = new GraphicsComposerHidlEnvironment;
|
||||
return instance;
|
||||
}
|
||||
|
||||
virtual void registerTestServices() override { registerTestService<IComposer>(); }
|
||||
|
||||
private:
|
||||
GraphicsComposerHidlEnvironment() {}
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(GraphicsComposerHidlEnvironment);
|
||||
};
|
||||
|
||||
class GraphicsComposerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
mComposer = std::make_unique<Composer>(
|
||||
GraphicsComposerHidlEnvironment::Instance()->getServiceName<IComposer>()));
|
||||
ASSERT_NO_FATAL_FAILURE(mComposerClient = mComposer->createClient());
|
||||
|
||||
mComposerCallback = new V2_1::vts::GraphicsComposerCallback;
|
||||
mComposerClient->registerCallback(mComposerCallback);
|
||||
|
||||
// assume the first display is primary and is never removed
|
||||
mPrimaryDisplay = waitForFirstDisplay();
|
||||
|
||||
mInvalidDisplayId = GetInvalidDisplayId();
|
||||
|
||||
// explicitly disable vsync
|
||||
mComposerClient->setVsyncEnabled(mPrimaryDisplay, false);
|
||||
mComposerCallback->setVsyncAllowed(false);
|
||||
|
||||
mWriter = std::make_unique<CommandWriterBase>(1024);
|
||||
mReader = std::make_unique<V2_1::vts::TestCommandReader>();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
ASSERT_EQ(0, mReader->mErrors.size());
|
||||
ASSERT_EQ(0, mReader->mCompositionChanges.size());
|
||||
if (mComposerCallback != nullptr) {
|
||||
EXPECT_EQ(0, mComposerCallback->getInvalidHotplugCount());
|
||||
EXPECT_EQ(0, mComposerCallback->getInvalidRefreshCount());
|
||||
EXPECT_EQ(0, mComposerCallback->getInvalidVsyncCount());
|
||||
}
|
||||
}
|
||||
|
||||
// returns an invalid display id (one that has not been registered to a
|
||||
// display. Currently assuming that a device will never have close to
|
||||
// std::numeric_limit<uint64_t>::max() displays registered while running tests
|
||||
Display GetInvalidDisplayId() {
|
||||
std::vector<Display> validDisplays = mComposerCallback->getDisplays();
|
||||
uint64_t id = std::numeric_limits<uint64_t>::max();
|
||||
while (id > 0) {
|
||||
if (std::find(validDisplays.begin(), validDisplays.end(), id) == validDisplays.end()) {
|
||||
return id;
|
||||
}
|
||||
id--;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void execute() { mComposerClient->execute(mReader.get(), mWriter.get()); }
|
||||
|
||||
std::unique_ptr<Composer> mComposer;
|
||||
std::unique_ptr<ComposerClient> mComposerClient;
|
||||
sp<V2_1::vts::GraphicsComposerCallback> mComposerCallback;
|
||||
// the first display and is assumed never to be removed
|
||||
Display mPrimaryDisplay;
|
||||
Display mInvalidDisplayId;
|
||||
std::unique_ptr<CommandWriterBase> mWriter;
|
||||
std::unique_ptr<V2_1::vts::TestCommandReader> mReader;
|
||||
|
||||
private:
|
||||
Display waitForFirstDisplay() {
|
||||
while (true) {
|
||||
std::vector<Display> displays = mComposerCallback->getDisplays();
|
||||
if (displays.empty()) {
|
||||
usleep(5 * 1000);
|
||||
continue;
|
||||
}
|
||||
|
||||
return displays[0];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Tests for IComposerClient::Command.
|
||||
class GraphicsComposerHidlCommandTest : public GraphicsComposerHidlTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
ASSERT_NO_FATAL_FAILURE(GraphicsComposerHidlTest::SetUp());
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(mGralloc = std::make_unique<Gralloc>());
|
||||
|
||||
mWriter = std::make_unique<CommandWriterBase>(1024);
|
||||
mReader = std::make_unique<V2_1::vts::TestCommandReader>();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
ASSERT_EQ(0, mReader->mErrors.size());
|
||||
ASSERT_NO_FATAL_FAILURE(GraphicsComposerHidlTest::TearDown());
|
||||
}
|
||||
|
||||
const native_handle_t* allocate() {
|
||||
IMapper::BufferDescriptorInfo info{};
|
||||
info.width = 64;
|
||||
info.height = 64;
|
||||
info.layerCount = 1;
|
||||
info.format = static_cast<common::V1_0::PixelFormat>(PixelFormat::RGBA_8888);
|
||||
info.usage =
|
||||
static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN | BufferUsage::CPU_READ_OFTEN);
|
||||
|
||||
return mGralloc->allocate(info);
|
||||
}
|
||||
|
||||
void execute() { mComposerClient->execute(mReader.get(), mWriter.get()); }
|
||||
|
||||
std::unique_ptr<CommandWriterBase> mWriter;
|
||||
std::unique_ptr<V2_1::vts::TestCommandReader> mReader;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Gralloc> mGralloc;
|
||||
};
|
||||
|
||||
TEST_F(GraphicsComposerHidlTest, getDisplayCapabilitiesBadDisplay) {
|
||||
std::vector<IComposerClient::DisplayCapability> capabilities;
|
||||
const auto error = mComposerClient->getDisplayCapabilities(mInvalidDisplayId, &capabilities);
|
||||
EXPECT_EQ(Error::BAD_DISPLAY, error);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace vts
|
||||
} // namespace V2_4
|
||||
} // namespace composer
|
||||
} // namespace graphics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
using android::hardware::graphics::composer::V2_4::vts::GraphicsComposerHidlEnvironment;
|
||||
::testing::AddGlobalTestEnvironment(GraphicsComposerHidlEnvironment::Instance());
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
GraphicsComposerHidlEnvironment::Instance()->init(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
return status;
|
||||
}
|
Loading…
Reference in a new issue