提交 2f849059 编写于 作者: S Simon Fels

Correct texture and frame size calculation to be correct in offscreen areas

上级 abb0497a
......@@ -996,7 +996,7 @@ void Renderer::setupViewport(RendererWindow *window,
void Renderer::tessellate(std::vector<anbox::graphics::Primitive> &primitives,
const anbox::graphics::Rect &buf_size,
const Renderable &renderable) {
auto rect = renderable.screen_position();
auto rect = renderable.crop();
GLfloat left = rect.left();
GLfloat right = rect.right();
GLfloat top = rect.top();
......@@ -1006,13 +1006,15 @@ void Renderer::tessellate(std::vector<anbox::graphics::Primitive> &primitives,
rectangle.tex_id = 0;
rectangle.type = GL_TRIANGLE_STRIP;
GLfloat tex_right = static_cast<GLfloat>(rect.width()) / buf_size.width();
GLfloat tex_bottom = static_cast<GLfloat>(rect.height()) / buf_size.height();
GLfloat tex_left = static_cast<GLfloat>(left) / buf_size.width();
GLfloat tex_top = static_cast<GLfloat>(top) / buf_size.height();
GLfloat tex_right = static_cast<GLfloat>(right) / buf_size.width();
GLfloat tex_bottom = static_cast<GLfloat>(bottom) / buf_size.height();
auto &vertices = rectangle.vertices;
vertices[0] = {{left, top, 0.0f}, {0.0f, 0.0f}};
vertices[1] = {{left, bottom, 0.0f}, {0.0f, tex_bottom}};
vertices[2] = {{right, top, 0.0f}, {tex_right, 0.0f}};
vertices[0] = {{left, top, 0.0f}, {tex_left, tex_top}};
vertices[1] = {{left, bottom, 0.0f}, {tex_left, tex_bottom}};
vertices[2] = {{right, top, 0.0f}, {tex_right, tex_top}};
vertices[3] = {{right, bottom, 0.0f}, {tex_right, tex_bottom}};
primitives.resize(1);
......
......@@ -72,9 +72,9 @@ void LayerComposer::submit_layers(const RenderableList &renderables) {
auto top = r.screen_position().top() - new_window_frame.top();
auto rect = Rect{
left - r.crop().left(), top - r.crop().top(),
r.screen_position().width() + left,
r.screen_position().height() + top,
left + r.crop().left(), top + r.crop().top(),
r.crop().right(),
r.crop().bottom(),
};
auto new_renderable = r;
......@@ -82,7 +82,6 @@ void LayerComposer::submit_layers(const RenderableList &renderables) {
final_renderables.push_back(new_renderable);
}
w.first->update_frame(new_window_frame);
Renderer::get()->draw(
window->native_handle(),
......
......@@ -48,7 +48,7 @@ void Rect::resize(const std::int32_t &width, const std::int32_t &height) {
std::ostream &operator<<(std::ostream &out, const Rect &rect) {
return out << "{" << rect.left() << "," << rect.top() << "," << rect.right()
<< "," << rect.bottom() << "}";
<< "," << rect.bottom() << "} {" << rect.width() << "," << rect.height() << "}";
}
} // namespace graphics
} // namespace anbox
......@@ -232,7 +232,7 @@ void PlatformPolicy::window_resized(const Window::Id &id,
// representing this window and then we're back to the original size of
// the task.
window->update_frame(new_frame);
android_api_->resize_task(window->task(), new_frame, 1);
android_api_->resize_task(window->task(), new_frame, 3);
}
}
......
......@@ -65,17 +65,10 @@ Window::Window(const Id &id, const wm::Task::Id &task,
ERROR("Unknown subsystem (%d)", info.subsystem);
BOOST_THROW_EXCEPTION(std::runtime_error("SDL subsystem not suported"));
}
int actual_width = 0, actual_height = 0;
int actual_x = 0, actual_y = 0;
SDL_GetWindowSize(window_, &actual_width, &actual_height);
SDL_GetWindowPosition(window_, &actual_x, &actual_y);
}
Window::~Window() {
if (window_) SDL_DestroyWindow(window_);
// if (observer_) observer_->window_deleted(id_);
}
void Window::process_event(const SDL_Event &event) {
......
......@@ -26,7 +26,17 @@ Window::Window(const Task::Id &task, const graphics::Rect &frame)
Window::~Window() {}
void Window::update_state(const WindowState::List &states) {}
void Window::update_state(const WindowState::List &states) {
graphics::Rect new_frame = graphics::Rect::Invalid;
for (const auto &s : states) {
if (new_frame == graphics::Rect::Invalid)
new_frame = s.frame();
else
new_frame.merge(s.frame());
}
update_frame(new_frame);
}
void Window::update_frame(const graphics::Rect &frame) {
if (frame == frame_) return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册