File: ScenicWindow.cpp

package info (click to toggle)
wpewebkit 2.50.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 438,332 kB
  • sloc: cpp: 3,777,828; javascript: 197,888; ansic: 156,951; python: 49,119; asm: 21,987; ruby: 18,540; perl: 16,722; xml: 4,623; yacc: 2,360; sh: 2,096; java: 2,019; lex: 1,327; pascal: 366; makefile: 90
file content (128 lines) | stat: -rw-r--r-- 2,765 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//
// Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ScenicWindow.cpp:
//    Implements methods from ScenicWindow
//

#include "util/fuchsia/ScenicWindow.h"

#include <fuchsia/element/cpp/fidl.h>
#include <lib/async-loop/cpp/loop.h>
#include <lib/async-loop/default.h>
#include <lib/fdio/directory.h>
#include <lib/fidl/cpp/interface_ptr.h>
#include <lib/fidl/cpp/interface_request.h>
#include <lib/zx/channel.h>
#include <zircon/status.h>

namespace
{

async::Loop *GetDefaultLoop()
{
    static async::Loop *defaultLoop = new async::Loop(&kAsyncLoopConfigNeverAttachToThread);
    return defaultLoop;
}

template <typename Interface>
fidl::InterfacePtr<Interface> ConnectToService(async_dispatcher_t *dispatcher)
{
    fidl::InterfacePtr<Interface> result;
    fidl::InterfaceRequest<Interface> request = result.NewRequest(dispatcher);
    ASSERT(request.is_valid());
    fdio_service_connect_by_name(Interface::Name_, request.TakeChannel().release());
    return result;
}

}  // namespace

// TODO: http://anglebug.com/42050005 - Implement using fuchsia.element.GraphicalPresenter to pass a
// ViewCreationToken to Fuchsia Flatland.
ScenicWindow::ScenicWindow()
    : mLoop(GetDefaultLoop()),
      mPresenter(ConnectToService<fuchsia::element::GraphicalPresenter>(mLoop->dispatcher()))
{}

ScenicWindow::~ScenicWindow()
{
    destroy();
}

bool ScenicWindow::initializeImpl(const std::string &name, int width, int height)
{
    return true;
}

void ScenicWindow::disableErrorMessageDialog() {}

void ScenicWindow::destroy()
{
    mFuchsiaEGLWindow.reset();
}

void ScenicWindow::resetNativeWindow()
{
    UNIMPLEMENTED();
}

EGLNativeWindowType ScenicWindow::getNativeWindow() const
{
    return reinterpret_cast<EGLNativeWindowType>(mFuchsiaEGLWindow.get());
}

EGLNativeDisplayType ScenicWindow::getNativeDisplay() const
{
    return EGL_DEFAULT_DISPLAY;
}

void ScenicWindow::messageLoop()
{
    mLoop->ResetQuit();
    mLoop->RunUntilIdle();
}

void ScenicWindow::setMousePosition(int x, int y)
{
    UNIMPLEMENTED();
}

bool ScenicWindow::setOrientation(int width, int height)
{
    UNIMPLEMENTED();
    return false;
}

bool ScenicWindow::setPosition(int x, int y)
{
    UNIMPLEMENTED();
    return false;
}

bool ScenicWindow::resize(int width, int height)
{
    fuchsia_egl_window_resize(mFuchsiaEGLWindow.get(), width, height);
    return true;
}

void ScenicWindow::setVisible(bool isVisible) {}

void ScenicWindow::signalTestEvent() {}

void ScenicWindow::present()
{
    UNIMPLEMENTED();
}

void ScenicWindow::updateViewSize()
{
    UNIMPLEMENTED();
}

// static
OSWindow *OSWindow::New()
{
    return new ScenicWindow;
}