提交 f0db1999 编写于 作者: A Adam Barth

Update to mojo 894a8dd5afe950d4ab0d5f38902e0c14c1ebd01b

上级 3911c0ec
# Copyright 2015 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.
import("//build/config/allocator.gni")
# GYP version: gpu/gles2_conform_support/gles2_conform_support.gyp:gles2_conform_support
executable("gles2_conform_support") {
sources = [
"gles2_conform_support.c",
"native/egl_native.cc",
"native/egl_native_win.cc",
"native/main.cc",
]
defines = [
"GLES2_CONFORM_SUPPORT_ONLY",
"GTF_GLES20",
"EGLAPI=",
"EGLAPIENTRY=",
]
deps = [
"//base",
"//gpu/gles2_conform_support/egl",
"//base/third_party/dynamic_annotations",
"//ui/gl",
"//gpu/command_buffer/client:gles2_c_lib_nocheck",
]
if (is_linux) {
sources += [
"native/egl_native_aura.cc",
"native/egl_native_x11.cc",
]
}
if (use_allocator != "none") {
# See http://crbug.com/162998#c4 for why this is needed.
deps += [ "//base/allocator" ]
}
}
To run OpenGL ES 2.0 conformance tests, do the following:
(These require access to Google-internal sources.)
1. Generate build files:
"python build/gyp_chromium gpu/gles2_conform_support/gles2_conform_test.gyp"
or set "GYP_DEFINES=internal_gles2_conform_tests=1" and rebuild your
projects using your standard method. Example:
"GYP_DEFINES=internal_gles2_conform_tests=1 gclient runhooks"
2. Build any of the two targets:
- gles2_conform_test_angle which tests ANGLE
- gles2_conform_test_native which tests command-buffer service
- gles2_conform_test_windowless which tests command-buffer service on most platforms
- gles2_conform_test_pepper will be added later
3. Run the targets as: "<path to>gles2_conform_test_native -noimagefileio
-run=<path to>third_party\gles2_conform\GTF_ES\glsl\GTF\mustpass.run"
// Copyright (c) 2013 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.
// gles2_conform_test_windowless target contains only .c files, and it no
// longer links against libstdc++. We have to create this empty dummy.cc
// file and add it to the target.
# Copyright 2015 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.
# GYP version: gpu/gles2_conform_support/gles_conform_support.gyp:egl_native
source_set("egl") {
output_name = "egl_native"
sources = [
"config.cc",
"config.h",
"display.cc",
"display.h",
"egl.cc",
"surface.cc",
"surface.h",
]
configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
defines = [
"EGLAPI=",
"EGLAPIENTRY=",
]
deps = [
"//base",
"//gpu/command_buffer/client:gles2_implementation_no_check",
"//gpu/command_buffer/service",
"//gpu",
"//ui/base",
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/gl",
]
}
// 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_FALSE),
bind_to_texture_rgba_(EGL_FALSE),
color_buffer_type_(EGL_RGB_BUFFER),
config_caveat_(EGL_NONE),
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_TRUE),
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) 2012 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 "base/bind.h"
#include "base/bind_helpers.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "gpu/command_buffer/client/gles2_lib.h"
#include "gpu/command_buffer/client/transfer_buffer.h"
#include "gpu/command_buffer/common/value_state.h"
#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/mailbox_manager.h"
#include "gpu/command_buffer/service/memory_tracking.h"
#include "gpu/command_buffer/service/transfer_buffer_manager.h"
#include "gpu/command_buffer/service/valuebuffer_manager.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),
create_offscreen_(false),
create_offscreen_width_(0),
create_offscreen_height_(0) {
}
Display::~Display() {
gles2::Terminate();
}
bool Display::Initialize() {
gles2::Initialize();
is_initialized_ = true;
return true;
}
bool Display::IsValidConfig(EGLConfig config) {
return (config != NULL) && (config == config_.get());
}
bool Display::ChooseConfigs(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::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;
}
{
gpu::TransferBufferManager* manager = new gpu::TransferBufferManager();
transfer_buffer_manager_.reset(manager);
manager->Initialize();
}
scoped_ptr<gpu::CommandBufferService> command_buffer(
new gpu::CommandBufferService(transfer_buffer_manager_.get()));
if (!command_buffer->Initialize())
return NULL;
scoped_refptr<gpu::gles2::ContextGroup> group(
new gpu::gles2::ContextGroup(NULL,
NULL,
new gpu::gles2::ShaderTranslatorCache,
NULL,
NULL,
NULL,
true));
decoder_.reset(gpu::gles2::GLES2Decoder::Create(group.get()));
if (!decoder_.get())
return EGL_NO_SURFACE;
gpu_scheduler_.reset(new gpu::GpuScheduler(command_buffer.get(),
decoder_.get(),
NULL));
decoder_->set_engine(gpu_scheduler_.get());
gfx::Size size(create_offscreen_width_, create_offscreen_height_);
if (create_offscreen_) {
gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(size);
create_offscreen_ = false;
create_offscreen_width_ = 0;
create_offscreen_height_ = 0;
} else {
gl_surface_ = gfx::GLSurface::CreateViewGLSurface(win);
}
if (!gl_surface_.get())
return EGL_NO_SURFACE;
gl_context_ = gfx::GLContext::CreateGLContext(NULL,
gl_surface_.get(),
gfx::PreferDiscreteGpu);
if (!gl_context_.get())
return EGL_NO_SURFACE;
gl_context_->MakeCurrent(gl_surface_.get());
EGLint depth_size = 0;
EGLint alpha_size = 0;
EGLint stencil_size = 0;
GetConfigAttrib(config, EGL_DEPTH_SIZE, &depth_size);
GetConfigAttrib(config, EGL_ALPHA_SIZE, &alpha_size);
GetConfigAttrib(config, EGL_STENCIL_SIZE, &stencil_size);
std::vector<int32> attribs;
attribs.push_back(EGL_DEPTH_SIZE);
attribs.push_back(depth_size);
attribs.push_back(EGL_ALPHA_SIZE);
attribs.push_back(alpha_size);
attribs.push_back(EGL_STENCIL_SIZE);
attribs.push_back(stencil_size);
// TODO(gman): Insert attrib_list. Although ES 1.1 says it must be null
attribs.push_back(EGL_NONE);
if (!decoder_->Initialize(gl_surface_.get(),
gl_context_.get(),
gl_surface_->IsOffscreen(),
size,
gpu::gles2::DisallowedFeatures(),
attribs)) {
return EGL_NO_SURFACE;
}
command_buffer->SetPutOffsetChangeCallback(
base::Bind(&gpu::GpuScheduler::PutChanged,
base::Unretained(gpu_scheduler_.get())));
command_buffer->SetGetBufferChangeCallback(
base::Bind(&gpu::GpuScheduler::SetGetBuffer,
base::Unretained(gpu_scheduler_.get())));
scoped_ptr<gpu::gles2::GLES2CmdHelper> cmd_helper(
new gpu::gles2::GLES2CmdHelper(command_buffer.get()));
if (!cmd_helper->Initialize(kCommandBufferSize))
return NULL;
scoped_ptr<gpu::TransferBuffer> transfer_buffer(new gpu::TransferBuffer(
cmd_helper.get()));
command_buffer_.reset(command_buffer.release());
transfer_buffer_.reset(transfer_buffer.release());
gles2_cmd_helper_.reset(cmd_helper.release());
surface_.reset(new Surface(win));
return surface_.get();
}
void Display::DestroySurface(EGLSurface surface) {
DCHECK(IsValidSurface(surface));
gpu_scheduler_.reset();
if (decoder_.get()) {
decoder_->Destroy(true);
}
decoder_.reset();
gl_surface_ = NULL;
gl_context_ = NULL;
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): Add support for shared contexts.
if (share_ctx != NULL)
return EGL_NO_CONTEXT;
DCHECK(command_buffer_ != NULL);
DCHECK(transfer_buffer_.get());
bool bind_generates_resources = true;
bool lose_context_when_out_of_memory = false;
bool support_client_side_arrays = true;
context_.reset(
new gpu::gles2::GLES2Implementation(gles2_cmd_helper_.get(),
NULL,
transfer_buffer_.get(),
bind_generates_resources,
lose_context_when_out_of_memory,
support_client_side_arrays,
this));
if (!context_->Initialize(
kTransferBufferSize,
kTransferBufferSize / 2,
kTransferBufferSize * 2,
gpu::gles2::GLES2Implementation::kNoLimit)) {
return EGL_NO_CONTEXT;
}
context_->EnableFeatureCHROMIUM("pepper3d_allow_buffers_on_multiple_targets");
context_->EnableFeatureCHROMIUM("pepper3d_support_fixed_attribs");
return context_.get();
}
void Display::DestroyContext(EGLContext ctx) {
DCHECK(IsValidContext(ctx));
context_.reset();
transfer_buffer_.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;
}
gpu::Capabilities Display::GetCapabilities() {
return decoder_->GetCapabilities();
}
int32_t Display::CreateImage(ClientBuffer buffer,
size_t width,
size_t height,
unsigned internalformat) {
NOTIMPLEMENTED();
return -1;
}
void Display::DestroyImage(int32 id) {
NOTIMPLEMENTED();
}
int32_t Display::CreateGpuMemoryBufferImage(size_t width,
size_t height,
unsigned internalformat,
unsigned usage) {
NOTIMPLEMENTED();
return -1;
}
uint32 Display::InsertSyncPoint() {
NOTIMPLEMENTED();
return 0u;
}
uint32 Display::InsertFutureSyncPoint() {
NOTIMPLEMENTED();
return 0u;
}
void Display::RetireSyncPoint(uint32 sync_point) {
NOTIMPLEMENTED();
}
void Display::SignalSyncPoint(uint32 sync_point,
const base::Closure& callback) {
NOTIMPLEMENTED();
}
void Display::SignalQuery(uint32 query, const base::Closure& callback) {
NOTIMPLEMENTED();
}
void Display::SetSurfaceVisible(bool visible) {
NOTIMPLEMENTED();
}
uint32 Display::CreateStreamTexture(uint32 texture_id) {
NOTIMPLEMENTED();
return 0;
}
void Display::SetLock(base::Lock*) {
NOTIMPLEMENTED();
}
} // namespace egl
// Copyright (c) 2012 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_SUPPORT_EGL_DISPLAY_H_
#define GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_
#include <EGL/egl.h>
#include "base/memory/scoped_ptr.h"
#include "gpu/command_buffer/client/gles2_cmd_helper.h"
#include "gpu/command_buffer/client/gpu_control.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 "ui/gfx/native_widget_types.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_surface.h"
namespace gpu {
class CommandBufferService;
class GpuControl;
class GpuScheduler;
class TransferBuffer;
class TransferBufferManagerInterface;
namespace gles2 {
class GLES2CmdHelper;
class GLES2Implementation;
} // namespace gles2
} // namespace gpu
namespace egl {
class Config;
class Surface;
class Display : private gpu::GpuControl {
public:
explicit Display(EGLNativeDisplayType display_id);
~Display() override;
void SetCreateOffscreen(int width, int height) {
create_offscreen_ = true;
create_offscreen_width_ = width;
create_offscreen_height_ = height;
}
bool is_initialized() const { return is_initialized_; }
bool Initialize();
// Config routines.
bool IsValidConfig(EGLConfig config);
bool ChooseConfigs(
EGLConfig* configs, EGLint config_size, EGLint* num_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);
// GpuControl implementation.
gpu::Capabilities GetCapabilities() override;
int32_t CreateImage(ClientBuffer buffer,
size_t width,
size_t height,
unsigned internalformat) override;
void DestroyImage(int32_t id) override;
int32_t CreateGpuMemoryBufferImage(size_t width,
size_t height,
unsigned internalformat,
unsigned usage) override;
uint32 InsertSyncPoint() override;
uint32 InsertFutureSyncPoint() override;
void RetireSyncPoint(uint32 sync_point) override;
void SignalSyncPoint(uint32 sync_point,
const base::Closure& callback) override;
void SignalQuery(uint32 query, const base::Closure& callback) override;
void SetSurfaceVisible(bool visible) override;
uint32 CreateStreamTexture(uint32 texture_id) override;
void SetLock(base::Lock*) override;
private:
EGLNativeDisplayType display_id_;
bool is_initialized_;
bool create_offscreen_;
int create_offscreen_width_;
int create_offscreen_height_;
scoped_ptr<gpu::TransferBufferManagerInterface> transfer_buffer_manager_;
scoped_ptr<gpu::CommandBufferService> command_buffer_;
scoped_ptr<gpu::GpuScheduler> gpu_scheduler_;
scoped_ptr<gpu::gles2::GLES2Decoder> decoder_;
scoped_refptr<gfx::GLContext> gl_context_;
scoped_refptr<gfx::GLSurface> gl_surface_;
scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_cmd_helper_;
scoped_ptr<gpu::TransferBuffer> transfer_buffer_;
// 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_SUPPORT_EGL_DISPLAY_H_
// Copyright (c) 2012 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 "base/command_line.h"
#include "gpu/command_buffer/client/gles2_lib.h"
#include "gpu/gles2_conform_support/egl/display.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_surface.h"
#if REGAL_STATIC_EGL
extern "C" {
typedef EGLContext RegalSystemContext;
#define REGAL_DECL
REGAL_DECL void RegalMakeCurrent( RegalSystemContext ctx );
} // extern "C"
#endif
namespace {
void SetCurrentError(EGLint error_code) {
}
template<typename T>
T EglError(EGLint error_code, T return_value) {
SetCurrentError(error_code);
return return_value;
}
template<typename T>
T EglSuccess(T return_value) {
SetCurrentError(EGL_SUCCESS);
return return_value;
}
EGLint ValidateDisplay(EGLDisplay dpy) {
if (dpy == EGL_NO_DISPLAY)
return EGL_BAD_DISPLAY;
egl::Display* display = static_cast<egl::Display*>(dpy);
if (!display->is_initialized())
return EGL_NOT_INITIALIZED;
return EGL_SUCCESS;
}
EGLint ValidateDisplayConfig(EGLDisplay dpy, EGLConfig config) {
EGLint error_code = ValidateDisplay(dpy);
if (error_code != EGL_SUCCESS)
return error_code;
egl::Display* display = static_cast<egl::Display*>(dpy);
if (!display->IsValidConfig(config))
return EGL_BAD_CONFIG;
return EGL_SUCCESS;
}
EGLint ValidateDisplaySurface(EGLDisplay dpy, EGLSurface surface) {
EGLint error_code = ValidateDisplay(dpy);
if (error_code != EGL_SUCCESS)
return error_code;
egl::Display* display = static_cast<egl::Display*>(dpy);
if (!display->IsValidSurface(surface))
return EGL_BAD_SURFACE;
return EGL_SUCCESS;
}
EGLint ValidateDisplayContext(EGLDisplay dpy, EGLContext context) {
EGLint error_code = ValidateDisplay(dpy);
if (error_code != EGL_SUCCESS)
return error_code;
egl::Display* display = static_cast<egl::Display*>(dpy);
if (!display->IsValidContext(context))
return EGL_BAD_CONTEXT;
return EGL_SUCCESS;
}
} // namespace
extern "C" {
EGLint eglGetError() {
// TODO(alokp): Fix me.
return EGL_SUCCESS;
}
EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id) {
return new egl::Display(display_id);
}
EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) {
if (dpy == EGL_NO_DISPLAY)
return EglError(EGL_BAD_DISPLAY, EGL_FALSE);
egl::Display* display = static_cast<egl::Display*>(dpy);
if (!display->Initialize())
return EglError(EGL_NOT_INITIALIZED, EGL_FALSE);
int argc = 1;
const char* const argv[] = {
"dummy"
};
base::CommandLine::Init(argc, argv);
gfx::GLSurface::InitializeOneOff();
*major = 1;
*minor = 4;
return EglSuccess(EGL_TRUE);
}
EGLBoolean eglTerminate(EGLDisplay dpy) {
EGLint error_code = ValidateDisplay(dpy);
if (error_code != EGL_SUCCESS)
return EglError(error_code, EGL_FALSE);
egl::Display* display = static_cast<egl::Display*>(dpy);
delete display;
return EglSuccess(EGL_TRUE);
}
const char* eglQueryString(EGLDisplay dpy, EGLint name) {
EGLint error_code = ValidateDisplay(dpy);
if (error_code != EGL_SUCCESS)
return EglError(error_code, static_cast<const char*>(NULL));
switch (name) {
case EGL_CLIENT_APIS:
return EglSuccess("OpenGL_ES");
case EGL_EXTENSIONS:
return EglSuccess("");
case EGL_VENDOR:
return EglSuccess("Google Inc.");
case EGL_VERSION:
return EglSuccess("1.4");
default:
return EglError(EGL_BAD_PARAMETER, static_cast<const char*>(NULL));
}
}
EGLBoolean eglChooseConfig(EGLDisplay dpy,
const EGLint* attrib_list,
EGLConfig* configs,
EGLint config_size,
EGLint* num_config) {
EGLint error_code = ValidateDisplay(dpy);
if (error_code != EGL_SUCCESS)
return EglError(error_code, EGL_FALSE);
if (num_config == NULL)
return EglError(EGL_BAD_PARAMETER, EGL_FALSE);
egl::Display* display = static_cast<egl::Display*>(dpy);
if (!display->ChooseConfigs(configs, config_size, num_config))
return EglError(EGL_BAD_ATTRIBUTE, EGL_FALSE);
return EglSuccess(EGL_TRUE);
}
EGLBoolean eglGetConfigs(EGLDisplay dpy,
EGLConfig* configs,
EGLint config_size,
EGLint* num_config) {
EGLint error_code = ValidateDisplay(dpy);
if (error_code != EGL_SUCCESS)
return EglError(error_code, EGL_FALSE);
if (num_config == NULL)
return EglError(EGL_BAD_PARAMETER, EGL_FALSE);
egl::Display* display = static_cast<egl::Display*>(dpy);
if (!display->GetConfigs(configs, config_size, num_config))
return EglError(EGL_BAD_ATTRIBUTE, EGL_FALSE);
return EglSuccess(EGL_TRUE);
}
EGLBoolean eglGetConfigAttrib(EGLDisplay dpy,
EGLConfig config,
EGLint attribute,
EGLint* value) {
EGLint error_code = ValidateDisplayConfig(dpy, config);
if (error_code != EGL_SUCCESS)
return EglError(error_code, EGL_FALSE);
egl::Display* display = static_cast<egl::Display*>(dpy);
if (!display->GetConfigAttrib(config, attribute, value))
return EglError(EGL_BAD_ATTRIBUTE, EGL_FALSE);
return EglSuccess(EGL_TRUE);
}
EGLSurface eglCreateWindowSurface(EGLDisplay dpy,
EGLConfig config,
EGLNativeWindowType win,
const EGLint* attrib_list) {
EGLint error_code = ValidateDisplayConfig(dpy, config);
if (error_code != EGL_SUCCESS)
return EglError(error_code, EGL_NO_SURFACE);
egl::Display* display = static_cast<egl::Display*>(dpy);
if (!display->IsValidNativeWindow(win))
return EglError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
EGLSurface surface = display->CreateWindowSurface(config, win, attrib_list);
if (surface == EGL_NO_SURFACE)
return EglError(EGL_BAD_ALLOC, EGL_NO_SURFACE);
return EglSuccess(surface);
}
EGLSurface eglCreatePbufferSurface(EGLDisplay dpy,
EGLConfig config,
const EGLint* attrib_list) {
return EGL_NO_SURFACE;
}
EGLSurface eglCreatePixmapSurface(EGLDisplay dpy,
EGLConfig config,
EGLNativePixmapType pixmap,
const EGLint* attrib_list) {
return EGL_NO_SURFACE;
}
EGLBoolean eglDestroySurface(EGLDisplay dpy,
EGLSurface surface) {
EGLint error_code = ValidateDisplaySurface(dpy, surface);
if (error_code != EGL_SUCCESS)
return EglError(error_code, EGL_FALSE);
egl::Display* display = static_cast<egl::Display*>(dpy);
display->DestroySurface(surface);
return EglSuccess(EGL_TRUE);
}
EGLBoolean eglQuerySurface(EGLDisplay dpy,
EGLSurface surface,
EGLint attribute,
EGLint* value) {
return EGL_FALSE;
}
EGLBoolean eglBindAPI(EGLenum api) {
return EGL_FALSE;
}
EGLenum eglQueryAPI() {
return EGL_OPENGL_ES_API;
}
EGLBoolean eglWaitClient(void) {
return EGL_FALSE;
}
EGLBoolean eglReleaseThread(void) {
return EGL_FALSE;
}
EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy,
EGLenum buftype,
EGLClientBuffer buffer,
EGLConfig config,
const EGLint* attrib_list) {
return EGL_NO_SURFACE;
}
EGLBoolean eglSurfaceAttrib(EGLDisplay dpy,
EGLSurface surface,
EGLint attribute,
EGLint value) {
return EGL_FALSE;
}
EGLBoolean eglBindTexImage(EGLDisplay dpy,
EGLSurface surface,
EGLint buffer) {
return EGL_FALSE;
}
EGLBoolean eglReleaseTexImage(EGLDisplay dpy,
EGLSurface surface,
EGLint buffer) {
return EGL_FALSE;
}
EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval) {
return EGL_FALSE;
}
EGLContext eglCreateContext(EGLDisplay dpy,
EGLConfig config,
EGLContext share_context,
const EGLint* attrib_list) {
EGLint error_code = ValidateDisplayConfig(dpy, config);
if (error_code != EGL_SUCCESS)
return EglError(error_code, EGL_NO_CONTEXT);
if (share_context != EGL_NO_CONTEXT) {
error_code = ValidateDisplayContext(dpy, share_context);
if (error_code != EGL_SUCCESS)
return EglError(error_code, EGL_NO_CONTEXT);
}
egl::Display* display = static_cast<egl::Display*>(dpy);
EGLContext context = display->CreateContext(
config, share_context, attrib_list);
if (context == EGL_NO_CONTEXT)
return EglError(EGL_BAD_ALLOC, EGL_NO_CONTEXT);
return EglSuccess(context);
}
EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) {
EGLint error_code = ValidateDisplayContext(dpy, ctx);
if (error_code != EGL_SUCCESS)
return EglError(error_code, EGL_FALSE);
egl::Display* display = static_cast<egl::Display*>(dpy);
display->DestroyContext(ctx);
return EGL_TRUE;
}
EGLBoolean eglMakeCurrent(EGLDisplay dpy,
EGLSurface draw,
EGLSurface read,
EGLContext ctx) {
if (ctx != EGL_NO_CONTEXT) {
EGLint error_code = ValidateDisplaySurface(dpy, draw);
if (error_code != EGL_SUCCESS)
return EglError(error_code, EGL_FALSE);
error_code = ValidateDisplaySurface(dpy, read);
if (error_code != EGL_SUCCESS)
return EglError(error_code, EGL_FALSE);
error_code = ValidateDisplayContext(dpy, ctx);
if (error_code != EGL_SUCCESS)
return EglError(error_code, EGL_FALSE);
}
egl::Display* display = static_cast<egl::Display*>(dpy);
if (!display->MakeCurrent(draw, read, ctx))
return EglError(EGL_CONTEXT_LOST, EGL_FALSE);
#if REGAL_STATIC_EGL
RegalMakeCurrent(ctx);
#endif
return EGL_TRUE;
}
EGLContext eglGetCurrentContext() {
return EGL_NO_CONTEXT;
}
EGLSurface eglGetCurrentSurface(EGLint readdraw) {
return EGL_NO_SURFACE;
}
EGLDisplay eglGetCurrentDisplay() {
return EGL_NO_DISPLAY;
}
EGLBoolean eglQueryContext(EGLDisplay dpy,
EGLContext ctx,
EGLint attribute,
EGLint* value) {
return EGL_FALSE;
}
EGLBoolean eglWaitGL() {
return EGL_FALSE;
}
EGLBoolean eglWaitNative(EGLint engine) {
return EGL_FALSE;
}
EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) {
EGLint error_code = ValidateDisplaySurface(dpy, surface);
if (error_code != EGL_SUCCESS)
return EglError(error_code, EGL_FALSE);
egl::Display* display = static_cast<egl::Display*>(dpy);
display->SwapBuffers(surface);
return EglSuccess(EGL_TRUE);
}
EGLBoolean eglCopyBuffers(EGLDisplay dpy,
EGLSurface surface,
EGLNativePixmapType target) {
return EGL_FALSE;
}
/* Now, define eglGetProcAddress using the generic function ptr. type */
__eglMustCastToProperFunctionPointerType
eglGetProcAddress(const char* procname) {
return gles2::GetGLFunctionPointer(procname);
}
} // extern "C"
// 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_
#!/usr/bin/env python
# Copyright (c) 2013 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.
"""code generator for OpenGL ES 2.0 conformance tests."""
import os
import re
import sys
def ReadFileAsLines(filename):
"""Reads a file, removing blank lines and lines that start with #"""
file = open(filename, "r")
raw_lines = file.readlines()
file.close()
lines = []
for line in raw_lines:
line = line.strip()
if len(line) > 0 and not line.startswith("#"):
lines.append(line)
return lines
def GenerateTests(file):
"""Generates gles2_conform_test_autogen.cc"""
tests = ReadFileAsLines(
"../../third_party/gles2_conform/GTF_ES/glsl/GTF/mustpass_es20.run")
file.write("""
#include "gpu/gles2_conform_support/gles2_conform_test.h"
#include "testing/gtest/include/gtest/gtest.h"
""")
for test in tests:
file.write("""
TEST(GLES2ConformTest, %(name)s) {
EXPECT_TRUE(RunGLES2ConformTest("%(path)s"));
}
""" % {
"name": re.sub(r'[^A-Za-z0-9]', '_', test),
"path": test,
})
def main(argv):
"""This is the main function."""
if len(argv) >= 1:
dir = argv[0]
else:
dir = '.'
file = open(os.path.join(dir, 'gles2_conform_test_autogen.cc'), 'wb')
GenerateTests(file)
file.close()
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
#!/usr/bin/env python
# Copyright (c) 2013 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.
"""generates files to embed the gles2 conformance test data in executable."""
import os
import sys
class GenerateEmbeddedFiles(object):
"""generates files to embed the gles2 conform test data in executable"""
paths_to_ignore = set([
".",
"..",
".svn",
".git",
".hg",
])
extensions_to_include = set([
".vert",
".frag",
".test",
".run",
])
def __init__(self, scan_dir, base_dir):
self.scan_dir = scan_dir
self.base_dir = base_dir
self.count = 0;
if self.base_dir != None:
self.files_data_h = open(os.path.join(base_dir, "FilesDATA.h"), "wb")
self.files_data_c = open(os.path.join(base_dir, "FilesDATA.c"), "wb")
self.files_toc_c = open(os.path.join(base_dir, "FilesTOC.c"), "wb")
self.files_data_h.write("#ifndef FilesDATA_h\n\n")
self.files_data_h.write("#define FilesDATA_h\n\n");
self.files_data_c.write("#include \"FilesDATA.h\"\n\n")
self.files_toc_c.write("#include \"FilesTOC.h\"\n\n");
self.files_toc_c.write("struct GTFVectorFileEntry tempFiles;\n\n");
self.files_toc_c.write("struct FileEntry files[] = {\n");
self.AddFiles(scan_dir)
if self.base_dir != None:
self.files_toc_c.write("\n};\n\n");
self.files_toc_c.write(
"int numFileEntrys = sizeof(files) / sizeof(struct FileEntry);\n");
self.files_data_h.write("\n\n#endif // FilesDATA_h\n");
self.files_data_c.close()
self.files_data_h.close()
self.files_toc_c.close()
def AddFiles(self, scan_dir):
"""Scan a folder and embed the contents of files."""
files = os.listdir(scan_dir)
sub_dirs = []
for file in files:
full_path = os.path.join(scan_dir, file)
ext = os.path.splitext(file)[1]
base_path = full_path[len(self.scan_dir) + 1:]
if os.path.isdir(full_path):
if not file in GenerateEmbeddedFiles.paths_to_ignore:
sub_dirs.append(full_path)
elif ext in GenerateEmbeddedFiles.extensions_to_include:
if self.base_dir == None:
print full_path.replace("\\", "/")
else:
self.count += 1
name = "_FILE_%s_%d" % (ext.upper(), self.count)
name = name.replace(".", "_")
self.files_data_h.write("extern const char %s[];\n" % name)
self.files_data_c.write("const char %s[] = \n" % name)
data = open(full_path, "r")
lines = data.readlines();
data.close()
for line in lines:
line = line.replace("\n", "")
line = line.replace("\r", "")
line = line.replace("\\", "\\\\")
line = line.replace("\"", "\\\"")
self.files_data_c.write('"%s\\n"\n' % line)
self.files_data_c.write(";\n")
self.files_toc_c.write("\t{ \"%s\", %s, 0 },\n" % (
base_path.replace("\\", "/"), name))
for sub_dir in sub_dirs:
self.AddFiles(sub_dir)
def main(argv):
"""This is the main function."""
if len(argv) >= 1:
scan_dir = argv[0]
else:
scan_dir = '.'
if len(argv) >= 2:
base_dir = argv[1]
else:
base_dir = None
GenerateEmbeddedFiles(scan_dir, base_dir)
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
// 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) 2013 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/gles2_conform_test.h"
#include <string>
#include "base/at_exit.h"
#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#if defined(OS_MACOSX)
#include "base/mac/scoped_nsautorelease_pool.h"
#endif
#include "base/path_service.h"
#include "base/process/launch.h"
#include "base/strings/string_util.h"
#include "gpu/config/gpu_test_config.h"
#include "gpu/config/gpu_test_expectations_parser.h"
#include "testing/gtest/include/gtest/gtest.h"
bool RunGLES2ConformTest(const char* path) {
// Load test expectations, and return early if a test is marked as FAIL.
base::FilePath src_path;
PathService::Get(base::DIR_SOURCE_ROOT, &src_path);
base::FilePath test_expectations_path =
src_path.Append(FILE_PATH_LITERAL("gpu")).
Append(FILE_PATH_LITERAL("gles2_conform_support")).
Append(FILE_PATH_LITERAL("gles2_conform_test_expectations.txt"));
if (!base::PathExists(test_expectations_path)) {
LOG(ERROR) << "Fail to locate gles2_conform_test_expectations.txt";
return false;
}
gpu::GPUTestExpectationsParser test_expectations;
if (!test_expectations.LoadTestExpectations(test_expectations_path)) {
LOG(ERROR) << "Fail to load gles2_conform_test_expectations.txt";
return false;
}
gpu::GPUTestBotConfig bot_config;
if (!bot_config.LoadCurrentConfig(NULL)) {
LOG(ERROR) << "Fail to load bot configuration";
return false;
}
if (!bot_config.IsValid()) {
LOG(ERROR) << "Invalid bot configuration";
return false;
}
std::string path_string(path);
std::string test_name;
base::ReplaceChars(path_string, "\\/.", "_", &test_name);
int32 expectation =
test_expectations.GetTestExpectation(test_name, bot_config);
if (expectation != gpu::GPUTestExpectationsParser::kGpuTestPass) {
LOG(WARNING) << "Test " << test_name << " is bypassed";
return true;
}
base::FilePath test_path;
PathService::Get(base::DIR_EXE, &test_path);
base::FilePath program(test_path.Append(FILE_PATH_LITERAL(
"gles2_conform_test_windowless")));
base::CommandLine* currentCmdLine = base::CommandLine::ForCurrentProcess();
base::CommandLine cmdline(program);
cmdline.AppendArguments(*currentCmdLine, false);
cmdline.AppendSwitch(std::string("--"));
cmdline.AppendArg(std::string("-run=") + path);
std::string output;
bool success = base::GetAppOutput(cmdline, &output);
if (success) {
size_t success_index = output.find("Conformance PASSED all");
size_t failed_index = output.find("FAILED");
success = (success_index != std::string::npos) &&
(failed_index == std::string::npos);
}
if (!success) {
LOG(ERROR) << output;
}
return success;
}
int main(int argc, char** argv) {
base::AtExitManager exit_manager;
base::CommandLine::Init(argc, argv);
#if defined(OS_MACOSX)
base::mac::ScopedNSAutoreleasePool pool;
#endif
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
// Copyright (c) 2013 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_SUPPORT_GLES2_CONFORM_TEST_H
#define GPU_GLES2_CONFORM_SUPPORT_GLES2_CONFORM_TEST_H
bool RunGLES2ConformTest(const char* path);
#endif // GPU_GLES2_CONFORM_SUPPORT_GLES2_CONFORM_TEST_H
// Copyright (c) 2013 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.
// This file contains a list of defective GLES2 conformance tests. The expected
// format is:
// {BUG#} {MODIFIERS} : {TEST_NAME} = {PASS,FAIL,FLAKY,TIMEOUT,SKIP}
//
// MODIFIERS can be a combination of the below list:
// WIN XP VISTA WIN7 MAC LEOPARD SNOWLEOPARD LION LINUX CHROMEOS MOUNTAINLION
// MAVERICKS
// NVIDIA AMD INTEL
// 0xabcd - GPU PCI device ID. Specifying a PCI id requires a vendor.
// DEBUG RELEASE
//
// TEST_NAME can be a specific test name, or have a '*' in the end, which
// indicates a prefix matching.
//
// Any tests whose expectations are not PASS will be skipped on the bots.
//
// Examples:
// 91530 MAC WIN LINUX : context_lost_restored = TIMEOUT
// 91533 WIN : gl_min_uniforms = FAIL
// 91531 MAC WIN LINUX : conformance_more_* = SKIP
// 91532 MAC NVIDIA 0x0640 : tex_image_and_sub_image_2d_with_video = PASS FAIL
253674 LION INTEL : GL2ExtensionTests_dFdy_input_run = FAIL
253674 LION INTEL : GL2FixedTests_point_sprites_input_run = FAIL
253674 LION INTEL : GL_control_flow_input_run = FAIL
253674 LION INTEL : GL_dot_input_run = FAIL
253674 LION INTEL : GL_faceforward_input_run = FAIL
253674 LION INTEL : GL_length_input_run = FAIL
253674 LION INTEL : GL_normalize_input_run = FAIL
253674 LION INTEL : GL_reflect_input_run = FAIL
253674 LION INTEL : GL_refract_input_run = FAIL
253674 LION INTEL : GL_tan_input_run = FAIL
253674 LION AMD : GL2FixedTests_point_sprites_input_run = FAIL
253674 LION AMD : GL_dot_input_run = FAIL
253674 LION AMD : GL_length_input_run = FAIL
// See also crbug.com/306485 for non-Lion instances.
253674 MAC AMD : GL_distance_input_run = FAIL
253674 MOUNTAINLION AMD : GL2ExtensionTests_dFdy_input_run = FAIL
253674 MOUNTAINLION AMD : GL2FixedTests_point_sprites_input_run = FAIL
253674 MOUNTAINLION AMD : GL_control_flow_input_run = FAIL
253674 MOUNTAINLION AMD : GL_operators_input_run = FAIL
253674 MOUNTAINLION INTEL : GL2ExtensionTests_dFdy_input_run = FAIL
253674 MOUNTAINLION INTEL : GL2FixedTests_point_sprites_input_run = FAIL
253674 MOUNTAINLION INTEL : GL_control_flow_input_run = FAIL
253674 MOUNTAINLION INTEL : GL_operators_input_run = FAIL
339911 MOUNTAINLION INTEL : GL2FixedTests_blend_input_run = FAIL
253674 MAC : GL2Tests_glUniform_input_run = FAIL
253674 MAC : GL2Tests_three_uniforms_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL_acos_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL_asin_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL_atan_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL_control_flow_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL_cos_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL_discard_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL_functions_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL_gl_FrontFacing_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL_log_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL_log2_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL_normalize_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL_sin_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL2ExtensionTests_dFdx_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL2ExtensionTests_dFdy_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL2ExtensionTests_fwidth_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL2FixedTests_blend_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL2FixedTests_point_rasterization_input_run = FAIL
393677 CHROMEOS INTEL 0xa011 : GL2FixedTests_scissor_input_run = FAIL
408251 WIN : GL2ExtensionTests_vertex_array_object_input_run = FAIL
408251 WIN : GL2FixedTests_blend_input_run = FAIL
408251 WIN : GL2FixedTests_buffer_clear_input_run = FAIL
408251 WIN : GL2FixedTests_buffer_color_input_run = FAIL
408251 WIN : GL2FixedTests_copy_texture_input_run = FAIL
408251 WIN : GL2FixedTests_depth_buffer_clear_input_run = FAIL
408251 WIN : GL2FixedTests_mipmaps_interpolation_input_run = FAIL
408251 WIN : GL2FixedTests_stencil_plane_clear_input_run = FAIL
408251 WIN : GL2FixedTests_triangle_tiling_input_run = FAIL
408251 WIN : GL2FixedTests_user_clip_planes_input_run = FAIL
408251 WIN : GL2Tests_fixed_data_type_input_run = FAIL
408251 WIN : GL_biConstants_input_run = FAIL
408251 WIN : GL_biuDepthRange_input_run = FAIL
408251 WIN : GL_mat_input_run = FAIL
408251 WIN : GL_struct_input_run = FAIL
////////////////////////////////////////////////////////////////////////////////
//
// Temprory entries: they should be removed once the bugs are fixed.
//
////////////////////////////////////////////////////////////////////////////////
// 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 2015 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.
# GYP version: gpu/gles2_conform_support/gles2_conform_support.gyp:egl_main_native
source_set("native") {
output_name = "egl_main_native"
sources = [
"egl_native.cc",
"egl_native_win.cc",
"main.cc",
]
defines = [
"GLES2_CONFORM_SUPPORT_ONLY",
"GTF_GLES20",
"EGLAPI=",
"EGLAPIENTRY=",
]
deps = [
"//base",
"//gpu/gles2_conform_support/egl",
"//ui/gl",
]
if (is_linux) {
sources += [
"egl_native_aura.cc",
"egl_native_x11.cc",
]
}
}
# GYP version: gpu/gles2_conform_support/gles2_conform_support.gyp:egl_main_windowless
source_set("windowless") {
output_name = "egl_main_windowless"
sources = [
"egl_native.cc",
"egl_native_win.cc",
"egl_native_windowless.cc",
"main.cc",
]
defines = [
"GLES2_CONFORM_SUPPORT_ONLY",
"GTF_GLES20",
"EGLAPI=",
"EGLAPIENTRY=",
]
deps = [
"//base",
"//gpu/gles2_conform_support/egl",
"//ui/gl",
]
if (is_linux) {
sources += [
"egl_native_aura.cc",
"egl_native_x11.cc",
]
}
}
// Copyright (c) 2012 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) {
}
EGLImageKHR GTFCreateEGLImageExternal(
int width, int height, int format,
float r, float g, float b, float a, void** resource) {
return (EGLImageKHR)0;
}
void GTFDestroyEGLImageExternal(EGLImageKHR image, void* resource) {
}
const int* GTFQueryFormatsEGLImageExternal(void) {
return 0;
}
GTFbool GTFIsAlphaFormatEGLImageExternal(int format) {
return GTFfalse;
}
} // extern "C"
// Copyright 2013 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.
// This is just a compile fix. If this is really needed when using aura, the
// methods below should be filled out.
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include "base/logging.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) {
NOTIMPLEMENTED();
return GTFfalse;
}
void GTFNativeDestroyDisplay(EGLNativeDisplayType nativeDisplay) {
NOTIMPLEMENTED();
}
void GTFNativeDestroyWindow(EGLNativeDisplayType nativeDisplay,
EGLNativeWindowType nativeWindow) {
NOTIMPLEMENTED();
}
GTFbool GTFNativeCreateWindow(EGLNativeDisplayType nativeDisplay,
EGLDisplay eglDisplay, EGLConfig eglConfig,
const char* title, int width, int height,
EGLNativeWindowType *pNativeWindow) {
NOTIMPLEMENTED();
return GTFfalse;
}
} // extern "C"
// Copyright (c) 2012 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.
extern "C" {
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) {
}
} // extern "C"
// Copyright (c) 2012 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"
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) {
*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) {
egl::Display* display = static_cast<egl::Display*>(eglDisplay);
display->SetCreateOffscreen(width, height);
return GTFtrue;
}
void GTFNativeDestroyWindow(EGLNativeDisplayType nativeDisplay,
EGLNativeWindowType nativeWindow) {
}
EGLImageKHR GTFCreateEGLImage(int width, int height,
GLenum format, GLenum type) {
return (EGLImageKHR)NULL;
}
void GTFDestroyEGLImage(EGLImageKHR image) {
}
} // extern "C"
// Copyright (c) 2012 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>
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
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);
}
} // extern "C"
// Copyright (c) 2012 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/command_line.h"
#include "base/message_loop/message_loop.h"
#if defined(OS_MACOSX)
#include "base/mac/scoped_nsautorelease_pool.h"
#endif
#if defined(OS_WIN)
#include "base/strings/utf_string_conversions.h"
#endif
#include "ui/gl/gl_surface.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/GTFMain.h"
#endif
}
int main(int argc, char *argv[]) {
base::AtExitManager at_exit;
base::CommandLine::Init(argc, argv);
base::MessageLoopForUI message_loop;
base::CommandLine::StringVector args =
base::CommandLine::ForCurrentProcess()->GetArgs();
#if defined(OS_MACOSX)
base::mac::ScopedNSAutoreleasePool pool;
#endif
scoped_ptr<const char*[]> argsArray(new const char*[args.size()+1]);
argsArray[0] = argv[0];
#if defined(OS_WIN)
std::vector<std::string> argsNonWide(args.size());
for (size_t index = 0; index < args.size(); ++index) {
argsNonWide[index] = base::UTF16ToASCII(args[index]);
argsArray[index+1] = argsNonWide[index].c_str();
}
#else
for (size_t index = 0; index < args.size(); ++index) {
argsArray[index+1] = args[index].c_str();
}
#endif
GTFMain(static_cast<int>(args.size()+1),
const_cast<char**>(argsArray.get()));
return 0;
}
#!/usr/bin/env python
#
# Copyright 2015 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.
"""Add an entry into the manifest file of a jar file."""
import optparse
import os
import os.path
import sys
import shutil
import tempfile
import zipfile
def AddKey(input_jar, output, key, value):
working_dir = tempfile.mkdtemp()
extracted_dir = os.path.join(working_dir, 'extracted')
try:
with zipfile.ZipFile(input_jar) as zf:
zf.extractall(extracted_dir)
manifest_file = os.path.join(extracted_dir, 'META-INF', 'MANIFEST.MF')
manifest_content = ''
if os.path.isfile(manifest_file):
with open(manifest_file, 'r') as f:
manifest_content = f.read().strip()
if len(manifest_content):
manifest_content += '\n'
os.unlink(manifest_file)
manifest_content += '%s: %s\n' % (key, value)
with open(manifest_file, 'w') as f:
f.write(manifest_content)
shutil.make_archive(os.path.join(working_dir, 'output'), 'zip',
extracted_dir, '.')
shutil.move(os.path.join(working_dir, 'output.zip'), output)
finally:
shutil.rmtree(working_dir)
def main():
parser = optparse.OptionParser()
parser.add_option('--input', help='Name of the input jar.')
parser.add_option('--output', help='Name of the output jar.')
parser.add_option('--key', help='Name of the key to add to the manifest.')
parser.add_option('--value', help='Name of the value to add to the manifest.')
options, _ = parser.parse_args()
AddKey(options.input, options.output, options.key, options.value)
if __name__ == '__main__':
sys.exit(main())
# Copyright 2015 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.
import("//build/config/android/rules.gni")
import("//mojo/public/mojo_application.gni")
mojo_android_path = get_path_info(".", "abspath")
template("mojo_android_java_application") {
assert(defined(invoker.mojo_main))
dex_output_path = "$target_out_dir/${target_name}.dex.jar"
dex_with_manifest_output_path =
"$target_out_dir/${target_name}_with_manifest.dex.jar"
android_lib_name = "__${target_name}_lib"
android_standalone_name = "__${target_name}_standalone"
android_with_manifest_name = "__${target_name}_with_manifest"
all_deps = [
"//mojo/public/java:bindings",
"//mojo/public/java:system",
]
if (defined(invoker.deps)) {
all_deps += invoker.deps
}
android_library(android_lib_name) {
java_files = invoker.sources
deps = all_deps
}
android_standalone_library(android_standalone_name) {
deps = [ ":${android_lib_name}" ] + all_deps
dex_path = dex_output_path
system_gen_dir = get_path_info("//mojo/public/java/BUILD.gn", "gen_dir")
excluded_jars = [ "${system_gen_dir}/system.dex.jar" ]
}
action(android_with_manifest_name) {
script = "${mojo_android_path}/add_manifest_entry.py"
deps = [
":$android_standalone_name",
]
input = dex_output_path
inputs = [
input,
]
output = dex_with_manifest_output_path
outputs = [
output,
]
rebase_input = rebase_path(input)
rebase_output = rebase_path(output)
mojo_main = invoker.mojo_main
args = [
"--input=$rebase_input",
"--output=$rebase_output",
"--key=Mojo-Class",
"--value=$mojo_main",
]
}
if (defined(invoker.output_name)) {
mojo_output = "$root_out_dir/" + invoker.output_name + ".mojo"
} else {
mojo_output = "$root_out_dir/" + target_name + ".mojo"
}
action(target_name) {
script = rebase_path("mojo/public/tools/prepend.py", ".", mojo_root)
deps = [
":$android_with_manifest_name",
]
input = dex_with_manifest_output_path
inputs = [
input,
]
output = mojo_output
outputs = [
output,
]
rebase_input = rebase_path(input, root_build_dir)
rebase_output = rebase_path(output, root_build_dir)
args = [
"--input=$rebase_input",
"--output=$rebase_output",
"--line=#!mojo mojo:java_handler",
]
}
}
......@@ -19,6 +19,7 @@ component("common") {
"data_pipe_utils_internal.h",
"handle_watcher.cc",
"handle_watcher.h",
"interface_ptr_set.h",
"message_pump_mojo.cc",
"message_pump_mojo.h",
"message_pump_mojo_handler.h",
......@@ -48,9 +49,10 @@ test("mojo_common_unittests") {
"common_type_converters_unittest.cc",
"data_pipe_utils_unittest.cc",
"handle_watcher_unittest.cc",
"interface_ptr_set_unittest.cc",
"message_pump_mojo_unittest.cc",
"task_tracker_unittest.cc",
"weak_interface_ptr_set_unittest.cc",
"weak_binding_set_unittest.cc",
]
deps = [
......
......@@ -2,70 +2,44 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MOJO_COMMON_WEAK_INTERFACE_PTR_SET_H_
#define MOJO_COMMON_WEAK_INTERFACE_PTR_SET_H_
#ifndef MOJO_COMMON_INTERFACE_PTR_SET_H_
#define MOJO_COMMON_INTERFACE_PTR_SET_H_
#include <vector>
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
#include "mojo/public/cpp/bindings/interface_ptr.h"
namespace mojo {
namespace internal {
// TODO(vtl): This name of this class is a little odd -- it's not a "weak
// pointer", but a wrapper around InterfacePtr that owns itself and can vend
// weak pointers to itself. Probably, with connection error callbacks instead of
// ErrorHandlers, this class is unneeded, and WeakInterfacePtrSet can simply
// own/remove interface pointers as connection errors occur.
// https://github.com/domokit/mojo/issues/311
template <typename Interface>
class WeakInterfacePtr {
public:
explicit WeakInterfacePtr(InterfacePtr<Interface> ptr)
: ptr_(ptr.Pass()), weak_ptr_factory_(this) {
ptr_.set_connection_error_handler([this]() { delete this; });
}
~WeakInterfacePtr() {}
void Close() { ptr_.reset(); }
Interface* get() { return ptr_.get(); }
base::WeakPtr<WeakInterfacePtr> GetWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}
private:
InterfacePtr<Interface> ptr_;
base::WeakPtrFactory<WeakInterfacePtr> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(WeakInterfacePtr);
};
} // namespace internal
// A WeakInterfacePtrSet contains a collection of InterfacePtrs
// An InterfacePtrSet contains a collection of InterfacePtrs
// that are automatically removed from the collection and destroyed
// when their associated MessagePipe experiences a connection error.
// When the set is destroyed all of the MessagePipes will be closed.
// TODO(rudominer) Rename this class since the ownership of the elements
// is not "weak" from the point of view of the client.
template <typename Interface>
class WeakInterfacePtrSet {
class InterfacePtrSet {
public:
WeakInterfacePtrSet() {}
~WeakInterfacePtrSet() { CloseAll(); }
InterfacePtrSet() {}
~InterfacePtrSet() { CloseAll(); }
// |ptr| must be bound to a message pipe.
void AddInterfacePtr(InterfacePtr<Interface> ptr) {
DCHECK(ptr.is_bound());
auto weak_interface_ptr =
new internal::WeakInterfacePtr<Interface>(ptr.Pass());
ptrs_.push_back(weak_interface_ptr->GetWeakPtr());
ClearNullInterfacePtrs();
ptrs_.emplace_back(ptr.Pass());
InterfacePtr<Interface>& intrfc_ptr = ptrs_.back();
Interface* pointer = intrfc_ptr.get();
// Set the connection error handler for the newly added InterfacePtr to be a
// function that will erase it from the vector.
intrfc_ptr.set_connection_error_handler([pointer, this]() {
// Since InterfacePtr itself is a movable type, the thing that uniquely
// identifies the InterfacePtr we wish to erase is its Interface*.
auto it = std::find_if(ptrs_.begin(), ptrs_.end(),
[pointer](const InterfacePtr<Interface>& p) {
return (p.get() == pointer);
});
DCHECK(it != ptrs_.end());
ptrs_.erase(it);
});
}
// Applies |function| to each of the InterfacePtrs in the set.
......@@ -73,40 +47,26 @@ class WeakInterfacePtrSet {
void ForAllPtrs(FunctionType function) {
for (const auto& it : ptrs_) {
if (it)
function(it->get());
function(it.get());
}
ClearNullInterfacePtrs();
}
// Closes the MessagePipe associated with each of the InterfacePtrs in
// this set and clears the set.
void CloseAll() {
for (const auto& it : ptrs_) {
for (auto& it : ptrs_) {
if (it)
it->Close();
it.reset();
}
ptrs_.clear();
}
// TODO(rudominer) After reworking this class and eliminating the method
// ClearNullInterfacePtrs, this method should become const.
size_t size() {
ClearNullInterfacePtrs();
return ptrs_.size();
}
size_t size() const { return ptrs_.size(); }
private:
using WPWIPI = base::WeakPtr<internal::WeakInterfacePtr<Interface>>;
void ClearNullInterfacePtrs() {
ptrs_.erase(std::remove_if(ptrs_.begin(), ptrs_.end(), [](const WPWIPI& p) {
return p.get() == nullptr;
}), ptrs_.end());
}
std::vector<WPWIPI> ptrs_;
std::vector<InterfacePtr<Interface>> ptrs_;
};
} // namespace mojo
#endif // MOJO_COMMON_WEAK_INTERFACE_PTR_SET_H_
#endif // MOJO_COMMON_INTERFACE_PTR_SET_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "mojo/common/weak_interface_ptr_set.h"
#include "mojo/common/interface_ptr_set.h"
#include "base/message_loop/message_loop.h"
#include "mojo/common/message_pump_mojo.h"
......@@ -32,8 +32,8 @@ class DummyImpl : public tests::Dummy {
DISALLOW_COPY_AND_ASSIGN(DummyImpl);
};
// Tests all of the functionality of WeakInterfacePtrSet.
TEST(WeakInterfacePtr, FullLifeCycleTest) {
// Tests all of the functionality of InterfacePtrSet.
TEST(InterfacePtrSetTest, FullLifeCycle) {
base::MessageLoop loop(MessagePumpMojo::Create());
// Create 10 InterfacePtrs.
......@@ -47,7 +47,7 @@ TEST(WeakInterfacePtr, FullLifeCycleTest) {
}
// Move all 10 InterfacePtrs into the set.
WeakInterfacePtrSet<tests::Dummy> intrfc_ptr_set;
InterfacePtrSet<tests::Dummy> intrfc_ptr_set;
EXPECT_EQ(0u, intrfc_ptr_set.size());
for (InterfacePtr<tests::Dummy>& ptr : intrfc_ptrs) {
intrfc_ptr_set.AddInterfacePtr(ptr.Pass());
......@@ -73,22 +73,20 @@ TEST(WeakInterfacePtr, FullLifeCycleTest) {
EXPECT_EQ(1, impl->call_count());
}
// Close the first 5 message pipes.
// Close the first 5 message pipes. This will (after RunUntilIdle) cause
// connection errors on the closed pipes which will cause the first five
// objects to be removed.
for (size_t i = 0; i < kNumObjects / 2; i++) {
impls[i]->CloseMessagePipe();
}
// Invoke ForAllPtrs() again. This will cause connection errors on the
// closed pipes which will cause the first five objects to be removed.
EXPECT_EQ(kNumObjects, intrfc_ptr_set.size());
// TODO(rudominer) It should not be necessary to invoke ForAllPtrs in order
// to see the effect of the error handlers. The error handlers are invoked
// just after PumpMessages() is invoked. Fix this test after we fix the
// implementation of WeakInterfacePtrSet.
intrfc_ptr_set.ForAllPtrs([](tests::Dummy* dummy) { dummy->Foo(); });
loop.RunUntilIdle();
EXPECT_EQ(kNumObjects / 2, intrfc_ptr_set.size());
// Invoke ForAllPtrs again on the remaining five pointers
intrfc_ptr_set.ForAllPtrs([](tests::Dummy* dummy) { dummy->Foo(); });
loop.RunUntilIdle();
// Check that now the first five counts are still 1 but the second five
// counts are two.
for (size_t i = 0; i < kNumObjects; i++) {
......
......@@ -13,47 +13,8 @@
namespace mojo {
namespace internal {
// TODO(vtl): https://github.com/domokit/mojo/issues/311 applies here as well.
template <typename Interface>
class WeakBinding {
public:
WeakBinding(Interface* impl, InterfaceRequest<Interface> request)
: binding_(impl, request.Pass()), weak_ptr_factory_(this) {
binding_.set_connection_error_handler([this]() { OnConnectionError(); });
}
~WeakBinding() {}
void set_connection_error_handler(const Closure& error_handler) {
error_handler_ = error_handler;
}
base::WeakPtr<WeakBinding> GetWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}
void Close() { binding_.Close(); }
private:
void OnConnectionError() {
Closure error_handler = error_handler_;
delete this;
error_handler.Run();
}
mojo::Binding<Interface> binding_;
Closure error_handler_;
base::WeakPtrFactory<WeakBinding> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(WeakBinding);
};
} // namespace internal
// Use this class to manage a set of weak pointers to bindings each of which is
// owned by the pipe they are bound to.
// Use this class to manage a set of bindings each of which is
// owned by the pipe it is bound to.
template <typename Interface>
class WeakBindingSet {
public:
......@@ -61,32 +22,29 @@ class WeakBindingSet {
~WeakBindingSet() { CloseAllBindings(); }
void AddBinding(Interface* impl, InterfaceRequest<Interface> request) {
auto binding = new internal::WeakBinding<Interface>(impl, request.Pass());
binding->set_connection_error_handler([this]() { OnConnectionError(); });
bindings_.push_back(binding->GetWeakPtr());
bindings_.emplace_back(new Binding<Interface>(impl, request.Pass()));
auto* binding = bindings_.back().get();
// Set the connection error handler for the newly added Binding to be a
// function that will erase it from the vector.
binding->set_connection_error_handler([this, binding]() {
auto it =
std::find_if(bindings_.begin(), bindings_.end(),
[binding](const std::unique_ptr<Binding<Interface>>& b) {
return (b.get() == binding);
});
DCHECK(it != bindings_.end());
bindings_.erase(it);
});
}
void CloseAllBindings() {
for (const auto& it : bindings_) {
if (it)
it->Close();
}
bindings_.clear();
}
private:
void OnConnectionError() {
// Clear any deleted bindings.
bindings_.erase(
std::remove_if(
bindings_.begin(), bindings_.end(),
[](const base::WeakPtr<internal::WeakBinding<Interface>>& p) {
return p.get() == nullptr;
}),
bindings_.end());
}
size_t size() const { return bindings_.size(); }
std::vector<base::WeakPtr<internal::WeakBinding<Interface>>> bindings_;
private:
std::vector<std::unique_ptr<Binding<Interface>>> bindings_;
DISALLOW_COPY_AND_ASSIGN(WeakBindingSet);
};
......
// Copyright 2015 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 "mojo/common/weak_binding_set.h"
#include "base/message_loop/message_loop.h"
#include "mojo/common/message_pump_mojo.h"
#include "mojo/common/test_interfaces.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace mojo {
namespace common {
namespace {
class DummyImpl : public tests::Dummy {
public:
DummyImpl() {}
void Foo() override { call_count_++; }
int call_count() const { return call_count_; }
private:
int call_count_ = 0;
DISALLOW_COPY_AND_ASSIGN(DummyImpl);
};
// Tests all of the functionality of WeakBindingSet.
TEST(WeakBindingSet, FullLifeCycleTest) {
base::MessageLoop loop(MessagePumpMojo::Create());
// Create 10 InterfacePtrs and DummyImpls.
const size_t kNumObjects = 10;
InterfacePtr<tests::Dummy> intrfc_ptrs[kNumObjects];
DummyImpl impls[kNumObjects];
// Create 10 message pipes, bind everything together, and add the
// bindings to binding_set.
WeakBindingSet<tests::Dummy> binding_set;
EXPECT_EQ(0u, binding_set.size());
for (size_t i = 0; i < kNumObjects; i++) {
binding_set.AddBinding(&impls[i], GetProxy(&intrfc_ptrs[i]));
}
EXPECT_EQ(kNumObjects, binding_set.size());
// Check that initially all call counts are zero.
for (const auto& impl : impls) {
EXPECT_EQ(0, impl.call_count());
}
// Invoke method foo() on all 10 InterfacePointers.
for (InterfacePtr<tests::Dummy>& ptr : intrfc_ptrs) {
ptr->Foo();
}
// Check that now all call counts are one.
loop.RunUntilIdle();
for (const auto& impl : impls) {
EXPECT_EQ(1, impl.call_count());
}
// Close the first 5 message pipes and destroy the first five
// InterfacePtrs.
for (size_t i = 0; i < kNumObjects / 2; i++) {
intrfc_ptrs[i].reset();
}
// Check that the set contains only five elements now.
loop.RunUntilIdle();
EXPECT_EQ(kNumObjects / 2, binding_set.size());
// Invoke method foo() on the second five InterfacePointers.
for (size_t i = kNumObjects / 2; i < kNumObjects; i++) {
intrfc_ptrs[i]->Foo();
}
loop.RunUntilIdle();
// Check that now the first five counts are still 1 but the second five
// counts are two.
for (size_t i = 0; i < kNumObjects; i++) {
int expected = (i < kNumObjects / 2 ? 1 : 2);
EXPECT_EQ(expected, impls[i].call_count());
}
// Invoke CloseAllBindings
binding_set.CloseAllBindings();
EXPECT_EQ(0u, binding_set.size());
// Invoke method foo() on the second five InterfacePointers.
for (size_t i = kNumObjects / 2; i < kNumObjects; i++) {
intrfc_ptrs[i]->Foo();
}
loop.RunUntilIdle();
// Check that the call counts are the same as before.
for (size_t i = 0; i < kNumObjects; i++) {
int expected = (i < kNumObjects / 2 ? 1 : 2);
EXPECT_EQ(expected, impls[i].call_count());
}
}
} // namespace
} // namespace common
} // namespace mojo
......@@ -43,7 +43,6 @@ source_set("dart_controller_no_snapshot") {
":generate_dart_embedder_service_isolate_resources_cc",
"//base",
"//base:i18n",
"//crypto",
"//dart/runtime:libdart",
"//dart/runtime/bin:libdart_embedder_noio",
"//third_party/dart-pkg",
......
......@@ -12,7 +12,7 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "crypto/random.h"
#include "base/rand_util.h"
#include "dart/runtime/include/dart_api.h"
#include "mojo/dart/embedder/builtin.h"
#include "mojo/dart/embedder/mojo_natives.h"
......@@ -324,7 +324,7 @@ void Crypto_GetRandomBytes(Dart_NativeArguments args) {
intptr_t count = static_cast<intptr_t>(count64);
scoped_ptr<uint8_t[]> buffer(new uint8_t[count]);
crypto::RandBytes(reinterpret_cast<void*>(buffer.get()), count);
base::RandBytes(reinterpret_cast<void*>(buffer.get()), count);
Dart_Handle result = Dart_NewTypedData(Dart_TypedData_kUint8, count);
if (Dart_IsError(result)) {
......
......@@ -6,8 +6,8 @@
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/rand_util.h"
#include "base/sys_info.h"
#include "crypto/random.h"
#include "dart/runtime/include/dart_api.h"
#include "dart/runtime/include/dart_native_api.h"
#include "mojo/dart/embedder/builtin.h"
......@@ -658,7 +658,7 @@ bool DartController::RunSingleDartScript(const DartControllerConfig& config) {
}
static bool generateEntropy(uint8_t* buffer, intptr_t length) {
crypto::RandBytes(reinterpret_cast<void*>(buffer), length);
base::RandBytes(reinterpret_cast<void*>(buffer), length);
return true;
}
......
......@@ -27,7 +27,6 @@ test("dart_unittests") {
":dart_controller_for_test",
":dart_to_cpp_unittests",
"//base",
"//crypto:crypto",
"//mojo/dart/embedder:dart_controller_no_snapshot",
"//mojo/edk/test:run_all_unittests",
"//mojo/edk/test:test_support",
......@@ -48,7 +47,6 @@ source_set("dart_to_cpp_unittests") {
":dart_controller_for_test",
":dart_to_cpp_bindings",
"//base",
"//crypto",
"//mojo/dart/embedder:dart_controller_no_snapshot",
"//mojo/edk/test:test_support",
"//mojo/public/cpp/bindings",
......
......@@ -9,10 +9,10 @@
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/rand_util.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread.h"
#include "crypto/random.h"
#include "mojo/dart/embedder/dart_controller.h"
#include "mojo/dart/embedder/test/dart_to_cpp.mojom.h"
#include "mojo/edk/test/test_utils.h"
......@@ -277,7 +277,7 @@ class DartToCppTest : public testing::Test {
}
static bool GenerateEntropy(uint8_t* buffer, intptr_t length) {
crypto::RandBytes(reinterpret_cast<void*>(buffer), length);
base::RandBytes(reinterpret_cast<void*>(buffer), length);
return true;
}
......
......@@ -7,7 +7,7 @@
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "crypto/random.h"
#include "base/rand_util.h"
#include "mojo/dart/embedder/dart_controller.h"
#include "mojo/public/c/system/types.h"
#include "mojo/public/cpp/environment/environment.h"
......@@ -20,7 +20,7 @@ namespace dart {
namespace {
static bool generateEntropy(uint8_t* buffer, intptr_t length) {
crypto::RandBytes(reinterpret_cast<void*>(buffer), length);
base::RandBytes(reinterpret_cast<void*>(buffer), length);
return true;
}
......
......@@ -13,7 +13,7 @@
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "crypto/random.h"
#include "base/rand_util.h"
#include "mojo/dart/embedder/dart_controller.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -36,7 +36,7 @@ std::string GetPath() {
}
static bool generateEntropy(uint8_t* buffer, intptr_t length) {
crypto::RandBytes(reinterpret_cast<void*>(buffer), length);
base::RandBytes(reinterpret_cast<void*>(buffer), length);
return true;
}
......
......@@ -25,6 +25,7 @@ import subprocess
import sys
import tempfile
import traceback
import urllib2
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import android_gdb.config as config
......@@ -128,13 +129,29 @@ class DebugSession(object):
text_address = mapping[0].start + s['sh_offset']
_gdb_execute("add-symbol-file %s 0x%x" % (local_file, text_address))
def _download_file(self, remote):
"""Downloads a remote file through GDB connection.
def _download_file(self, signature, remote):
"""Downloads a remote file either from the cloud or through GDB connection.
Returns:
The filename of the downloaded file
"""
temp_file = tempfile.NamedTemporaryFile()
logging.info("Trying to download symbols from the cloud.")
symbols_url = "http://storage.googleapis.com/mojo/symbols/%s" % signature
try:
symbol_file = urllib2.urlopen(symbols_url)
try:
with open(temp_file.name, "w") as dst:
shutil.copyfileobj(symbol_file, dst)
logging.info("Getting symbols for %s at %s." % (remote, symbols_url))
# This allows the deletion of temporary files on disk when the
# debugging session terminates.
self._downloaded_files.append(temp_file)
return temp_file.name
finally:
symbol_file.close()
except urllib2.HTTPError:
pass
logging.info("Downloading file %s" % remote)
_gdb_execute("remote get %s %s" % (remote, temp_file.name))
# This allows the deletion of temporary files on disk when the debugging
......@@ -142,9 +159,6 @@ class DebugSession(object):
self._downloaded_files.append(temp_file)
return temp_file.name
def _download_and_associate_symbol(self, mapping):
self._associate_symbols(mapping, self._download_file(mapping[0].filename))
def _find_mapping_for_address(self, mappings, address):
"""Returns the list of all mappings of the file occupying the |address|
memory address.
......@@ -166,11 +180,11 @@ class DebugSession(object):
if signature in self._libraries:
self._associate_symbols(mapping, self._libraries[signature])
else:
# This library file is not known locally. Download it from the device
# and put it in cache so, if it got symbols, we can see them.
# This library file is not known locally. Download it from the device or
# the cloud and put it in cache so, if it got symbols, we can see them.
local_file = os.path.join(self._remote_file_cache, signature)
if not os.path.exists(local_file):
tmp_output = self._download_file(remote_file)
tmp_output = self._download_file(signature, remote_file)
shutil.move(tmp_output, local_file)
self._associate_symbols(mapping, local_file)
return True
......
......@@ -87,7 +87,6 @@ mojo_edk_source_set("platform") {
deps = [
"//base",
"//crypto",
]
if (is_android) {
......
......@@ -4,7 +4,7 @@
#include "mojo/edk/embedder/simple_platform_support.h"
#include "crypto/random.h"
#include "base/rand_util.h"
#include "mojo/edk/embedder/simple_platform_shared_buffer.h"
namespace mojo {
......@@ -12,7 +12,7 @@ namespace embedder {
void SimplePlatformSupport::GetCryptoRandomBytes(void* bytes,
size_t num_bytes) {
crypto::RandBytes(bytes, num_bytes);
base::RandBytes(bytes, num_bytes);
}
PlatformSharedBuffer* SimplePlatformSupport::CreateSharedBuffer(
......
......@@ -133,50 +133,6 @@ def upload_shell(config, dry_run, verbose):
write_file_to_gs(version, latest_file, config, dry_run)
def upload_sky_shell_linux(config, dry_run, verbose, dest_prefix):
paths = Paths(config)
dest = '%(prefix)s/sky_shell.zip' % { 'prefix': dest_prefix }
with tempfile.NamedTemporaryFile() as zip_file:
with zipfile.ZipFile(zip_file, 'w') as z:
shell_path = paths.target_sky_shell_path
shell_filename = os.path.basename(shell_path)
if verbose:
print 'zipping %s' % shell_path
z.write(shell_path, shell_filename, zipfile.ZIP_DEFLATED)
icu_filename = 'icudtl.dat'
icu_path = os.path.join(os.path.dirname(shell_path), icu_filename)
if verbose:
print 'zipping %s' % icu_path
z.write(icu_path, icu_filename, zipfile.ZIP_DEFLATED)
upload(config, zip_file.name, dest, dry_run)
def upload_sky_shell_android(config, dry_run, _, dest_prefix):
paths = Paths(config)
shell_path = paths.target_sky_shell_path
shell_filename = os.path.basename(shell_path)
dest = '%(prefix)s/%(filename)s' % {
'prefix': dest_prefix,
'filename': shell_filename,
}
upload(config, shell_path, dest, dry_run)
def upload_sky_shell(config, dry_run, verbose):
target_name = target(config)
version = Version().version
template_data = { 'target': target_name, 'version': version }
dest_prefix = 'gs://mojo/sky/shell/%(target)s/%(version)s' % template_data
latest_file = 'gs://mojo/sky/shell/%(target)s/LATEST' % template_data
if config.target_os == Config.OS_LINUX:
upload_sky_shell_linux(config, dry_run, verbose, dest_prefix)
elif config.target_os == Config.OS_ANDROID:
upload_sky_shell_android(config, dry_run, verbose, dest_prefix)
else:
return
write_file_to_gs(version, latest_file, config, dry_run)
def upload_app(app_binary_path, config, dry_run):
app_binary_name = os.path.basename(app_binary_path)
version = Version().version
......@@ -231,7 +187,6 @@ def main():
is_official_build=is_official_build)
upload_shell(config, args.dry_run, args.verbose)
upload_sky_shell(config, args.dry_run, args.verbose)
if is_official_build:
print "Skipping uploading apps (official apk build)."
......
......@@ -3,8 +3,8 @@
# found in the LICENSE file.
if (is_android) {
import("//services/android/rules.gni")
import("//build/config/android/config.gni")
import("//mojo/android/rules.gni")
mojo_android_java_application("sensors") {
sources = [
......
#!/usr/bin/env python
# Copyright 2015 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.
import argparse
import json
import os
import subprocess
import sys
import urllib2
from utils import commit
from utils import system
import patch
# //base and its dependencies
_base_deps = [
'base',
'testing',
'third_party/ashmem',
'third_party/libevent',
'third_party/libxml', # via //base/test
'third_party/modp_b64',
'third_party/tcmalloc',
]
# //build and its dependencies
_build_deps = [
'build',
'third_party/android_testrunner',
'third_party/binutils',
'third_party/instrumented_libraries',
'third_party/pymock',
'tools/android',
'tools/clang',
'tools/generate_library_loader',
'tools/gritsettings',
'tools/valgrind',
]
_chromium_libs = [
'crypto',
'url',
]
_third_party_deps = [
'third_party/android_platform',
'third_party/apple_apsl',
'third_party/brotli',
'third_party/expat',
'third_party/freetype-android',
'third_party/harfbuzz-ng',
'third_party/iccjpeg',
'third_party/jinja2',
'third_party/jsr-305',
'third_party/junit',
'third_party/khronos',
'third_party/libjpeg',
'third_party/libpng',
'third_party/libXNVCtrl',
'third_party/markupsafe',
'third_party/mesa',
'third_party/mockito',
'third_party/ots',
'third_party/ply',
'third_party/qcms',
'third_party/re2',
'third_party/robolectric',
'third_party/zlib',
]
dirs_from_chromium = _base_deps + _build_deps + _chromium_libs + _third_party_deps
dirs_from_mojo = [
'gpu',
'mojo',
'mojom',
'services/android',
'services/asset_bundle',
'services/keyboard',
'services/sensors',
]
# The contents of these files before the roll will be preserved after the roll,
# even though they live in directories rolled in from Chromium.
files_not_to_roll = [
'build/config/crypto.gni',
'build/config/ui.gni',
'build/ls.py',
'build/module_args/mojo.gni',
'crypto/BUILD.gn',
'gpu/BUILD.gn',
'tools/android/download_android_tools.py',
'tools/android/VERSION_LINUX_NDK',
'tools/android/VERSION_LINUX_SDK',
'tools/android/VERSION_MACOSX_NDK',
'tools/android/VERSION_MACOSX_SDK',
]
def rev(source_dir, dest_dir, dirs_to_rev, name):
for d in dirs_to_rev:
print "removing directory %s" % d
try:
system(["git", "rm", "-r", d], cwd=dest_dir)
except subprocess.CalledProcessError:
print "Could not remove %s" % d
print "cloning directory %s" % d
files = system(["git", "ls-files", d], cwd=source_dir)
for f in files.splitlines():
source_path = os.path.join(source_dir, f)
if not os.path.isfile(source_path):
continue
dest_path = os.path.join(dest_dir, f)
system(["mkdir", "-p", os.path.dirname(dest_path)], cwd=source_dir)
system(["cp", source_path, dest_path], cwd=source_dir)
system(["git", "add", d], cwd=dest_dir)
for f in files_not_to_roll:
system(["git", "checkout", "HEAD", f], cwd=dest_dir)
system(["git", "add", "."], cwd=dest_dir)
src_commit = system(["git", "rev-parse", "HEAD"], cwd=source_dir).strip()
commit("Update to %s %s" % (name, src_commit), cwd=dest_dir)
def main():
parser = argparse.ArgumentParser(description="Update the mojo repo's " +
"snapshot of things imported from chromium.")
parser.add_argument("--mojo-dir", type=str)
parser.add_argument("--chromium-dir", type=str)
parser.add_argument("--dest-dir", type=str)
args = parser.parse_args()
if args.mojo_dir:
rev(args.mojo_dir, args.dest_dir, dirs_from_mojo, 'mojo')
if args.chromium_dir:
rev(args.chromium_dir, args.dest_dir, dirs_from_chromium, 'chromium')
try:
patch.patch_and_filter(args.dest_dir)
except subprocess.CalledProcessError:
print "ERROR: Roll failed due to a patch not applying"
print "Fix the patch to apply, commit the result, and re-run this script"
return 1
return 0
if __name__ == "__main__":
sys.exit(main())
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册