graphics: correctly pass layer alpha level through
This commit is contained in:
parent
238a26aee3
commit
1037e8aab9
9 changed files with 28 additions and 25 deletions
|
|
@ -197,6 +197,7 @@ static int hwc_set(hwc_composer_device_1_t* dev, size_t numDisplays,
|
|||
rcEnc->rcPostLayer(rcEnc,
|
||||
layer->name,
|
||||
cb->hostHandle,
|
||||
layer->planeAlpha / 255,
|
||||
layer->sourceCrop.left,
|
||||
layer->sourceCrop.top,
|
||||
layer->sourceCrop.right,
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ typedef int (renderControl_APIENTRY *rcGetDisplayHeight_client_proc_t) (void * c
|
|||
typedef int (renderControl_APIENTRY *rcGetDisplayDpiX_client_proc_t) (void * ctx, uint32_t);
|
||||
typedef int (renderControl_APIENTRY *rcGetDisplayDpiY_client_proc_t) (void * ctx, uint32_t);
|
||||
typedef int (renderControl_APIENTRY *rcGetDisplayVsyncPeriod_client_proc_t) (void * ctx, uint32_t);
|
||||
typedef void (renderControl_APIENTRY *rcPostLayer_client_proc_t) (void * ctx, const char*, uint32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t);
|
||||
typedef void (renderControl_APIENTRY *rcPostLayer_client_proc_t) (void * ctx, const char*, uint32_t, float, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t);
|
||||
typedef void (renderControl_APIENTRY *rcPostAllLayersDone_client_proc_t) (void * ctx);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1283,7 +1283,7 @@ int rcGetDisplayVsyncPeriod_enc(void *self , uint32_t displayId)
|
|||
return retval;
|
||||
}
|
||||
|
||||
void rcPostLayer_enc(void *self , const char* name, uint32_t colorBuffer, int32_t sourceCropLeft, int32_t sourceCropTop, int32_t sourceCropRight, int32_t sourceCropBottom, int32_t displayFrameLeft, int32_t displayFrameTop, int32_t displayFrameRight, int32_t displayFrameBottom)
|
||||
void rcPostLayer_enc(void *self , const char* name, uint32_t colorBuffer, float alpha, int32_t sourceCropLeft, int32_t sourceCropTop, int32_t sourceCropRight, int32_t sourceCropBottom, int32_t displayFrameLeft, int32_t displayFrameTop, int32_t displayFrameRight, int32_t displayFrameBottom)
|
||||
{
|
||||
|
||||
renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
|
||||
|
|
@ -1294,7 +1294,7 @@ void rcPostLayer_enc(void *self , const char* name, uint32_t colorBuffer, int32_
|
|||
const unsigned int __size_name = (strlen(name) + 1);
|
||||
unsigned char *ptr;
|
||||
unsigned char *buf;
|
||||
const size_t sizeWithoutChecksum = 8 + __size_name + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 1*4;
|
||||
const size_t sizeWithoutChecksum = 8 + __size_name + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 1*4;
|
||||
const size_t checksumSize = checksumCalculator->checksumByteSize();
|
||||
const size_t totalSize = sizeWithoutChecksum + checksumSize;
|
||||
buf = stream->alloc(totalSize);
|
||||
|
|
@ -1305,6 +1305,7 @@ void rcPostLayer_enc(void *self , const char* name, uint32_t colorBuffer, int32_
|
|||
*(unsigned int *)(ptr) = __size_name; ptr += 4;
|
||||
memcpy(ptr, name, __size_name);ptr += __size_name;
|
||||
memcpy(ptr, &colorBuffer, 4); ptr += 4;
|
||||
memcpy(ptr, &alpha, 4); ptr += 4;
|
||||
memcpy(ptr, &sourceCropLeft, 4); ptr += 4;
|
||||
memcpy(ptr, &sourceCropTop, 4); ptr += 4;
|
||||
memcpy(ptr, &sourceCropRight, 4); ptr += 4;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ extern "C" {
|
|||
int rcGetDisplayDpiX(uint32_t displayId);
|
||||
int rcGetDisplayDpiY(uint32_t displayId);
|
||||
int rcGetDisplayVsyncPeriod(uint32_t displayId);
|
||||
void rcPostLayer(const char* name, uint32_t colorBuffer, int32_t sourceCropLeft, int32_t sourceCropTop, int32_t sourceCropRight, int32_t sourceCropBottom, int32_t displayFrameLeft, int32_t displayFrameTop, int32_t displayFrameRight, int32_t displayFrameBottom);
|
||||
void rcPostLayer(const char* name, uint32_t colorBuffer, float alpha, int32_t sourceCropLeft, int32_t sourceCropTop, int32_t sourceCropRight, int32_t sourceCropBottom, int32_t displayFrameLeft, int32_t displayFrameTop, int32_t displayFrameRight, int32_t displayFrameBottom);
|
||||
void rcPostAllLayersDone();
|
||||
};
|
||||
|
||||
|
|
@ -262,10 +262,10 @@ int rcGetDisplayVsyncPeriod(uint32_t displayId)
|
|||
return ctx->rcGetDisplayVsyncPeriod(ctx, displayId);
|
||||
}
|
||||
|
||||
void rcPostLayer(const char* name, uint32_t colorBuffer, int32_t sourceCropLeft, int32_t sourceCropTop, int32_t sourceCropRight, int32_t sourceCropBottom, int32_t displayFrameLeft, int32_t displayFrameTop, int32_t displayFrameRight, int32_t displayFrameBottom)
|
||||
void rcPostLayer(const char* name, uint32_t colorBuffer, float alpha, int32_t sourceCropLeft, int32_t sourceCropTop, int32_t sourceCropRight, int32_t sourceCropBottom, int32_t displayFrameLeft, int32_t displayFrameTop, int32_t displayFrameRight, int32_t displayFrameBottom)
|
||||
{
|
||||
GET_CONTEXT;
|
||||
ctx->rcPostLayer(ctx, name, colorBuffer, sourceCropLeft, sourceCropTop, sourceCropRight, sourceCropBottom, displayFrameLeft, displayFrameTop, displayFrameRight, displayFrameBottom);
|
||||
ctx->rcPostLayer(ctx, name, colorBuffer, alpha, sourceCropLeft, sourceCropTop, sourceCropRight, sourceCropBottom, displayFrameLeft, displayFrameTop, displayFrameRight, displayFrameBottom);
|
||||
}
|
||||
|
||||
void rcPostAllLayersDone()
|
||||
|
|
|
|||
|
|
@ -33,5 +33,5 @@ GL_ENTRY(int, rcGetDisplayHeight, uint32_t displayId)
|
|||
GL_ENTRY(int, rcGetDisplayDpiX, uint32_t displayId)
|
||||
GL_ENTRY(int, rcGetDisplayDpiY, uint32_t displayId)
|
||||
GL_ENTRY(int, rcGetDisplayVsyncPeriod, uint32_t displayId)
|
||||
GL_ENTRY(void, rcPostLayer, const char* name, uint32_t colorBuffer, int32_t sourceCropLeft, int32_t sourceCropTop, int32_t sourceCropRight, int32_t sourceCropBottom, int32_t displayFrameLeft, int32_t displayFrameTop, int32_t displayFrameRight, int32_t displayFrameBottom)
|
||||
GL_ENTRY(void, rcPostLayer, const char* name, uint32_t colorBuffer, float alpha, int32_t sourceCropLeft, int32_t sourceCropTop, int32_t sourceCropRight, int32_t sourceCropBottom, int32_t displayFrameLeft, int32_t displayFrameTop, int32_t displayFrameRight, int32_t displayFrameBottom)
|
||||
GL_ENTRY(void, rcPostAllLayersDone)
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ bool is_layer_blacklisted(const std::string &name) {
|
|||
return std::find(blacklist.begin(), blacklist.end(), name) != blacklist.end();
|
||||
}
|
||||
|
||||
void rcPostLayer(const char *name, uint32_t color_buffer,
|
||||
void rcPostLayer(const char *name, uint32_t color_buffer, float alpha,
|
||||
int32_t sourceCropLeft, int32_t sourceCropTop,
|
||||
int32_t sourceCropRight, int32_t sourceCropBottom,
|
||||
int32_t displayFrameLeft, int32_t displayFrameTop,
|
||||
|
|
@ -422,6 +422,7 @@ void rcPostLayer(const char *name, uint32_t color_buffer,
|
|||
Renderable r{
|
||||
name,
|
||||
color_buffer,
|
||||
alpha,
|
||||
{displayFrameLeft, displayFrameTop, displayFrameRight, displayFrameBottom},
|
||||
{sourceCropLeft, sourceCropTop, sourceCropRight, sourceCropBottom}};
|
||||
frame_layers.push_back(r);
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@
|
|||
|
||||
#include "anbox/graphics/emugl/Renderable.h"
|
||||
|
||||
Renderable::Renderable(const std::string &name, const std::uint32_t &buffer,
|
||||
Renderable::Renderable(const std::string &name, const std::uint32_t &buffer, float alpha,
|
||||
const anbox::graphics::Rect &screen_position,
|
||||
const anbox::graphics::Rect &crop,
|
||||
const glm::mat4 &transformation, const float &alpha)
|
||||
const glm::mat4 &transformation)
|
||||
: name_(name),
|
||||
buffer_(buffer),
|
||||
screen_position_(screen_position),
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@
|
|||
|
||||
class Renderable {
|
||||
public:
|
||||
Renderable(const std::string &name, const std::uint32_t &buffer,
|
||||
Renderable(const std::string &name, const std::uint32_t &buffer, float alpha,
|
||||
const anbox::graphics::Rect &screen_position,
|
||||
const anbox::graphics::Rect &crop = {},
|
||||
const glm::mat4 &transformation = {}, const float &alpha = 1.0f);
|
||||
const glm::mat4 &transformation = {});
|
||||
~Renderable();
|
||||
|
||||
std::string name() const;
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ TEST(LayerComposer, FindsNoSuitableWindowForLayer) {
|
|||
// A single renderable which has a different task id then the window we know
|
||||
// about
|
||||
RenderableList renderables = {
|
||||
{"org.anbox.surface.2", 0, {0, 0, 1024, 768}, {0, 0, 1024, 768}},
|
||||
{"org.anbox.surface.2", 0, 1.0f, {0, 0, 1024, 768}, {0, 0, 1024, 768}},
|
||||
};
|
||||
|
||||
// The renderer should not be called for a layer which doesn't exist
|
||||
|
|
@ -108,16 +108,16 @@ TEST(LayerComposer, MapsLayersToWindows) {
|
|||
// A single renderable which has a different task id then the window we know
|
||||
// about
|
||||
RenderableList renderables = {
|
||||
{"org.anbox.surface.1", 0, {0, 0, 1024, 768}, {0, 0, 1024, 768}},
|
||||
{"org.anbox.surface.2", 1, {0, 0, 1024, 768}, {0, 0, 1024, 768}},
|
||||
{"org.anbox.surface.1", 0, 1.0f, {0, 0, 1024, 768}, {0, 0, 1024, 768}},
|
||||
{"org.anbox.surface.2", 1, 1.0f, {0, 0, 1024, 768}, {0, 0, 1024, 768}},
|
||||
};
|
||||
|
||||
RenderableList first_window_renderables{
|
||||
{"org.anbox.surface.1", 0, {0, 0, 1024, 768}, {0, 0, 1024, 768}},
|
||||
{"org.anbox.surface.1", 0, 1.0f, {0, 0, 1024, 768}, {0, 0, 1024, 768}},
|
||||
};
|
||||
|
||||
RenderableList second_window_renderables{
|
||||
{"org.anbox.surface.2", 1, {0, 0, 1024, 768}, {0, 0, 1024, 768}},
|
||||
{"org.anbox.surface.2", 1, 1.0f, {0, 0, 1024, 768}, {0, 0, 1024, 768}},
|
||||
};
|
||||
|
||||
EXPECT_CALL(*renderer, draw(_, Rect{0, 0, first_window.frame().width(),
|
||||
|
|
@ -160,13 +160,13 @@ TEST(LayerComposer, WindowPartiallyOffscreen) {
|
|||
// but the layer covering the whole window is placed with its top left
|
||||
// origin outside of the visible display area.
|
||||
RenderableList renderables = {
|
||||
{"org.anbox.surface.1", 0, {-100, -100, 924, 668}, {0, 0, 1024, 768}},
|
||||
{"org.anbox.surface.1", 1, {0, 0, 100, 200}, {0, 0, 100, 200}},
|
||||
{"org.anbox.surface.1", 0, 1.0f, {-100, -100, 924, 668}, {0, 0, 1024, 768}},
|
||||
{"org.anbox.surface.1", 1, 1.0f, {0, 0, 100, 200}, {0, 0, 100, 200}},
|
||||
};
|
||||
|
||||
RenderableList expected_renderables{
|
||||
{"org.anbox.surface.1", 0, {0, 0, 1024, 768}, {0, 0, 1024, 768}},
|
||||
{"org.anbox.surface.1", 1, {100, 100, 200, 300}, {0, 0, 100, 200}},
|
||||
{"org.anbox.surface.1", 0, 1.0f, {0, 0, 1024, 768}, {0, 0, 1024, 768}},
|
||||
{"org.anbox.surface.1", 1, 1.0f, {100, 100, 200, 300}, {0, 0, 100, 200}},
|
||||
};
|
||||
|
||||
EXPECT_CALL(*renderer, draw(_, Rect{0, 0,
|
||||
|
|
@ -208,13 +208,13 @@ TEST(LayerComposer, PopupShouldNotCauseWindowLayerOffset) {
|
|||
// out of the window area. In our case this is not possible as the area the
|
||||
// window has available is static.
|
||||
RenderableList renderables = {
|
||||
{"org.anbox.surface.3", 0, {1120,270,2144,1038}, {0, 0, 1024, 768}},
|
||||
{"org.anbox.surface.3", 1, {1904, 246, 2164, 406}, {0, 0, 260, 160}},
|
||||
{"org.anbox.surface.3", 0, 1.0f, {1120,270,2144,1038}, {0, 0, 1024, 768}},
|
||||
{"org.anbox.surface.3", 1, 1.0f, {1904, 246, 2164, 406}, {0, 0, 260, 160}},
|
||||
};
|
||||
|
||||
RenderableList expected_renderables{
|
||||
{"org.anbox.surface.3", 0, {0, 0, 1024, 768}, {0, 0, 1024, 768}},
|
||||
{"org.anbox.surface.3", 1, {784, -24, 1044, 136}, {0, 0, 260, 160}},
|
||||
{"org.anbox.surface.3", 0, 1.0f, {0, 0, 1024, 768}, {0, 0, 1024, 768}},
|
||||
{"org.anbox.surface.3", 1, 1.0f, {784, -24, 1044, 136}, {0, 0, 260, 160}},
|
||||
};
|
||||
|
||||
EXPECT_CALL(*renderer, draw(_, Rect{0, 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue