summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/CompositionEngine/src/RenderSurface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'services/surfaceflinger/CompositionEngine/src/RenderSurface.cpp')
-rw-r--r--services/surfaceflinger/CompositionEngine/src/RenderSurface.cpp73
1 files changed, 22 insertions, 51 deletions
diff --git a/services/surfaceflinger/CompositionEngine/src/RenderSurface.cpp b/services/surfaceflinger/CompositionEngine/src/RenderSurface.cpp
index ef50870615..2773fd3a16 100644
--- a/services/surfaceflinger/CompositionEngine/src/RenderSurface.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/RenderSurface.cpp
@@ -25,8 +25,8 @@
#include <compositionengine/impl/DumpHelpers.h>
#include <compositionengine/impl/OutputCompositionState.h>
#include <compositionengine/impl/RenderSurface.h>
+
#include <log/log.h>
-#include <renderengine/ExternalTexture.h>
#include <renderengine/RenderEngine.h>
#include <system/window.h>
#include <ui/GraphicBuffer.h>
@@ -48,8 +48,6 @@ RenderSurface::~RenderSurface() = default;
namespace impl {
-constexpr auto DEFAULT_USAGE = GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE;
-
std::unique_ptr<compositionengine::RenderSurface> createRenderSurface(
const compositionengine::CompositionEngine& compositionEngine,
compositionengine::Display& display,
@@ -63,8 +61,7 @@ RenderSurface::RenderSurface(const CompositionEngine& compositionEngine, Display
mDisplay(display),
mNativeWindow(args.nativeWindow),
mDisplaySurface(args.displaySurface),
- mSize(args.displayWidth, args.displayHeight),
- mMaxTextureCacheSize(args.maxTextureCacheSize) {
+ mSize(args.displayWidth, args.displayHeight) {
LOG_ALWAYS_FATAL_IF(!mNativeWindow);
}
@@ -84,7 +81,7 @@ void RenderSurface::initialize() {
ALOGE_IF(status != NO_ERROR, "Unable to connect BQ producer: %d", status);
status = native_window_set_buffers_format(window, HAL_PIXEL_FORMAT_RGBA_8888);
ALOGE_IF(status != NO_ERROR, "Unable to set BQ format to RGBA888: %d", status);
- status = native_window_set_usage(window, DEFAULT_USAGE);
+ status = native_window_set_usage(window, GRALLOC_USAGE_HW_RENDER);
ALOGE_IF(status != NO_ERROR, "Unable to set BQ usage bits for GPU rendering: %d", status);
}
@@ -97,7 +94,8 @@ const sp<Fence>& RenderSurface::getClientTargetAcquireFence() const {
}
void RenderSurface::setDisplaySize(const ui::Size& size) {
- mDisplaySurface->resizeBuffers(size);
+ mDisplaySurface->resizeBuffers(static_cast<uint32_t>(size.width),
+ static_cast<uint32_t>(size.height));
mSize = size;
}
@@ -111,7 +109,7 @@ void RenderSurface::setBufferPixelFormat(ui::PixelFormat pixelFormat) {
}
void RenderSurface::setProtected(bool useProtected) {
- uint64_t usageFlags = DEFAULT_USAGE;
+ uint64_t usageFlags = GRALLOC_USAGE_HW_RENDER;
if (useProtected) {
usageFlags |= GRALLOC_USAGE_PROTECTED;
}
@@ -147,8 +145,7 @@ void RenderSurface::prepareFrame(bool usesClientComposition, bool usesDeviceComp
}
}
-std::shared_ptr<renderengine::ExternalTexture> RenderSurface::dequeueBuffer(
- base::unique_fd* bufferFence) {
+sp<GraphicBuffer> RenderSurface::dequeueBuffer(base::unique_fd* bufferFence) {
ATRACE_CALL();
int fd = -1;
ANativeWindowBuffer* buffer = nullptr;
@@ -160,41 +157,16 @@ std::shared_ptr<renderengine::ExternalTexture> RenderSurface::dequeueBuffer(
mDisplay.getName().c_str(), result);
// Return fast here as we can't do much more - any rendering we do
// now will just be wrong.
- return mTexture;
+ return mGraphicBuffer;
}
- ALOGW_IF(mTexture != nullptr, "Clobbering a non-null pointer to a buffer [%p].",
- mTexture->getBuffer()->getNativeBuffer()->handle);
-
- sp<GraphicBuffer> newBuffer = GraphicBuffer::from(buffer);
-
- std::shared_ptr<renderengine::ExternalTexture> texture;
-
- for (auto it = mTextureCache.begin(); it != mTextureCache.end(); it++) {
- const auto& cachedTexture = *it;
- if (cachedTexture->getBuffer()->getId() == newBuffer->getId()) {
- texture = cachedTexture;
- mTextureCache.erase(it);
- break;
- }
- }
-
- if (texture) {
- mTexture = texture;
- } else {
- mTexture = std::make_shared<
- renderengine::ExternalTexture>(GraphicBuffer::from(buffer),
- mCompositionEngine.getRenderEngine(),
- renderengine::ExternalTexture::Usage::WRITEABLE);
- }
- mTextureCache.push_back(mTexture);
- if (mTextureCache.size() > mMaxTextureCacheSize) {
- mTextureCache.erase(mTextureCache.begin());
- }
+ ALOGW_IF(mGraphicBuffer != nullptr, "Clobbering a non-null pointer to a buffer [%p].",
+ mGraphicBuffer->getNativeBuffer()->handle);
+ mGraphicBuffer = GraphicBuffer::from(buffer);
*bufferFence = base::unique_fd(fd);
- return mTexture;
+ return mGraphicBuffer;
}
void RenderSurface::queueBuffer(base::unique_fd readyFence) {
@@ -204,24 +176,24 @@ void RenderSurface::queueBuffer(base::unique_fd readyFence) {
// hasFlipClientTargetRequest could return true even if we haven't
// dequeued a buffer before. Try dequeueing one if we don't have a
// buffer ready.
- if (mTexture == nullptr) {
+ if (mGraphicBuffer == nullptr) {
ALOGI("Attempting to queue a client composited buffer without one "
"previously dequeued for display [%s]. Attempting to dequeue "
"a scratch buffer now",
mDisplay.getName().c_str());
- // We shouldn't deadlock here, since mTexture == nullptr only
+ // We shouldn't deadlock here, since mGraphicBuffer == nullptr only
// after a successful call to queueBuffer, or if dequeueBuffer has
// never been called.
base::unique_fd unused;
dequeueBuffer(&unused);
}
- if (mTexture == nullptr) {
+ if (mGraphicBuffer == nullptr) {
ALOGE("No buffer is ready for display [%s]", mDisplay.getName().c_str());
} else {
- status_t result = mNativeWindow->queueBuffer(mNativeWindow.get(),
- mTexture->getBuffer()->getNativeBuffer(),
- dup(readyFence));
+ status_t result =
+ mNativeWindow->queueBuffer(mNativeWindow.get(),
+ mGraphicBuffer->getNativeBuffer(), dup(readyFence));
if (result != NO_ERROR) {
ALOGE("Error when queueing buffer for display [%s]: %d", mDisplay.getName().c_str(),
result);
@@ -231,12 +203,11 @@ void RenderSurface::queueBuffer(base::unique_fd readyFence) {
LOG_ALWAYS_FATAL("ANativeWindow::queueBuffer failed with error: %d", result);
} else {
mNativeWindow->cancelBuffer(mNativeWindow.get(),
- mTexture->getBuffer()->getNativeBuffer(),
- dup(readyFence));
+ mGraphicBuffer->getNativeBuffer(), dup(readyFence));
}
}
- mTexture = nullptr;
+ mGraphicBuffer = nullptr;
}
}
@@ -284,8 +255,8 @@ void RenderSurface::setSizeForTest(const ui::Size& size) {
mSize = size;
}
-std::shared_ptr<renderengine::ExternalTexture>& RenderSurface::mutableTextureForTest() {
- return mTexture;
+sp<GraphicBuffer>& RenderSurface::mutableGraphicBufferForTest() {
+ return mGraphicBuffer;
}
} // namespace impl