aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuncheol Heo <ycheo@google.com>2020-06-23 14:08:23 -0700
committerYuncheol Heo <ycheo@google.com>2020-06-23 18:17:04 -0700
commitf64f952db2302c888eeaa7f65be2cf039f5c1bdd (patch)
tree7381d5850b9462fa19d3ef9cb2ae383d764cd0f3
parent651d02bc53e642b7c817ae80dd5283983aab678b (diff)
downloaddevice_generic_goldfish-opengl-f64f952db2302c888eeaa7f65be2cf039f5c1bdd.tar.gz
device_generic_goldfish-opengl-f64f952db2302c888eeaa7f65be2cf039f5c1bdd.tar.bz2
device_generic_goldfish-opengl-f64f952db2302c888eeaa7f65be2cf039f5c1bdd.zip
Initialize the framebuffer of secondary display with its own size.
Bug: 158801569 Test: set the secondary display size to the different size with the default display and check if it shows normally. Change-Id: Ia7a072b619a46d63916580b9dc3ce6f6f08ce6f5
-rw-r--r--system/hwc2/EmuHWC2.cpp19
-rw-r--r--system/hwc2/EmuHWC2.h4
2 files changed, 12 insertions, 11 deletions
diff --git a/system/hwc2/EmuHWC2.cpp b/system/hwc2/EmuHWC2.cpp
index ad01b06d..e77e27df 100644
--- a/system/hwc2/EmuHWC2.cpp
+++ b/system/hwc2/EmuHWC2.cpp
@@ -391,7 +391,7 @@ Error EmuHWC2::registerCallback(Callback descriptor,
return Error::None;
}
-const native_handle_t* EmuHWC2::allocateDisplayColorBuffer() {
+const native_handle_t* EmuHWC2::allocateDisplayColorBuffer(int width, int height) {
const uint32_t layerCount = 1;
const uint64_t graphicBufferId = 0; // not used
@@ -399,7 +399,7 @@ const native_handle_t* EmuHWC2::allocateDisplayColorBuffer() {
uint32_t stride;
if (GraphicBufferAllocator::get().allocate(
- mDisplayWidth, mDisplayHeight,
+ width, height,
PIXEL_FORMAT_RGBA_8888,
layerCount,
(GraphicBuffer::USAGE_HW_COMPOSER | GraphicBuffer::USAGE_HW_RENDER),
@@ -437,7 +437,7 @@ static int getVsyncPeriodFromProperty() {
std::atomic<hwc2_display_t> EmuHWC2::Display::sNextId(0);
-EmuHWC2::Display::Display(EmuHWC2& device, DisplayType type)
+EmuHWC2::Display::Display(EmuHWC2& device, DisplayType type, int width, int height)
: mDevice(device),
mId(sNextId++),
mHostDisplayId(0),
@@ -458,7 +458,7 @@ EmuHWC2::Display::Display(EmuHWC2& device, DisplayType type)
mSetColorTransform(false),
mStateMutex() {
mVsyncThread.run("", ANDROID_PRIORITY_URGENT_DISPLAY);
- mTargetCb = device.allocateDisplayColorBuffer();
+ mTargetCb = device.allocateDisplayColorBuffer(width, height);
}
EmuHWC2::Display::~Display() {
@@ -1338,13 +1338,13 @@ HWC2::Error EmuHWC2::Display::populateSecondaryConfigs(uint32_t width, uint32_t
newConfig->setAttribute(Attribute::DpiX, dpi*1000);
newConfig->setAttribute(Attribute::DpiY, dpi*1000);
- newConfig->setId(static_cast<hwc2_config_t>(mConfigs.size()));
+ int configId = mConfigs.size();
+ newConfig->setId(static_cast<hwc2_config_t>(configId));
ALOGV("Found new secondary config %d: %s", (uint32_t)newConfig->getId(),
newConfig->toString().c_str());
mConfigs.emplace_back(std::move(newConfig));
- // we need to reset these values after populatePrimaryConfigs()
- mActiveConfig = mConfigs[0];
+ mActiveConfig = mConfigs[configId];
mActiveColorMode = HAL_COLOR_MODE_NATIVE;
mColorModes.emplace((android_color_mode_t)HAL_COLOR_MODE_NATIVE);
@@ -1628,7 +1628,8 @@ void EmuHWC2::populateCapabilities() {
int EmuHWC2::populatePrimary() {
int ret = 0;
- auto display = std::make_shared<Display>(*this, HWC2::DisplayType::Physical);
+ auto display = std::make_shared<Display>(*this, HWC2::DisplayType::Physical,
+ mDisplayWidth, mDisplayHeight);
ret = display->populatePrimaryConfigs(mDisplayWidth, mDisplayHeight,
mDisplayDpiX, mDisplayDpiY);
if (ret != 0) {
@@ -1693,7 +1694,7 @@ int EmuHWC2::populateSecondaryDisplays() {
values.erase(values.begin(), values.begin() + 5);
Error ret = Error::None;
- auto display = std::make_shared<Display>(*this, HWC2::DisplayType::Physical);
+ auto display = std::make_shared<Display>(*this, HWC2::DisplayType::Physical, width, height);
ret = display->populateSecondaryConfigs(width, height, dpi, idx++);
if (ret != Error::None) {
return -2;
diff --git a/system/hwc2/EmuHWC2.h b/system/hwc2/EmuHWC2.h
index 07218b62..4ab09e1e 100644
--- a/system/hwc2/EmuHWC2.h
+++ b/system/hwc2/EmuHWC2.h
@@ -205,7 +205,7 @@ private:
class Display {
public:
- Display(EmuHWC2& device, HWC2::DisplayType type);
+ Display(EmuHWC2& device, HWC2::DisplayType type, int width, int height);
~Display();
hwc2_display_t getId() const {return mId;}
@@ -467,7 +467,7 @@ private:
hwc2_layer_t layerId);
HWC2::Error initDisplayParameters();
- const native_handle_t* allocateDisplayColorBuffer();
+ const native_handle_t* allocateDisplayColorBuffer(int width, int height);
void freeDisplayColorBuffer(const native_handle_t* h);
std::unordered_set<HWC2::Capability> mCapabilities;