diff options
author | 2016-01-08 10:52:16 -0800 | |
---|---|---|
committer | 2016-01-11 16:29:39 -0800 | |
commit | c044ae5dfc62031924c2f4c0ecc87b0da72a6b3f (patch) | |
tree | 094e146f6bf769aae8c142aa5b846b346015a141 | |
parent | 35f475653c2ca922acc358c607b204c8fafd6ad5 (diff) |
libagl: Switch from gralloc to GraphicBufferMapper
Removes all direct references to the gralloc module from libagl and
uses the GraphicBufferMapper class instead when locking and unlocking
buffers.
Also a couple of minor code cleanups to eliminate warnings.
Change-Id: Ie982d375b3152d5f677ab54c2067179b8d34c06d
-rw-r--r-- | opengl/libagl/context.h | 5 | ||||
-rw-r--r-- | opengl/libagl/egl.cpp | 28 | ||||
-rw-r--r-- | opengl/libagl/light.cpp | 2 | ||||
-rw-r--r-- | opengl/libagl/matrix.cpp | 12 | ||||
-rw-r--r-- | opengl/libagl/texture.cpp | 25 |
5 files changed, 28 insertions, 44 deletions
diff --git a/opengl/libagl/context.h b/opengl/libagl/context.h index d23f43568e..18ef7d5716 100644 --- a/opengl/libagl/context.h +++ b/opengl/libagl/context.h @@ -26,7 +26,8 @@ #endif #include <private/pixelflinger/ggl_context.h> -#include <hardware/gralloc.h> + +#include <system/window.h> #include <GLES/gl.h> #include <GLES/glext.h> @@ -615,7 +616,7 @@ struct ogles_context_t { culling_t cull; lighting_t lighting; user_clip_planes_t clipPlanes; - compute_iterators_t lerp; __attribute__((aligned(32))); + compute_iterators_t lerp __attribute__((aligned(32))); vertex_t current; vec4_t currentColorClamped; vec3_t currentNormal; diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp index 7560d8fdf0..47733e6d3d 100644 --- a/opengl/libagl/egl.cpp +++ b/opengl/libagl/egl.cpp @@ -32,6 +32,7 @@ #include <utils/threads.h> #include <ui/ANativeObjectBase.h> #include <ui/Fence.h> +#include <ui/GraphicBufferMapper.h> #include <EGL/egl.h> #include <EGL/eglext.h> @@ -242,7 +243,6 @@ private: ANativeWindow* nativeWindow; ANativeWindowBuffer* buffer; ANativeWindowBuffer* previousBuffer; - gralloc_module_t const* module; int width; int height; void* bits; @@ -341,16 +341,12 @@ egl_window_surface_v2_t::egl_window_surface_v2_t(EGLDisplay dpy, EGLConfig config, int32_t depthFormat, ANativeWindow* window) - : egl_surface_t(dpy, config, depthFormat), - nativeWindow(window), buffer(0), previousBuffer(0), module(0), - bits(NULL) + : egl_surface_t(dpy, config, depthFormat), + nativeWindow(window), buffer(0), previousBuffer(0), bits(NULL) { - hw_module_t const* pModule; - hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &pModule); - module = reinterpret_cast<gralloc_module_t const*>(pModule); pixelFormatTable = gglGetPixelFormatTable(); - + // keep a reference on the window nativeWindow->common.incRef(&nativeWindow->common); nativeWindow->query(nativeWindow, NATIVE_WINDOW_WIDTH, &width); @@ -440,22 +436,16 @@ void egl_window_surface_v2_t::disconnect() status_t egl_window_surface_v2_t::lock( ANativeWindowBuffer* buf, int usage, void** vaddr) { - int err; - - err = module->lock(module, buf->handle, - usage, 0, 0, buf->width, buf->height, vaddr); - - return err; + auto& mapper = GraphicBufferMapper::get(); + return mapper.lock(buf->handle, usage, + android::Rect(buf->width, buf->height), vaddr); } status_t egl_window_surface_v2_t::unlock(ANativeWindowBuffer* buf) { if (!buf) return BAD_VALUE; - int err = NO_ERROR; - - err = module->unlock(module, buf->handle); - - return err; + auto& mapper = GraphicBufferMapper::get(); + return mapper.unlock(buf->handle); } void egl_window_surface_v2_t::copyBlt( diff --git a/opengl/libagl/light.cpp b/opengl/libagl/light.cpp index 479bf7ee07..e7fe9d71a3 100644 --- a/opengl/libagl/light.cpp +++ b/opengl/libagl/light.cpp @@ -229,7 +229,7 @@ static inline void validate_light_mvi(ogles_context_t* c) #endif vnorm3(l.normalizedObjPosition.v, l.objPosition.v); } - const vec4_t eyeViewer = { 0, 0, 0x10000, 0 }; + const vec4_t eyeViewer = {{{ 0, 0, 0x10000, 0 }}}; #if OBJECT_SPACE_LIGHTING c->transforms.mvui.point3(&c->transforms.mvui, &c->lighting.objViewer, &eyeViewer); diff --git a/opengl/libagl/matrix.cpp b/opengl/libagl/matrix.cpp index cdeccb3f78..034c857fa7 100644 --- a/opengl/libagl/matrix.cpp +++ b/opengl/libagl/matrix.cpp @@ -253,13 +253,13 @@ void matrixf_t::multiply(matrixf_t& r, const matrixf_t& lhs, const matrixf_t& rh { GLfloat const* const m = lhs.m; for (int i=0 ; i<4 ; i++) { - register const float rhs_i0 = rhs.m[ I(i,0) ]; - register float ri0 = m[ I(0,0) ] * rhs_i0; - register float ri1 = m[ I(0,1) ] * rhs_i0; - register float ri2 = m[ I(0,2) ] * rhs_i0; - register float ri3 = m[ I(0,3) ] * rhs_i0; + const float rhs_i0 = rhs.m[ I(i,0) ]; + float ri0 = m[ I(0,0) ] * rhs_i0; + float ri1 = m[ I(0,1) ] * rhs_i0; + float ri2 = m[ I(0,2) ] * rhs_i0; + float ri3 = m[ I(0,3) ] * rhs_i0; for (int j=1 ; j<4 ; j++) { - register const float rhs_ij = rhs.m[ I(i,j) ]; + const float rhs_ij = rhs.m[ I(i,j) ]; ri0 += m[ I(j,0) ] * rhs_ij; ri1 += m[ I(j,1) ] * rhs_ij; ri2 += m[ I(j,2) ] * rhs_ij; diff --git a/opengl/libagl/texture.cpp b/opengl/libagl/texture.cpp index 9aa1c4f867..3fe5ed0630 100644 --- a/opengl/libagl/texture.cpp +++ b/opengl/libagl/texture.cpp @@ -25,6 +25,9 @@ #include <ETC1/etc1.h> +#include <ui/GraphicBufferMapper.h> +#include <ui/Rect.h> + namespace android { // ---------------------------------------------------------------------------- @@ -128,17 +131,11 @@ void ogles_lock_textures(ogles_context_t* c) ANativeWindowBuffer* native_buffer = u.texture->buffer; if (native_buffer) { c->rasterizer.procs.activeTexture(c, i); - hw_module_t const* pModule; - if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &pModule)) - continue; - - gralloc_module_t const* module = - reinterpret_cast<gralloc_module_t const*>(pModule); + auto& mapper = GraphicBufferMapper::get(); void* vaddr; - int err = module->lock(module, native_buffer->handle, - GRALLOC_USAGE_SW_READ_OFTEN, - 0, 0, native_buffer->width, native_buffer->height, + mapper.lock(native_buffer->handle, GRALLOC_USAGE_SW_READ_OFTEN, + Rect(native_buffer->width, native_buffer->height), &vaddr); u.texture->setImageBits(vaddr); @@ -156,14 +153,10 @@ void ogles_unlock_textures(ogles_context_t* c) ANativeWindowBuffer* native_buffer = u.texture->buffer; if (native_buffer) { c->rasterizer.procs.activeTexture(c, i); - hw_module_t const* pModule; - if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &pModule)) - continue; - gralloc_module_t const* module = - reinterpret_cast<gralloc_module_t const*>(pModule); + auto& mapper = GraphicBufferMapper::get(); + mapper.unlock(native_buffer->handle); - module->unlock(module, native_buffer->handle); u.texture->setImageBits(NULL); c->rasterizer.procs.bindTexture(c, &(u.texture->surface)); } @@ -405,7 +398,7 @@ int createTextureSurface(ogles_context_t* c, return 0; } -static size_t dataSizePalette4(int numLevels, int width, int height, int format) +static GLsizei dataSizePalette4(int numLevels, int width, int height, int format) { int indexBits = 8; int entrySize = 0; |