Update hwcomposer include paths
In preparation of new hwcomposer interface, updating
existing includes to include specific version.
Note: IComposerCommandBuffer.h was moved, renamed and clang
formated, but otherwise had no code changes.
Bug: 71513561
Test: compile
Change-Id: If34cb6f63012592a245708109590653ace7009f5
diff --git a/graphics/composer/2.1/default/Android.bp b/graphics/composer/2.1/default/Android.bp
index 140e50e..b46a1de 100644
--- a/graphics/composer/2.1/default/Android.bp
+++ b/graphics/composer/2.1/default/Android.bp
@@ -17,6 +17,9 @@
"libsync",
"libutils",
],
+ header_libs: [
+ "android.hardware.graphics.composer@2.1-command-buffer",
+ ],
}
cc_library_shared {
@@ -41,6 +44,9 @@
"libhwc2on1adapter",
"libhwc2onfbadapter",
],
+ header_libs: [
+ "android.hardware.graphics.composer@2.1-command-buffer",
+ ],
}
cc_binary {
@@ -65,10 +71,3 @@
"libutils",
],
}
-
-cc_library_static {
- name: "libhwcomposer-command-buffer",
- defaults: ["hidl_defaults"],
- shared_libs: ["android.hardware.graphics.composer@2.1"],
- export_include_dirs: ["."],
-}
diff --git a/graphics/composer/2.1/default/ComposerClient.cpp b/graphics/composer/2.1/default/ComposerClient.cpp
index 8aa9af0..0fcb9de 100644
--- a/graphics/composer/2.1/default/ComposerClient.cpp
+++ b/graphics/composer/2.1/default/ComposerClient.cpp
@@ -19,9 +19,8 @@
#include <android/hardware/graphics/mapper/2.0/IMapper.h>
#include <log/log.h>
-#include "ComposerClient.h"
#include "ComposerBase.h"
-#include "IComposerCommandBuffer.h"
+#include "ComposerClient.h"
namespace android {
namespace hardware {
diff --git a/graphics/composer/2.1/default/ComposerClient.h b/graphics/composer/2.1/default/ComposerClient.h
index fc5c223..104ed5a 100644
--- a/graphics/composer/2.1/default/ComposerClient.h
+++ b/graphics/composer/2.1/default/ComposerClient.h
@@ -21,8 +21,8 @@
#include <unordered_map>
#include <vector>
+#include <composer-command-buffer/2.1/ComposerCommandBuffer.h>
#include <hardware/hwcomposer2.h>
-#include "IComposerCommandBuffer.h"
#include "ComposerBase.h"
namespace android {
diff --git a/graphics/composer/2.1/default/OWNERS b/graphics/composer/2.1/default/OWNERS
index 3aa5fa1..4714be2 100644
--- a/graphics/composer/2.1/default/OWNERS
+++ b/graphics/composer/2.1/default/OWNERS
@@ -1,4 +1,5 @@
# Graphics team
+courtneygo@google.com
jessehall@google.com
olv@google.com
stoza@google.com
diff --git a/graphics/composer/2.1/utils/OWNERS b/graphics/composer/2.1/utils/OWNERS
new file mode 100644
index 0000000..d515a23
--- /dev/null
+++ b/graphics/composer/2.1/utils/OWNERS
@@ -0,0 +1,4 @@
+courtneygo@google.com
+jessehall@google.com
+olv@google.com
+stoza@google.com
diff --git a/graphics/composer/2.1/utils/command-buffer/Android.bp b/graphics/composer/2.1/utils/command-buffer/Android.bp
new file mode 100644
index 0000000..e8d41c2
--- /dev/null
+++ b/graphics/composer/2.1/utils/command-buffer/Android.bp
@@ -0,0 +1,7 @@
+cc_library_headers {
+ name: "android.hardware.graphics.composer@2.1-command-buffer",
+ defaults: ["hidl_defaults"],
+ vendor_available: true,
+ shared_libs: ["android.hardware.graphics.composer@2.1"],
+ export_include_dirs: ["include"],
+}
diff --git a/graphics/composer/2.1/default/IComposerCommandBuffer.h b/graphics/composer/2.1/utils/command-buffer/include/composer-command-buffer/2.1/ComposerCommandBuffer.h
similarity index 69%
rename from graphics/composer/2.1/default/IComposerCommandBuffer.h
rename to graphics/composer/2.1/utils/command-buffer/include/composer-command-buffer/2.1/ComposerCommandBuffer.h
index c752f8a..df529ec 100644
--- a/graphics/composer/2.1/default/IComposerCommandBuffer.h
+++ b/graphics/composer/2.1/utils/command-buffer/include/composer-command-buffer/2.1/ComposerCommandBuffer.h
@@ -18,7 +18,7 @@
#define ANDROID_HARDWARE_GRAPHICS_COMPOSER_COMMAND_BUFFER_H
#ifndef LOG_TAG
-#warn "IComposerCommandBuffer.h included without LOG_TAG"
+#warn "ComposerCommandBuffer.h included without LOG_TAG"
#endif
#undef LOG_NDEBUG
@@ -33,9 +33,9 @@
#include <string.h>
#include <android/hardware/graphics/composer/2.1/IComposer.h>
+#include <fmq/MessageQueue.h>
#include <log/log.h>
#include <sync/sync.h>
-#include <fmq/MessageQueue.h>
namespace android {
namespace hardware {
@@ -53,21 +53,15 @@
// This class helps build a command queue. Note that all sizes/lengths are in
// units of uint32_t's.
class CommandWriterBase {
-public:
- CommandWriterBase(uint32_t initialMaxSize)
- : mDataMaxSize(initialMaxSize)
- {
+ public:
+ CommandWriterBase(uint32_t initialMaxSize) : mDataMaxSize(initialMaxSize) {
mData = std::make_unique<uint32_t[]>(mDataMaxSize);
reset();
}
- virtual ~CommandWriterBase()
- {
- reset();
- }
+ virtual ~CommandWriterBase() { reset(); }
- void reset()
- {
+ void reset() {
mDataWritten = 0;
mCommandEnd = 0;
@@ -82,16 +76,14 @@
mTemporaryHandles.clear();
}
- IComposerClient::Command getCommand(uint32_t offset)
- {
+ IComposerClient::Command getCommand(uint32_t offset) {
uint32_t val = (offset < mDataWritten) ? mData[offset] : 0;
- return static_cast<IComposerClient::Command>(val &
- static_cast<uint32_t>(IComposerClient::Command::OPCODE_MASK));
+ return static_cast<IComposerClient::Command>(
+ val & static_cast<uint32_t>(IComposerClient::Command::OPCODE_MASK));
}
bool writeQueue(bool* outQueueChanged, uint32_t* outCommandLength,
- hidl_vec<hidl_handle>* outCommandHandles)
- {
+ hidl_vec<hidl_handle>* outCommandHandles) {
if (mDataWritten == 0) {
*outQueueChanged = false;
*outCommandLength = 0;
@@ -126,8 +118,7 @@
*outQueueChanged = false;
} else {
auto newQueue = std::make_unique<CommandQueueType>(mDataMaxSize);
- if (!newQueue->isValid() ||
- !newQueue->write(mData.get(), mDataWritten)) {
+ if (!newQueue->isValid() || !newQueue->write(mData.get(), mDataWritten)) {
ALOGE("failed to prepare a new message queue ");
return false;
}
@@ -137,39 +128,32 @@
}
*outCommandLength = mDataWritten;
- outCommandHandles->setToExternal(
- const_cast<hidl_handle*>(mDataHandles.data()),
- mDataHandles.size());
+ outCommandHandles->setToExternal(const_cast<hidl_handle*>(mDataHandles.data()),
+ mDataHandles.size());
return true;
}
- const MQDescriptorSync<uint32_t>* getMQDescriptor() const
- {
+ const MQDescriptorSync<uint32_t>* getMQDescriptor() const {
return (mQueue) ? mQueue->getDesc() : nullptr;
}
static constexpr uint16_t kSelectDisplayLength = 2;
- void selectDisplay(Display display)
- {
- beginCommand(IComposerClient::Command::SELECT_DISPLAY,
- kSelectDisplayLength);
+ void selectDisplay(Display display) {
+ beginCommand(IComposerClient::Command::SELECT_DISPLAY, kSelectDisplayLength);
write64(display);
endCommand();
}
static constexpr uint16_t kSelectLayerLength = 2;
- void selectLayer(Layer layer)
- {
- beginCommand(IComposerClient::Command::SELECT_LAYER,
- kSelectLayerLength);
+ void selectLayer(Layer layer) {
+ beginCommand(IComposerClient::Command::SELECT_LAYER, kSelectLayerLength);
write64(layer);
endCommand();
}
static constexpr uint16_t kSetErrorLength = 2;
- void setError(uint32_t location, Error error)
- {
+ void setError(uint32_t location, Error error) {
beginCommand(IComposerClient::Command::SET_ERROR, kSetErrorLength);
write(location);
writeSigned(static_cast<int32_t>(error));
@@ -177,25 +161,23 @@
}
static constexpr uint32_t kPresentOrValidateDisplayResultLength = 1;
- void setPresentOrValidateResult(uint32_t state) {
- beginCommand(IComposerClient::Command::SET_PRESENT_OR_VALIDATE_DISPLAY_RESULT, kPresentOrValidateDisplayResultLength);
- write(state);
- endCommand();
+ void setPresentOrValidateResult(uint32_t state) {
+ beginCommand(IComposerClient::Command::SET_PRESENT_OR_VALIDATE_DISPLAY_RESULT,
+ kPresentOrValidateDisplayResultLength);
+ write(state);
+ endCommand();
}
void setChangedCompositionTypes(const std::vector<Layer>& layers,
- const std::vector<IComposerClient::Composition>& types)
- {
+ const std::vector<IComposerClient::Composition>& types) {
size_t totalLayers = std::min(layers.size(), types.size());
size_t currentLayer = 0;
while (currentLayer < totalLayers) {
- size_t count = std::min(totalLayers - currentLayer,
- static_cast<size_t>(kMaxLength) / 3);
+ size_t count =
+ std::min(totalLayers - currentLayer, static_cast<size_t>(kMaxLength) / 3);
- beginCommand(
- IComposerClient::Command::SET_CHANGED_COMPOSITION_TYPES,
- count * 3);
+ beginCommand(IComposerClient::Command::SET_CHANGED_COMPOSITION_TYPES, count * 3);
for (size_t i = 0; i < count; i++) {
write64(layers[currentLayer + i]);
writeSigned(static_cast<int32_t>(types[currentLayer + i]));
@@ -206,20 +188,16 @@
}
}
- void setDisplayRequests(uint32_t displayRequestMask,
- const std::vector<Layer>& layers,
- const std::vector<uint32_t>& layerRequestMasks)
- {
- size_t totalLayers = std::min(layers.size(),
- layerRequestMasks.size());
+ void setDisplayRequests(uint32_t displayRequestMask, const std::vector<Layer>& layers,
+ const std::vector<uint32_t>& layerRequestMasks) {
+ size_t totalLayers = std::min(layers.size(), layerRequestMasks.size());
size_t currentLayer = 0;
while (currentLayer < totalLayers) {
- size_t count = std::min(totalLayers - currentLayer,
- static_cast<size_t>(kMaxLength - 1) / 3);
+ size_t count =
+ std::min(totalLayers - currentLayer, static_cast<size_t>(kMaxLength - 1) / 3);
- beginCommand(IComposerClient::Command::SET_DISPLAY_REQUESTS,
- 1 + count * 3);
+ beginCommand(IComposerClient::Command::SET_DISPLAY_REQUESTS, 1 + count * 3);
write(displayRequestMask);
for (size_t i = 0; i < count; i++) {
write64(layers[currentLayer + i]);
@@ -232,26 +210,21 @@
}
static constexpr uint16_t kSetPresentFenceLength = 1;
- void setPresentFence(int presentFence)
- {
- beginCommand(IComposerClient::Command::SET_PRESENT_FENCE,
- kSetPresentFenceLength);
+ void setPresentFence(int presentFence) {
+ beginCommand(IComposerClient::Command::SET_PRESENT_FENCE, kSetPresentFenceLength);
writeFence(presentFence);
endCommand();
}
- void setReleaseFences(const std::vector<Layer>& layers,
- const std::vector<int>& releaseFences)
- {
+ void setReleaseFences(const std::vector<Layer>& layers, const std::vector<int>& releaseFences) {
size_t totalLayers = std::min(layers.size(), releaseFences.size());
size_t currentLayer = 0;
while (currentLayer < totalLayers) {
- size_t count = std::min(totalLayers - currentLayer,
- static_cast<size_t>(kMaxLength) / 3);
+ size_t count =
+ std::min(totalLayers - currentLayer, static_cast<size_t>(kMaxLength) / 3);
- beginCommand(IComposerClient::Command::SET_RELEASE_FENCES,
- count * 3);
+ beginCommand(IComposerClient::Command::SET_RELEASE_FENCES, count * 3);
for (size_t i = 0; i < count; i++) {
write64(layers[currentLayer + i]);
writeFence(releaseFences[currentLayer + i]);
@@ -263,10 +236,8 @@
}
static constexpr uint16_t kSetColorTransformLength = 17;
- void setColorTransform(const float* matrix, ColorTransform hint)
- {
- beginCommand(IComposerClient::Command::SET_COLOR_TRANSFORM,
- kSetColorTransformLength);
+ void setColorTransform(const float* matrix, ColorTransform hint) {
+ beginCommand(IComposerClient::Command::SET_COLOR_TRANSFORM, kSetColorTransformLength);
for (int i = 0; i < 16; i++) {
writeFloat(matrix[i]);
}
@@ -274,10 +245,8 @@
endCommand();
}
- void setClientTarget(uint32_t slot, const native_handle_t* target,
- int acquireFence, Dataspace dataspace,
- const std::vector<IComposerClient::Rect>& damage)
- {
+ void setClientTarget(uint32_t slot, const native_handle_t* target, int acquireFence,
+ Dataspace dataspace, const std::vector<IComposerClient::Rect>& damage) {
bool doWrite = (damage.size() <= (kMaxLength - 4) / 4);
size_t length = 4 + ((doWrite) ? damage.size() * 4 : 0);
@@ -296,11 +265,8 @@
}
static constexpr uint16_t kSetOutputBufferLength = 3;
- void setOutputBuffer(uint32_t slot, const native_handle_t* buffer,
- int releaseFence)
- {
- beginCommand(IComposerClient::Command::SET_OUTPUT_BUFFER,
- kSetOutputBufferLength);
+ void setOutputBuffer(uint32_t slot, const native_handle_t* buffer, int releaseFence) {
+ beginCommand(IComposerClient::Command::SET_OUTPUT_BUFFER, kSetOutputBufferLength);
write(slot);
writeHandle(buffer, true);
writeFence(releaseFence);
@@ -308,67 +274,53 @@
}
static constexpr uint16_t kValidateDisplayLength = 0;
- void validateDisplay()
- {
- beginCommand(IComposerClient::Command::VALIDATE_DISPLAY,
- kValidateDisplayLength);
+ void validateDisplay() {
+ beginCommand(IComposerClient::Command::VALIDATE_DISPLAY, kValidateDisplayLength);
endCommand();
}
static constexpr uint16_t kPresentOrValidateDisplayLength = 0;
- void presentOrvalidateDisplay()
- {
+ void presentOrvalidateDisplay() {
beginCommand(IComposerClient::Command::PRESENT_OR_VALIDATE_DISPLAY,
kPresentOrValidateDisplayLength);
endCommand();
}
static constexpr uint16_t kAcceptDisplayChangesLength = 0;
- void acceptDisplayChanges()
- {
- beginCommand(IComposerClient::Command::ACCEPT_DISPLAY_CHANGES,
- kAcceptDisplayChangesLength);
+ void acceptDisplayChanges() {
+ beginCommand(IComposerClient::Command::ACCEPT_DISPLAY_CHANGES, kAcceptDisplayChangesLength);
endCommand();
}
static constexpr uint16_t kPresentDisplayLength = 0;
- void presentDisplay()
- {
- beginCommand(IComposerClient::Command::PRESENT_DISPLAY,
- kPresentDisplayLength);
+ void presentDisplay() {
+ beginCommand(IComposerClient::Command::PRESENT_DISPLAY, kPresentDisplayLength);
endCommand();
}
static constexpr uint16_t kSetLayerCursorPositionLength = 2;
- void setLayerCursorPosition(int32_t x, int32_t y)
- {
+ void setLayerCursorPosition(int32_t x, int32_t y) {
beginCommand(IComposerClient::Command::SET_LAYER_CURSOR_POSITION,
- kSetLayerCursorPositionLength);
+ kSetLayerCursorPositionLength);
writeSigned(x);
writeSigned(y);
endCommand();
}
static constexpr uint16_t kSetLayerBufferLength = 3;
- void setLayerBuffer(uint32_t slot, const native_handle_t* buffer,
- int acquireFence)
- {
- beginCommand(IComposerClient::Command::SET_LAYER_BUFFER,
- kSetLayerBufferLength);
+ void setLayerBuffer(uint32_t slot, const native_handle_t* buffer, int acquireFence) {
+ beginCommand(IComposerClient::Command::SET_LAYER_BUFFER, kSetLayerBufferLength);
write(slot);
writeHandle(buffer, true);
writeFence(acquireFence);
endCommand();
}
- void setLayerSurfaceDamage(
- const std::vector<IComposerClient::Rect>& damage)
- {
+ void setLayerSurfaceDamage(const std::vector<IComposerClient::Rect>& damage) {
bool doWrite = (damage.size() <= kMaxLength / 4);
size_t length = (doWrite) ? damage.size() * 4 : 0;
- beginCommand(IComposerClient::Command::SET_LAYER_SURFACE_DAMAGE,
- length);
+ beginCommand(IComposerClient::Command::SET_LAYER_SURFACE_DAMAGE, length);
// When there are too many rectangles in the damage region and doWrite
// is false, we write no rectangle at all which means the entire
// layer is damaged.
@@ -379,94 +331,76 @@
}
static constexpr uint16_t kSetLayerBlendModeLength = 1;
- void setLayerBlendMode(IComposerClient::BlendMode mode)
- {
- beginCommand(IComposerClient::Command::SET_LAYER_BLEND_MODE,
- kSetLayerBlendModeLength);
+ void setLayerBlendMode(IComposerClient::BlendMode mode) {
+ beginCommand(IComposerClient::Command::SET_LAYER_BLEND_MODE, kSetLayerBlendModeLength);
writeSigned(static_cast<int32_t>(mode));
endCommand();
}
static constexpr uint16_t kSetLayerColorLength = 1;
- void setLayerColor(IComposerClient::Color color)
- {
- beginCommand(IComposerClient::Command::SET_LAYER_COLOR,
- kSetLayerColorLength);
+ void setLayerColor(IComposerClient::Color color) {
+ beginCommand(IComposerClient::Command::SET_LAYER_COLOR, kSetLayerColorLength);
writeColor(color);
endCommand();
}
static constexpr uint16_t kSetLayerCompositionTypeLength = 1;
- void setLayerCompositionType(IComposerClient::Composition type)
- {
+ void setLayerCompositionType(IComposerClient::Composition type) {
beginCommand(IComposerClient::Command::SET_LAYER_COMPOSITION_TYPE,
- kSetLayerCompositionTypeLength);
+ kSetLayerCompositionTypeLength);
writeSigned(static_cast<int32_t>(type));
endCommand();
}
static constexpr uint16_t kSetLayerDataspaceLength = 1;
- void setLayerDataspace(Dataspace dataspace)
- {
- beginCommand(IComposerClient::Command::SET_LAYER_DATASPACE,
- kSetLayerDataspaceLength);
+ void setLayerDataspace(Dataspace dataspace) {
+ beginCommand(IComposerClient::Command::SET_LAYER_DATASPACE, kSetLayerDataspaceLength);
writeSigned(static_cast<int32_t>(dataspace));
endCommand();
}
static constexpr uint16_t kSetLayerDisplayFrameLength = 4;
- void setLayerDisplayFrame(const IComposerClient::Rect& frame)
- {
+ void setLayerDisplayFrame(const IComposerClient::Rect& frame) {
beginCommand(IComposerClient::Command::SET_LAYER_DISPLAY_FRAME,
- kSetLayerDisplayFrameLength);
+ kSetLayerDisplayFrameLength);
writeRect(frame);
endCommand();
}
static constexpr uint16_t kSetLayerPlaneAlphaLength = 1;
- void setLayerPlaneAlpha(float alpha)
- {
- beginCommand(IComposerClient::Command::SET_LAYER_PLANE_ALPHA,
- kSetLayerPlaneAlphaLength);
+ void setLayerPlaneAlpha(float alpha) {
+ beginCommand(IComposerClient::Command::SET_LAYER_PLANE_ALPHA, kSetLayerPlaneAlphaLength);
writeFloat(alpha);
endCommand();
}
static constexpr uint16_t kSetLayerSidebandStreamLength = 1;
- void setLayerSidebandStream(const native_handle_t* stream)
- {
+ void setLayerSidebandStream(const native_handle_t* stream) {
beginCommand(IComposerClient::Command::SET_LAYER_SIDEBAND_STREAM,
- kSetLayerSidebandStreamLength);
+ kSetLayerSidebandStreamLength);
writeHandle(stream);
endCommand();
}
static constexpr uint16_t kSetLayerSourceCropLength = 4;
- void setLayerSourceCrop(const IComposerClient::FRect& crop)
- {
- beginCommand(IComposerClient::Command::SET_LAYER_SOURCE_CROP,
- kSetLayerSourceCropLength);
+ void setLayerSourceCrop(const IComposerClient::FRect& crop) {
+ beginCommand(IComposerClient::Command::SET_LAYER_SOURCE_CROP, kSetLayerSourceCropLength);
writeFRect(crop);
endCommand();
}
static constexpr uint16_t kSetLayerTransformLength = 1;
- void setLayerTransform(Transform transform)
- {
- beginCommand(IComposerClient::Command::SET_LAYER_TRANSFORM,
- kSetLayerTransformLength);
+ void setLayerTransform(Transform transform) {
+ beginCommand(IComposerClient::Command::SET_LAYER_TRANSFORM, kSetLayerTransformLength);
writeSigned(static_cast<int32_t>(transform));
endCommand();
}
- void setLayerVisibleRegion(
- const std::vector<IComposerClient::Rect>& visible)
- {
+ void setLayerVisibleRegion(const std::vector<IComposerClient::Rect>& visible) {
bool doWrite = (visible.size() <= kMaxLength / 4);
size_t length = (doWrite) ? visible.size() * 4 : 0;
- beginCommand(IComposerClient::Command::SET_LAYER_VISIBLE_REGION,
- length);
+ beginCommand(IComposerClient::Command::SET_LAYER_VISIBLE_REGION, length);
// When there are too many rectangles in the visible region and
// doWrite is false, we write no rectangle at all which means the
// entire layer is visible.
@@ -477,20 +411,16 @@
}
static constexpr uint16_t kSetLayerZOrderLength = 1;
- void setLayerZOrder(uint32_t z)
- {
- beginCommand(IComposerClient::Command::SET_LAYER_Z_ORDER,
- kSetLayerZOrderLength);
+ void setLayerZOrder(uint32_t z) {
+ beginCommand(IComposerClient::Command::SET_LAYER_Z_ORDER, kSetLayerZOrderLength);
write(z);
endCommand();
}
-protected:
- void beginCommand(IComposerClient::Command command, uint16_t length)
- {
+ protected:
+ void beginCommand(IComposerClient::Command command, uint16_t length) {
if (mCommandEnd) {
- LOG_FATAL("endCommand was not called before command 0x%x",
- command);
+ LOG_FATAL("endCommand was not called before command 0x%x", command);
}
growData(1 + length);
@@ -499,8 +429,7 @@
mCommandEnd = mDataWritten + length;
}
- void endCommand()
- {
+ void endCommand() {
if (!mCommandEnd) {
LOG_FATAL("beginCommand was not called");
} else if (mDataWritten > mCommandEnd) {
@@ -516,67 +445,48 @@
mCommandEnd = 0;
}
- void write(uint32_t val)
- {
- mData[mDataWritten++] = val;
- }
+ void write(uint32_t val) { mData[mDataWritten++] = val; }
- void writeSigned(int32_t val)
- {
- memcpy(&mData[mDataWritten++], &val, sizeof(val));
- }
+ void writeSigned(int32_t val) { memcpy(&mData[mDataWritten++], &val, sizeof(val)); }
- void writeFloat(float val)
- {
- memcpy(&mData[mDataWritten++], &val, sizeof(val));
- }
+ void writeFloat(float val) { memcpy(&mData[mDataWritten++], &val, sizeof(val)); }
- void write64(uint64_t val)
- {
+ void write64(uint64_t val) {
uint32_t lo = static_cast<uint32_t>(val & 0xffffffff);
uint32_t hi = static_cast<uint32_t>(val >> 32);
write(lo);
write(hi);
}
- void writeRect(const IComposerClient::Rect& rect)
- {
+ void writeRect(const IComposerClient::Rect& rect) {
writeSigned(rect.left);
writeSigned(rect.top);
writeSigned(rect.right);
writeSigned(rect.bottom);
}
- void writeRegion(const std::vector<IComposerClient::Rect>& region)
- {
+ void writeRegion(const std::vector<IComposerClient::Rect>& region) {
for (const auto& rect : region) {
writeRect(rect);
}
}
- void writeFRect(const IComposerClient::FRect& rect)
- {
+ void writeFRect(const IComposerClient::FRect& rect) {
writeFloat(rect.left);
writeFloat(rect.top);
writeFloat(rect.right);
writeFloat(rect.bottom);
}
- void writeColor(const IComposerClient::Color& color)
- {
- write((color.r << 0) |
- (color.g << 8) |
- (color.b << 16) |
- (color.a << 24));
+ void writeColor(const IComposerClient::Color& color) {
+ write((color.r << 0) | (color.g << 8) | (color.b << 16) | (color.a << 24));
}
// ownership of handle is not transferred
- void writeHandle(const native_handle_t* handle, bool useCache)
- {
+ void writeHandle(const native_handle_t* handle, bool useCache) {
if (!handle) {
- writeSigned(static_cast<int32_t>((useCache) ?
- IComposerClient::HandleIndex::CACHED :
- IComposerClient::HandleIndex::EMPTY));
+ writeSigned(static_cast<int32_t>((useCache) ? IComposerClient::HandleIndex::CACHED
+ : IComposerClient::HandleIndex::EMPTY));
return;
}
@@ -584,14 +494,10 @@
writeSigned(mDataHandles.size() - 1);
}
- void writeHandle(const native_handle_t* handle)
- {
- writeHandle(handle, false);
- }
+ void writeHandle(const native_handle_t* handle) { writeHandle(handle, false); }
// ownership of fence is transferred
- void writeFence(int fence)
- {
+ void writeFence(int fence) {
native_handle_t* handle = nullptr;
if (fence >= 0) {
handle = getTemporaryHandle(1, 0);
@@ -607,8 +513,7 @@
writeHandle(handle);
}
- native_handle_t* getTemporaryHandle(int numFds, int numInts)
- {
+ native_handle_t* getTemporaryHandle(int numFds, int numInts) {
native_handle_t* handle = native_handle_create(numFds, numInts);
if (handle) {
mTemporaryHandles.push_back(handle);
@@ -616,16 +521,14 @@
return handle;
}
- static constexpr uint16_t kMaxLength =
- std::numeric_limits<uint16_t>::max();
+ static constexpr uint16_t kMaxLength = std::numeric_limits<uint16_t>::max();
-private:
- void growData(uint32_t grow)
- {
+ private:
+ void growData(uint32_t grow) {
uint32_t newWritten = mDataWritten + grow;
if (newWritten < mDataWritten) {
- LOG_ALWAYS_FATAL("buffer overflowed; data written %" PRIu32
- ", growing by %" PRIu32, mDataWritten, grow);
+ LOG_ALWAYS_FATAL("buffer overflowed; data written %" PRIu32 ", growing by %" PRIu32,
+ mDataWritten, grow);
}
if (newWritten <= mDataMaxSize) {
@@ -651,7 +554,7 @@
uint32_t mCommandEnd;
std::vector<hidl_handle> mDataHandles;
- std::vector<native_handle_t *> mTemporaryHandles;
+ std::vector<native_handle_t*> mTemporaryHandles;
std::unique_ptr<CommandQueueType> mQueue;
};
@@ -659,14 +562,10 @@
// This class helps parse a command queue. Note that all sizes/lengths are in
// units of uint32_t's.
class CommandReaderBase {
-public:
- CommandReaderBase() : mDataMaxSize(0)
- {
- reset();
- }
+ public:
+ CommandReaderBase() : mDataMaxSize(0) { reset(); }
- bool setMQDescriptor(const MQDescriptorSync<uint32_t>& descriptor)
- {
+ bool setMQDescriptor(const MQDescriptorSync<uint32_t>& descriptor) {
mQueue = std::make_unique<CommandQueueType>(descriptor, false);
if (mQueue->isValid()) {
return true;
@@ -676,9 +575,7 @@
}
}
- bool readQueue(uint32_t commandLength,
- const hidl_vec<hidl_handle>& commandHandles)
- {
+ bool readQueue(uint32_t commandLength, const hidl_vec<hidl_handle>& commandHandles) {
if (!mQueue) {
return false;
}
@@ -689,8 +586,7 @@
mData = std::make_unique<uint32_t[]>(mDataMaxSize);
}
- if (commandLength > mDataMaxSize ||
- !mQueue->read(mData.get(), commandLength)) {
+ if (commandLength > mDataMaxSize || !mQueue->read(mData.get(), commandLength)) {
ALOGE("failed to read commands from message queue");
return false;
}
@@ -699,15 +595,13 @@
mDataRead = 0;
mCommandBegin = 0;
mCommandEnd = 0;
- mDataHandles.setToExternal(
- const_cast<hidl_handle*>(commandHandles.data()),
- commandHandles.size());
+ mDataHandles.setToExternal(const_cast<hidl_handle*>(commandHandles.data()),
+ commandHandles.size());
return true;
}
- void reset()
- {
+ void reset() {
mDataSize = 0;
mDataRead = 0;
mCommandBegin = 0;
@@ -715,15 +609,10 @@
mDataHandles.setToExternal(nullptr, 0);
}
-protected:
- bool isEmpty() const
- {
- return (mDataRead >= mDataSize);
- }
+ protected:
+ bool isEmpty() const { return (mDataRead >= mDataSize); }
- bool beginCommand(IComposerClient::Command* outCommand,
- uint16_t* outLength)
- {
+ bool beginCommand(IComposerClient::Command* outCommand, uint16_t* outLength) {
if (mCommandEnd) {
LOG_FATAL("endCommand was not called for last command");
}
@@ -734,13 +623,11 @@
static_cast<uint32_t>(IComposerClient::Command::LENGTH_MASK);
uint32_t val = read();
- *outCommand = static_cast<IComposerClient::Command>(
- val & opcode_mask);
+ *outCommand = static_cast<IComposerClient::Command>(val & opcode_mask);
*outLength = static_cast<uint16_t>(val & length_mask);
if (mDataRead + *outLength > mDataSize) {
- ALOGE("command 0x%x has invalid command length %" PRIu16,
- *outCommand, *outLength);
+ ALOGE("command 0x%x has invalid command length %" PRIu16, *outCommand, *outLength);
// undo the read() above
mDataRead--;
return false;
@@ -751,8 +638,7 @@
return true;
}
- void endCommand()
- {
+ void endCommand() {
if (!mCommandEnd) {
LOG_FATAL("beginCommand was not called");
} else if (mDataRead > mCommandEnd) {
@@ -767,83 +653,68 @@
mCommandEnd = 0;
}
- uint32_t getCommandLoc() const
- {
- return mCommandBegin;
- }
+ uint32_t getCommandLoc() const { return mCommandBegin; }
- uint32_t read()
- {
- return mData[mDataRead++];
- }
+ uint32_t read() { return mData[mDataRead++]; }
- int32_t readSigned()
- {
+ int32_t readSigned() {
int32_t val;
memcpy(&val, &mData[mDataRead++], sizeof(val));
return val;
}
- float readFloat()
- {
+ float readFloat() {
float val;
memcpy(&val, &mData[mDataRead++], sizeof(val));
return val;
}
- uint64_t read64()
- {
+ uint64_t read64() {
uint32_t lo = read();
uint32_t hi = read();
return (static_cast<uint64_t>(hi) << 32) | lo;
}
- IComposerClient::Color readColor()
- {
+ IComposerClient::Color readColor() {
uint32_t val = read();
return IComposerClient::Color{
- static_cast<uint8_t>((val >> 0) & 0xff),
- static_cast<uint8_t>((val >> 8) & 0xff),
- static_cast<uint8_t>((val >> 16) & 0xff),
- static_cast<uint8_t>((val >> 24) & 0xff),
+ static_cast<uint8_t>((val >> 0) & 0xff), static_cast<uint8_t>((val >> 8) & 0xff),
+ static_cast<uint8_t>((val >> 16) & 0xff), static_cast<uint8_t>((val >> 24) & 0xff),
};
}
// ownership of handle is not transferred
- const native_handle_t* readHandle(bool* outUseCache)
- {
+ const native_handle_t* readHandle(bool* outUseCache) {
const native_handle_t* handle = nullptr;
int32_t index = readSigned();
switch (index) {
- case static_cast<int32_t>(IComposerClient::HandleIndex::EMPTY):
- *outUseCache = false;
- break;
- case static_cast<int32_t>(IComposerClient::HandleIndex::CACHED):
- *outUseCache = true;
- break;
- default:
- if (static_cast<size_t>(index) < mDataHandles.size()) {
- handle = mDataHandles[index].getNativeHandle();
- } else {
- ALOGE("invalid handle index %zu", static_cast<size_t>(index));
- }
- *outUseCache = false;
- break;
+ case static_cast<int32_t>(IComposerClient::HandleIndex::EMPTY):
+ *outUseCache = false;
+ break;
+ case static_cast<int32_t>(IComposerClient::HandleIndex::CACHED):
+ *outUseCache = true;
+ break;
+ default:
+ if (static_cast<size_t>(index) < mDataHandles.size()) {
+ handle = mDataHandles[index].getNativeHandle();
+ } else {
+ ALOGE("invalid handle index %zu", static_cast<size_t>(index));
+ }
+ *outUseCache = false;
+ break;
}
return handle;
}
- const native_handle_t* readHandle()
- {
+ const native_handle_t* readHandle() {
bool useCache;
return readHandle(&useCache);
}
// ownership of fence is transferred
- int readFence()
- {
+ int readFence() {
auto handle = readHandle();
if (!handle || handle->numFds == 0) {
return -1;
@@ -864,7 +735,7 @@
return fd;
}
-private:
+ private:
std::unique_ptr<CommandQueueType> mQueue;
uint32_t mDataMaxSize;
std::unique_ptr<uint32_t[]> mData;
@@ -879,10 +750,10 @@
hidl_vec<hidl_handle> mDataHandles;
};
-} // namespace V2_1
-} // namespace composer
-} // namespace graphics
-} // namespace hardware
-} // namespace android
+} // namespace V2_1
+} // namespace composer
+} // namespace graphics
+} // namespace hardware
+} // namespace android
-#endif // ANDROID_HARDWARE_GRAPHICS_COMPOSER_COMMAND_BUFFER_H
+#endif // ANDROID_HARDWARE_GRAPHICS_COMPOSER_COMMAND_BUFFER_H
diff --git a/graphics/composer/2.1/vts/functional/Android.bp b/graphics/composer/2.1/vts/functional/Android.bp
index 1ba7c9a..40f18c0 100644
--- a/graphics/composer/2.1/vts/functional/Android.bp
+++ b/graphics/composer/2.1/vts/functional/Android.bp
@@ -28,9 +28,11 @@
"libsync",
],
static_libs: [
- "libhwcomposer-command-buffer",
"VtsHalHidlTargetTestBase",
],
+ header_libs: [
+ "android.hardware.graphics.composer@2.1-command-buffer",
+ ],
cflags: [
"-Wall",
"-Wextra",
@@ -58,7 +60,9 @@
"android.hardware.graphics.mapper@2.0",
"libVtsHalGraphicsComposerTestUtils",
"libVtsHalGraphicsMapperTestUtils",
- "libhwcomposer-command-buffer",
"libnativehelper",
],
+ header_libs: [
+ "android.hardware.graphics.composer@2.1-command-buffer",
+ ],
}
diff --git a/graphics/composer/2.1/vts/functional/TestCommandReader.h b/graphics/composer/2.1/vts/functional/TestCommandReader.h
index 657a463..ae25d2d 100644
--- a/graphics/composer/2.1/vts/functional/TestCommandReader.h
+++ b/graphics/composer/2.1/vts/functional/TestCommandReader.h
@@ -17,7 +17,7 @@
#ifndef TEST_COMMAND_READER_H
#define TEST_COMMAND_READER_H
-#include <IComposerCommandBuffer.h>
+#include <composer-command-buffer/2.1/ComposerCommandBuffer.h>
namespace android {
namespace hardware {
diff --git a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.h b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.h
index 4e69f61..29b9de3 100644
--- a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.h
+++ b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.h
@@ -23,8 +23,8 @@
#include <unordered_set>
#include <vector>
-#include <IComposerCommandBuffer.h>
#include <android/hardware/graphics/composer/2.1/IComposer.h>
+#include <composer-command-buffer/2.1/ComposerCommandBuffer.h>
#include <utils/StrongPointer.h>
#include "TestCommandReader.h"