dvr_api.cpp \
dvr_buffer.cpp \
dvr_buffer_queue.cpp \
+ dvr_hardware_composer_client.cpp \
dvr_surface.cpp \
vsync_client_api.cpp \
libdisplay \
libvrsensor \
libvirtualtouchpadclient \
+ libvr_hwc-impl \
+ libvr_hwc-binder \
LOCAL_SHARED_LIBRARIES := \
android.hardware.graphics.bufferqueue@1.0 \
android.hidl.token@1.0-utils \
libandroid_runtime \
libbase \
+ libnativewindow \
include $(BUILD_STATIC_LIBRARY)
// Headers not yet moved into libdvr.
// TODO(jwcai) Move these once their callers are moved into Google3.
+#include <dvr/dvr_hardware_composer_client.h>
#include <dvr/pose_client.h>
#include <dvr/virtual_touchpad_client.h>
dvr_api->virtual_touchpad_touch_ = dvrVirtualTouchpadTouch;
dvr_api->virtual_touchpad_button_state_ = dvrVirtualTouchpadButtonState;
+ // dvr_hardware_composer_client.h
+ dvr_api->hwc_create_client_ = dvrHwcCreateClient;
+ dvr_api->hwc_client_destroy_ = dvrHwcClientDestroy;
+ dvr_api->hwc_frame_destroy_ = dvrHwcFrameDestroy;
+ dvr_api->hwc_frame_get_display_id_ = dvrHwcFrameGetDisplayId;
+ dvr_api->hwc_frame_get_display_width_ = dvrHwcFrameGetDisplayWidth;
+ dvr_api->hwc_frame_get_display_height_ = dvrHwcFrameGetDisplayHeight;
+ dvr_api->hwc_frame_get_layer_count_ = dvrHwcFrameGetLayerCount;
+ dvr_api->hwc_frame_get_layer_id_ = dvrHwcFrameGetLayerId;
+ dvr_api->hwc_frame_get_layer_buffer_ = dvrHwcFrameGetLayerBuffer;
+ dvr_api->hwc_frame_get_layer_fence_ = dvrHwcFrameGetLayerFence;
+ dvr_api->hwc_frame_get_layer_display_frame_ =
+ dvrHwcFrameGetLayerDisplayFrame;
+ dvr_api->hwc_frame_get_layer_crop_ = dvrHwcFrameGetLayerCrop;
+ dvr_api->hwc_frame_get_layer_blend_mode_ = dvrHwcFrameGetLayerBlendMode;
+ dvr_api->hwc_frame_get_layer_alpha_ = dvrHwcFrameGetLayerAlpha;
+ dvr_api->hwc_frame_get_layer_type_ = dvrHwcFrameGetLayerType;
+ dvr_api->hwc_frame_get_layer_application_id_ =
+ dvrHwcFrameGetLayerApplicationId;
+
return 0;
}
return -EINVAL;
-#include "private/android/dvr_hardware_composer_client.h"
+#include "include/dvr/dvr_hardware_composer_client.h"
#include <android/dvr/IVrComposer.h>
#include <android/dvr/BnVrComposerCallback.h>
+#include <android/hardware_buffer.h>
#include <binder/IServiceManager.h>
#include <private/android/AHardwareBufferHelpers.h>
class HwcCallback : public android::dvr::BnVrComposerCallback {
public:
- explicit HwcCallback(DvrHwcOnFrameCallback callback);
+ explicit HwcCallback(DvrHwcOnFrameCallback callback,
+ void* client_state);
~HwcCallback() override;
std::unique_ptr<DvrHwcFrame> DequeueFrame();
android::dvr::ParcelableUniqueFd* fence) override;
DvrHwcOnFrameCallback callback_;
+ void* client_state_;
HwcCallback(const HwcCallback&) = delete;
void operator=(const HwcCallback&) = delete;
};
-HwcCallback::HwcCallback(DvrHwcOnFrameCallback callback)
- : callback_(callback) {}
+HwcCallback::HwcCallback(DvrHwcOnFrameCallback callback, void* client_state)
+ : callback_(callback), client_state_(client_state) {}
HwcCallback::~HwcCallback() {}
std::unique_ptr<DvrHwcFrame> dvr_frame(new DvrHwcFrame());
dvr_frame->frame = frame.frame();
- fence->set_fence(android::base::unique_fd(callback_(dvr_frame.release())));
+ fence->set_fence(android::base::unique_fd(callback_(client_state_,
+ dvr_frame.release())));
return android::binder::Status::ok();
}
android::sp<HwcCallback> callback;
};
-DvrHwcClient* dvrHwcCreateClient(DvrHwcOnFrameCallback callback) {
+DvrHwcClient* dvrHwcCreateClient(DvrHwcOnFrameCallback callback, void* data) {
std::unique_ptr<DvrHwcClient> client(new DvrHwcClient());
android::sp<android::IServiceManager> sm(android::defaultServiceManager());
if (!client->composer.get())
return nullptr;
- client->callback = new HwcCallback(callback);
+ client->callback = new HwcCallback(callback, data);
android::binder::Status status = client->composer->registerObserver(
client->callback);
if (!status.isOk())
return client.release();
}
+void dvrHwcClientDestroy(DvrHwcClient* client) {
+ delete client;
+}
+
void dvrHwcFrameDestroy(DvrHwcFrame* frame) {
delete frame;
}
return frame->frame.display_id;
}
+int32_t dvrHwcFrameGetDisplayWidth(DvrHwcFrame* frame) {
+ return frame->frame.display_width;
+}
+
+int32_t dvrHwcFrameGetDisplayHeight(DvrHwcFrame* frame) {
+ return frame->frame.display_height;
+}
+
+bool dvrHwcFrameGetDisplayRemoved(DvrHwcFrame* frame) {
+ return frame->frame.removed;
+}
+
size_t dvrHwcFrameGetLayerCount(DvrHwcFrame* frame) {
return frame->frame.layers.size();
}
#include <stddef.h>
#include <stdint.h>
+#include <dvr/dvr_hardware_composer_defs.h>
#include <jni.h>
#ifdef __cplusplus
typedef int (*DvrVirtualTouchpadButtonStatePtr)(DvrVirtualTouchpad* client,
int touchpad, int buttons);
+// dvr_hardware_composer_client.h
+typedef struct AHardwareBuffer AHardwareBuffer;
+typedef struct DvrHwcClient DvrHwcClient;
+typedef struct DvrHwcFrame DvrHwcFrame;
+typedef int(*DvrHwcOnFrameCallback)(void* client_state, DvrHwcFrame* frame);
+typedef DvrHwcClient* (*DvrHwcCreateClientPtr)(DvrHwcOnFrameCallback callback,
+ void* client_state);
+typedef void (*DvrHwcClientDestroyPtr)(DvrHwcClient* client);
+typedef void (*DvrHwcFrameDestroyPtr)(DvrHwcFrame* frame);
+typedef Display (*DvrHwcFrameGetDisplayIdPtr)(DvrHwcFrame* frame);
+typedef int32_t (*DvrHwcFrameGetDisplayWidthPtr)(DvrHwcFrame* frame);
+typedef int32_t (*DvrHwcFrameGetDisplayHeightPtr)(DvrHwcFrame* frame);
+typedef bool (*DvrHwcFrameGetDisplayRemovedPtr)(DvrHwcFrame* frame);
+typedef size_t (*DvrHwcFrameGetLayerCountPtr)(DvrHwcFrame* frame);
+typedef Layer (*DvrHwcFrameGetLayerIdPtr)(DvrHwcFrame* frame, size_t layer_index);
+typedef AHardwareBuffer* (*DvrHwcFrameGetLayerBufferPtr)(DvrHwcFrame* frame,
+ size_t layer_index);
+typedef int (*DvrHwcFrameGetLayerFencePtr)(DvrHwcFrame* frame,
+ size_t layer_index);
+typedef Recti (*DvrHwcFrameGetLayerDisplayFramePtr)(DvrHwcFrame* frame,
+ size_t layer_index);
+typedef Rectf (*DvrHwcFrameGetLayerCropPtr)(DvrHwcFrame* frame,
+ size_t layer_index);
+typedef BlendMode (*DvrHwcFrameGetLayerBlendModePtr)(DvrHwcFrame* frame,
+ size_t layer_index);
+typedef float (*DvrHwcFrameGetLayerAlphaPtr)(DvrHwcFrame* frame,
+ size_t layer_index);
+typedef uint32_t (*DvrHwcFrameGetLayerTypePtr)(DvrHwcFrame* frame,
+ size_t layer_index);
+typedef uint32_t (*DvrHwcFrameGetLayerApplicationIdPtr)(DvrHwcFrame* frame,
+ size_t layer_index);
+
struct DvrApi_v1 {
// Display manager client
DvrDisplayManagerClientCreatePtr display_manager_client_create_;
DvrVirtualTouchpadDetachPtr virtual_touchpad_detach_;
DvrVirtualTouchpadTouchPtr virtual_touchpad_touch_;
DvrVirtualTouchpadButtonStatePtr virtual_touchpad_button_state_;
+
+ // VR HWComposer client
+ DvrHwcCreateClientPtr hwc_create_client_;
+ DvrHwcClientDestroyPtr hwc_client_destroy_;
+ DvrHwcFrameDestroyPtr hwc_frame_destroy_;
+ DvrHwcFrameGetDisplayIdPtr hwc_frame_get_display_id_;
+ DvrHwcFrameGetDisplayWidthPtr hwc_frame_get_display_width_;
+ DvrHwcFrameGetDisplayHeightPtr hwc_frame_get_display_height_;
+ DvrHwcFrameGetDisplayRemovedPtr hwc_frame_get_display_removed_;
+ DvrHwcFrameGetLayerCountPtr hwc_frame_get_layer_count_;
+ DvrHwcFrameGetLayerIdPtr hwc_frame_get_layer_id_;
+ DvrHwcFrameGetLayerBufferPtr hwc_frame_get_layer_buffer_;
+ DvrHwcFrameGetLayerFencePtr hwc_frame_get_layer_fence_;
+ DvrHwcFrameGetLayerDisplayFramePtr hwc_frame_get_layer_display_frame_;
+ DvrHwcFrameGetLayerCropPtr hwc_frame_get_layer_crop_;
+ DvrHwcFrameGetLayerBlendModePtr hwc_frame_get_layer_blend_mode_;
+ DvrHwcFrameGetLayerAlphaPtr hwc_frame_get_layer_alpha_;
+ DvrHwcFrameGetLayerTypePtr hwc_frame_get_layer_type_;
+ DvrHwcFrameGetLayerApplicationIdPtr hwc_frame_get_layer_application_id_;
};
int dvrGetApi(void* api, size_t struct_size, int version);
-#ifndef VR_HARDWARE_COMPOSER_PRIVATE_ANDROID_DVR_HARDWARE_COMPOSER_CLIENT_H
-#define VR_HARDWARE_COMPOSER_PRIVATE_ANDROID_DVR_HARDWARE_COMPOSER_CLIENT_H
+#ifndef ANDROID_DVR_HARDWARE_COMPOSER_CLIENT_H
+#define ANDROID_DVR_HARDWARE_COMPOSER_CLIENT_H
-#include <android/dvr_hardware_composer_defs.h>
-#include <android/hardware_buffer.h>
+#include <dvr/dvr_hardware_composer_defs.h>
+#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
+typedef struct AHardwareBuffer AHardwareBuffer;
typedef struct DvrHwcClient DvrHwcClient;
typedef struct DvrHwcFrame DvrHwcFrame;
// Called when a new frame has arrived.
//
+// @param client_state Pointer to client state passed in |dvrHwcCreateClient()|.
// @param frame New frame. Owned by the client.
// @return fence FD for the release of the last frame.
-typedef int(*DvrHwcOnFrameCallback)(DvrHwcFrame* frame);
+typedef int(*DvrHwcOnFrameCallback)(void* client_state, DvrHwcFrame* frame);
-DvrHwcClient* dvrHwcCreateClient(DvrHwcOnFrameCallback callback);
+// @param callback Called when a new frame is available.
+// @param client_state Pointer to client state passed back in the callback.
+DvrHwcClient* dvrHwcCreateClient(DvrHwcOnFrameCallback callback,
+ void* client_state);
+
+void dvrHwcClientDestroy(DvrHwcClient* client);
// Called to free the frame information.
void dvrHwcFrameDestroy(DvrHwcFrame* frame);
Display dvrHwcFrameGetDisplayId(DvrHwcFrame* frame);
+int32_t dvrHwcFrameGetDisplayWidth(DvrHwcFrame* frame);
+
+int32_t dvrHwcFrameGetDisplayHeight(DvrHwcFrame* frame);
+
+// @return True if the display has been removed. In this case the current frame
+// does not contain any valid layers to display. It is a signal to clean up any
+// display related state.
+bool dvrHwcFrameGetDisplayRemoved(DvrHwcFrame* frame);
+
// @return Number of layers in the frame.
size_t dvrHwcFrameGetLayerCount(DvrHwcFrame* frame);
} // extern "C"
#endif
-#endif // VR_HARDWARE_COMPOSER_PRIVATE_ANDROID_DVR_HARDWARE_COMPOSER_CLIENT_H
+#endif // ANDROID_DVR_HARDWARE_COMPOSER_CLIENT_H
-#ifndef VR_HARDWARE_COMPOSER_PRIVATE_ANDROID_VR_HARDWARE_COMPOSER_DEFS_H
-#define VR_HARDWARE_COMPOSER_PRIVATE_ANDROID_VR_HARDWARE_COMPOSER_DEFS_H
+#ifndef ANDROID_VR_HARDWARE_COMPOSER_DEFS_H
+#define ANDROID_VR_HARDWARE_COMPOSER_DEFS_H
#include <inttypes.h>
} // extern "C"
#endif
-#endif // VR_HARDWARE_COMPOSER_PRIVATE_ANDROID_DVR_HARDWARE_COMPOSER_DEFS_H
+#endif // ANDROID_DVR_HARDWARE_COMPOSER_DEFS_H
],
}
-cc_library_static {
- name: "libdvr_hwc",
- srcs: [
- "dvr_hardware_composer_client.cpp",
- ],
- static_libs: [
- "libvr_hwc-impl",
- // NOTE: This needs to be included after the *-impl lib otherwise the
- // symbols in the *-binder library get optimized out.
- "libvr_hwc-binder",
- ],
- shared_libs: [
- "libbase",
- "libbinder",
- "liblog",
- "libnativewindow",
- "libui",
- "libutils",
- ],
- export_include_dirs: ["private"],
- export_shared_lib_headers: [
- "libnativewindow",
- ],
-}
-
cc_test {
name: "vr_hwc_test",
gtest: true,