Respect layer crop when calculating surface dimensions and position
This commit is contained in:
parent
586a2c7bc3
commit
48bd7f9692
6 changed files with 31 additions and 5 deletions
|
|
@ -444,7 +444,12 @@ void rcPostLayer(const char *name, uint32_t color_buffer,
|
||||||
int32_t displayFrameLeft, int32_t displayFrameTop,
|
int32_t displayFrameLeft, int32_t displayFrameTop,
|
||||||
int32_t displayFrameRight, int32_t displayFrameBottom)
|
int32_t displayFrameRight, int32_t displayFrameBottom)
|
||||||
{
|
{
|
||||||
Renderable r{name, color_buffer, {displayFrameLeft, displayFrameTop, displayFrameRight, displayFrameBottom}};
|
Renderable r{
|
||||||
|
name,
|
||||||
|
color_buffer,
|
||||||
|
{displayFrameLeft, displayFrameTop, displayFrameRight, displayFrameBottom},
|
||||||
|
{sourceCropLeft, sourceCropTop, sourceCropRight, sourceCropBottom}
|
||||||
|
};
|
||||||
frame_layers.push_back(r);
|
frame_layers.push_back(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@
|
||||||
Renderable::Renderable(const std::string &name,
|
Renderable::Renderable(const std::string &name,
|
||||||
const std::uint32_t &buffer,
|
const std::uint32_t &buffer,
|
||||||
const anbox::graphics::Rect &screen_position,
|
const anbox::graphics::Rect &screen_position,
|
||||||
|
const anbox::graphics::Rect &crop,
|
||||||
const glm::mat4 &transformation,
|
const glm::mat4 &transformation,
|
||||||
const float &alpha) :
|
const float &alpha) :
|
||||||
name_(name),
|
name_(name),
|
||||||
buffer_(buffer),
|
buffer_(buffer),
|
||||||
screen_position_(screen_position),
|
screen_position_(screen_position),
|
||||||
|
crop_(crop),
|
||||||
transformation_(transformation),
|
transformation_(transformation),
|
||||||
alpha_(alpha)
|
alpha_(alpha)
|
||||||
{
|
{
|
||||||
|
|
@ -48,6 +50,11 @@ anbox::graphics::Rect Renderable::screen_position() const
|
||||||
return screen_position_;
|
return screen_position_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
anbox::graphics::Rect Renderable::crop() const
|
||||||
|
{
|
||||||
|
return crop_;
|
||||||
|
}
|
||||||
|
|
||||||
glm::mat4 Renderable::transformation() const
|
glm::mat4 Renderable::transformation() const
|
||||||
{
|
{
|
||||||
return transformation_;
|
return transformation_;
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ public:
|
||||||
Renderable(const std::string &name,
|
Renderable(const std::string &name,
|
||||||
const std::uint32_t &buffer,
|
const std::uint32_t &buffer,
|
||||||
const anbox::graphics::Rect &screen_position,
|
const anbox::graphics::Rect &screen_position,
|
||||||
|
const anbox::graphics::Rect &crop = {},
|
||||||
const glm::mat4 &transformation = {},
|
const glm::mat4 &transformation = {},
|
||||||
const float &alpha = 1.0f);
|
const float &alpha = 1.0f);
|
||||||
~Renderable();
|
~Renderable();
|
||||||
|
|
@ -39,6 +40,7 @@ public:
|
||||||
std::string name() const;
|
std::string name() const;
|
||||||
std::uint32_t buffer() const;
|
std::uint32_t buffer() const;
|
||||||
anbox::graphics::Rect screen_position() const;
|
anbox::graphics::Rect screen_position() const;
|
||||||
|
anbox::graphics::Rect crop() const;
|
||||||
glm::mat4 transformation() const;
|
glm::mat4 transformation() const;
|
||||||
float alpha() const;
|
float alpha() const;
|
||||||
|
|
||||||
|
|
@ -48,6 +50,7 @@ private:
|
||||||
std::string name_;
|
std::string name_;
|
||||||
std::uint32_t buffer_;
|
std::uint32_t buffer_;
|
||||||
anbox::graphics::Rect screen_position_;
|
anbox::graphics::Rect screen_position_;
|
||||||
|
anbox::graphics::Rect crop_;
|
||||||
glm::mat4 transformation_;
|
glm::mat4 transformation_;
|
||||||
float alpha_;
|
float alpha_;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -63,9 +63,6 @@ void LayerComposer::submit_layers(const RenderableList &renderables)
|
||||||
RenderableList final_renderables;
|
RenderableList final_renderables;
|
||||||
auto new_window_frame = Rect::Invalid;
|
auto new_window_frame = Rect::Invalid;
|
||||||
|
|
||||||
// As we get absolute display coordinates from the Android hwcomposer we
|
|
||||||
// need to recalculate all layer coordinates into relatives ones to the
|
|
||||||
// window they are drawn into.
|
|
||||||
for (auto &r : renderables)
|
for (auto &r : renderables)
|
||||||
{
|
{
|
||||||
if (new_window_frame == Rect::Invalid)
|
if (new_window_frame == Rect::Invalid)
|
||||||
|
|
@ -76,11 +73,15 @@ void LayerComposer::submit_layers(const RenderableList &renderables)
|
||||||
|
|
||||||
for (auto &r : renderables)
|
for (auto &r : renderables)
|
||||||
{
|
{
|
||||||
|
// As we get absolute display coordinates from the Android hwcomposer we
|
||||||
|
// need to recalculate all layer coordinates into relatives ones to the
|
||||||
|
// window they are drawn into.
|
||||||
auto left = r.screen_position().left() - new_window_frame.left();
|
auto left = r.screen_position().left() - new_window_frame.left();
|
||||||
auto top = r.screen_position().top() - new_window_frame.top();
|
auto top = r.screen_position().top() - new_window_frame.top();
|
||||||
|
|
||||||
auto rect = Rect{
|
auto rect = Rect{
|
||||||
left, top,
|
left - r.crop().left(),
|
||||||
|
top - r.crop().top(),
|
||||||
r.screen_position().width() + left,
|
r.screen_position().width() + left,
|
||||||
r.screen_position().height() + top,
|
r.screen_position().height() + top,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#include "anbox/graphics/rect.h"
|
#include "anbox/graphics/rect.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace graphics {
|
namespace graphics {
|
||||||
|
|
@ -31,5 +32,10 @@ void Rect::merge(const Rect &rhs)
|
||||||
right_ = std::max(right_, rhs.right());
|
right_ = std::max(right_, rhs.right());
|
||||||
bottom_ = std::max(bottom_, rhs.bottom());
|
bottom_ = std::max(bottom_, rhs.bottom());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream &out, const Rect &rect)
|
||||||
|
{
|
||||||
|
return out << "{" << rect.left() << "," << rect.top() << ","<< rect.right() << "," << rect.bottom() << "}";
|
||||||
|
}
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
} // namespace anbox
|
} // namespace anbox
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace graphics {
|
namespace graphics {
|
||||||
class Rect {
|
class Rect {
|
||||||
|
|
@ -97,6 +99,8 @@ private:
|
||||||
std::int32_t right_;
|
std::int32_t right_;
|
||||||
std::int32_t bottom_;
|
std::int32_t bottom_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream &out, const Rect &rect);
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
} // namespace anbox
|
} // namespace anbox
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue