Commit f63d12fe authored by gman@chromium.org's avatar gman@chromium.org

Move OpenGL ES 2.0 conformance test support into main tree

This support breaks often because it is not built but the buildbots.
This CL adds it to the main tree so it will be built by the buildbots.

Not sure where to add it in all.gyp but I need to make sure it's built

TEST=opengl es 2.0 conformance tests still build
BUG=83382

R=apatrick@chromium.org

Review URL: http://codereview.chromium.org/7057033

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86306 0039d316-1c4b-4281-b951-d872f2087c98
parent 11c2bdd1
......@@ -17,6 +17,7 @@
'../ui/ui.gyp:*',
'../gpu/gpu.gyp:*',
'../gpu/demos/demos.gyp:*',
'../gpu/gles2_conform_support/gles2_conform_support.gyp:*',
'../ipc/ipc.gyp:*',
'../jingle/jingle.gyp:*',
'../media/media.gyp:*',
......@@ -157,6 +158,7 @@
'../crypto/crypto.gyp:crypto_unittests',
'../ui/ui.gyp:gfx_unittests',
'../gpu/gpu.gyp:gpu_unittests',
'../gpu/gles2_conform_support/gles2_conform_support.gyp:gles2_conform_support',
'../ipc/ipc.gyp:ipc_tests',
'../jingle/jingle.gyp:jingle_unittests',
'../media/media.gyp:media_unittests',
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gpu/gles2_conform_support/egl/config.h"
namespace egl {
Config::Config()
: buffer_size_(0),
red_size_(0),
green_size_(0),
blue_size_(0),
luminance_size_(0),
alpha_size_(0),
alpha_mask_size_(0),
bind_to_texture_rgb_(EGL_DONT_CARE),
bind_to_texture_rgba_(EGL_DONT_CARE),
color_buffer_type_(EGL_RGB_BUFFER),
config_caveat_(EGL_DONT_CARE),
config_id_(EGL_DONT_CARE),
conformant_(EGL_OPENGL_ES2_BIT),
depth_size_(0),
level_(0),
max_pbuffer_width_(0),
max_pbuffer_height_(0),
max_pbuffer_pixels_(0),
min_swap_interval_(EGL_DONT_CARE),
max_swap_interval_(EGL_DONT_CARE),
native_renderable_(EGL_DONT_CARE),
native_visual_id_(0),
native_visual_type_(EGL_DONT_CARE),
renderable_type_(EGL_OPENGL_ES2_BIT),
sample_buffers_(0),
samples_(0),
stencil_size_(0),
surface_type_(EGL_WINDOW_BIT),
transparent_type_(EGL_NONE),
transparent_red_value_(EGL_DONT_CARE),
transparent_green_value_(EGL_DONT_CARE),
transparent_blue_value_(EGL_DONT_CARE) {
}
Config::~Config() {
}
bool Config::GetAttrib(EGLint attribute, EGLint* value) const {
// TODO(alokp): Find out how to get correct values.
switch (attribute) {
case EGL_BUFFER_SIZE:
*value = buffer_size_;
break;
case EGL_RED_SIZE:
*value = red_size_;
break;
case EGL_GREEN_SIZE:
*value = green_size_;
break;
case EGL_BLUE_SIZE:
*value = blue_size_;
break;
case EGL_LUMINANCE_SIZE:
*value = luminance_size_;
break;
case EGL_ALPHA_SIZE:
*value = alpha_size_;
break;
case EGL_ALPHA_MASK_SIZE:
*value = alpha_mask_size_;
break;
case EGL_BIND_TO_TEXTURE_RGB:
*value = bind_to_texture_rgb_;
break;
case EGL_BIND_TO_TEXTURE_RGBA:
*value = bind_to_texture_rgba_;
break;
case EGL_COLOR_BUFFER_TYPE:
*value = color_buffer_type_;
break;
case EGL_CONFIG_CAVEAT:
*value = config_caveat_;
break;
case EGL_CONFIG_ID:
*value = config_id_;
break;
case EGL_CONFORMANT:
*value = conformant_;
break;
case EGL_DEPTH_SIZE:
*value = depth_size_;
break;
case EGL_LEVEL:
*value = level_;
break;
case EGL_MAX_PBUFFER_WIDTH:
*value = max_pbuffer_width_;
break;
case EGL_MAX_PBUFFER_HEIGHT:
*value = max_pbuffer_height_;
break;
case EGL_MAX_PBUFFER_PIXELS:
*value = max_pbuffer_pixels_;
break;
case EGL_MIN_SWAP_INTERVAL:
*value = min_swap_interval_;
break;
case EGL_MAX_SWAP_INTERVAL:
*value = max_swap_interval_;
break;
case EGL_NATIVE_RENDERABLE:
*value = native_renderable_;
break;
case EGL_NATIVE_VISUAL_ID:
*value = native_visual_id_;
break;
case EGL_NATIVE_VISUAL_TYPE:
*value = native_visual_type_;
break;
case EGL_RENDERABLE_TYPE:
*value = renderable_type_;
break;
case EGL_SAMPLE_BUFFERS:
*value = sample_buffers_;
break;
case EGL_SAMPLES:
*value = samples_;
break;
case EGL_STENCIL_SIZE:
*value = stencil_size_;
break;
case EGL_SURFACE_TYPE:
*value = surface_type_;
break;
case EGL_TRANSPARENT_TYPE:
*value = transparent_type_;
break;
case EGL_TRANSPARENT_RED_VALUE:
*value = transparent_red_value_;
break;
case EGL_TRANSPARENT_GREEN_VALUE:
*value = transparent_green_value_;
break;
case EGL_TRANSPARENT_BLUE_VALUE:
*value = transparent_blue_value_;
break;
default:
return false;
}
return true;
}
} // namespace egl
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GPU_GLES2_CONFORM_TEST_CONFIG_H_
#define GPU_GLES2_CONFORM_TEST_CONFIG_H_
#include <EGL/egl.h>
#include "base/basictypes.h"
namespace egl {
class Config {
public:
Config();
~Config();
bool GetAttrib(EGLint attribute, EGLint* value) const;
private:
// Total color component bits in the color buffer.
EGLint buffer_size_;
// Bits of Red in the color buffer.
EGLint red_size_;
// Bits of Green in the color buffer.
EGLint green_size_;
// Bits of Blue in the color buffer.
EGLint blue_size_;
// Bits of Luminance in the color buffer.
EGLint luminance_size_;
// Bits of Alpha in the color buffer.
EGLint alpha_size_;
// Bits of Alpha Mask in the mask buffer.
EGLint alpha_mask_size_;
// True if bindable to RGB textures.
EGLBoolean bind_to_texture_rgb_;
// True if bindable to RGBA textures.
EGLBoolean bind_to_texture_rgba_;
// Color buffer type.
EGLenum color_buffer_type_;
// Any caveats for the configuration.
EGLenum config_caveat_;
// Unique EGLConfig identifier.
EGLint config_id_;
// Whether contexts created with this config are conformant.
EGLint conformant_;
// Bits of Z in the depth buffer.
EGLint depth_size_;
// Frame buffer level.
EGLint level_;
// Maximum width of pbuffer.
EGLint max_pbuffer_width_;
// Maximum height of pbuffer.
EGLint max_pbuffer_height_;
// Maximum size of pbuffer.
EGLint max_pbuffer_pixels_;
// Minimum swap interval.
EGLint min_swap_interval_;
// Maximum swap interval.
EGLint max_swap_interval_;
// True if native rendering APIs can render to surface.
EGLBoolean native_renderable_;
// Handle of corresponding native visual.
EGLint native_visual_id_;
// Native visual type of the associated visual.
EGLint native_visual_type_;
// Which client rendering APIs are supported.
EGLint renderable_type_;
// Number of multisample buffers.
EGLint sample_buffers_;
// Number of samples per pixel.
EGLint samples_;
// Bits of Stencil in the stencil buffer.
EGLint stencil_size_;
// Which types of EGL surfaces are supported.
EGLint surface_type_;
// Type of transparency supported
EGLenum transparent_type_;
// Transparent red value
EGLint transparent_red_value_;
// Transparent green value
EGLint transparent_green_value_;
// Transparent blue value
EGLint transparent_blue_value_;
DISALLOW_COPY_AND_ASSIGN(Config);
};
} // namespace egl
#endif // GPU_GLES2_CONFORM_TEST_CONFIG_H_
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gpu/gles2_conform_support/egl/display.h"
#include <vector>
#include "gpu/command_buffer/client/gles2_lib.h"
#include "gpu/command_buffer/service/command_buffer_service.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/gpu_scheduler.h"
#include "gpu/GLES2/gles2_command_buffer.h"
#include "gpu/gles2_conform_support/egl/config.h"
#include "gpu/gles2_conform_support/egl/surface.h"
namespace {
const int32 kCommandBufferSize = 1024 * 1024;
const int32 kTransferBufferSize = 512 * 1024;
}
namespace egl {
Display::Display(EGLNativeDisplayType display_id)
: display_id_(display_id),
is_initialized_(false),
transfer_buffer_id_(-1) {
}
Display::~Display() {
gles2::Terminate();
}
bool Display::Initialize() {
using gpu::CommandBufferService;
scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService);
if (!command_buffer->Initialize(kCommandBufferSize))
return false;
using gpu::Buffer;
int32 transfer_buffer_id =
command_buffer->CreateTransferBuffer(kTransferBufferSize, -1);
Buffer transfer_buffer =
command_buffer->GetTransferBuffer(transfer_buffer_id);
if (transfer_buffer.ptr == NULL)
return false;
using gpu::gles2::GLES2CmdHelper;
scoped_ptr<GLES2CmdHelper> cmd_helper(
new GLES2CmdHelper(command_buffer.get()));
if (!cmd_helper->Initialize(kCommandBufferSize))
return false;
gles2::Initialize();
is_initialized_ = true;
command_buffer_.reset(command_buffer.release());
transfer_buffer_id_ = transfer_buffer_id;
gles2_cmd_helper_.reset(cmd_helper.release());
return true;
}
bool Display::IsValidConfig(EGLConfig config) {
return (config != NULL) && (config == config_.get());
}
bool Display::GetConfigs(EGLConfig* configs,
EGLint config_size,
EGLint* num_config) {
// TODO(alokp): Find out a way to find all configs. CommandBuffer currently
// does not support finding or choosing configs.
*num_config = 1;
if (configs != NULL) {
if (config_ == NULL) {
config_.reset(new Config);
}
configs[0] = config_.get();
}
return true;
}
bool Display::GetConfigAttrib(EGLConfig config,
EGLint attribute,
EGLint* value) {
const egl::Config* cfg = static_cast<egl::Config*>(config);
return cfg->GetAttrib(attribute, value);
}
bool Display::IsValidNativeWindow(EGLNativeWindowType win) {
#if defined OS_WIN
return ::IsWindow(win) != FALSE;
#else
// TODO(alokp): Validate window handle.
return true;
#endif // OS_WIN
}
bool Display::IsValidSurface(EGLSurface surface) {
return (surface != NULL) && (surface == surface_.get());
}
EGLSurface Display::CreateWindowSurface(EGLConfig config,
EGLNativeWindowType win,
const EGLint* attrib_list) {
if (surface_ != NULL) {
// We do not support more than one window surface.
return EGL_NO_SURFACE;
}
using gpu::GpuScheduler;
std::vector<int32> attribs;
scoped_ptr<GpuScheduler> gpu_scheduler(
new GpuScheduler(command_buffer_.get(), NULL));
if (!gpu_scheduler->Initialize(
win, gfx::Size(), gpu::gles2::DisallowedExtensions(), NULL,
attribs, NULL, 0))
return EGL_NO_SURFACE;
command_buffer_->SetPutOffsetChangeCallback(
NewCallback(gpu_scheduler.get(), &GpuScheduler::PutChanged));
gpu_scheduler_.reset(gpu_scheduler.release());
surface_.reset(new Surface(win));
return surface_.get();
}
void Display::DestroySurface(EGLSurface surface) {
DCHECK(IsValidSurface(surface));
gpu_scheduler_.reset();
surface_.reset();
}
void Display::SwapBuffers(EGLSurface surface) {
DCHECK(IsValidSurface(surface));
context_->SwapBuffers();
}
bool Display::IsValidContext(EGLContext ctx) {
return (ctx != NULL) && (ctx == context_.get());
}
EGLContext Display::CreateContext(EGLConfig config,
EGLContext share_ctx,
const EGLint* attrib_list) {
DCHECK(IsValidConfig(config));
// TODO(alokp): Command buffer does not support shared contexts.
if (share_ctx != NULL)
return EGL_NO_CONTEXT;
DCHECK(command_buffer_ != NULL);
DCHECK(transfer_buffer_id_ != -1);
gpu::Buffer buffer = command_buffer_->GetTransferBuffer(transfer_buffer_id_);
DCHECK(buffer.ptr != NULL);
bool share_resources = share_ctx != NULL;
using gpu::gles2::GLES2Implementation;
context_.reset(new GLES2Implementation(
gles2_cmd_helper_.get(),
buffer.size,
buffer.ptr,
transfer_buffer_id_,
share_resources));
context_->CommandBufferEnableCHROMIUM(
PEPPER3D_ALLOW_BUFFERS_ON_MULTIPLE_TARGETS);
context_->CommandBufferEnableCHROMIUM(
PEPPER3D_SUPPORT_FIXED_ATTRIBS);
return context_.get();
}
void Display::DestroyContext(EGLContext ctx) {
DCHECK(IsValidContext(ctx));
context_.reset();
}
bool Display::MakeCurrent(EGLSurface draw, EGLSurface read, EGLContext ctx) {
if (ctx == EGL_NO_CONTEXT) {
gles2::SetGLContext(NULL);
} else {
DCHECK(IsValidSurface(draw));
DCHECK(IsValidSurface(read));
DCHECK(IsValidContext(ctx));
gles2::SetGLContext(context_.get());
}
return true;
}
} // namespace egl
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GPU_GLES2_CONFORM_TEST_DISPLAY_H_
#define GPU_GLES2_CONFORM_TEST_DISPLAY_H_
#include <EGL/egl.h>
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
namespace gpu {
class CommandBufferService;
class GpuScheduler;
namespace gles2 {
class GLES2CmdHelper;
class GLES2Implementation;
} // namespace gles2
} // namespace gpu
namespace egl {
class Config;
class Surface;
class Display {
public:
explicit Display(EGLNativeDisplayType display_id);
virtual ~Display();
bool is_initialized() const { return is_initialized_; }
bool Initialize();
// Config routines.
bool IsValidConfig(EGLConfig config);
bool GetConfigs(EGLConfig* configs, EGLint config_size, EGLint* num_config);
bool GetConfigAttrib(EGLConfig config, EGLint attribute, EGLint* value);
// Surface routines.
bool IsValidNativeWindow(EGLNativeWindowType win);
bool IsValidSurface(EGLSurface surface);
EGLSurface CreateWindowSurface(EGLConfig config,
EGLNativeWindowType win,
const EGLint* attrib_list);
void DestroySurface(EGLSurface surface);
void SwapBuffers(EGLSurface surface);
// Context routines.
bool IsValidContext(EGLContext ctx);
EGLContext CreateContext(EGLConfig config,
EGLContext share_ctx,
const EGLint* attrib_list);
void DestroyContext(EGLContext ctx);
bool MakeCurrent(EGLSurface draw, EGLSurface read, EGLContext ctx);
private:
EGLNativeDisplayType display_id_;
bool is_initialized_;
scoped_ptr<gpu::CommandBufferService> command_buffer_;
scoped_ptr<gpu::GpuScheduler> gpu_scheduler_;
scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_cmd_helper_;
int32 transfer_buffer_id_;
// TODO(alokp): Support more than one config, surface, and context.
scoped_ptr<Config> config_;
scoped_ptr<Surface> surface_;
scoped_ptr<gpu::gles2::GLES2Implementation> context_;
DISALLOW_COPY_AND_ASSIGN(Display);
};
} // namespace egl
#endif // GPU_GLES2_CONFORM_TEST_DISPLAY_H_
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#ifndef __eglplatform_h_
#define __eglplatform_h_
/*
** Copyright (c) 2007-2009 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Platform-specific types and definitions for egl.h
* $Revision: 9724 $ on $Date: 2009-12-02 02:05:33 -0800 (Wed, 02 Dec 2009) $
*
* Adopters may modify khrplatform.h and this file to suit their platform.
* You are encouraged to submit all modifications to the Khronos group so that
* they can be included in future versions of this file. Please submit changes
* by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
* by filing a bug against product "EGL" component "Registry".
*/
#include <KHR/khrplatform.h>
/* Macros used in EGL function prototype declarations.
*
* EGL functions should be prototyped as:
*
* EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
* typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
*
* KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
*/
#ifndef EGLAPI
#define EGLAPI //KHRONOS_APICALL
#endif
#ifndef EGLAPIENTRY
#define EGLAPIENTRY //KHRONOS_APIENTRY
#endif
#define EGLAPIENTRYP EGLAPIENTRY*
/* The types NativeDisplayType, NativeWindowType, and NativePixmapType
* are aliases of window-system-dependent types, such as X Display * or
* Windows Device Context. They must be defined in platform-specific
* code below. The EGL-prefixed versions of Native*Type are the same
* types, renamed in EGL 1.3 so all types in the API start with "EGL".
*/
#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
typedef HDC EGLNativeDisplayType;
typedef HBITMAP EGLNativePixmapType;
typedef HWND EGLNativeWindowType;
#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */
typedef int EGLNativeDisplayType;
typedef void *EGLNativeWindowType;
typedef void *EGLNativePixmapType;
#elif defined(__unix__)
/* X11 (tentative) */
#include <X11/Xlib.h>
#include <X11/Xutil.h>
typedef Display *EGLNativeDisplayType;
typedef Pixmap EGLNativePixmapType;
typedef Window EGLNativeWindowType;
#elif defined(__APPLE__)
// TODO(gman): these are place holders.
typedef void *EGLNativeDisplayType;
typedef int EGLNativePixmapType;
typedef int EGLNativeWindowType;
#else
#error "Platform not recognized"
#endif
/* EGL 1.2 types, renamed for consistency in EGL 1.3 */
typedef EGLNativeDisplayType NativeDisplayType;
typedef EGLNativePixmapType NativePixmapType;
typedef EGLNativeWindowType NativeWindowType;
/* Define EGLint. This must be a signed integral type large enough to contain
* all legal attribute names and values passed into and out of EGL, whether
* their type is boolean, bitmask, enumerant (symbolic constant), integer,
* handle, or other. While in general a 32-bit integer will suffice, if
* handles are 64 bit types, then EGLint should be defined as a signed 64-bit
* integer type.
*/
typedef khronos_int32_t EGLint;
#endif /* __eglplatform_h */
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gpu/gles2_conform_support/egl/surface.h"
namespace egl {
Surface::Surface(EGLNativeWindowType win) : window_(win) {
}
Surface::~Surface() {
}
} // namespace egl
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GPU_GLES2_CONFORM_TEST_SURFACE_H_
#define GPU_GLES2_CONFORM_TEST_SURFACE_H_
#include <EGL/egl.h>
#include "base/basictypes.h"
namespace egl {
class Surface {
public:
explicit Surface(EGLNativeWindowType win);
~Surface();
EGLNativeWindowType window() { return window_; }
private:
EGLNativeWindowType window_;
DISALLOW_COPY_AND_ASSIGN(Surface);
};
} // namespace egl
#endif // GPU_GLES2_CONFORM_TEST_SURFACE_H_
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// A small sample just to make sure we can actually compile and link
// our OpenGL ES 2.0 conformance test support code.
#include <EGL/egl.h>
#include "gpu/gles2_conform_support/gtf/gtf_stubs.h"
// Note: This code is not intended to run, only compile and link.
int GTFMain(int argc, char** argv) {
EGLint major, minor;
EGLDisplay eglDisplay;
EGLNativeDisplayType nativeDisplay = EGL_DEFAULT_DISPLAY;
eglDisplay = eglGetDisplay(nativeDisplay);
eglInitialize(eglDisplay, &major, &minor);
return 0;
}
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'variables': {
# These are defined here because we want to be able to compile them on
# the buildbots without needed the OpenGL ES 2.0 conformance tests
# which are not open source.
'bootstrap_sources_native': [
'native/main.cc',
],
'conditions': [
['OS=="linux"', {
'bootstrap_sources_native': [
'native/egl_native.cc',
'native/egl_native_linux.cc',
],
}],
['OS=="win"', {
'bootstrap_sources_native': [
'native/egl_native.cc',
'native/egl_native_win.cc',
],
}],
],
},
'targets': [
{
'target_name': 'egl_native',
'type': 'static_library',
'dependencies': [
'<(DEPTH)/gpu/gpu.gyp:command_buffer_service',
],
'include_dirs': ['egl/native'],
'sources': [
'egl/config.cc',
'egl/config.h',
'egl/display.cc',
'egl/display.h',
'egl/egl.cc',
'egl/surface.cc',
'egl/surface.h',
],
'direct_dependent_settings': {
'include_dirs': ['egl/native'],
},
},
{
'target_name': 'egl_main_native',
'type': 'static_library',
'dependencies': [
'egl_native',
],
'conditions': [
['OS=="linux"', {
'dependencies': ['../../build/linux/system.gyp:gtk'],
}],
],
'include_dirs': ['egl/native'],
'sources': [
'<@(bootstrap_sources_native)',
],
'direct_dependent_settings': {
'include_dirs': ['egl/native'],
},
'defines': ['GTF_GLES20'],
},
{
'target_name': 'gles2_conform_support',
'type': 'executable',
'dependencies': [
'egl_native',
'<(DEPTH)/gpu/gpu.gyp:gles2_c_lib_nocheck',
'<(DEPTH)/third_party/expat/expat.gyp:expat',
],
'conditions': [
['OS=="linux"', {
'dependencies': ['../../build/linux/system.gyp:gtk'],
}],
],
'defines': [
'GLES2_CONFORM_SUPPORT_ONLY',
'GTF_GLES20',
],
'sources': [
'<@(bootstrap_sources_native)',
'gles2_conform_support.c'
],
},
],
}
# Local Variables:
# tab-width:2
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=2 shiftwidth=2:
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// A few stubs so we don't need the actual OpenGL ES 2.0 conformance tests
// to compile the support for them.
#ifndef GPU_GLES2_CONFORM_SUPPORT_GTF_GTF_STUBS_H_
#define GPU_GLES2_CONFORM_SUPPORT_GTF_GTF_STUBS_H_
#include <GLES2/gl2.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
typedef unsigned char GTFbool;
#define GTFfalse 0
#define GTFtrue 1
int GTFMain(int argc, char** argv);
#endif // GPU_GLES2_CONFORM_SUPPORT_GTF_GTF_STUBS_H_
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern "C" {
#if defined(GLES2_CONFORM_SUPPORT_ONLY)
#include "gpu/gles2_conform_support/gtf/gtf_stubs.h"
#else
#include "third_party/gles2_conform/GTF_ES/glsl/GTF/Source/eglNative.h"
#endif
}
GTFbool GTFNativeCreatePixmap(EGLNativeDisplayType nativeDisplay,
EGLDisplay eglDisplay, EGLConfig eglConfig,
const char *title, int width, int height,
EGLNativePixmapType *pNativePixmap) {
return GTFtrue;
}
void GTFNativeDestroyPixmap(EGLNativeDisplayType nativeDisplay,
EGLNativePixmapType nativePixmap) {
}
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
extern "C" {
#if defined(GLES2_CONFORM_SUPPORT_ONLY)
#include "gpu/gles2_conform_support/gtf/gtf_stubs.h"
#else
#include "third_party/gles2_conform/GTF_ES/glsl/GTF/Source/eglNative.h"
#endif
}
GTFbool GTFNativeCreateDisplay(EGLNativeDisplayType *pNativeDisplay) {
int argc = 0;
char **argv = NULL;
gtk_init(&argc, &argv);
*pNativeDisplay = GDK_DISPLAY();;
return *pNativeDisplay ? GTFtrue : GTFfalse;
}
void GTFNativeDestroyDisplay(EGLNativeDisplayType nativeDisplay) {
gtk_exit(0);
}
GTFbool GTFNativeCreateWindow(EGLNativeDisplayType nativeDisplay,
EGLDisplay eglDisplay, EGLConfig eglConfig,
const char* title, int width, int height,
EGLNativeWindowType *pNativeWindow) {
#ifdef CHROMEOS_GLES2_CONFORMANCE
// Due to the behavior of ChromeOS window manager, which always resize the
// top level window etc, we had to create a popup window.
GtkWidget* hwnd = gtk_window_new(GTK_WINDOW_POPUP);
#else
GtkWidget* hwnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#endif
gtk_window_set_title(GTK_WINDOW(hwnd), title);
gtk_window_set_default_size(GTK_WINDOW(hwnd), width, height);
gtk_widget_set_double_buffered(hwnd, FALSE);
gtk_widget_set_app_paintable(hwnd, TRUE);
// We had to enter gtk main loop to realize the window on ChromeOS.
gtk_widget_show_now(hwnd);
*pNativeWindow = GDK_WINDOW_XWINDOW(hwnd->window);
return GTFtrue;
}
void GTFNativeDestroyWindow(EGLNativeDisplayType nativeDisplay,
EGLNativeWindowType nativeWindow) {
GdkWindow* window = gdk_window_lookup(nativeWindow);
gpointer widget = NULL;
gdk_window_get_user_data(window, &widget);
gtk_widget_destroy(GTK_WIDGET(widget));
}
EGLImageKHR GTFCreateEGLImage(int width, int height,
GLenum format, GLenum type) {
PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr_;
egl_create_image_khr_ = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>
(eglGetProcAddress("eglCreateImageKHR"));
static const EGLint attrib[] = {
EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
EGL_GL_TEXTURE_LEVEL_KHR, 0,
EGL_NONE
};
if (format != GL_RGBA && format != GL_RGB)
return static_cast<EGLImageKHR>(NULL);
if (type != GL_UNSIGNED_BYTE)
return static_cast<EGLImageKHR>(NULL);
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D,
0,
format,
width,
height,
0,
format,
type,
NULL);
// Disable mip-maps because we do not require it.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
if(glGetError() != GL_NO_ERROR)
return static_cast<EGLImageKHR>(NULL);
EGLImageKHR egl_image =
egl_create_image_khr_(eglGetCurrentDisplay(),
eglGetCurrentContext(),
EGL_GL_TEXTURE_2D_KHR,
reinterpret_cast<EGLClientBuffer>(texture),
attrib);
if (eglGetError() == EGL_SUCCESS)
return egl_image;
else
return static_cast<EGLImageKHR>(NULL);
}
void GTFDestroyEGLImage(EGLImageKHR image) {
PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr_;
egl_destroy_image_khr_ = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>
(eglGetProcAddress("eglDestroyImageKHR"));
egl_destroy_image_khr_(eglGetCurrentDisplay(), image);
}
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern "C" {
#if defined(GLES2_CONFORM_SUPPORT_ONLY)
#include "gpu/gles2_conform_support/gtf/gtf_stubs.h"
#else
#include "third_party/gles2_conform/GTF_ES/glsl/GTF/Source/eglNative.h"
#endif
}
#include <string>
namespace {
LPCTSTR kWindowClassName = TEXT("ES2CONFORM");
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg,
WPARAM w_param, LPARAM l_param) {
LRESULT result = 0;
switch (msg) {
case WM_CLOSE:
::DestroyWindow(hwnd);
break;
case WM_DESTROY:
::PostQuitMessage(0);
break;
case WM_ERASEBKGND:
// Return a non-zero value to indicate that the background has been
// erased.
result = 1;
break;
default:
result = ::DefWindowProc(hwnd, msg, w_param, l_param);
break;
}
return result;
}
} // namespace.
GTFbool GTFNativeCreateDisplay(EGLNativeDisplayType *pNativeDisplay) {
*pNativeDisplay = EGL_DEFAULT_DISPLAY;
return GTFtrue;
}
void GTFNativeDestroyDisplay(EGLNativeDisplayType nativeDisplay) {
// Nothing to destroy since we are using EGL_DEFAULT_DISPLAY
}
GTFbool GTFNativeCreateWindow(EGLNativeDisplayType nativeDisplay,
EGLDisplay eglDisplay, EGLConfig eglConfig,
const char* title, int width, int height,
EGLNativeWindowType *pNativeWindow) {
WNDCLASS wnd_class = {0};
HINSTANCE instance = GetModuleHandle(NULL);
wnd_class.style = CS_OWNDC;
wnd_class.lpfnWndProc = WindowProc;
wnd_class.hInstance = instance;
wnd_class.hbrBackground =
reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH));
wnd_class.lpszClassName = kWindowClassName;
if (!RegisterClass(&wnd_class))
return GTFfalse;
DWORD wnd_style = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
RECT wnd_rect;
wnd_rect.left = 0;
wnd_rect.top = 0;
wnd_rect.right = width;
wnd_rect.bottom = height;
if (!AdjustWindowRect(&wnd_rect, wnd_style, FALSE))
return GTFfalse;
#ifdef UNICODE
// Convert ascii string to wide string.
const std::wstring wnd_title(title, title + strlen(title));
#else
const std::string wnd_title = title;
#endif // UNICODE
HWND hwnd = CreateWindow(
wnd_class.lpszClassName,
wnd_title.c_str(),
wnd_style,
0,
0,
wnd_rect.right - wnd_rect.left,
wnd_rect.bottom - wnd_rect.top,
NULL,
NULL,
instance,
NULL);
if (hwnd == NULL)
return GTFfalse;
ShowWindow(hwnd, SW_SHOWNORMAL);
*pNativeWindow = hwnd;
return GTFtrue;
}
void GTFNativeDestroyWindow(EGLNativeDisplayType nativeDisplay,
EGLNativeWindowType nativeWindow) {
DestroyWindow(nativeWindow);
UnregisterClass(kWindowClassName, GetModuleHandle(NULL));
}
EGLImageKHR GTFCreateEGLImage(int width, int height,
GLenum format, GLenum type) {
return (EGLImageKHR)NULL;
}
void GTFDestroyEGLImage(EGLImageKHR image) {
}
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/at_exit.h"
#include "base/message_loop.h"
#if defined(OS_LINUX)
#include <gtk/gtk.h>
#endif // OS_LINUX
extern "C" {
#if defined(GLES2_CONFORM_SUPPORT_ONLY)
#include "gpu/gles2_conform_support/gtf/gtf_stubs.h"
#else
#include "third_party/gles2_conform/GTF_ES/glsl/GTF/Source/GTFMain.h"
#endif
}
int main(int argc, char *argv[]) {
#if defined(OS_LINUX)
gtk_init(&argc, &argv);
#endif // OS_LINUX
base::AtExitManager at_exit;
MessageLoopForUI message_loop;
GTFMain(argc, argv);
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment