Rename Framebuffer to Renderer
This commit is contained in:
parent
7c7c8982b2
commit
467874a196
11 changed files with 129 additions and 129 deletions
|
|
@ -109,8 +109,8 @@ set(SOURCES
|
||||||
|
|
||||||
anbox/graphics/emugl/ColorBuffer.cpp
|
anbox/graphics/emugl/ColorBuffer.cpp
|
||||||
anbox/graphics/emugl/DisplayManager.cpp
|
anbox/graphics/emugl/DisplayManager.cpp
|
||||||
anbox/graphics/emugl/FbConfig.cpp
|
anbox/graphics/emugl/RendererConfig.cpp
|
||||||
anbox/graphics/emugl/FrameBuffer.cpp
|
anbox/graphics/emugl/Renderer.cpp
|
||||||
anbox/graphics/emugl/LayerManager.cpp
|
anbox/graphics/emugl/LayerManager.cpp
|
||||||
anbox/graphics/emugl/NativeSubWindow_delegate.cpp
|
anbox/graphics/emugl/NativeSubWindow_delegate.cpp
|
||||||
anbox/graphics/emugl/NativeSubWindow.h
|
anbox/graphics/emugl/NativeSubWindow.h
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ void LayerManager::post_layer(const LayerInfo &layer) {
|
||||||
if (is_layer_blacklisted(layer.name))
|
if (is_layer_blacklisted(layer.name))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FrameBufferWindow *window = nullptr;
|
RendererWindow *window = nullptr;
|
||||||
for (auto &l : layers_) {
|
for (auto &l : layers_) {
|
||||||
if (l.first == layer.name || from_same_package(l.first, layer.name)) {
|
if (l.first == layer.name || from_same_package(l.first, layer.name)) {
|
||||||
window = l.second.window;
|
window = l.second.window;
|
||||||
|
|
@ -99,7 +99,7 @@ void LayerManager::post_layer(const LayerInfo &layer) {
|
||||||
layer.source_crop.right,
|
layer.source_crop.right,
|
||||||
layer.source_crop.bottom);
|
layer.source_crop.bottom);
|
||||||
|
|
||||||
window = FrameBuffer::getFB()->createWindow(layer.display_frame.left,
|
window = Renderer::get()->createWindow(layer.display_frame.left,
|
||||||
layer.display_frame.top,
|
layer.display_frame.top,
|
||||||
width, height);
|
width, height);
|
||||||
if (!window) {
|
if (!window) {
|
||||||
|
|
@ -110,17 +110,17 @@ void LayerManager::post_layer(const LayerInfo &layer) {
|
||||||
layers_.insert({ layer.name, Layer{window, true}});
|
layers_.insert({ layer.name, Layer{window, true}});
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameBuffer::getFB()->updateWindow(window,
|
Renderer::get()->updateWindow(window,
|
||||||
layer.display_frame.left,
|
layer.display_frame.left,
|
||||||
layer.display_frame.top,
|
layer.display_frame.top,
|
||||||
width, height);
|
width, height);
|
||||||
FrameBuffer::getFB()->post(window, layer.buffer_handle);
|
Renderer::get()->post(window, layer.buffer_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerManager::finish_cycle() {
|
void LayerManager::finish_cycle() {
|
||||||
for (auto iter = layers_.begin(); iter != layers_.end(); ++iter) {
|
for (auto iter = layers_.begin(); iter != layers_.end(); ++iter) {
|
||||||
if (!iter->second.updated) {
|
if (!iter->second.updated) {
|
||||||
FrameBuffer::getFB()->destroyWindow(iter->second.window);
|
Renderer::get()->destroyWindow(iter->second.window);
|
||||||
layers_.erase(iter);
|
layers_.erase(iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "FrameBuffer.h"
|
#include "Renderer.h"
|
||||||
|
|
||||||
struct LayerRect {
|
struct LayerRect {
|
||||||
int left;
|
int left;
|
||||||
|
|
@ -53,7 +53,7 @@ private:
|
||||||
LayerManager();
|
LayerManager();
|
||||||
|
|
||||||
struct Layer {
|
struct Layer {
|
||||||
FrameBufferWindow *window;
|
RendererWindow *window;
|
||||||
bool updated;
|
bool updated;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
#include "RenderControl.h"
|
#include "RenderControl.h"
|
||||||
|
|
||||||
#include "DispatchTables.h"
|
#include "DispatchTables.h"
|
||||||
#include "FbConfig.h"
|
#include "RendererConfig.h"
|
||||||
#include "FrameBuffer.h"
|
#include "Renderer.h"
|
||||||
#include "RenderThreadInfo.h"
|
#include "RenderThreadInfo.h"
|
||||||
#include "ChecksumCalculatorThreadInfo.h"
|
#include "ChecksumCalculatorThreadInfo.h"
|
||||||
#include "LayerManager.h"
|
#include "LayerManager.h"
|
||||||
|
|
@ -37,7 +37,7 @@ static GLint rcGetRendererVersion()
|
||||||
|
|
||||||
static EGLint rcGetEGLVersion(EGLint* major, EGLint* minor)
|
static EGLint rcGetEGLVersion(EGLint* major, EGLint* minor)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return EGL_FALSE;
|
return EGL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
@ -49,7 +49,7 @@ static EGLint rcGetEGLVersion(EGLint* major, EGLint* minor)
|
||||||
|
|
||||||
static EGLint rcQueryEGLString(EGLenum name, void* buffer, EGLint bufferSize)
|
static EGLint rcQueryEGLString(EGLenum name, void* buffer, EGLint bufferSize)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -123,7 +123,7 @@ static EGLint rcGetNumConfigs(uint32_t* p_numAttribs)
|
||||||
{
|
{
|
||||||
int numConfigs = 0, numAttribs = 0;
|
int numConfigs = 0, numAttribs = 0;
|
||||||
|
|
||||||
FrameBuffer::getFB()->getConfigs()->getPackInfo(&numConfigs, &numAttribs);
|
Renderer::get()->getConfigs()->getPackInfo(&numConfigs, &numAttribs);
|
||||||
if (p_numAttribs) {
|
if (p_numAttribs) {
|
||||||
*p_numAttribs = static_cast<uint32_t>(numAttribs);
|
*p_numAttribs = static_cast<uint32_t>(numAttribs);
|
||||||
}
|
}
|
||||||
|
|
@ -133,7 +133,7 @@ static EGLint rcGetNumConfigs(uint32_t* p_numAttribs)
|
||||||
static EGLint rcGetConfigs(uint32_t bufSize, GLuint* buffer)
|
static EGLint rcGetConfigs(uint32_t bufSize, GLuint* buffer)
|
||||||
{
|
{
|
||||||
GLuint bufferSize = (GLuint)bufSize;
|
GLuint bufferSize = (GLuint)bufSize;
|
||||||
return FrameBuffer::getFB()->getConfigs()->packConfigs(bufferSize, buffer);
|
return Renderer::get()->getConfigs()->packConfigs(bufferSize, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static EGLint rcChooseConfig(EGLint *attribs,
|
static EGLint rcChooseConfig(EGLint *attribs,
|
||||||
|
|
@ -141,7 +141,7 @@ static EGLint rcChooseConfig(EGLint *attribs,
|
||||||
uint32_t *configs,
|
uint32_t *configs,
|
||||||
uint32_t configs_size)
|
uint32_t configs_size)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb || attribs_size==0) {
|
if (!fb || attribs_size==0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -152,7 +152,7 @@ static EGLint rcChooseConfig(EGLint *attribs,
|
||||||
|
|
||||||
static EGLint rcGetFBParam(EGLint param)
|
static EGLint rcGetFBParam(EGLint param)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -191,7 +191,7 @@ static EGLint rcGetFBParam(EGLint param)
|
||||||
static uint32_t rcCreateContext(uint32_t config,
|
static uint32_t rcCreateContext(uint32_t config,
|
||||||
uint32_t share, uint32_t glVersion)
|
uint32_t share, uint32_t glVersion)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -204,7 +204,7 @@ static uint32_t rcCreateContext(uint32_t config,
|
||||||
|
|
||||||
static void rcDestroyContext(uint32_t context)
|
static void rcDestroyContext(uint32_t context)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -215,7 +215,7 @@ static void rcDestroyContext(uint32_t context)
|
||||||
static uint32_t rcCreateWindowSurface(uint32_t config,
|
static uint32_t rcCreateWindowSurface(uint32_t config,
|
||||||
uint32_t width, uint32_t height)
|
uint32_t width, uint32_t height)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -225,7 +225,7 @@ static uint32_t rcCreateWindowSurface(uint32_t config,
|
||||||
|
|
||||||
static void rcDestroyWindowSurface(uint32_t windowSurface)
|
static void rcDestroyWindowSurface(uint32_t windowSurface)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -236,7 +236,7 @@ static void rcDestroyWindowSurface(uint32_t windowSurface)
|
||||||
static uint32_t rcCreateColorBuffer(uint32_t width,
|
static uint32_t rcCreateColorBuffer(uint32_t width,
|
||||||
uint32_t height, GLenum internalFormat)
|
uint32_t height, GLenum internalFormat)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -246,7 +246,7 @@ static uint32_t rcCreateColorBuffer(uint32_t width,
|
||||||
|
|
||||||
static int rcOpenColorBuffer2(uint32_t colorbuffer)
|
static int rcOpenColorBuffer2(uint32_t colorbuffer)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -262,7 +262,7 @@ static void rcOpenColorBuffer(uint32_t colorbuffer)
|
||||||
|
|
||||||
static void rcCloseColorBuffer(uint32_t colorbuffer)
|
static void rcCloseColorBuffer(uint32_t colorbuffer)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -271,7 +271,7 @@ static void rcCloseColorBuffer(uint32_t colorbuffer)
|
||||||
|
|
||||||
static int rcFlushWindowColorBuffer(uint32_t windowSurface)
|
static int rcFlushWindowColorBuffer(uint32_t windowSurface)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -284,7 +284,7 @@ static int rcFlushWindowColorBuffer(uint32_t windowSurface)
|
||||||
static void rcSetWindowColorBuffer(uint32_t windowSurface,
|
static void rcSetWindowColorBuffer(uint32_t windowSurface,
|
||||||
uint32_t colorBuffer)
|
uint32_t colorBuffer)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -294,7 +294,7 @@ static void rcSetWindowColorBuffer(uint32_t windowSurface,
|
||||||
static EGLint rcMakeCurrent(uint32_t context,
|
static EGLint rcMakeCurrent(uint32_t context,
|
||||||
uint32_t drawSurf, uint32_t readSurf)
|
uint32_t drawSurf, uint32_t readSurf)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return EGL_FALSE;
|
return EGL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
@ -306,7 +306,7 @@ static EGLint rcMakeCurrent(uint32_t context,
|
||||||
|
|
||||||
static void rcFBPost(uint32_t colorBuffer)
|
static void rcFBPost(uint32_t colorBuffer)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -321,7 +321,7 @@ static void rcFBSetSwapInterval(EGLint interval)
|
||||||
|
|
||||||
static void rcBindTexture(uint32_t colorBuffer)
|
static void rcBindTexture(uint32_t colorBuffer)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -331,7 +331,7 @@ static void rcBindTexture(uint32_t colorBuffer)
|
||||||
|
|
||||||
static void rcBindRenderbuffer(uint32_t colorBuffer)
|
static void rcBindRenderbuffer(uint32_t colorBuffer)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -351,7 +351,7 @@ static void rcReadColorBuffer(uint32_t colorBuffer,
|
||||||
GLint width, GLint height,
|
GLint width, GLint height,
|
||||||
GLenum format, GLenum type, void* pixels)
|
GLenum format, GLenum type, void* pixels)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -364,7 +364,7 @@ static int rcUpdateColorBuffer(uint32_t colorBuffer,
|
||||||
GLint width, GLint height,
|
GLint width, GLint height,
|
||||||
GLenum format, GLenum type, void* pixels)
|
GLenum format, GLenum type, void* pixels)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -375,7 +375,7 @@ static int rcUpdateColorBuffer(uint32_t colorBuffer,
|
||||||
|
|
||||||
static uint32_t rcCreateClientImage(uint32_t context, EGLenum target, GLuint buffer)
|
static uint32_t rcCreateClientImage(uint32_t context, EGLenum target, GLuint buffer)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -385,7 +385,7 @@ static uint32_t rcCreateClientImage(uint32_t context, EGLenum target, GLuint buf
|
||||||
|
|
||||||
static int rcDestroyClientImage(uint32_t image)
|
static int rcDestroyClientImage(uint32_t image)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
Renderer *fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
#include "RenderThread.h"
|
#include "RenderThread.h"
|
||||||
|
|
||||||
#include "FrameBuffer.h"
|
#include "Renderer.h"
|
||||||
#include "ReadBuffer.h"
|
#include "ReadBuffer.h"
|
||||||
#include "RenderControl.h"
|
#include "RenderControl.h"
|
||||||
#include "RenderThreadInfo.h"
|
#include "RenderThreadInfo.h"
|
||||||
|
|
@ -108,14 +108,14 @@ intptr_t RenderThread::main() {
|
||||||
//
|
//
|
||||||
// Release references to the current thread's context/surfaces if any
|
// Release references to the current thread's context/surfaces if any
|
||||||
//
|
//
|
||||||
FrameBuffer::getFB()->bindContext(0, 0, 0);
|
Renderer::get()->bindContext(0, 0, 0);
|
||||||
if (tInfo.currContext || tInfo.currDrawSurf || tInfo.currReadSurf) {
|
if (tInfo.currContext || tInfo.currDrawSurf || tInfo.currReadSurf) {
|
||||||
fprintf(stderr, "ERROR: RenderThread exiting with current context/surfaces\n");
|
fprintf(stderr, "ERROR: RenderThread exiting with current context/surfaces\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameBuffer::getFB()->drainWindowSurface();
|
Renderer::get()->drainWindowSurface();
|
||||||
|
|
||||||
FrameBuffer::getFB()->drainRenderContext();
|
Renderer::get()->drainRenderContext();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
#include "emugl/common/message_channel.h"
|
#include "emugl/common/message_channel.h"
|
||||||
#include "emugl/common/mutex.h"
|
#include "emugl/common/mutex.h"
|
||||||
#include "emugl/common/thread.h"
|
#include "emugl/common/thread.h"
|
||||||
#include "FrameBuffer.h"
|
#include "Renderer.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -109,13 +109,13 @@ struct RenderWindowMessage {
|
||||||
// Returns true on success, or false on failure.
|
// Returns true on success, or false on failure.
|
||||||
bool process() const {
|
bool process() const {
|
||||||
const RenderWindowMessage& msg = *this;
|
const RenderWindowMessage& msg = *this;
|
||||||
FrameBuffer* fb;
|
Renderer* fb;
|
||||||
bool result = false;
|
bool result = false;
|
||||||
switch (msg.cmd) {
|
switch (msg.cmd) {
|
||||||
case CMD_INITIALIZE:
|
case CMD_INITIALIZE:
|
||||||
D("CMD_INITIALIZE\n");
|
D("CMD_INITIALIZE\n");
|
||||||
GL_LOG("RenderWindow: CMD_INITIALIZE");
|
GL_LOG("RenderWindow: CMD_INITIALIZE");
|
||||||
result = FrameBuffer::initialize(msg.init.nativeDisplay);
|
result = Renderer::initialize(msg.init.nativeDisplay);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_FINALIZE:
|
case CMD_FINALIZE:
|
||||||
|
|
@ -123,7 +123,7 @@ struct RenderWindowMessage {
|
||||||
// this command may be issued even when frame buffer is not
|
// this command may be issued even when frame buffer is not
|
||||||
// yet created (e.g. if CMD_INITIALIZE failed),
|
// yet created (e.g. if CMD_INITIALIZE failed),
|
||||||
// so make sure we check if it is there before finalizing
|
// so make sure we check if it is there before finalizing
|
||||||
if (const auto fb = FrameBuffer::getFB()) {
|
if (const auto fb = Renderer::get()) {
|
||||||
fb->finalize();
|
fb->finalize();
|
||||||
}
|
}
|
||||||
result = true;
|
result = true;
|
||||||
|
|
@ -278,7 +278,7 @@ bool RenderWindow::getHardwareStrings(const char** vendor,
|
||||||
const char** version) {
|
const char** version) {
|
||||||
D("Entering\n");
|
D("Entering\n");
|
||||||
// TODO(digit): Move this to render window thread.
|
// TODO(digit): Move this to render window thread.
|
||||||
FrameBuffer* fb = FrameBuffer::getFB();
|
Renderer* fb = Renderer::get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
D("No framebuffer!\n");
|
D("No framebuffer!\n");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FrameBuffer.h"
|
#include "Renderer.h"
|
||||||
|
|
||||||
#include "DispatchTables.h"
|
#include "DispatchTables.h"
|
||||||
#include "NativeSubWindow.h"
|
#include "NativeSubWindow.h"
|
||||||
|
|
@ -35,7 +35,7 @@ class ScopedBind {
|
||||||
public:
|
public:
|
||||||
// Constructor will call bind_locked() on |fb|.
|
// Constructor will call bind_locked() on |fb|.
|
||||||
// Use isValid() to check for errors.
|
// Use isValid() to check for errors.
|
||||||
ScopedBind(FrameBuffer* fb) : mFb(fb) {
|
ScopedBind(Renderer* fb) : mFb(fb) {
|
||||||
if (!mFb->bind_locked()) {
|
if (!mFb->bind_locked()) {
|
||||||
mFb = NULL;
|
mFb = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -59,14 +59,14 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FrameBuffer* mFb;
|
Renderer* mFb;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Implementation of a ColorBuffer::Helper instance that redirects calls
|
// Implementation of a ColorBuffer::Helper instance that redirects calls
|
||||||
// to a FrameBuffer instance.
|
// to a FrameBuffer instance.
|
||||||
class ColorBufferHelper : public ColorBuffer::Helper {
|
class ColorBufferHelper : public ColorBuffer::Helper {
|
||||||
public:
|
public:
|
||||||
ColorBufferHelper(FrameBuffer* fb) : mFb(fb) {}
|
ColorBufferHelper(Renderer* fb) : mFb(fb) {}
|
||||||
|
|
||||||
virtual bool setupContext() {
|
virtual bool setupContext() {
|
||||||
return mFb->bind_locked();
|
return mFb->bind_locked();
|
||||||
|
|
@ -80,13 +80,13 @@ public:
|
||||||
return mFb->getTextureDraw();
|
return mFb->getTextureDraw();
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
FrameBuffer* mFb;
|
Renderer* mFb;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
FrameBuffer *FrameBuffer::s_theFrameBuffer = NULL;
|
Renderer *Renderer::s_renderer = NULL;
|
||||||
HandleType FrameBuffer::s_nextHandle = 0;
|
HandleType Renderer::s_nextHandle = 0;
|
||||||
|
|
||||||
static char* getGLES1ExtensionString(EGLDisplay p_dpy)
|
static char* getGLES1ExtensionString(EGLDisplay p_dpy)
|
||||||
{
|
{
|
||||||
|
|
@ -152,7 +152,7 @@ static char* getGLES1ExtensionString(EGLDisplay p_dpy)
|
||||||
return extString;
|
return extString;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameBuffer::finalize(){
|
void Renderer::finalize(){
|
||||||
m_colorbuffers.clear();
|
m_colorbuffers.clear();
|
||||||
m_windows.clear();
|
m_windows.clear();
|
||||||
m_contexts.clear();
|
m_contexts.clear();
|
||||||
|
|
@ -162,17 +162,17 @@ void FrameBuffer::finalize(){
|
||||||
s_egl.eglDestroySurface(m_eglDisplay, m_pbufSurface);
|
s_egl.eglDestroySurface(m_eglDisplay, m_pbufSurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameBuffer::initialize(EGLNativeDisplayType nativeDisplay)
|
bool Renderer::initialize(EGLNativeDisplayType nativeDisplay)
|
||||||
{
|
{
|
||||||
GL_LOG("FrameBuffer::initialize");
|
GL_LOG("FrameBuffer::initialize");
|
||||||
if (s_theFrameBuffer != NULL) {
|
if (s_renderer != NULL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// allocate space for the FrameBuffer object
|
// allocate space for the FrameBuffer object
|
||||||
//
|
//
|
||||||
FrameBuffer *fb = new FrameBuffer();
|
Renderer *fb = new Renderer();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
ERR("Failed to create fb\n");
|
ERR("Failed to create fb\n");
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -355,7 +355,7 @@ bool FrameBuffer::initialize(EGLNativeDisplayType nativeDisplay)
|
||||||
//
|
//
|
||||||
// Initialize set of configs
|
// Initialize set of configs
|
||||||
//
|
//
|
||||||
fb->m_configs = new FbConfigList(fb->m_eglDisplay);
|
fb->m_configs = new RendererConfigList(fb->m_eglDisplay);
|
||||||
if (fb->m_configs->empty()) {
|
if (fb->m_configs->empty()) {
|
||||||
ERR("Failed: Initialize set of configs\n");
|
ERR("Failed: Initialize set of configs\n");
|
||||||
bind.release();
|
bind.release();
|
||||||
|
|
@ -422,12 +422,12 @@ bool FrameBuffer::initialize(EGLNativeDisplayType nativeDisplay)
|
||||||
//
|
//
|
||||||
// Keep the singleton framebuffer pointer
|
// Keep the singleton framebuffer pointer
|
||||||
//
|
//
|
||||||
s_theFrameBuffer = fb;
|
s_renderer = fb;
|
||||||
GL_LOG("basic EGL initialization successful");
|
GL_LOG("basic EGL initialization successful");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameBuffer::FrameBuffer() :
|
Renderer::Renderer() :
|
||||||
m_configs(NULL),
|
m_configs(NULL),
|
||||||
m_eglDisplay(EGL_NO_DISPLAY),
|
m_eglDisplay(EGL_NO_DISPLAY),
|
||||||
m_colorBufferHelper(new ColorBufferHelper(this)),
|
m_colorBufferHelper(new ColorBufferHelper(this)),
|
||||||
|
|
@ -447,13 +447,13 @@ FrameBuffer::FrameBuffer() :
|
||||||
m_fpsStats = getenv("SHOW_FPS_STATS") != NULL;
|
m_fpsStats = getenv("SHOW_FPS_STATS") != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameBuffer::~FrameBuffer() {
|
Renderer::~Renderer() {
|
||||||
delete m_textureDraw;
|
delete m_textureDraw;
|
||||||
delete m_configs;
|
delete m_configs;
|
||||||
delete m_colorBufferHelper;
|
delete m_colorBufferHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FrameBufferWindow {
|
struct RendererWindow {
|
||||||
EGLNativeWindowType native_window = 0;
|
EGLNativeWindowType native_window = 0;
|
||||||
EGLSurface surface = EGL_NO_SURFACE;
|
EGLSurface surface = EGL_NO_SURFACE;
|
||||||
bool needViewportUpdate = false;
|
bool needViewportUpdate = false;
|
||||||
|
|
@ -461,7 +461,7 @@ struct FrameBufferWindow {
|
||||||
int height;
|
int height;
|
||||||
};
|
};
|
||||||
|
|
||||||
FrameBufferWindow* FrameBuffer::createWindow(int x, int y, int width, int height) {
|
RendererWindow* Renderer::createWindow(int x, int y, int width, int height) {
|
||||||
m_lock.lock();
|
m_lock.lock();
|
||||||
|
|
||||||
auto native_window = createSubWindow(0, x, y, width, height);
|
auto native_window = createSubWindow(0, x, y, width, height);
|
||||||
|
|
@ -470,7 +470,7 @@ FrameBufferWindow* FrameBuffer::createWindow(int x, int y, int width, int height
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto window = new FrameBufferWindow;
|
auto window = new RendererWindow;
|
||||||
window->native_window = native_window;
|
window->native_window = native_window;
|
||||||
window->width = width;
|
window->width = width;
|
||||||
window->height = height;
|
window->height = height;
|
||||||
|
|
@ -502,7 +502,7 @@ FrameBufferWindow* FrameBuffer::createWindow(int x, int y, int width, int height
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameBuffer::updateWindow(FrameBufferWindow *window, int x, int y, int width, int height) {
|
void Renderer::updateWindow(RendererWindow *window, int x, int y, int width, int height) {
|
||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -512,7 +512,7 @@ void FrameBuffer::updateWindow(FrameBufferWindow *window, int x, int y, int widt
|
||||||
window->needViewportUpdate = true;
|
window->needViewportUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameBuffer::destroyWindow(FrameBufferWindow *window) {
|
void Renderer::destroyWindow(RendererWindow *window) {
|
||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -530,7 +530,7 @@ void FrameBuffer::destroyWindow(FrameBufferWindow *window) {
|
||||||
m_lock.unlock();
|
m_lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleType FrameBuffer::genHandle()
|
HandleType Renderer::genHandle()
|
||||||
{
|
{
|
||||||
HandleType id;
|
HandleType id;
|
||||||
do {
|
do {
|
||||||
|
|
@ -542,7 +542,7 @@ HandleType FrameBuffer::genHandle()
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleType FrameBuffer::createColorBuffer(int p_width, int p_height,
|
HandleType Renderer::createColorBuffer(int p_width, int p_height,
|
||||||
GLenum p_internalFormat)
|
GLenum p_internalFormat)
|
||||||
{
|
{
|
||||||
emugl::Mutex::AutoLock mutex(m_lock);
|
emugl::Mutex::AutoLock mutex(m_lock);
|
||||||
|
|
@ -563,13 +563,13 @@ HandleType FrameBuffer::createColorBuffer(int p_width, int p_height,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleType FrameBuffer::createRenderContext(int p_config, HandleType p_share,
|
HandleType Renderer::createRenderContext(int p_config, HandleType p_share,
|
||||||
bool p_isGL2)
|
bool p_isGL2)
|
||||||
{
|
{
|
||||||
emugl::Mutex::AutoLock mutex(m_lock);
|
emugl::Mutex::AutoLock mutex(m_lock);
|
||||||
HandleType ret = 0;
|
HandleType ret = 0;
|
||||||
|
|
||||||
const FbConfig* config = getConfigs()->get(p_config);
|
const RendererConfig* config = getConfigs()->get(p_config);
|
||||||
if (!config) {
|
if (!config) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -596,13 +596,13 @@ HandleType FrameBuffer::createRenderContext(int p_config, HandleType p_share,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleType FrameBuffer::createWindowSurface(int p_config, int p_width, int p_height)
|
HandleType Renderer::createWindowSurface(int p_config, int p_width, int p_height)
|
||||||
{
|
{
|
||||||
emugl::Mutex::AutoLock mutex(m_lock);
|
emugl::Mutex::AutoLock mutex(m_lock);
|
||||||
|
|
||||||
HandleType ret = 0;
|
HandleType ret = 0;
|
||||||
|
|
||||||
const FbConfig* config = getConfigs()->get(p_config);
|
const RendererConfig* config = getConfigs()->get(p_config);
|
||||||
if (!config) {
|
if (!config) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -619,7 +619,7 @@ HandleType FrameBuffer::createWindowSurface(int p_config, int p_width, int p_hei
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameBuffer::drainRenderContext()
|
void Renderer::drainRenderContext()
|
||||||
{
|
{
|
||||||
emugl::Mutex::AutoLock mutex(m_lock);
|
emugl::Mutex::AutoLock mutex(m_lock);
|
||||||
RenderThreadInfo *tinfo = RenderThreadInfo::get();
|
RenderThreadInfo *tinfo = RenderThreadInfo::get();
|
||||||
|
|
@ -632,7 +632,7 @@ void FrameBuffer::drainRenderContext()
|
||||||
tinfo->m_contextSet.clear();
|
tinfo->m_contextSet.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameBuffer::drainWindowSurface()
|
void Renderer::drainWindowSurface()
|
||||||
{
|
{
|
||||||
emugl::Mutex::AutoLock mutex(m_lock);
|
emugl::Mutex::AutoLock mutex(m_lock);
|
||||||
RenderThreadInfo *tinfo = RenderThreadInfo::get();
|
RenderThreadInfo *tinfo = RenderThreadInfo::get();
|
||||||
|
|
@ -654,7 +654,7 @@ void FrameBuffer::drainWindowSurface()
|
||||||
tinfo->m_windowSet.clear();
|
tinfo->m_windowSet.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameBuffer::DestroyRenderContext(HandleType p_context)
|
void Renderer::DestroyRenderContext(HandleType p_context)
|
||||||
{
|
{
|
||||||
emugl::Mutex::AutoLock mutex(m_lock);
|
emugl::Mutex::AutoLock mutex(m_lock);
|
||||||
m_contexts.erase(p_context);
|
m_contexts.erase(p_context);
|
||||||
|
|
@ -663,7 +663,7 @@ void FrameBuffer::DestroyRenderContext(HandleType p_context)
|
||||||
tinfo->m_contextSet.erase(p_context);
|
tinfo->m_contextSet.erase(p_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameBuffer::DestroyWindowSurface(HandleType p_surface)
|
void Renderer::DestroyWindowSurface(HandleType p_surface)
|
||||||
{
|
{
|
||||||
emugl::Mutex::AutoLock mutex(m_lock);
|
emugl::Mutex::AutoLock mutex(m_lock);
|
||||||
if (m_windows.find(p_surface) != m_windows.end()) {
|
if (m_windows.find(p_surface) != m_windows.end()) {
|
||||||
|
|
@ -674,7 +674,7 @@ void FrameBuffer::DestroyWindowSurface(HandleType p_surface)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FrameBuffer::openColorBuffer(HandleType p_colorbuffer)
|
int Renderer::openColorBuffer(HandleType p_colorbuffer)
|
||||||
{
|
{
|
||||||
emugl::Mutex::AutoLock mutex(m_lock);
|
emugl::Mutex::AutoLock mutex(m_lock);
|
||||||
ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer));
|
ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer));
|
||||||
|
|
@ -687,7 +687,7 @@ int FrameBuffer::openColorBuffer(HandleType p_colorbuffer)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameBuffer::closeColorBuffer(HandleType p_colorbuffer)
|
void Renderer::closeColorBuffer(HandleType p_colorbuffer)
|
||||||
{
|
{
|
||||||
emugl::Mutex::AutoLock mutex(m_lock);
|
emugl::Mutex::AutoLock mutex(m_lock);
|
||||||
ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer));
|
ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer));
|
||||||
|
|
@ -703,7 +703,7 @@ void FrameBuffer::closeColorBuffer(HandleType p_colorbuffer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameBuffer::flushWindowSurfaceColorBuffer(HandleType p_surface)
|
bool Renderer::flushWindowSurfaceColorBuffer(HandleType p_surface)
|
||||||
{
|
{
|
||||||
emugl::Mutex::AutoLock mutex(m_lock);
|
emugl::Mutex::AutoLock mutex(m_lock);
|
||||||
|
|
||||||
|
|
@ -720,7 +720,7 @@ bool FrameBuffer::flushWindowSurfaceColorBuffer(HandleType p_surface)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameBuffer::setWindowSurfaceColorBuffer(HandleType p_surface,
|
bool Renderer::setWindowSurfaceColorBuffer(HandleType p_surface,
|
||||||
HandleType p_colorbuffer)
|
HandleType p_colorbuffer)
|
||||||
{
|
{
|
||||||
emugl::Mutex::AutoLock mutex(m_lock);
|
emugl::Mutex::AutoLock mutex(m_lock);
|
||||||
|
|
@ -744,7 +744,7 @@ bool FrameBuffer::setWindowSurfaceColorBuffer(HandleType p_surface,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameBuffer::readColorBuffer(HandleType p_colorbuffer,
|
void Renderer::readColorBuffer(HandleType p_colorbuffer,
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height,
|
||||||
GLenum format, GLenum type, void *pixels)
|
GLenum format, GLenum type, void *pixels)
|
||||||
{
|
{
|
||||||
|
|
@ -759,7 +759,7 @@ void FrameBuffer::readColorBuffer(HandleType p_colorbuffer,
|
||||||
(*c).second.cb->readPixels(x, y, width, height, format, type, pixels);
|
(*c).second.cb->readPixels(x, y, width, height, format, type, pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameBuffer::updateColorBuffer(HandleType p_colorbuffer,
|
bool Renderer::updateColorBuffer(HandleType p_colorbuffer,
|
||||||
int x, int y, int width, int height,
|
int x, int y, int width, int height,
|
||||||
GLenum format, GLenum type, void *pixels)
|
GLenum format, GLenum type, void *pixels)
|
||||||
{
|
{
|
||||||
|
|
@ -776,7 +776,7 @@ bool FrameBuffer::updateColorBuffer(HandleType p_colorbuffer,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameBuffer::bindColorBufferToTexture(HandleType p_colorbuffer)
|
bool Renderer::bindColorBufferToTexture(HandleType p_colorbuffer)
|
||||||
{
|
{
|
||||||
emugl::Mutex::AutoLock mutex(m_lock);
|
emugl::Mutex::AutoLock mutex(m_lock);
|
||||||
|
|
||||||
|
|
@ -789,7 +789,7 @@ bool FrameBuffer::bindColorBufferToTexture(HandleType p_colorbuffer)
|
||||||
return (*c).second.cb->bindToTexture();
|
return (*c).second.cb->bindToTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameBuffer::bindColorBufferToRenderbuffer(HandleType p_colorbuffer)
|
bool Renderer::bindColorBufferToRenderbuffer(HandleType p_colorbuffer)
|
||||||
{
|
{
|
||||||
emugl::Mutex::AutoLock mutex(m_lock);
|
emugl::Mutex::AutoLock mutex(m_lock);
|
||||||
|
|
||||||
|
|
@ -802,7 +802,7 @@ bool FrameBuffer::bindColorBufferToRenderbuffer(HandleType p_colorbuffer)
|
||||||
return (*c).second.cb->bindToRenderbuffer();
|
return (*c).second.cb->bindToRenderbuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameBuffer::bindContext(HandleType p_context,
|
bool Renderer::bindContext(HandleType p_context,
|
||||||
HandleType p_drawSurface,
|
HandleType p_drawSurface,
|
||||||
HandleType p_readSurface)
|
HandleType p_readSurface)
|
||||||
{
|
{
|
||||||
|
|
@ -891,7 +891,7 @@ bool FrameBuffer::bindContext(HandleType p_context,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleType FrameBuffer::createClientImage(HandleType context, EGLenum target, GLuint buffer)
|
HandleType Renderer::createClientImage(HandleType context, EGLenum target, GLuint buffer)
|
||||||
{
|
{
|
||||||
RenderContextPtr ctx(NULL);
|
RenderContextPtr ctx(NULL);
|
||||||
|
|
||||||
|
|
@ -913,7 +913,7 @@ HandleType FrameBuffer::createClientImage(HandleType context, EGLenum target, GL
|
||||||
return (HandleType)reinterpret_cast<uintptr_t>(image);
|
return (HandleType)reinterpret_cast<uintptr_t>(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLBoolean FrameBuffer::destroyClientImage(HandleType image)
|
EGLBoolean Renderer::destroyClientImage(HandleType image)
|
||||||
{
|
{
|
||||||
return s_egl.eglDestroyImageKHR(m_eglDisplay,
|
return s_egl.eglDestroyImageKHR(m_eglDisplay,
|
||||||
reinterpret_cast<EGLImageKHR>(image));
|
reinterpret_cast<EGLImageKHR>(image));
|
||||||
|
|
@ -922,7 +922,7 @@ EGLBoolean FrameBuffer::destroyClientImage(HandleType image)
|
||||||
//
|
//
|
||||||
// The framebuffer lock should be held when calling this function !
|
// The framebuffer lock should be held when calling this function !
|
||||||
//
|
//
|
||||||
bool FrameBuffer::bind_locked()
|
bool Renderer::bind_locked()
|
||||||
{
|
{
|
||||||
EGLContext prevContext = s_egl.eglGetCurrentContext();
|
EGLContext prevContext = s_egl.eglGetCurrentContext();
|
||||||
EGLSurface prevReadSurf = s_egl.eglGetCurrentSurface(EGL_READ);
|
EGLSurface prevReadSurf = s_egl.eglGetCurrentSurface(EGL_READ);
|
||||||
|
|
@ -940,7 +940,7 @@ bool FrameBuffer::bind_locked()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameBuffer::bindWindow_locked(FrameBufferWindow *window)
|
bool Renderer::bindWindow_locked(RendererWindow *window)
|
||||||
{
|
{
|
||||||
EGLContext prevContext = s_egl.eglGetCurrentContext();
|
EGLContext prevContext = s_egl.eglGetCurrentContext();
|
||||||
EGLSurface prevReadSurf = s_egl.eglGetCurrentSurface(EGL_READ);
|
EGLSurface prevReadSurf = s_egl.eglGetCurrentSurface(EGL_READ);
|
||||||
|
|
@ -958,7 +958,7 @@ bool FrameBuffer::bindWindow_locked(FrameBufferWindow *window)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameBuffer::unbind_locked()
|
bool Renderer::unbind_locked()
|
||||||
{
|
{
|
||||||
if (!s_egl.eglMakeCurrent(m_eglDisplay, m_prevDrawSurf,
|
if (!s_egl.eglMakeCurrent(m_eglDisplay, m_prevDrawSurf,
|
||||||
m_prevReadSurf, m_prevContext)) {
|
m_prevReadSurf, m_prevContext)) {
|
||||||
|
|
@ -971,7 +971,7 @@ bool FrameBuffer::unbind_locked()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameBuffer::post(FrameBufferWindow *window, HandleType p_colorbuffer, bool needLock)
|
bool Renderer::post(RendererWindow *window, HandleType p_colorbuffer, bool needLock)
|
||||||
{
|
{
|
||||||
if (!window)
|
if (!window)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include "ColorBuffer.h"
|
#include "ColorBuffer.h"
|
||||||
#include "emugl/common/mutex.h"
|
#include "emugl/common/mutex.h"
|
||||||
#include "FbConfig.h"
|
#include "RendererConfig.h"
|
||||||
#include "RenderContext.h"
|
#include "RenderContext.h"
|
||||||
#include "TextureDraw.h"
|
#include "TextureDraw.h"
|
||||||
#include "WindowSurface.h"
|
#include "WindowSurface.h"
|
||||||
|
|
@ -51,14 +51,14 @@ typedef std::map<HandleType, ColorBufferRef> ColorBufferMap;
|
||||||
// extension is supported.
|
// extension is supported.
|
||||||
// |eglMajor| and |eglMinor| are the major and minor version numbers of
|
// |eglMajor| and |eglMinor| are the major and minor version numbers of
|
||||||
// the underlying EGL implementation.
|
// the underlying EGL implementation.
|
||||||
struct FrameBufferCaps {
|
struct RendererCaps {
|
||||||
bool has_eglimage_texture_2d;
|
bool has_eglimage_texture_2d;
|
||||||
bool has_eglimage_renderbuffer;
|
bool has_eglimage_renderbuffer;
|
||||||
EGLint eglMajor;
|
EGLint eglMajor;
|
||||||
EGLint eglMinor;
|
EGLint eglMinor;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FrameBufferWindow;
|
struct RendererWindow;
|
||||||
|
|
||||||
// The FrameBuffer class holds the global state of the emulation library on
|
// The FrameBuffer class holds the global state of the emulation library on
|
||||||
// top of the underlying EGL/GLES implementation. It should probably be
|
// top of the underlying EGL/GLES implementation. It should probably be
|
||||||
|
|
@ -67,7 +67,7 @@ struct FrameBufferWindow;
|
||||||
// There is only one global instance, that can be retrieved with getFB(),
|
// There is only one global instance, that can be retrieved with getFB(),
|
||||||
// and which must be previously setup by calling initialize().
|
// and which must be previously setup by calling initialize().
|
||||||
//
|
//
|
||||||
class FrameBuffer {
|
class Renderer {
|
||||||
public:
|
public:
|
||||||
// Initialize the global instance.
|
// Initialize the global instance.
|
||||||
// |width| and |height| are the dimensions of the emulator GPU display
|
// |width| and |height| are the dimensions of the emulator GPU display
|
||||||
|
|
@ -78,22 +78,22 @@ public:
|
||||||
// Returns true on success, false otherwise.
|
// Returns true on success, false otherwise.
|
||||||
static bool initialize(EGLNativeDisplayType nativeDisplay);
|
static bool initialize(EGLNativeDisplayType nativeDisplay);
|
||||||
|
|
||||||
FrameBufferWindow* createWindow(int x, int y, int width, int height);
|
RendererWindow* createWindow(int x, int y, int width, int height);
|
||||||
void updateWindow(FrameBufferWindow *window, int x, int y, int width, int height);
|
void updateWindow(RendererWindow *window, int x, int y, int width, int height);
|
||||||
void destroyWindow(FrameBufferWindow *window);
|
void destroyWindow(RendererWindow *window);
|
||||||
|
|
||||||
// Finalize the instance.
|
// Finalize the instance.
|
||||||
void finalize();
|
void finalize();
|
||||||
|
|
||||||
// Return a pointer to the global instance. initialize() must be called
|
// Return a pointer to the global instance. initialize() must be called
|
||||||
// previously, or this will return NULL.
|
// previously, or this will return NULL.
|
||||||
static FrameBuffer *getFB() { return s_theFrameBuffer; }
|
static Renderer *get() { return s_renderer; }
|
||||||
|
|
||||||
// Return the capabilities of the underlying display.
|
// Return the capabilities of the underlying display.
|
||||||
const FrameBufferCaps &getCaps() const { return m_caps; }
|
const RendererCaps &getCaps() const { return m_caps; }
|
||||||
|
|
||||||
// Return the list of configs available from this display.
|
// Return the list of configs available from this display.
|
||||||
const FbConfigList* getConfigs() const { return m_configs; }
|
const RendererConfigList* getConfigs() const { return m_configs; }
|
||||||
|
|
||||||
// Set a callback that will be called each time the emulated GPU content
|
// Set a callback that will be called each time the emulated GPU content
|
||||||
// is updated. This can be relatively slow with host-based GPU emulation,
|
// is updated. This can be relatively slow with host-based GPU emulation,
|
||||||
|
|
@ -232,7 +232,7 @@ public:
|
||||||
// |needLock| is used to indicate whether the operation requires
|
// |needLock| is used to indicate whether the operation requires
|
||||||
// acquiring/releasing the FrameBuffer instance's lock. It should be
|
// acquiring/releasing the FrameBuffer instance's lock. It should be
|
||||||
// false only when called internally.
|
// false only when called internally.
|
||||||
bool post(FrameBufferWindow *window, HandleType p_colorbuffer, bool needLock = true);
|
bool post(RendererWindow *window, HandleType p_colorbuffer, bool needLock = true);
|
||||||
|
|
||||||
// Return the host EGLDisplay used by this instance.
|
// Return the host EGLDisplay used by this instance.
|
||||||
EGLDisplay getDisplay() const { return m_eglDisplay; }
|
EGLDisplay getDisplay() const { return m_eglDisplay; }
|
||||||
|
|
@ -249,19 +249,19 @@ public:
|
||||||
bool unbind_locked();
|
bool unbind_locked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FrameBuffer();
|
Renderer();
|
||||||
~FrameBuffer();
|
~Renderer();
|
||||||
HandleType genHandle();
|
HandleType genHandle();
|
||||||
|
|
||||||
bool bindWindow_locked(FrameBufferWindow *window);
|
bool bindWindow_locked(RendererWindow *window);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static FrameBuffer *s_theFrameBuffer;
|
static Renderer *s_renderer;
|
||||||
static HandleType s_nextHandle;
|
static HandleType s_nextHandle;
|
||||||
emugl::Mutex m_lock;
|
emugl::Mutex m_lock;
|
||||||
FbConfigList* m_configs;
|
RendererConfigList* m_configs;
|
||||||
FBNativeWindowType m_nativeWindow;
|
FBNativeWindowType m_nativeWindow;
|
||||||
FrameBufferCaps m_caps;
|
RendererCaps m_caps;
|
||||||
EGLDisplay m_eglDisplay;
|
EGLDisplay m_eglDisplay;
|
||||||
RenderContextMap m_contexts;
|
RenderContextMap m_contexts;
|
||||||
WindowSurfaceMap m_windows;
|
WindowSurfaceMap m_windows;
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "FbConfig.h"
|
#include "RendererConfig.h"
|
||||||
|
|
||||||
#include "OpenGLESDispatch/EGLDispatch.h"
|
#include "OpenGLESDispatch/EGLDispatch.h"
|
||||||
|
|
||||||
|
|
@ -92,11 +92,11 @@ bool isCompatibleHostConfig(EGLConfig config, EGLDisplay display) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
FbConfig::~FbConfig() {
|
RendererConfig::~RendererConfig() {
|
||||||
delete [] mAttribValues;
|
delete [] mAttribValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
FbConfig::FbConfig(EGLConfig hostConfig, EGLDisplay hostDisplay) :
|
RendererConfig::RendererConfig(EGLConfig hostConfig, EGLDisplay hostDisplay) :
|
||||||
mEglConfig(hostConfig), mAttribValues(NULL) {
|
mEglConfig(hostConfig), mAttribValues(NULL) {
|
||||||
mAttribValues = new GLint[kConfigAttributesLen];
|
mAttribValues = new GLint[kConfigAttributesLen];
|
||||||
for (size_t i = 0; i < kConfigAttributesLen; ++i) {
|
for (size_t i = 0; i < kConfigAttributesLen; ++i) {
|
||||||
|
|
@ -114,7 +114,7 @@ FbConfig::FbConfig(EGLConfig hostConfig, EGLDisplay hostDisplay) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FbConfigList::FbConfigList(EGLDisplay display) :
|
RendererConfigList::RendererConfigList(EGLDisplay display) :
|
||||||
mCount(0), mConfigs(NULL), mDisplay(display) {
|
mCount(0), mConfigs(NULL), mDisplay(display) {
|
||||||
if (display == EGL_NO_DISPLAY) {
|
if (display == EGL_NO_DISPLAY) {
|
||||||
E("%s: Invalid display value %p (EGL_NO_DISPLAY)\n",
|
E("%s: Invalid display value %p (EGL_NO_DISPLAY)\n",
|
||||||
|
|
@ -130,27 +130,27 @@ FbConfigList::FbConfigList(EGLDisplay display) :
|
||||||
EGLConfig* hostConfigs = new EGLConfig[numHostConfigs];
|
EGLConfig* hostConfigs = new EGLConfig[numHostConfigs];
|
||||||
s_egl.eglGetConfigs(display, hostConfigs, numHostConfigs, &numHostConfigs);
|
s_egl.eglGetConfigs(display, hostConfigs, numHostConfigs, &numHostConfigs);
|
||||||
|
|
||||||
mConfigs = new FbConfig*[numHostConfigs];
|
mConfigs = new RendererConfig*[numHostConfigs];
|
||||||
for (EGLint i = 0; i < numHostConfigs; ++i) {
|
for (EGLint i = 0; i < numHostConfigs; ++i) {
|
||||||
// Filter out configs that are not compatible with our implementation.
|
// Filter out configs that are not compatible with our implementation.
|
||||||
if (!isCompatibleHostConfig(hostConfigs[i], display)) {
|
if (!isCompatibleHostConfig(hostConfigs[i], display)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
mConfigs[mCount] = new FbConfig(hostConfigs[i], display);
|
mConfigs[mCount] = new RendererConfig(hostConfigs[i], display);
|
||||||
mCount++;
|
mCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] hostConfigs;
|
delete [] hostConfigs;
|
||||||
}
|
}
|
||||||
|
|
||||||
FbConfigList::~FbConfigList() {
|
RendererConfigList::~RendererConfigList() {
|
||||||
for (int n = 0; n < mCount; ++n) {
|
for (int n = 0; n < mCount; ++n) {
|
||||||
delete mConfigs[n];
|
delete mConfigs[n];
|
||||||
}
|
}
|
||||||
delete [] mConfigs;
|
delete [] mConfigs;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FbConfigList::chooseConfig(const EGLint* attribs,
|
int RendererConfigList::chooseConfig(const EGLint* attribs,
|
||||||
EGLint* configs,
|
EGLint* configs,
|
||||||
EGLint configsSize) const {
|
EGLint configsSize) const {
|
||||||
EGLint numHostConfigs = 0;
|
EGLint numHostConfigs = 0;
|
||||||
|
|
@ -245,7 +245,7 @@ int FbConfigList::chooseConfig(const EGLint* attribs,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FbConfigList::getPackInfo(EGLint* numConfigs,
|
void RendererConfigList::getPackInfo(EGLint* numConfigs,
|
||||||
EGLint* numAttributes) const {
|
EGLint* numAttributes) const {
|
||||||
if (numConfigs) {
|
if (numConfigs) {
|
||||||
*numConfigs = mCount;
|
*numConfigs = mCount;
|
||||||
|
|
@ -255,7 +255,7 @@ void FbConfigList::getPackInfo(EGLint* numConfigs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLint FbConfigList::packConfigs(GLuint bufferByteSize, GLuint* buffer) const {
|
EGLint RendererConfigList::packConfigs(GLuint bufferByteSize, GLuint* buffer) const {
|
||||||
GLuint numAttribs = static_cast<GLuint>(kConfigAttributesLen);
|
GLuint numAttribs = static_cast<GLuint>(kConfigAttributesLen);
|
||||||
GLuint kGLuintSize = static_cast<GLuint>(sizeof(GLuint));
|
GLuint kGLuintSize = static_cast<GLuint>(sizeof(GLuint));
|
||||||
GLuint neededByteSize = (mCount + 1) * numAttribs * kGLuintSize;
|
GLuint neededByteSize = (mCount + 1) * numAttribs * kGLuintSize;
|
||||||
|
|
@ -32,10 +32,10 @@
|
||||||
// One doesn't create an FbConfig instance. Instead, create and initialize
|
// One doesn't create an FbConfig instance. Instead, create and initialize
|
||||||
// an FbConfigList from the host EGLDisplay, and use its size() and get()
|
// an FbConfigList from the host EGLDisplay, and use its size() and get()
|
||||||
// methods to access it.
|
// methods to access it.
|
||||||
class FbConfig {
|
class RendererConfig {
|
||||||
public:
|
public:
|
||||||
// Destructor
|
// Destructor
|
||||||
~FbConfig();
|
~RendererConfig();
|
||||||
|
|
||||||
// Retrieve host EGLConfig.
|
// Retrieve host EGLConfig.
|
||||||
EGLConfig getEglConfig() const { return mEglConfig; }
|
EGLConfig getEglConfig() const { return mEglConfig; }
|
||||||
|
|
@ -57,12 +57,12 @@ public:
|
||||||
GLint getConfigId() const { return (GLint)getAttribValue(4); }
|
GLint getConfigId() const { return (GLint)getAttribValue(4); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FbConfig();
|
RendererConfig();
|
||||||
FbConfig(FbConfig& other);
|
RendererConfig(RendererConfig& other);
|
||||||
|
|
||||||
explicit FbConfig(EGLConfig hostConfig, EGLDisplay hostDisplay);
|
explicit RendererConfig(EGLConfig hostConfig, EGLDisplay hostDisplay);
|
||||||
|
|
||||||
friend class FbConfigList;
|
friend class RendererConfigList;
|
||||||
|
|
||||||
GLuint getAttribValue(int n) const {
|
GLuint getAttribValue(int n) const {
|
||||||
return mAttribValues ? mAttribValues[n] : 0U;
|
return mAttribValues ? mAttribValues[n] : 0U;
|
||||||
|
|
@ -91,7 +91,7 @@ private:
|
||||||
//
|
//
|
||||||
// 5) Use getPackInfo() and packConfigs() to retrieve information about
|
// 5) Use getPackInfo() and packConfigs() to retrieve information about
|
||||||
// available configs to the guest.
|
// available configs to the guest.
|
||||||
class FbConfigList {
|
class RendererConfigList {
|
||||||
public:
|
public:
|
||||||
// Create a new list of FbConfig instance, by querying all compatible
|
// Create a new list of FbConfig instance, by querying all compatible
|
||||||
// host configs from |display|. A compatible config is one that supports
|
// host configs from |display|. A compatible config is one that supports
|
||||||
|
|
@ -99,10 +99,10 @@ public:
|
||||||
//
|
//
|
||||||
// After construction, call empty() to check if there are items.
|
// After construction, call empty() to check if there are items.
|
||||||
// An empty list means there was an error during construction.
|
// An empty list means there was an error during construction.
|
||||||
explicit FbConfigList(EGLDisplay display);
|
explicit RendererConfigList(EGLDisplay display);
|
||||||
|
|
||||||
// Destructor.
|
// Destructor.
|
||||||
~FbConfigList();
|
~RendererConfigList();
|
||||||
|
|
||||||
// Return true iff the list is empty. true means there was an error
|
// Return true iff the list is empty. true means there was an error
|
||||||
// during construction.
|
// during construction.
|
||||||
|
|
@ -116,7 +116,7 @@ public:
|
||||||
// Retrieve the FbConfig instance associated with |guestId|,
|
// Retrieve the FbConfig instance associated with |guestId|,
|
||||||
// which must be an integer between 0 and |size() - 1|. Returns
|
// which must be an integer between 0 and |size() - 1|. Returns
|
||||||
// NULL in case of failure.
|
// NULL in case of failure.
|
||||||
const FbConfig* get(int guestId) const {
|
const RendererConfig* get(int guestId) const {
|
||||||
if (guestId >= 0 && guestId < mCount) {
|
if (guestId >= 0 && guestId < mCount) {
|
||||||
return mConfigs[guestId];
|
return mConfigs[guestId];
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -152,11 +152,11 @@ public:
|
||||||
EGLint packConfigs(GLuint bufferByteSize, GLuint* buffer) const;
|
EGLint packConfigs(GLuint bufferByteSize, GLuint* buffer) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FbConfigList();
|
RendererConfigList();
|
||||||
FbConfigList(const FbConfigList& other);
|
RendererConfigList(const RendererConfigList& other);
|
||||||
|
|
||||||
int mCount;
|
int mCount;
|
||||||
FbConfig** mConfigs;
|
RendererConfig** mConfigs;
|
||||||
EGLDisplay mDisplay;
|
EGLDisplay mDisplay;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
#include "WindowSurface.h"
|
#include "WindowSurface.h"
|
||||||
|
|
||||||
#include "ErrorLog.h"
|
#include "ErrorLog.h"
|
||||||
#include "FbConfig.h"
|
#include "RendererConfig.h"
|
||||||
|
|
||||||
#include "OpenGLESDispatch/EGLDispatch.h"
|
#include "OpenGLESDispatch/EGLDispatch.h"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue