aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTapani Pälli <tapani.palli@intel.com>2015-02-16 08:49:52 +0200
committerChad Versace <chad.versace@intel.com>2015-02-23 14:27:04 -0800
commitf7aede59be61b9bebc4b979077aeb6accefc7280 (patch)
tree9a081fd7dee69c343ca0b5f8d54c0c344cd0414b
parentfea601e0b4ef9d3227fb7645b126433e7b1b6aed (diff)
downloadwaffle-f7aede59be61b9bebc4b979077aeb6accefc7280.tar.gz
nacl: add implementation for waffle_config_choose
Patch fills attributes table suitable for Pepper API from wcore_config_attrs passed by the application. v2: throw error on unsupported context type (Chad Versace) code cleanup, comment for max attribs (Emil Velikov) v3: free memory if context type not supported (Emil Velikov) Signed-off-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Chad Versace <chad.versace@intel.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
-rw-r--r--src/waffle/nacl/nacl_config.c37
-rw-r--r--src/waffle/nacl/nacl_config.h1
2 files changed, 38 insertions, 0 deletions
diff --git a/src/waffle/nacl/nacl_config.c b/src/waffle/nacl/nacl_config.c
index 27a75e1..16adc66 100644
--- a/src/waffle/nacl/nacl_config.c
+++ b/src/waffle/nacl/nacl_config.c
@@ -23,7 +23,9 @@
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#include "ppapi/c/pp_graphics_3d.h"
#include "nacl_config.h"
+#include "wcore_error.h"
bool
nacl_config_destroy(struct wcore_config *wc_self)
@@ -50,6 +52,41 @@ nacl_config_choose(struct wcore_platform *wc_plat,
if (self == NULL)
return NULL;
+ // Currently only OpenGL ES 2.0 is supported.
+ if (attrs->context_api != WAFFLE_CONTEXT_OPENGL_ES2) {
+ wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
+ "NaCl does no support context type %s.",
+ wcore_enum_to_string(attrs->context_api));
+ goto error;
+ }
+
+ unsigned attr = 0;
+
+ // Max amount of attribs is hardcoded in nacl_config.h (64)
+#define PUSH_ATTRIB(a, val) \
+ if (val != WAFFLE_DONT_CARE) {\
+ self->attribs[attr++] = a; \
+ self->attribs[attr++] = val;\
+ }
+
+ PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_ALPHA_SIZE, attrs->alpha_size);
+ PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_BLUE_SIZE, attrs->blue_size);
+ PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_GREEN_SIZE, attrs->green_size);
+ PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_RED_SIZE, attrs->red_size);
+ PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_DEPTH_SIZE, attrs->depth_size);
+ PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_STENCIL_SIZE, attrs->stencil_size);
+ PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_SAMPLES, attrs->samples);
+ PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, attrs->sample_buffers);
+
+ // Note, we have to have at least 1x1 size so that initial context
+ // backing surface creation will succeed without errors. Later on
+ // it is resized by window creation/resize.
+ PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_WIDTH, 1);
+ PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_HEIGHT, 1);
+ PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_NONE, 0);
+
+#undef PUSH_ATTRIB
+
ok = wcore_config_init(&self->wcore, wc_dpy, attrs);
if (!ok)
goto error;
diff --git a/src/waffle/nacl/nacl_config.h b/src/waffle/nacl/nacl_config.h
index 3270179..47fa252 100644
--- a/src/waffle/nacl/nacl_config.h
+++ b/src/waffle/nacl/nacl_config.h
@@ -33,6 +33,7 @@ struct wcore_platform;
struct nacl_config {
struct wcore_config wcore;
+ int32_t attribs[64];
};
DEFINE_CONTAINER_CAST_FUNC(nacl_config,