1 #include "surface_flinger_view.h"
3 #include <impl/vr_composer_view.h>
4 #include <private/dvr/native_buffer.h>
6 #include "hwc_callback.h"
12 SurfaceFlingerView::SurfaceFlingerView() {}
14 SurfaceFlingerView::~SurfaceFlingerView() {}
16 bool SurfaceFlingerView::Initialize(HwcCallback::Client *client) {
17 sp<IComposer> vr_hwcomposer = IComposer::getService("vr_hwcomposer");
18 if (!vr_hwcomposer.get()) {
19 ALOGE("vr_hwcomposer not registered as service");
24 std::make_unique<VrComposerView>(std::make_unique<HwcCallback>(client));
25 vr_composer_view_->Initialize(GetComposerViewFromIComposer(
26 vr_hwcomposer.get()));
28 // TODO(dnicoara): Query this from the composer service.
34 bool SurfaceFlingerView::GetTextures(const HwcCallback::Frame& frame,
35 std::vector<TextureLayer>* texture_layers,
36 TextureLayer* ime_layer,
37 bool debug, bool skip_first_layer) const {
38 auto& layers = frame.layers();
39 texture_layers->clear();
42 // Skip the second layer if it is from the VR app.
43 if (!debug && skip_first_layer) {
45 if (layers[0].appid && layers[0].appid == layers[1].appid)
49 for (size_t i = start; i < layers.size(); ++i) {
50 if (!debug && layers[i].should_skip_layer())
53 std::unique_ptr<Texture> texture(new Texture());
54 if (!texture->Initialize(layers[i].buffer->getNativeBuffer())) {
55 ALOGE("Failed to create texture");
56 texture_layers->clear();
60 TextureLayer texture_layer = {
61 std::move(texture), layers[i].crop, layers[i].display_frame,
62 layers[i].blending, layers[i].alpha,
64 if (debug && layers[i].type == HwcCallback::HwcLayer::kInputMethod) {
65 *ime_layer = std::move(texture_layer);
67 texture_layers->emplace_back(std::move(texture_layer));
74 void SurfaceFlingerView::ReleaseFrame() {
75 vr_composer_view_->ReleaseFrame();
79 } // namespace android