diff --git a/.gitignore b/.gitignore index f0485644f..cfcb3e811 100644 --- a/.gitignore +++ b/.gitignore @@ -52,7 +52,6 @@ Thumbs.db /third_party/llvm/ /third_party/llvm-build/ /third_party/junit/src/ -/third_party/mesa/src/ /third_party/mockito/src/ /third_party/pdfium/ /third_party/pywebsocket/src/ diff --git a/DEPS b/DEPS index 4f6d77cd9..7a01a9c60 100644 --- a/DEPS +++ b/DEPS @@ -85,9 +85,6 @@ deps = { 'src/third_party/libjpeg_turbo': Var('chromium_git') + '/chromium/deps/libjpeg_turbo.git' + '@' + '7260e4d8b8e1e40b17f03fafdf1cd83296900f76', - 'src/third_party/mesa/src': - Var('chromium_git') + '/chromium/deps/mesa.git' + '@' + '071d25db04c23821a12a8b260ab9d96a097402f0', - 'src/third_party/gcm': 'https://github.com/flutter/flutter_gcm.git@master', } diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 04d4bd9c5..321bfb5fa 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -224,6 +224,12 @@ config("compiler") { } } + if (!is_clang) { + color_diagnostics_flag = [ "-fdiagnostics-color=always" ] + cflags_cc += color_diagnostics_flag + cflags_objcc += color_diagnostics_flag + } + if (is_clang && is_debug) { # Allow comparing the address of references and 'this' against 0 # in debug builds. Technically, these can never be null in diff --git a/mojo/converters/geometry/BUILD.gn b/mojo/converters/geometry/BUILD.gn deleted file mode 100644 index f82a24345..000000000 --- a/mojo/converters/geometry/BUILD.gn +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2014 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: mojo/mojo_converters.gypi:mojo_geometry_lib -component("geometry") { - output_name = "mojo_geometry_lib" - - public_deps = [ - "//ui/gfx", - ] - deps = [ - "//mojo/public/c/system", - "//mojo/services/geometry/interfaces", - "//skia", - "//ui/gfx/geometry", - ] - - sources = [ - "geometry_type_converters.cc", - "geometry_type_converters.h", - ] -} diff --git a/mojo/converters/geometry/geometry_type_converters.cc b/mojo/converters/geometry/geometry_type_converters.cc deleted file mode 100644 index ad66c1112..000000000 --- a/mojo/converters/geometry/geometry_type_converters.cc +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2014 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/converters/geometry/geometry_type_converters.h" - -namespace mojo { - -// static -PointPtr TypeConverter::Convert(const gfx::Point& input) { - PointPtr point(Point::New()); - point->x = input.x(); - point->y = input.y(); - return point; -} - -// static -gfx::Point TypeConverter::Convert(const PointPtr& input) { - if (input.is_null()) - return gfx::Point(); - return gfx::Point(input->x, input->y); -} - -// static -PointFPtr TypeConverter::Convert( - const gfx::PointF& input) { - PointFPtr point(PointF::New()); - point->x = input.x(); - point->y = input.y(); - return point; -} - -// static -gfx::PointF TypeConverter::Convert( - const PointFPtr& input) { - if (input.is_null()) - return gfx::PointF(); - return gfx::PointF(input->x, input->y); -} - -// static -SizePtr TypeConverter::Convert(const gfx::Size& input) { - SizePtr size(Size::New()); - size->width = input.width(); - size->height = input.height(); - return size; -} - -// static -gfx::Size TypeConverter::Convert(const SizePtr& input) { - if (input.is_null()) - return gfx::Size(); - return gfx::Size(input->width, input->height); -} - -// static -RectPtr TypeConverter::Convert(const gfx::Rect& input) { - RectPtr rect(Rect::New()); - rect->x = input.x(); - rect->y = input.y(); - rect->width = input.width(); - rect->height = input.height(); - return rect; -} - -// static -gfx::Rect TypeConverter::Convert(const RectPtr& input) { - if (input.is_null()) - return gfx::Rect(); - return gfx::Rect(input->x, input->y, input->width, input->height); -} - -// static -RectFPtr TypeConverter::Convert(const gfx::RectF& input) { - RectFPtr rect(RectF::New()); - rect->x = input.x(); - rect->y = input.y(); - rect->width = input.width(); - rect->height = input.height(); - return rect; -} - -// static -gfx::RectF TypeConverter::Convert(const RectFPtr& input) { - if (input.is_null()) - return gfx::RectF(); - return gfx::RectF(input->x, input->y, input->width, input->height); -} - -// static -TransformPtr TypeConverter::Convert( - const gfx::Transform& input) { - std::vector storage(16); - input.matrix().asRowMajorf(&storage[0]); - mojo::Array matrix; - matrix.Swap(&storage); - TransformPtr transform(Transform::New()); - transform->matrix = matrix.Pass(); - return transform; -} - -// static -gfx::Transform TypeConverter::Convert( - const TransformPtr& input) { - if (input.is_null()) - return gfx::Transform(); - gfx::Transform transform(gfx::Transform::kSkipInitialization); - transform.matrix().setRowMajorf(&input->matrix.storage()[0]); - return transform; -} - -// static -Size TypeConverter::Convert(const gfx::Size& input) { - Size size; - size.width = input.width(); - size.height = input.height(); - return size; -} - -// static -gfx::Size TypeConverter::Convert(const Size& input) { - return gfx::Size(input.width, input.height); -} - -// static -Rect TypeConverter::Convert(const gfx::Rect& input) { - Rect rect; - rect.x = input.x(); - rect.y = input.y(); - rect.width = input.width(); - rect.height = input.height(); - return rect; -} - -// static -gfx::Rect TypeConverter::Convert(const Rect& input) { - return gfx::Rect(input.x, input.y, input.width, input.height); -} - -} // namespace mojo diff --git a/mojo/converters/geometry/geometry_type_converters.h b/mojo/converters/geometry/geometry_type_converters.h deleted file mode 100644 index 7dfc0a617..000000000 --- a/mojo/converters/geometry/geometry_type_converters.h +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2014 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 MOJO_CONVERTERS_GEOMETRY_GEOMETRY_TYPE_CONVERTERS_H_ -#define MOJO_CONVERTERS_GEOMETRY_GEOMETRY_TYPE_CONVERTERS_H_ - -#include "mojo/services/geometry/interfaces/geometry.mojom.h" -#include "ui/gfx/geometry/point.h" -#include "ui/gfx/geometry/point_f.h" -#include "ui/gfx/geometry/rect.h" -#include "ui/gfx/geometry/size.h" -#include "ui/gfx/transform.h" - -namespace mojo { - -template <> -struct TypeConverter { - static PointPtr Convert(const gfx::Point& input); -}; -template <> -struct TypeConverter { - static gfx::Point Convert(const PointPtr& input); -}; - -template <> -struct TypeConverter { - static PointFPtr Convert(const gfx::PointF& input); -}; -template <> -struct TypeConverter { - static gfx::PointF Convert(const PointFPtr& input); -}; - -template <> -struct TypeConverter { - static SizePtr Convert(const gfx::Size& input); -}; -template <> -struct TypeConverter { - static gfx::Size Convert(const SizePtr& input); -}; - -template <> -struct TypeConverter { - static RectPtr Convert(const gfx::Rect& input); -}; -template <> -struct TypeConverter { - static gfx::Rect Convert(const RectPtr& input); -}; - -template <> -struct TypeConverter { - static RectFPtr Convert(const gfx::RectF& input); -}; -template <> -struct TypeConverter { - static gfx::RectF Convert(const RectFPtr& input); -}; - -template <> -struct TypeConverter { - static TransformPtr Convert(const gfx::Transform& input); -}; -template <> -struct TypeConverter { - static gfx::Transform Convert(const TransformPtr& input); -}; - -template <> -struct TypeConverter { - static Size Convert(const gfx::Size& input); -}; -template <> -struct TypeConverter { - static gfx::Size Convert(const Size& input); -}; - -template <> -struct TypeConverter { - static Rect Convert(const gfx::Rect& input); -}; -template <> -struct TypeConverter { - static gfx::Rect Convert(const Rect& input); -}; - -} // namespace mojo - -inline bool operator==(const mojo::Size& lhs, const mojo::Size& rhs) { - return lhs.width == rhs.width && lhs.height == rhs.height; -} - -inline bool operator==(const gfx::Size& lhs, const mojo::Size& rhs) { - return lhs.width() == rhs.width && lhs.height() == rhs.height; -} - -inline bool operator==(const mojo::Size& lhs, const gfx::Size& rhs) { - return rhs == lhs; -} - -inline bool operator!=(const mojo::Size& lhs, const mojo::Size& rhs) { - return !(lhs == rhs); -} - -inline bool operator!=(const gfx::Size& lhs, const mojo::Size& rhs) { - return !(lhs == rhs); -} - -inline bool operator!=(const mojo::Size& lhs, const gfx::Size& rhs) { - return !(lhs == rhs); -} - -#endif // MOJO_CONVERTERS_GEOMETRY_GEOMETRY_TYPE_CONVERTERS_H_ diff --git a/mojo/converters/surfaces/BUILD.gn b/mojo/converters/surfaces/BUILD.gn deleted file mode 100644 index b8e2fa7f4..000000000 --- a/mojo/converters/surfaces/BUILD.gn +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2014 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. - -component("surfaces") { - output_name = "mojo_surfaces_lib" - - sources = [ - "surfaces_type_converters.cc", - "surfaces_type_converters.h", - ] - - public_deps = [ - "//mojo/converters/geometry", - ] - - deps = [ - "//base", - "//cc", - "//cc/surfaces", - "//cc/surfaces:surface_id", - "//gpu", - "//mojo/environment:chromium", - "//mojo/public/c/system", - "//mojo/services/surfaces/interfaces", - "//mojo/services/surfaces/interfaces:surface_id", - ] -} diff --git a/mojo/converters/surfaces/surfaces_type_converters.cc b/mojo/converters/surfaces/surfaces_type_converters.cc deleted file mode 100644 index f16dac12e..000000000 --- a/mojo/converters/surfaces/surfaces_type_converters.cc +++ /dev/null @@ -1,590 +0,0 @@ -// Copyright 2014 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/converters/surfaces/surfaces_type_converters.h" - -#include "base/macros.h" -#include "cc/output/compositor_frame.h" -#include "cc/output/delegated_frame_data.h" -#include "cc/quads/draw_quad.h" -#include "cc/quads/render_pass.h" -#include "cc/quads/render_pass_draw_quad.h" -#include "cc/quads/shared_quad_state.h" -#include "cc/quads/solid_color_draw_quad.h" -#include "cc/quads/surface_draw_quad.h" -#include "cc/quads/texture_draw_quad.h" -#include "cc/quads/tile_draw_quad.h" -#include "cc/quads/yuv_video_draw_quad.h" -#include "cc/surfaces/surface_id_allocator.h" -#include "mojo/converters/geometry/geometry_type_converters.h" - -namespace mojo { - -#define ASSERT_ENUM_VALUES_EQUAL(value) \ - COMPILE_ASSERT(static_cast(cc::DrawQuad::value) == \ - static_cast(Material::value), \ - value##_enum_value_matches) - -ASSERT_ENUM_VALUES_EQUAL(CHECKERBOARD); -ASSERT_ENUM_VALUES_EQUAL(DEBUG_BORDER); -ASSERT_ENUM_VALUES_EQUAL(IO_SURFACE_CONTENT); -ASSERT_ENUM_VALUES_EQUAL(RENDER_PASS); -ASSERT_ENUM_VALUES_EQUAL(SOLID_COLOR); -ASSERT_ENUM_VALUES_EQUAL(STREAM_VIDEO_CONTENT); -ASSERT_ENUM_VALUES_EQUAL(SURFACE_CONTENT); -ASSERT_ENUM_VALUES_EQUAL(TEXTURE_CONTENT); -ASSERT_ENUM_VALUES_EQUAL(TILED_CONTENT); -ASSERT_ENUM_VALUES_EQUAL(YUV_VIDEO_CONTENT); - -COMPILE_ASSERT( - cc::YUVVideoDrawQuad::REC_601 == - static_cast(YUVColorSpace::REC_601), - rec_601_enum_matches); -COMPILE_ASSERT(cc::YUVVideoDrawQuad::JPEG == - static_cast( - YUVColorSpace::JPEG), - rec_601_jpeg_enum_matches); - -namespace { - -cc::SharedQuadState* ConvertSharedQuadState(const SharedQuadStatePtr& input, - cc::RenderPass* render_pass) { - cc::SharedQuadState* state = render_pass->CreateAndAppendSharedQuadState(); - state->SetAll(input->content_to_target_transform.To(), - input->content_bounds.To(), - input->visible_content_rect.To(), - input->clip_rect.To(), - input->is_clipped, - input->opacity, - static_cast<::SkXfermode::Mode>(input->blend_mode), - input->sorting_context_id); - return state; -} - -bool ConvertDrawQuad(const QuadPtr& input, - cc::SharedQuadState* sqs, - cc::RenderPass* render_pass) { - switch (input->material) { - case Material::RENDER_PASS: { - cc::RenderPassDrawQuad* render_pass_quad = - render_pass->CreateAndAppendDrawQuad(); - RenderPassQuadState* render_pass_quad_state = - input->render_pass_quad_state.get(); - gfx::PointF mask_uv_scale_as_point = - render_pass_quad_state->mask_uv_scale.To(); - gfx::PointF filter_scale_as_point = - render_pass_quad_state->filters_scale.To(); - render_pass_quad->SetAll( - sqs, - input->rect.To(), - input->opaque_rect.To(), - input->visible_rect.To(), - input->needs_blending, - render_pass_quad_state->render_pass_id.To(), - render_pass_quad_state->mask_resource_id, - mask_uv_scale_as_point.OffsetFromOrigin(), - render_pass_quad_state->mask_texture_size.To(), - cc::FilterOperations(), // TODO(jamesr): filters - filter_scale_as_point.OffsetFromOrigin(), - cc::FilterOperations()); // TODO(jamesr): background_filters - break; - } - case Material::SOLID_COLOR: { - if (input->solid_color_quad_state.is_null()) - return false; - cc::SolidColorDrawQuad* color_quad = - render_pass->CreateAndAppendDrawQuad(); - color_quad->SetAll( - sqs, - input->rect.To(), - input->opaque_rect.To(), - input->visible_rect.To(), - input->needs_blending, - input->solid_color_quad_state->color.To(), - input->solid_color_quad_state->force_anti_aliasing_off); - break; - } - case Material::SURFACE_CONTENT: { - if (input->surface_quad_state.is_null()) - return false; - cc::SurfaceDrawQuad* surface_quad = - render_pass->CreateAndAppendDrawQuad(); - surface_quad->SetAll( - sqs, - input->rect.To(), - input->opaque_rect.To(), - input->visible_rect.To(), - input->needs_blending, - input->surface_quad_state->surface.To()); - break; - } - case Material::TEXTURE_CONTENT: { - TextureQuadStatePtr& texture_quad_state = - input->texture_quad_state; - if (texture_quad_state.is_null() || - texture_quad_state->vertex_opacity.is_null() || - texture_quad_state->background_color.is_null()) - return false; - cc::TextureDrawQuad* texture_quad = - render_pass->CreateAndAppendDrawQuad(); - texture_quad->SetAll( - sqs, - input->rect.To(), - input->opaque_rect.To(), - input->visible_rect.To(), - input->needs_blending, - texture_quad_state->resource_id, - texture_quad_state->premultiplied_alpha, - texture_quad_state->uv_top_left.To(), - texture_quad_state->uv_bottom_right.To(), - texture_quad_state->background_color.To(), - &texture_quad_state->vertex_opacity.storage()[0], - texture_quad_state->flipped, - texture_quad_state->nearest_neighbor); - break; - } - case Material::TILED_CONTENT: { - TileQuadStatePtr& tile_state = input->tile_quad_state; - if (tile_state.is_null()) - return false; - cc::TileDrawQuad* tile_quad = - render_pass->CreateAndAppendDrawQuad(); - tile_quad->SetAll(sqs, - input->rect.To(), - input->opaque_rect.To(), - input->visible_rect.To(), - input->needs_blending, - tile_state->resource_id, - tile_state->tex_coord_rect.To(), - tile_state->texture_size.To(), - tile_state->swizzle_contents, - tile_state->nearest_neighbor); - break; - } - case Material::YUV_VIDEO_CONTENT: { - YUVVideoQuadStatePtr& yuv_state = input->yuv_video_quad_state; - if (yuv_state.is_null()) - return false; - cc::YUVVideoDrawQuad* yuv_quad = - render_pass->CreateAndAppendDrawQuad(); - yuv_quad->SetAll(sqs, - input->rect.To(), - input->opaque_rect.To(), - input->visible_rect.To(), - input->needs_blending, - yuv_state->tex_coord_rect.To(), - gfx::Size(), // TODO(jamesr): texture size - yuv_state->y_plane_resource_id, - yuv_state->u_plane_resource_id, - yuv_state->v_plane_resource_id, - yuv_state->a_plane_resource_id, - static_cast( - yuv_state->color_space)); - break; - } - default: - NOTREACHED() << "Unsupported material " << input->material; - return false; - } - return true; -} - -} // namespace - -// static -SurfaceIdPtr TypeConverter::Convert( - const cc::SurfaceId& input) { - SurfaceIdPtr id(SurfaceId::New()); - id->local = static_cast(input.id); - id->id_namespace = cc::SurfaceIdAllocator::NamespaceForId(input); - return id; -} - -// static -cc::SurfaceId TypeConverter::Convert( - const SurfaceIdPtr& input) { - uint64_t packed_id = input->id_namespace; - packed_id <<= 32ull; - packed_id |= input->local; - return cc::SurfaceId(packed_id); -} - -// static -ColorPtr TypeConverter::Convert(const SkColor& input) { - ColorPtr color(Color::New()); - color->rgba = input; - return color; -} - -// static -SkColor TypeConverter::Convert(const ColorPtr& input) { - return input->rgba; -} - -// static -RenderPassIdPtr TypeConverter::Convert( - const cc::RenderPassId& input) { - RenderPassIdPtr pass_id(RenderPassId::New()); - pass_id->layer_id = input.layer_id; - pass_id->index = input.index; - return pass_id; -} - -// static -cc::RenderPassId TypeConverter::Convert( - const RenderPassIdPtr& input) { - return cc::RenderPassId(input->layer_id, input->index); -} - -// static -QuadPtr TypeConverter::Convert( - const cc::DrawQuad& input) { - QuadPtr quad = Quad::New(); - quad->material = static_cast(input.material); - quad->rect = Rect::From(input.rect); - quad->opaque_rect = Rect::From(input.opaque_rect); - quad->visible_rect = Rect::From(input.visible_rect); - quad->needs_blending = input.needs_blending; - // This is intentionally left set to an invalid value here. It's set when - // converting an entire pass since it's an index into the pass' shared quad - // state list. - quad->shared_quad_state_index = UINT32_MAX; - switch (input.material) { - case cc::DrawQuad::RENDER_PASS: { - const cc::RenderPassDrawQuad* render_pass_quad = - cc::RenderPassDrawQuad::MaterialCast(&input); - RenderPassQuadStatePtr pass_state = RenderPassQuadState::New(); - pass_state->render_pass_id = - RenderPassId::From(render_pass_quad->render_pass_id); - pass_state->mask_resource_id = render_pass_quad->mask_resource_id; - pass_state->mask_uv_scale = PointF::From( - gfx::PointAtOffsetFromOrigin(render_pass_quad->mask_uv_scale)); - pass_state->mask_texture_size = - Size::From(render_pass_quad->mask_texture_size); - // TODO(jamesr): pass_state->filters - pass_state->filters_scale = PointF::From( - gfx::PointAtOffsetFromOrigin(render_pass_quad->filters_scale)); - // TODO(jamesr): pass_state->background_filters - quad->render_pass_quad_state = pass_state.Pass(); - break; - } - case cc::DrawQuad::SOLID_COLOR: { - const cc::SolidColorDrawQuad* color_quad = - cc::SolidColorDrawQuad::MaterialCast(&input); - SolidColorQuadStatePtr color_state = SolidColorQuadState::New(); - color_state->color = Color::From(color_quad->color); - color_state->force_anti_aliasing_off = - color_quad->force_anti_aliasing_off; - quad->solid_color_quad_state = color_state.Pass(); - break; - } - case cc::DrawQuad::SURFACE_CONTENT: { - const cc::SurfaceDrawQuad* surface_quad = - cc::SurfaceDrawQuad::MaterialCast(&input); - SurfaceQuadStatePtr surface_state = - SurfaceQuadState::New(); - surface_state->surface = SurfaceId::From(surface_quad->surface_id); - quad->surface_quad_state = surface_state.Pass(); - break; - } - case cc::DrawQuad::TEXTURE_CONTENT: { - const cc::TextureDrawQuad* texture_quad = - cc::TextureDrawQuad::MaterialCast(&input); - TextureQuadStatePtr texture_state = TextureQuadState::New(); - texture_state->resource_id = texture_quad->resource_id; - texture_state->premultiplied_alpha = texture_quad->premultiplied_alpha; - texture_state->uv_top_left = PointF::From(texture_quad->uv_top_left); - texture_state->uv_bottom_right = - PointF::From(texture_quad->uv_bottom_right); - texture_state->background_color = - Color::From(texture_quad->background_color); - auto vertex_opacity = Array::New(4); - for (size_t i = 0; i < 4; ++i) { - vertex_opacity[i] = texture_quad->vertex_opacity[i]; - } - texture_state->vertex_opacity = vertex_opacity.Pass(); - texture_state->flipped = texture_quad->flipped; - quad->texture_quad_state = texture_state.Pass(); - break; - } - case cc::DrawQuad::TILED_CONTENT: { - const cc::TileDrawQuad* tile_quad = - cc::TileDrawQuad::MaterialCast(&input); - TileQuadStatePtr tile_state = TileQuadState::New(); - tile_state->tex_coord_rect = RectF::From(tile_quad->tex_coord_rect); - tile_state->texture_size = Size::From(tile_quad->texture_size); - tile_state->swizzle_contents = tile_quad->swizzle_contents; - tile_state->resource_id = tile_quad->resource_id; - quad->tile_quad_state = tile_state.Pass(); - break; - } - case cc::DrawQuad::YUV_VIDEO_CONTENT: { - const cc::YUVVideoDrawQuad* yuv_quad = - cc::YUVVideoDrawQuad::MaterialCast(&input); - YUVVideoQuadStatePtr yuv_state = YUVVideoQuadState::New(); - yuv_state->tex_coord_rect = RectF::From(yuv_quad->tex_coord_rect); - yuv_state->y_plane_resource_id = yuv_quad->y_plane_resource_id; - yuv_state->u_plane_resource_id = yuv_quad->u_plane_resource_id; - yuv_state->v_plane_resource_id = yuv_quad->v_plane_resource_id; - yuv_state->a_plane_resource_id = yuv_quad->a_plane_resource_id; - yuv_state->color_space = - static_cast(yuv_quad->color_space); - quad->yuv_video_quad_state = yuv_state.Pass(); - break; - } - - default: - NOTREACHED() << "Unsupported material " << input.material; - } - return quad; -} - -// static -SharedQuadStatePtr -TypeConverter::Convert( - const cc::SharedQuadState& input) { - SharedQuadStatePtr state = SharedQuadState::New(); - state->content_to_target_transform = - Transform::From(input.content_to_target_transform); - state->content_bounds = Size::From(input.content_bounds); - state->visible_content_rect = Rect::From(input.visible_content_rect); - state->clip_rect = Rect::From(input.clip_rect); - state->is_clipped = input.is_clipped; - state->opacity = input.opacity; - state->blend_mode = static_cast(input.blend_mode); - state->sorting_context_id = input.sorting_context_id; - return state; -} - -// static -PassPtr TypeConverter::Convert( - const cc::RenderPass& input) { - PassPtr pass = Pass::New(); - pass->id = input.id.index; - pass->output_rect = Rect::From(input.output_rect); - pass->damage_rect = Rect::From(input.damage_rect); - pass->transform_to_root_target = - Transform::From(input.transform_to_root_target); - pass->has_transparent_background = input.has_transparent_background; - auto quads = Array::New(input.quad_list.size()); - auto shared_quad_state = - Array::New(input.shared_quad_state_list.size()); - const cc::SharedQuadState* last_sqs = nullptr; - cc::SharedQuadStateList::ConstIterator next_sqs_iter = - input.shared_quad_state_list.begin(); - for (auto iter = input.quad_list.cbegin(); iter != input.quad_list.cend(); - ++iter) { - const cc::DrawQuad& quad = **iter; - quads[iter.index()] = Quad::From(quad); - if (quad.shared_quad_state != last_sqs) { - shared_quad_state[next_sqs_iter.index()] = - SharedQuadState::From(**next_sqs_iter); - last_sqs = *next_sqs_iter; - ++next_sqs_iter; - } - DCHECK_LE(next_sqs_iter.index() - 1, UINT32_MAX); - quads[iter.index()]->shared_quad_state_index = - static_cast(next_sqs_iter.index() - 1); - } - // We should copy all shared quad states. - DCHECK_EQ(next_sqs_iter.index(), shared_quad_state.size()); - pass->quads = quads.Pass(); - pass->shared_quad_states = shared_quad_state.Pass(); - return pass; -} - -// static -scoped_ptr -TypeConverter, PassPtr>::Convert( - const PassPtr& input) { - scoped_ptr pass = cc::RenderPass::Create( - input->shared_quad_states.size(), input->quads.size()); - pass->SetAll(cc::RenderPassId(1, input->id), - input->output_rect.To(), - input->damage_rect.To(), - input->transform_to_root_target.To(), - input->has_transparent_background); - for (size_t i = 0; i < input->shared_quad_states.size(); ++i) { - ConvertSharedQuadState(input->shared_quad_states[i], pass.get()); - } - cc::SharedQuadStateList::Iterator sqs_iter = - pass->shared_quad_state_list.begin(); - for (size_t i = 0; i < input->quads.size(); ++i) { - QuadPtr quad = input->quads[i].Pass(); - while (quad->shared_quad_state_index > sqs_iter.index()) { - ++sqs_iter; - } - if (!ConvertDrawQuad(quad, *sqs_iter, pass.get())) - return nullptr; - } - return pass; -} - -// static -MailboxPtr TypeConverter::Convert( - const gpu::Mailbox& input) { - auto name = Array::New(64); - for (int i = 0; i < 64; ++i) { - name[i] = input.name[i]; - } - MailboxPtr mailbox(Mailbox::New()); - mailbox->name = name.Pass(); - return mailbox; -} - -// static -gpu::Mailbox TypeConverter::Convert( - const MailboxPtr& input) { - gpu::Mailbox mailbox; - if (!input->name.is_null()) - mailbox.SetName(&input->name.storage()[0]); - return mailbox; -} - -// static -MailboxHolderPtr TypeConverter::Convert( - const gpu::MailboxHolder& input) { - MailboxHolderPtr holder(MailboxHolder::New()); - holder->mailbox = Mailbox::From(input.mailbox); - holder->texture_target = input.texture_target; - holder->sync_point = input.sync_point; - return holder; -} - -// static -gpu::MailboxHolder TypeConverter::Convert( - const MailboxHolderPtr& input) { - gpu::MailboxHolder holder; - holder.mailbox = input->mailbox.To(); - holder.texture_target = input->texture_target; - holder.sync_point = input->sync_point; - return holder; -} - -// static -TransferableResourcePtr -TypeConverter::Convert( - const cc::TransferableResource& input) { - TransferableResourcePtr transferable = TransferableResource::New(); - transferable->id = input.id; - transferable->format = static_cast(input.format); - transferable->filter = input.filter; - transferable->size = Size::From(input.size); - transferable->mailbox_holder = MailboxHolder::From(input.mailbox_holder); - transferable->is_repeated = input.is_repeated; - transferable->is_software = input.is_software; - return transferable; -} - -// static -cc::TransferableResource -TypeConverter::Convert( - const TransferableResourcePtr& input) { - cc::TransferableResource transferable; - transferable.id = input->id; - transferable.format = static_cast(input->format); - transferable.filter = input->filter; - transferable.size = input->size.To(); - transferable.mailbox_holder = input->mailbox_holder.To(); - transferable.is_repeated = input->is_repeated; - transferable.is_software = input->is_software; - return transferable; -} - -// static -Array TypeConverter< - Array, - cc::TransferableResourceArray>::Convert(const cc::TransferableResourceArray& - input) { - auto resources = Array::New(input.size()); - for (size_t i = 0; i < input.size(); ++i) { - resources[i] = TransferableResource::From(input[i]); - } - return resources; -} - -// static -cc::TransferableResourceArray -TypeConverter >:: - Convert(const Array& input) { - cc::TransferableResourceArray resources(input.size()); - for (size_t i = 0; i < input.size(); ++i) { - resources[i] = input[i].To(); - } - return resources; -} - -// static -ReturnedResourcePtr -TypeConverter::Convert( - const cc::ReturnedResource& input) { - ReturnedResourcePtr returned = ReturnedResource::New(); - returned->id = input.id; - returned->sync_point = input.sync_point; - returned->count = input.count; - returned->lost = input.lost; - return returned; -} - -// static -cc::ReturnedResource -TypeConverter::Convert( - const ReturnedResourcePtr& input) { - cc::ReturnedResource returned; - returned.id = input->id; - returned.sync_point = input->sync_point; - returned.count = input->count; - returned.lost = input->lost; - return returned; -} - -// static -Array -TypeConverter, cc::ReturnedResourceArray>::Convert( - const cc::ReturnedResourceArray& input) { - auto resources = Array::New(input.size()); - for (size_t i = 0; i < input.size(); ++i) { - resources[i] = ReturnedResource::From(input[i]); - } - return resources; -} - -// static -FramePtr TypeConverter::Convert( - const cc::CompositorFrame& input) { - FramePtr frame = Frame::New(); - DCHECK(input.delegated_frame_data); - cc::DelegatedFrameData* frame_data = input.delegated_frame_data.get(); - frame->resources = - Array::From(frame_data->resource_list); - const cc::RenderPassList& pass_list = frame_data->render_pass_list; - frame->passes = Array::New(pass_list.size()); - for (size_t i = 0; i < pass_list.size(); ++i) { - frame->passes[i] = Pass::From(*pass_list[i]); - } - return frame; -} - -// static -scoped_ptr -TypeConverter, FramePtr>::Convert( - const FramePtr& input) { - scoped_ptr frame_data(new cc::DelegatedFrameData); - frame_data->device_scale_factor = 1.f; - frame_data->resource_list = - input->resources.To(); - frame_data->render_pass_list.reserve(input->passes.size()); - for (size_t i = 0; i < input->passes.size(); ++i) { - scoped_ptr pass = - input->passes[i].To >(); - if (!pass) - return scoped_ptr(); - frame_data->render_pass_list.push_back(pass.Pass()); - } - scoped_ptr frame(new cc::CompositorFrame); - frame->delegated_frame_data = frame_data.Pass(); - return frame; -} - -} // namespace mojo diff --git a/mojo/converters/surfaces/surfaces_type_converters.h b/mojo/converters/surfaces/surfaces_type_converters.h deleted file mode 100644 index 1f41613f9..000000000 --- a/mojo/converters/surfaces/surfaces_type_converters.h +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright 2014 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 MOJO_CONVERTERS_SURFACES_SURFACES_TYPE_CONVERTERS_H_ -#define MOJO_CONVERTERS_SURFACES_SURFACES_TYPE_CONVERTERS_H_ - -#include "base/memory/scoped_ptr.h" -#include "cc/resources/returned_resource.h" -#include "cc/resources/transferable_resource.h" -#include "cc/surfaces/surface_id.h" -#include "gpu/command_buffer/common/mailbox.h" -#include "gpu/command_buffer/common/mailbox_holder.h" -#include "mojo/services/surfaces/interfaces/quads.mojom.h" -#include "mojo/services/surfaces/interfaces/surface_id.mojom.h" -#include "mojo/services/surfaces/interfaces/surfaces.mojom.h" -#include "third_party/skia/include/core/SkColor.h" - -namespace cc { -class CompositorFrame; -class DrawQuad; -class RenderPass; -class RenderPassId; -class SharedQuadState; -} // namespace cc - -namespace mojo { - -// Types from surface_id.mojom -template <> -struct TypeConverter { - static SurfaceIdPtr Convert(const cc::SurfaceId& input); -}; -template <> -struct TypeConverter { - static cc::SurfaceId Convert(const SurfaceIdPtr& input); -}; - -// Types from quads.mojom -template <> -struct TypeConverter { - static ColorPtr Convert(const SkColor& input); -}; -template <> -struct TypeConverter { - static SkColor Convert(const ColorPtr& input); -}; - -template <> -struct TypeConverter { - static RenderPassIdPtr Convert(const cc::RenderPassId& input); -}; - -template <> -struct TypeConverter { - static cc::RenderPassId Convert(const RenderPassIdPtr& input); -}; - -template <> -struct TypeConverter { - static QuadPtr Convert(const cc::DrawQuad& input); -}; - -template <> -struct TypeConverter { - static SharedQuadStatePtr Convert(const cc::SharedQuadState& input); -}; - -template <> -struct TypeConverter { - static PassPtr Convert(const cc::RenderPass& input); -}; - -template <> -struct TypeConverter, PassPtr> { - static scoped_ptr Convert(const PassPtr& input); -}; - -// Types from surfaces.mojom -template <> -struct TypeConverter { - static MailboxPtr Convert(const gpu::Mailbox& input); -}; -template <> -struct TypeConverter { - static gpu::Mailbox Convert(const MailboxPtr& input); -}; - -template <> -struct TypeConverter { - static MailboxHolderPtr Convert(const gpu::MailboxHolder& input); -}; -template <> -struct TypeConverter { - static gpu::MailboxHolder Convert(const MailboxHolderPtr& input); -}; - -template <> -struct TypeConverter { - static TransferableResourcePtr Convert(const cc::TransferableResource& input); -}; -template <> -struct TypeConverter { - static cc::TransferableResource Convert(const TransferableResourcePtr& input); -}; - -template <> -struct TypeConverter, - cc::TransferableResourceArray> { - static Array Convert( - const cc::TransferableResourceArray& input); -}; -template <> -struct TypeConverter> { - static cc::TransferableResourceArray Convert( - const Array& input); -}; - -template <> -struct TypeConverter { - static ReturnedResourcePtr Convert(const cc::ReturnedResource& input); -}; -template <> -struct TypeConverter { - static cc::ReturnedResource Convert(const ReturnedResourcePtr& input); -}; - -template <> -struct TypeConverter, cc::ReturnedResourceArray> { - static Array Convert( - const cc::ReturnedResourceArray& input); -}; - -template <> -struct TypeConverter { - static FramePtr Convert(const cc::CompositorFrame& input); -}; - -template <> -struct TypeConverter, FramePtr> { - static scoped_ptr Convert(const FramePtr& input); -}; - -} // namespace mojo - -#endif // MOJO_CONVERTERS_SURFACES_SURFACES_TYPE_CONVERTERS_H_ diff --git a/mojo/converters/surfaces/tests/BUILD.gn b/mojo/converters/surfaces/tests/BUILD.gn deleted file mode 100644 index 2a9499df2..000000000 --- a/mojo/converters/surfaces/tests/BUILD.gn +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2014 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("//testing/test.gni") - -test("mojo_surfaces_lib_unittests") { - deps = [ - "//base", - "//base/test:test_support", - "//cc", - "//cc/surfaces", - "//gpu", - "//mojo/converters/geometry", - "//mojo/converters/surfaces", - "//mojo/edk/test:run_all_unittests", - "//mojo/environment:chromium", - "//mojo/services/geometry/interfaces", - "//mojo/services/surfaces/interfaces", - "//skia", - "//testing/gtest", - "//ui/gfx", - "//ui/gfx/geometry", - "//ui/gfx:test_support", - ] - - sources = [ - "surface_unittest.cc", - ] -} diff --git a/mojo/converters/surfaces/tests/surface_unittest.cc b/mojo/converters/surfaces/tests/surface_unittest.cc deleted file mode 100644 index 4c16d78d3..000000000 --- a/mojo/converters/surfaces/tests/surface_unittest.cc +++ /dev/null @@ -1,464 +0,0 @@ -// Copyright 2014 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 "cc/quads/render_pass.h" -#include "cc/quads/solid_color_draw_quad.h" -#include "cc/quads/surface_draw_quad.h" -#include "cc/quads/texture_draw_quad.h" -#include "gpu/command_buffer/common/mailbox.h" -#include "gpu/command_buffer/common/mailbox_holder.h" -#include "mojo/converters/geometry/geometry_type_converters.h" -#include "mojo/converters/surfaces/surfaces_type_converters.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/skia/include/core/SkColor.h" -#include "third_party/skia/include/core/SkXfermode.h" - -namespace mojo { -namespace { - -TEST(SurfaceLibTest, SurfaceIdConverterNullId) { - cc::SurfaceId null_id; - cc::SurfaceId round_trip = SurfaceId::From(null_id).To(); - EXPECT_TRUE(round_trip.is_null()); -} - -TEST(SurfaceLibTest, SurfaceIdConverterValidId) { - cc::SurfaceId valid_id(7); - cc::SurfaceId round_trip = SurfaceId::From(valid_id).To(); - EXPECT_FALSE(round_trip.is_null()); - EXPECT_EQ(valid_id, round_trip); -} - -TEST(SurfaceLibTest, Color) { - SkColor arbitrary_color = SK_ColorMAGENTA; - SkColor round_trip = Color::From(arbitrary_color).To(); - EXPECT_EQ(arbitrary_color, round_trip); -} - -class SurfaceLibQuadTest : public testing::Test { - public: - SurfaceLibQuadTest() - : rect(5, 7, 13, 19), - opaque_rect(rect), - visible_rect(9, 11, 5, 7), - needs_blending(false) { - pass = cc::RenderPass::Create(); - sqs = pass->CreateAndAppendSharedQuadState(); - } - - protected: - gfx::Rect rect; - gfx::Rect opaque_rect; - gfx::Rect visible_rect; - bool needs_blending; - scoped_ptr pass; - cc::SharedQuadState* sqs; -}; - -TEST_F(SurfaceLibQuadTest, ColorQuad) { - cc::SolidColorDrawQuad* color_quad = - pass->CreateAndAppendDrawQuad(); - SkColor arbitrary_color = SK_ColorGREEN; - bool force_anti_aliasing_off = true; - color_quad->SetAll(sqs, - rect, - opaque_rect, - visible_rect, - needs_blending, - arbitrary_color, - force_anti_aliasing_off); - - QuadPtr mojo_quad = Quad::From(*color_quad); - ASSERT_FALSE(mojo_quad.is_null()); - EXPECT_EQ(Material::SOLID_COLOR, mojo_quad->material); - EXPECT_EQ(Rect::From(rect), mojo_quad->rect); - EXPECT_EQ(Rect::From(opaque_rect), mojo_quad->opaque_rect); - EXPECT_EQ(Rect::From(visible_rect), mojo_quad->visible_rect); - EXPECT_EQ(needs_blending, mojo_quad->needs_blending); - ASSERT_TRUE(mojo_quad->solid_color_quad_state); - SolidColorQuadStatePtr& mojo_color_state = mojo_quad->solid_color_quad_state; - EXPECT_EQ(Color::From(arbitrary_color), mojo_color_state->color); - EXPECT_EQ(force_anti_aliasing_off, mojo_color_state->force_anti_aliasing_off); -} - -TEST_F(SurfaceLibQuadTest, SurfaceQuad) { - cc::SurfaceDrawQuad* surface_quad = - pass->CreateAndAppendDrawQuad(); - cc::SurfaceId arbitrary_id(5); - surface_quad->SetAll( - sqs, rect, opaque_rect, visible_rect, needs_blending, arbitrary_id); - - QuadPtr mojo_quad = Quad::From(*surface_quad); - ASSERT_FALSE(mojo_quad.is_null()); - EXPECT_EQ(Material::SURFACE_CONTENT, mojo_quad->material); - ASSERT_TRUE(mojo_quad->surface_quad_state); - SurfaceQuadStatePtr& mojo_surface_state = mojo_quad->surface_quad_state; - EXPECT_EQ(SurfaceId::From(arbitrary_id), - mojo_surface_state->surface); -} - -TEST_F(SurfaceLibQuadTest, TextureQuad) { - cc::TextureDrawQuad* texture_quad = - pass->CreateAndAppendDrawQuad(); - unsigned resource_id = 9; - bool premultiplied_alpha = true; - gfx::PointF uv_top_left(1.7f, 2.1f); - gfx::PointF uv_bottom_right(-7.f, 16.3f); - SkColor background_color = SK_ColorYELLOW; - float vertex_opacity[4] = {0.1f, 0.5f, 0.4f, 0.8f}; - bool flipped = false; - bool nearest_neighbor = false; - texture_quad->SetAll(sqs, - rect, - opaque_rect, - visible_rect, - needs_blending, - resource_id, - premultiplied_alpha, - uv_top_left, - uv_bottom_right, - background_color, - vertex_opacity, - flipped, - nearest_neighbor); - - QuadPtr mojo_quad = Quad::From(*texture_quad); - ASSERT_FALSE(mojo_quad.is_null()); - EXPECT_EQ(Material::TEXTURE_CONTENT, mojo_quad->material); - ASSERT_TRUE(mojo_quad->texture_quad_state); - TextureQuadStatePtr& mojo_texture_state = mojo_quad->texture_quad_state; - EXPECT_EQ(resource_id, mojo_texture_state->resource_id); - EXPECT_EQ(premultiplied_alpha, mojo_texture_state->premultiplied_alpha); - EXPECT_EQ(PointF::From(uv_top_left), mojo_texture_state->uv_top_left); - EXPECT_EQ(PointF::From(uv_bottom_right), mojo_texture_state->uv_bottom_right); - EXPECT_EQ(Color::From(background_color), - mojo_texture_state->background_color); - for (size_t i = 0; i < 4; ++i) { - EXPECT_EQ(vertex_opacity[i], mojo_texture_state->vertex_opacity[i]) << i; - } - EXPECT_EQ(flipped, mojo_texture_state->flipped); -} - -TEST_F(SurfaceLibQuadTest, TextureQuadEmptyVertexOpacity) { - QuadPtr mojo_texture_quad = Quad::New(); - mojo_texture_quad->material = Material::TEXTURE_CONTENT; - TextureQuadStatePtr mojo_texture_state = TextureQuadState::New(); - mojo_texture_state->background_color = Color::New(); - mojo_texture_quad->texture_quad_state = mojo_texture_state.Pass(); - PassPtr mojo_pass = Pass::New(); - mojo_pass->quads.push_back(mojo_texture_quad.Pass()); - SharedQuadStatePtr mojo_sqs = SharedQuadState::New(); - mojo_pass->shared_quad_states.push_back(mojo_sqs.Pass()); - - scoped_ptr pass = mojo_pass.To >(); - - EXPECT_FALSE(pass); -} - -TEST_F(SurfaceLibQuadTest, TextureQuadEmptyBackgroundColor) { - QuadPtr mojo_texture_quad = Quad::New(); - mojo_texture_quad->material = Material::TEXTURE_CONTENT; - TextureQuadStatePtr mojo_texture_state = TextureQuadState::New(); - mojo_texture_state->vertex_opacity = mojo::Array::New(4); - mojo_texture_quad->texture_quad_state = mojo_texture_state.Pass(); - PassPtr mojo_pass = Pass::New(); - mojo_pass->quads.push_back(mojo_texture_quad.Pass()); - SharedQuadStatePtr mojo_sqs = SharedQuadState::New(); - mojo_pass->shared_quad_states.push_back(mojo_sqs.Pass()); - - scoped_ptr pass = mojo_pass.To >(); - EXPECT_FALSE(pass); -} - -TEST(SurfaceLibTest, SharedQuadState) { - gfx::Transform content_to_target_transform; - content_to_target_transform.Scale3d(0.3f, 0.7f, 0.9f); - gfx::Size content_bounds(57, 39); - gfx::Rect visible_content_rect(3, 7, 28, 42); - gfx::Rect clip_rect(9, 12, 21, 31); - bool is_clipped = true; - float opacity = 0.65f; - int sorting_context_id = 13; - ::SkXfermode::Mode blend_mode = ::SkXfermode::kSrcOver_Mode; - scoped_ptr pass = cc::RenderPass::Create(); - cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); - sqs->SetAll(content_to_target_transform, - content_bounds, - visible_content_rect, - clip_rect, - is_clipped, - opacity, - blend_mode, - sorting_context_id); - - SharedQuadStatePtr mojo_sqs = SharedQuadState::From(*sqs); - ASSERT_FALSE(mojo_sqs.is_null()); - EXPECT_EQ(Transform::From(content_to_target_transform), - mojo_sqs->content_to_target_transform); - EXPECT_EQ(Size::From(content_bounds), mojo_sqs->content_bounds); - EXPECT_EQ(Rect::From(visible_content_rect), mojo_sqs->visible_content_rect); - EXPECT_EQ(Rect::From(clip_rect), mojo_sqs->clip_rect); - EXPECT_EQ(is_clipped, mojo_sqs->is_clipped); - EXPECT_EQ(opacity, mojo_sqs->opacity); - EXPECT_EQ(sorting_context_id, mojo_sqs->sorting_context_id); -} - -TEST(SurfaceLibTest, RenderPass) { - scoped_ptr pass = cc::RenderPass::Create(); - cc::RenderPassId pass_id(1, 6); - gfx::Rect output_rect(4, 9, 13, 71); - gfx::Rect damage_rect(9, 17, 41, 45); - gfx::Transform transform_to_root_target; - transform_to_root_target.SkewY(43.0); - bool has_transparent_background = false; - pass->SetAll(pass_id, - output_rect, - damage_rect, - transform_to_root_target, - has_transparent_background); - - gfx::Transform content_to_target_transform; - content_to_target_transform.Scale3d(0.3f, 0.7f, 0.9f); - gfx::Size content_bounds(57, 39); - gfx::Rect visible_content_rect(3, 7, 28, 42); - gfx::Rect clip_rect(9, 12, 21, 31); - bool is_clipped = true; - float opacity = 0.65f; - int sorting_context_id = 13; - ::SkXfermode::Mode blend_mode = ::SkXfermode::kSrcOver_Mode; - cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); - sqs->SetAll(content_to_target_transform, - content_bounds, - visible_content_rect, - clip_rect, - is_clipped, - opacity, - blend_mode, - sorting_context_id); - - gfx::Rect rect(5, 7, 13, 19); - gfx::Rect opaque_rect(rect); - gfx::Rect visible_rect(9, 11, 5, 7); - bool needs_blending = false; - - cc::SolidColorDrawQuad* color_quad = - pass->CreateAndAppendDrawQuad(); - SkColor arbitrary_color = SK_ColorGREEN; - bool force_anti_aliasing_off = true; - color_quad->SetAll(pass->shared_quad_state_list.back(), - rect, - opaque_rect, - visible_rect, - needs_blending, - arbitrary_color, - force_anti_aliasing_off); - - cc::SurfaceDrawQuad* surface_quad = - pass->CreateAndAppendDrawQuad(); - cc::SurfaceId arbitrary_id(5); - surface_quad->SetAll( - sqs, rect, opaque_rect, visible_rect, needs_blending, arbitrary_id); - - cc::TextureDrawQuad* texture_quad = - pass->CreateAndAppendDrawQuad(); - unsigned resource_id = 9; - bool premultiplied_alpha = true; - gfx::PointF uv_top_left(1.7f, 2.1f); - gfx::PointF uv_bottom_right(-7.f, 16.3f); - SkColor background_color = SK_ColorYELLOW; - float vertex_opacity[4] = {0.1f, 0.5f, 0.4f, 0.8f}; - bool flipped = false; - bool nearest_neighbor = false; - texture_quad->SetAll(sqs, - rect, - opaque_rect, - visible_rect, - needs_blending, - resource_id, - premultiplied_alpha, - uv_top_left, - uv_bottom_right, - background_color, - vertex_opacity, - flipped, - nearest_neighbor); - - PassPtr mojo_pass = Pass::From(*pass); - ASSERT_FALSE(mojo_pass.is_null()); - EXPECT_EQ(6, mojo_pass->id); - EXPECT_EQ(Rect::From(output_rect), mojo_pass->output_rect); - EXPECT_EQ(Rect::From(damage_rect), mojo_pass->damage_rect); - EXPECT_EQ(Transform::From(transform_to_root_target), - mojo_pass->transform_to_root_target); - EXPECT_EQ(has_transparent_background, mojo_pass->has_transparent_background); - ASSERT_EQ(1u, mojo_pass->shared_quad_states.size()); - ASSERT_EQ(3u, mojo_pass->quads.size()); - EXPECT_EQ(0u, mojo_pass->quads[0]->shared_quad_state_index); - - scoped_ptr round_trip_pass = - mojo_pass.To >(); - EXPECT_EQ(pass_id, round_trip_pass->id); - EXPECT_EQ(output_rect, round_trip_pass->output_rect); - EXPECT_EQ(damage_rect, round_trip_pass->damage_rect); - EXPECT_EQ(transform_to_root_target, - round_trip_pass->transform_to_root_target); - EXPECT_EQ(has_transparent_background, - round_trip_pass->has_transparent_background); - ASSERT_EQ(1u, round_trip_pass->shared_quad_state_list.size()); - ASSERT_EQ(3u, round_trip_pass->quad_list.size()); - EXPECT_EQ(round_trip_pass->shared_quad_state_list.front(), - round_trip_pass->quad_list.front()->shared_quad_state); - - cc::SharedQuadState* round_trip_sqs = - round_trip_pass->shared_quad_state_list.front(); - EXPECT_EQ(content_to_target_transform, - round_trip_sqs->content_to_target_transform); - EXPECT_EQ(content_bounds, round_trip_sqs->content_bounds); - EXPECT_EQ(visible_content_rect, round_trip_sqs->visible_content_rect); - EXPECT_EQ(clip_rect, round_trip_sqs->clip_rect); - EXPECT_EQ(is_clipped, round_trip_sqs->is_clipped); - EXPECT_EQ(opacity, round_trip_sqs->opacity); - EXPECT_EQ(sorting_context_id, round_trip_sqs->sorting_context_id); - - cc::DrawQuad* round_trip_quad = round_trip_pass->quad_list.front(); - // First is solid color quad. - ASSERT_EQ(cc::DrawQuad::SOLID_COLOR, round_trip_quad->material); - EXPECT_EQ(rect, round_trip_quad->rect); - EXPECT_EQ(opaque_rect, round_trip_quad->opaque_rect); - EXPECT_EQ(visible_rect, round_trip_quad->visible_rect); - EXPECT_EQ(needs_blending, round_trip_quad->needs_blending); - const cc::SolidColorDrawQuad* round_trip_color_quad = - cc::SolidColorDrawQuad::MaterialCast(round_trip_quad); - EXPECT_EQ(arbitrary_color, round_trip_color_quad->color); - EXPECT_EQ(force_anti_aliasing_off, - round_trip_color_quad->force_anti_aliasing_off); - - round_trip_quad = round_trip_pass->quad_list.ElementAt(1); - // Second is surface quad. - ASSERT_EQ(cc::DrawQuad::SURFACE_CONTENT, round_trip_quad->material); - const cc::SurfaceDrawQuad* round_trip_surface_quad = - cc::SurfaceDrawQuad::MaterialCast(round_trip_quad); - EXPECT_EQ(arbitrary_id, round_trip_surface_quad->surface_id); - - round_trip_quad = round_trip_pass->quad_list.ElementAt(2); - // Third is texture quad. - ASSERT_EQ(cc::DrawQuad::TEXTURE_CONTENT, round_trip_quad->material); - const cc::TextureDrawQuad* round_trip_texture_quad = - cc::TextureDrawQuad::MaterialCast(round_trip_quad); - EXPECT_EQ(resource_id, round_trip_texture_quad->resource_id); - EXPECT_EQ(premultiplied_alpha, round_trip_texture_quad->premultiplied_alpha); - EXPECT_EQ(uv_top_left, round_trip_texture_quad->uv_top_left); - EXPECT_EQ(uv_bottom_right, round_trip_texture_quad->uv_bottom_right); - EXPECT_EQ(background_color, round_trip_texture_quad->background_color); - for (size_t i = 0; i < 4; ++i) { - EXPECT_EQ(vertex_opacity[i], round_trip_texture_quad->vertex_opacity[i]) - << i; - } - EXPECT_EQ(flipped, round_trip_texture_quad->flipped); -} - -TEST(SurfaceLibTest, Mailbox) { - gpu::Mailbox mailbox; - mailbox.Generate(); - - MailboxPtr mojo_mailbox = Mailbox::From(mailbox); - EXPECT_EQ(0, memcmp(mailbox.name, &mojo_mailbox->name.storage()[0], 64)); - - gpu::Mailbox round_trip_mailbox = mojo_mailbox.To(); - EXPECT_EQ(mailbox, round_trip_mailbox); -} - -TEST(SurfaceLibTest, MailboxEmptyName) { - MailboxPtr mojo_mailbox = Mailbox::New(); - - gpu::Mailbox converted_mailbox = mojo_mailbox.To(); - EXPECT_TRUE(converted_mailbox.IsZero()); -} - -TEST(SurfaceLibTest, MailboxHolder) { - gpu::Mailbox mailbox; - mailbox.Generate(); - uint32_t texture_target = GL_TEXTURE_2D; - uint32_t sync_point = 7u; - gpu::MailboxHolder holder(mailbox, texture_target, sync_point); - - MailboxHolderPtr mojo_holder = MailboxHolder::From(holder); - EXPECT_EQ(texture_target, mojo_holder->texture_target); - EXPECT_EQ(sync_point, mojo_holder->sync_point); - - gpu::MailboxHolder round_trip_holder = mojo_holder.To(); - EXPECT_EQ(mailbox, round_trip_holder.mailbox); - EXPECT_EQ(texture_target, round_trip_holder.texture_target); - EXPECT_EQ(sync_point, round_trip_holder.sync_point); -} - -TEST(SurfaceLibTest, TransferableResource) { - uint32_t id = 7u; - cc::ResourceFormat format = cc::BGRA_8888; - uint32_t filter = 123u; - gfx::Size size(17, 18); - gpu::MailboxHolder mailbox_holder; - bool is_repeated = false; - ; - bool is_software = false; - cc::TransferableResource resource; - resource.id = id; - resource.format = format; - resource.filter = filter; - resource.size = size; - resource.mailbox_holder = mailbox_holder; - resource.is_repeated = is_repeated; - resource.is_software = is_software; - - TransferableResourcePtr mojo_resource = TransferableResource::From(resource); - EXPECT_EQ(id, mojo_resource->id); - EXPECT_EQ(static_cast(format), - mojo_resource->format); - EXPECT_EQ(filter, mojo_resource->filter); - EXPECT_EQ(Size::From(size), mojo_resource->size); - EXPECT_EQ(is_repeated, mojo_resource->is_repeated); - EXPECT_EQ(is_software, mojo_resource->is_software); - - cc::TransferableResource round_trip_resource = - mojo_resource.To(); - EXPECT_EQ(id, round_trip_resource.id); - EXPECT_EQ(format, round_trip_resource.format); - EXPECT_EQ(filter, round_trip_resource.filter); - EXPECT_EQ(size, round_trip_resource.size); - EXPECT_EQ(mailbox_holder.mailbox, round_trip_resource.mailbox_holder.mailbox); - EXPECT_EQ(mailbox_holder.texture_target, - round_trip_resource.mailbox_holder.texture_target); - EXPECT_EQ(mailbox_holder.sync_point, - round_trip_resource.mailbox_holder.sync_point); - EXPECT_EQ(is_repeated, round_trip_resource.is_repeated); - EXPECT_EQ(is_software, round_trip_resource.is_software); -} - -TEST(SurfaceLibTest, ReturnedResource) { - uint32_t id = 5u; - uint32_t sync_point = 24u; - int count = 2; - bool lost = false; - cc::ReturnedResource resource; - resource.id = id; - resource.sync_point = sync_point; - resource.count = count; - resource.lost = lost; - - ReturnedResourcePtr mojo_resource = ReturnedResource::From(resource); - EXPECT_EQ(id, mojo_resource->id); - EXPECT_EQ(sync_point, mojo_resource->sync_point); - EXPECT_EQ(count, mojo_resource->count); - EXPECT_EQ(lost, mojo_resource->lost); - - cc::ReturnedResource round_trip_resource = - mojo_resource.To(); - EXPECT_EQ(id, round_trip_resource.id); - EXPECT_EQ(sync_point, round_trip_resource.sync_point); - EXPECT_EQ(count, round_trip_resource.count); - EXPECT_EQ(lost, round_trip_resource.lost); -} - -} // namespace -} // namespace mojo diff --git a/sky/BUILD.gn b/sky/BUILD.gn index 228a0de19..bc52b94ab 100644 --- a/sky/BUILD.gn +++ b/sky/BUILD.gn @@ -32,10 +32,6 @@ group("sky") { deps += [ "//sky/services/activity" ] } - if (!is_android) { - deps += [ "//third_party/mesa:osmesa" ] - } - # TODO(mpcomplete): This is temporary until we move GCM and Firebase # out of the engine repo. if (enable_firebase) { diff --git a/sky/shell/BUILD.gn b/sky/shell/BUILD.gn index 5c1e927ef..88b7b91a2 100644 --- a/sky/shell/BUILD.gn +++ b/sky/shell/BUILD.gn @@ -16,6 +16,7 @@ dart_embedder_resources("generate_sky_embedder_diagnostic_server_resources_cc") source_set("common") { sources = [ + "$target_gen_dir/sky_embedder_diagnostic_server_resources.cc", "diagnostic/diagnostic_server.cc", "diagnostic/diagnostic_server.h", "gpu/picture_serializer.cc", @@ -42,7 +43,6 @@ source_set("common") { "ui/platform_impl.h", "ui_delegate.cc", "ui_delegate.h", - "$target_gen_dir/sky_embedder_diagnostic_server_resources.cc", ] public_deps = [ @@ -75,22 +75,18 @@ source_set("common") { "//sky/services/rasterizer:interfaces", "//sky/services/semantics:interfaces", "//sky/shell/dart", - "//ui/gfx", ] } source_set("gpu_direct") { sources = [ - "gpu/direct/surface_notifications_direct.cc", - "gpu/direct/surface_notifications_direct.h", - "gpu/direct/rasterizer_direct.cc", - "gpu/direct/rasterizer_direct.h", "gpu/direct/ganesh_canvas.cc", "gpu/direct/ganesh_canvas.h", + "gpu/direct/rasterizer_direct.cc", + "gpu/direct/rasterizer_direct.h", ] deps = [ - "//ui/gl", ":common", ] } @@ -157,12 +153,12 @@ if (is_android) { "//mojo/android:libsystem_java", "//mojo/edk/base_edk", "//mojo/edk/system", - "//ui/gl", ] ldflags = [ - "-lGLESv2", + "-landroid", "-lEGL", + "-lGLESv2", ] } @@ -257,6 +253,8 @@ if (is_android) { "platform/ios/framework/Source/accessibility_bridge.mm", "platform/ios/framework/Source/application_messages_impl.h", "platform/ios/framework/Source/application_messages_impl.mm", + "platform/ios/framework/Source/flutter_touch_mapper.h", + "platform/ios/framework/Source/flutter_touch_mapper.mm", "platform/ios/framework/Source/FlutterAppDelegate.mm", "platform/ios/framework/Source/FlutterDartProject.mm", "platform/ios/framework/Source/FlutterDartProject_Internal.h", @@ -267,8 +265,8 @@ if (is_android) { "platform/ios/framework/Source/FlutterView.h", "platform/ios/framework/Source/FlutterView.mm", "platform/ios/framework/Source/FlutterViewController.mm", - "platform/ios/framework/Source/flutter_touch_mapper.h", - "platform/ios/framework/Source/flutter_touch_mapper.mm", + "platform/ios/platform_view_ios.h", + "platform/ios/platform_view_ios.mm", ] set_sources_assignment_filter([]) @@ -277,8 +275,6 @@ if (is_android) { "platform/mac/platform_mac.mm", "platform/mac/platform_service_provider.cc", "platform/mac/platform_service_provider.h", - "platform/mac/platform_view_mac.h", - "platform/mac/platform_view_mac.mm", "platform/mac/view_service_provider.cc", "platform/mac/view_service_provider.h", ] @@ -295,7 +291,6 @@ if (is_android) { "//sky/services/ns_net", "//sky/services/semantics", "//sky/services/vsync", - "//ui/gl", ":common", ":gpu_direct", ] @@ -455,7 +450,6 @@ if (is_android) { "//mojo/edk/base_edk", "//mojo/edk/system", "//sky/services/ns_net", - "//ui/gl", ":common", ":gpu_direct", ":testing", diff --git a/sky/shell/gpu/direct/ganesh_canvas.cc b/sky/shell/gpu/direct/ganesh_canvas.cc index 7a16a6fa5..2a3c2a4df 100644 --- a/sky/shell/gpu/direct/ganesh_canvas.cc +++ b/sky/shell/gpu/direct/ganesh_canvas.cc @@ -27,18 +27,14 @@ GaneshCanvas::GaneshCanvas() { GaneshCanvas::~GaneshCanvas() { } -void GaneshCanvas::SetGrGLInterface(const GrGLInterface* interface) { +void GaneshCanvas::SetupGrGLInterface() { sk_surface_ = nullptr; - if (interface) { - gr_context_ = skia::AdoptRef(GrContext::Create(kOpenGL_GrBackend, - reinterpret_cast(interface))); - DCHECK(gr_context_); - gr_context_->setResourceCacheLimits(kMaxGaneshResourceCacheCount, - kMaxGaneshResourceCacheBytes); - } else if (gr_context_) { - gr_context_->abandonContext(); - gr_context_.clear(); - } + gr_context_ = skia::AdoptRef(GrContext::Create( + kOpenGL_GrBackend, + reinterpret_cast(GrGLCreateNativeInterface()))); + DCHECK(gr_context_); + gr_context_->setResourceCacheLimits(kMaxGaneshResourceCacheCount, + kMaxGaneshResourceCacheBytes); } bool GaneshCanvas::SelectPixelConfig(GrPixelConfig* config) { diff --git a/sky/shell/gpu/direct/ganesh_canvas.h b/sky/shell/gpu/direct/ganesh_canvas.h index a71bdb568..16c652c53 100644 --- a/sky/shell/gpu/direct/ganesh_canvas.h +++ b/sky/shell/gpu/direct/ganesh_canvas.h @@ -21,7 +21,8 @@ class GaneshCanvas { GaneshCanvas(); ~GaneshCanvas(); - void SetGrGLInterface(const GrGLInterface* interface); + void SetupGrGLInterface(); + SkCanvas* GetCanvas(int32_t fbo, const SkISize& size); bool IsValid(); diff --git a/sky/shell/gpu/direct/rasterizer_direct.cc b/sky/shell/gpu/direct/rasterizer_direct.cc index d4ab6c58e..0daab7899 100644 --- a/sky/shell/gpu/direct/rasterizer_direct.cc +++ b/sky/shell/gpu/direct/rasterizer_direct.cc @@ -9,42 +9,32 @@ #include "sky/engine/wtf/PassRefPtr.h" #include "sky/engine/wtf/RefPtr.h" #include "sky/shell/gpu/picture_serializer.h" +#include "sky/shell/platform_view.h" #include "sky/shell/shell.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkPicture.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_bindings_skia_in_process.h" -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_share_group.h" -#include "ui/gl/gl_surface.h" namespace sky { namespace shell { -static const double kOneFrameDuration = 1e3 / 60.0; - -std::unique_ptr Rasterizer::Create() { - return std::unique_ptr(new RasterizerDirect()); -} - -RasterizerDirect::RasterizerDirect() - : share_group_(new gfx::GLShareGroup()), binding_(this), - weak_factory_(this) { -} +RasterizerDirect::RasterizerDirect() : binding_(this), weak_factory_(this) {} RasterizerDirect::~RasterizerDirect() { weak_factory_.InvalidateWeakPtrs(); Shell::Shared().PurgeRasterizers(); } -base::WeakPtr RasterizerDirect::GetWeakPtr() { +// Implementation of declaration in sky/shell/rasterizer.h. +std::unique_ptr Rasterizer::Create() { + return std::unique_ptr(new RasterizerDirect()); +} + +// sky::shell::Rasterizer override. +base::WeakPtr RasterizerDirect::GetWeakRasterizerPtr() { return weak_factory_.GetWeakPtr(); } -base::WeakPtr RasterizerDirect::GetWeakRasterizerPtr() { - return GetWeakPtr(); -} - +// sky::shell::Rasterizer override. void RasterizerDirect::ConnectToRasterizer( mojo::InterfaceRequest request) { binding_.Bind(request.Pass()); @@ -52,23 +42,37 @@ void RasterizerDirect::ConnectToRasterizer( Shell::Shared().AddRasterizer(GetWeakRasterizerPtr()); } -void RasterizerDirect::OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, - base::WaitableEvent* did_draw) { - gfx::SurfaceConfiguration config; - config.stencil_bits = 8; - surface_ = gfx::GLSurface::CreateViewGLSurface(widget, config); - CHECK(surface_) << "GLSurface required."; - // Eagerly create the GL context. For a while after the accelerated widget - // is first available (after startup), the process is busy setting up dart - // isolates. During this time, we are free to create the context. Thus - // avoiding a delay when the first frame is painted. - EnsureGLContext(); - CHECK(context_->MakeCurrent(surface_.get())); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - surface_->SwapBuffers(); - if (did_draw) - did_draw->Signal(); +// sky::shell::Rasterizer override. +void RasterizerDirect::Setup(PlatformView* platform_view, + base::Closure continuation, + base::WaitableEvent* setup_completion_event) { + CHECK(platform_view) << "Must be able to acquire the view."; + + // The context needs to be made current before the GrGL interface can be + // setup. + bool success = platform_view->ContextMakeCurrent(); + + CHECK(success) << "Could not make the context current for initial GL setup"; + + ganesh_canvas_.SetupGrGLInterface(); + + platform_view_ = platform_view; + + continuation.Run(); + + setup_completion_event->Signal(); +} + +// sky::shell::Rasterizer override. +void RasterizerDirect::Teardown( + base::WaitableEvent* teardown_completion_event) { + platform_view_ = nullptr; + teardown_completion_event->Signal(); +} + +// sky::shell::Rasterizer override. +flow::LayerTree* RasterizerDirect::GetLastLayerTree() { + return last_layer_tree_.get(); } void RasterizerDirect::Draw(uint64_t layer_tree_ptr, @@ -78,16 +82,13 @@ void RasterizerDirect::Draw(uint64_t layer_tree_ptr, std::unique_ptr layer_tree( reinterpret_cast(layer_tree_ptr)); - if (!surface_ || !layer_tree->root_layer()) { + if (platform_view_ == nullptr || !platform_view_->ContextMakeCurrent() || + !layer_tree->root_layer()) { callback.Run(); return; } - gfx::Size size(layer_tree->frame_size().width(), - layer_tree->frame_size().height()); - - if (surface_->GetSize() != size) - surface_->Resize(size); + SkISize size = layer_tree->frame_size(); // There is no way for the compositor to know how long the layer tree // construction took. Fortunately, the layer tree does. Grab that time @@ -95,19 +96,19 @@ void RasterizerDirect::Draw(uint64_t layer_tree_ptr, compositor_context_.engine_time().SetLapTime(layer_tree->construction_time()); { - EnsureGLContext(); - CHECK(context_->MakeCurrent(surface_.get())); SkCanvas* canvas = ganesh_canvas_.GetCanvas( - surface_->GetBackingFrameBufferObject(), layer_tree->frame_size()); + platform_view_->DefaultFramebuffer(), layer_tree->frame_size()); flow::CompositorContext::ScopedFrame frame = compositor_context_.AcquireFrame(ganesh_canvas_.gr_context(), *canvas); canvas->clear(SK_ColorBLACK); layer_tree->Raster(frame); canvas->flush(); - surface_->SwapBuffers(); + + platform_view_->SwapBuffers(); } // Trace to a file if necessary + static const double kOneFrameDuration = 1e3 / 60.0; bool frameExceededThreshold = false; uint32_t thresholdInterval = layer_tree->rasterizer_tracing_threshold(); if (thresholdInterval != 0 && @@ -141,32 +142,5 @@ void RasterizerDirect::Draw(uint64_t layer_tree_ptr, last_layer_tree_ = std::move(layer_tree); } -void RasterizerDirect::OnOutputSurfaceDestroyed() { - if (context_) { - CHECK(context_->MakeCurrent(surface_.get())); - compositor_context_.OnGrContextDestroyed(); - ganesh_canvas_.SetGrGLInterface(nullptr); - context_ = nullptr; - } - CHECK(!ganesh_canvas_.IsValid()); - CHECK(!context_); - surface_ = nullptr; -} - -void RasterizerDirect::EnsureGLContext() { - if (context_) - return; - context_ = gfx::GLContext::CreateGLContext(share_group_.get(), surface_.get(), - gfx::PreferIntegratedGpu); - CHECK(context_) << "GLContext required."; - CHECK(context_->MakeCurrent(surface_.get())); - gr_gl_interface_ = skia::AdoptRef(gfx::CreateInProcessSkiaGLBinding()); - ganesh_canvas_.SetGrGLInterface(gr_gl_interface_.get()); -} - -flow::LayerTree* RasterizerDirect::GetLastLayerTree() { - return last_layer_tree_.get(); -} - } // namespace shell } // namespace sky diff --git a/sky/shell/gpu/direct/rasterizer_direct.h b/sky/shell/gpu/direct/rasterizer_direct.h index 072aa7214..44e6a21c5 100644 --- a/sky/shell/gpu/direct/rasterizer_direct.h +++ b/sky/shell/gpu/direct/rasterizer_direct.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_GPU_DIRECT_RASTERIZER_H_ -#define SKY_SHELL_GPU_DIRECT_RASTERIZER_H_ +#ifndef SKY_SHELL_GPU_DIRECT_RASTERIZER_DIRECT_H_ +#define SKY_SHELL_GPU_DIRECT_RASTERIZER_DIRECT_H_ #include "base/memory/weak_ptr.h" #include "base/synchronization/waitable_event.h" @@ -11,61 +11,50 @@ #include "skia/ext/refptr.h" #include "sky/shell/gpu/direct/ganesh_canvas.h" #include "sky/shell/rasterizer.h" -#include "ui/gfx/native_widget_types.h" - -namespace gfx { -class GLContext; -class GLShareGroup; -class GLSurface; -} namespace sky { namespace shell { -class GaneshContext; -class GaneshSurface; class RasterizerDirect : public Rasterizer { public: - explicit RasterizerDirect(); + RasterizerDirect(); + ~RasterizerDirect() override; - base::WeakPtr GetWeakPtr(); - - base::WeakPtr<::sky::shell::Rasterizer> GetWeakRasterizerPtr() override; - + // sky::shell::Rasterizer override. void ConnectToRasterizer( mojo::InterfaceRequest request) override; - void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, - base::WaitableEvent* did_draw); - void OnOutputSurfaceDestroyed(); + // sky::shell::Rasterizer override. + void Setup(PlatformView* platform_view, + base::Closure continuation, + base::WaitableEvent* setup_completion_event) override; + // sky::shell::Rasterizer override. + void Teardown(base::WaitableEvent* teardown_completion_event) override; + + // sky::shell::Rasterizer override. + base::WeakPtr GetWeakRasterizerPtr() override; + + // sky::shell::Rasterizer override. flow::LayerTree* GetLastLayerTree() override; private: - void Draw(uint64_t layer_tree_ptr, const DrawCallback& callback) override; - - void EnsureGLContext(); - - scoped_refptr share_group_; - scoped_refptr surface_; - scoped_refptr context_; - skia::RefPtr gr_gl_interface_; GaneshCanvas ganesh_canvas_; - flow::CompositorContext compositor_context_; - mojo::Binding binding_; - std::unique_ptr last_layer_tree_; - + PlatformView* platform_view_; base::WeakPtrFactory weak_factory_; + // sky::services::rasterizer::Rasterizer (from rasterizer.mojom) override. + void Draw(uint64_t layer_tree_ptr, const DrawCallback& callback) override; + DISALLOW_COPY_AND_ASSIGN(RasterizerDirect); }; } // namespace shell } // namespace sky -#endif // SKY_SHELL_GPU_DIRECT_RASTERIZER_H_ +#endif // SKY_SHELL_GPU_DIRECT_RASTERIZER_DIRECT_H_ diff --git a/sky/shell/gpu/direct/surface_notifications_direct.cc b/sky/shell/gpu/direct/surface_notifications_direct.cc deleted file mode 100644 index 167d88eb2..000000000 --- a/sky/shell/gpu/direct/surface_notifications_direct.cc +++ /dev/null @@ -1,39 +0,0 @@ -// 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 "sky/shell/gpu/direct/surface_notifications_direct.h" - -#include "base/bind.h" -#include "base/location.h" -#include "base/single_thread_task_runner.h" -#include "sky/shell/gpu/direct/rasterizer_direct.h" -#include "sky/shell/shell.h" - -namespace sky { -namespace shell { - -void SurfaceNotificationsDirect::NotifyCreated( - const PlatformView::Config& config, - gfx::AcceleratedWidget widget, - base::WaitableEvent* did_draw) { - RasterizerDirect* rasterizer = static_cast(config.rasterizer); - config.ui_task_runner->PostTask( - FROM_HERE, base::Bind(&UIDelegate::OnOutputSurfaceCreated, - config.ui_delegate, - base::Bind(&RasterizerDirect::OnAcceleratedWidgetAvailable, - rasterizer->GetWeakPtr(), widget, did_draw))); -} - -void SurfaceNotificationsDirect::NotifyDestroyed( - const PlatformView::Config& config) { - RasterizerDirect* rasterizer = static_cast(config.rasterizer); - config.ui_task_runner->PostTask( - FROM_HERE, base::Bind(&UIDelegate::OnOutputSurfaceDestroyed, - config.ui_delegate, - base::Bind(&RasterizerDirect::OnOutputSurfaceDestroyed, - rasterizer->GetWeakPtr()))); -} - -} // namespace shell -} // namespace sky diff --git a/sky/shell/gpu/direct/surface_notifications_direct.h b/sky/shell/gpu/direct/surface_notifications_direct.h deleted file mode 100644 index d3ac16910..000000000 --- a/sky/shell/gpu/direct/surface_notifications_direct.h +++ /dev/null @@ -1,25 +0,0 @@ -// 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. - -#ifndef SKY_SHELL_GPU_DIRECT_SURFACE_NOTIFICATIONS_DIRECT_H_ -#define SKY_SHELL_GPU_DIRECT_SURFACE_NOTIFICATIONS_DIRECT_H_ - -#include "base/synchronization/waitable_event.h" -#include "sky/shell/platform_view.h" - -namespace sky { -namespace shell { - -class SurfaceNotificationsDirect { - public: - static void NotifyCreated(const PlatformView::Config& config, - gfx::AcceleratedWidget widget, - base::WaitableEvent* did_draw); - static void NotifyDestroyed(const PlatformView::Config& config); -}; - -} // namespace shell -} // namespace sky - -#endif // SKY_SHELL_GPU_DIRECT_SURFACE_NOTIFICATIONS_DIRECT_H_ diff --git a/sky/shell/gpu/mojo/rasterizer_mojo.cc b/sky/shell/gpu/mojo/rasterizer_mojo.cc index c7f66c0c9..5c176a1f6 100644 --- a/sky/shell/gpu/mojo/rasterizer_mojo.cc +++ b/sky/shell/gpu/mojo/rasterizer_mojo.cc @@ -18,7 +18,8 @@ namespace { void DidEcho(void* context) { TRACE_EVENT_ASYNC_END0("flutter", "MGLEcho", context); - Rasterizer::DrawCallback* callback = static_cast(context); + Rasterizer::DrawCallback* callback = + static_cast(context); callback->Run(); delete callback; } @@ -32,24 +33,19 @@ std::unique_ptr Rasterizer::Create() { return std::unique_ptr(new RasterizerMojo()); } -RasterizerMojo::RasterizerMojo() : binding_(this), weak_factory_(this) { -} +RasterizerMojo::RasterizerMojo() : binding_(this), weak_factory_(this) {} RasterizerMojo::~RasterizerMojo() { weak_factory_.InvalidateWeakPtrs(); Shell::Shared().PurgeRasterizers(); } -base::WeakPtr RasterizerMojo::GetWeakPtr() { +base::WeakPtr RasterizerMojo::GetWeakRasterizerPtr() { return weak_factory_.GetWeakPtr(); } -base::WeakPtr RasterizerMojo::GetWeakRasterizerPtr() { - return GetWeakPtr(); -} - -void RasterizerMojo::ConnectToRasterizer ( - mojo::InterfaceRequest request ) { +void RasterizerMojo::ConnectToRasterizer( + mojo::InterfaceRequest request) { binding_.Bind(request.Pass()); Shell::Shared().AddRasterizer(GetWeakRasterizerPtr()); @@ -61,6 +57,17 @@ void RasterizerMojo::Init(mojo::ApplicationConnectorPtr connector, scene_ = scene.Pass(); } +void RasterizerMojo::Setup(PlatformView* platform_view, + base::Closure rasterizer_continuation, + base::WaitableEvent* setup_completion_event) { + rasterizer_continuation.Run(); + setup_completion_event->Signal(); +} + +void RasterizerMojo::Teardown(base::WaitableEvent* teardown_completion_event) { + teardown_completion_event->Signal(); +} + void RasterizerMojo::Draw(uint64_t layer_tree_ptr, const DrawCallback& callback) { TRACE_EVENT0("flutter", "RasterizerMojo::Draw"); @@ -69,7 +76,8 @@ void RasterizerMojo::Draw(uint64_t layer_tree_ptr, reinterpret_cast(layer_tree_ptr)); if (!scene_ || !gl_state_ || gl_state_->gl_context->is_lost()) { - TRACE_EVENT_INSTANT0("flutter", "RasterizerMojo::Draw error one", TRACE_EVENT_SCOPE_THREAD); + TRACE_EVENT_INSTANT0("flutter", "RasterizerMojo::Draw error one", + TRACE_EVENT_SCOPE_THREAD); callback.Run(); return; } @@ -79,7 +87,8 @@ void RasterizerMojo::Draw(uint64_t layer_tree_ptr, size.height = layer_tree->frame_size().height(); if (size.width <= 0 || size.height <= 0.0) { - TRACE_EVENT_INSTANT0("flutter", "RasterizerMojo::Draw empty frame size", TRACE_EVENT_SCOPE_THREAD); + TRACE_EVENT_INSTANT0("flutter", "RasterizerMojo::Draw empty frame size", + TRACE_EVENT_SCOPE_THREAD); callback.Run(); return; } @@ -145,13 +154,11 @@ flow::LayerTree* RasterizerMojo::GetLastLayerTree() { } RasterizerMojo::GLState::GLState(mojo::ApplicationConnector* connector) - : gl_context(mojo::GLContext::CreateOffscreen(connector)), - gl_texture_recycler(gl_context), - ganesh_context(new mojo::skia::GaneshContext(gl_context)) { -} + : gl_context(mojo::GLContext::CreateOffscreen(connector)), + gl_texture_recycler(gl_context), + ganesh_context(new mojo::skia::GaneshContext(gl_context)) {} -RasterizerMojo::GLState::~GLState() { -} +RasterizerMojo::GLState::~GLState() {} } // namespace shell } // namespace sky diff --git a/sky/shell/gpu/mojo/rasterizer_mojo.h b/sky/shell/gpu/mojo/rasterizer_mojo.h index a27e710fe..7107eac4a 100644 --- a/sky/shell/gpu/mojo/rasterizer_mojo.h +++ b/sky/shell/gpu/mojo/rasterizer_mojo.h @@ -19,26 +19,35 @@ namespace shell { class RasterizerMojo : public Rasterizer { public: - explicit RasterizerMojo(); + RasterizerMojo(); + ~RasterizerMojo() override; - base::WeakPtr GetWeakPtr(); - - base::WeakPtr GetWeakRasterizerPtr() override; - - void ConnectToRasterizer( - mojo::InterfaceRequest request) override; - void Init(mojo::ApplicationConnectorPtr connector, mojo::gfx::composition::ScenePtr scene); + // sky::shell::rasterizer::Rasterizer override + void ConnectToRasterizer( + mojo::InterfaceRequest request) override; + + // sky::shell::rasterizer::Rasterizer override + void Setup(PlatformView* platform_view, + base::Closure rasterizer_continuation, + base::WaitableEvent* setup_completion_event) override; + + // sky::shell::rasterizer::Rasterizer override + void Teardown(base::WaitableEvent* teardown_completion_event) override; + + // sky::shell::rasterizer::Rasterizer override + base::WeakPtr GetWeakRasterizerPtr() override; + + // sky::shell::rasterizer::Rasterizer override flow::LayerTree* GetLastLayerTree() override; private: - void Draw(uint64_t layer_tree_ptr, const DrawCallback& callback) override; - struct GLState { explicit GLState(mojo::ApplicationConnector* connector); + ~GLState(); scoped_refptr gl_context; @@ -51,9 +60,10 @@ class RasterizerMojo : public Rasterizer { std::unique_ptr gl_state_; flow::CompositorContext compositor_context_; std::unique_ptr last_layer_tree_; - base::WeakPtrFactory weak_factory_; + void Draw(uint64_t layer_tree_ptr, const DrawCallback& callback) override; + DISALLOW_COPY_AND_ASSIGN(RasterizerMojo); }; diff --git a/sky/shell/gpu/picture_serializer.cc b/sky/shell/gpu/picture_serializer.cc index 0f20e8bef..4706f5771 100644 --- a/sky/shell/gpu/picture_serializer.cc +++ b/sky/shell/gpu/picture_serializer.cc @@ -4,12 +4,11 @@ #include "sky/shell/gpu/picture_serializer.h" -#include #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkData.h" +#include "third_party/skia/include/core/SkImageEncoder.h" #include "third_party/skia/include/core/SkPixelSerializer.h" #include "third_party/skia/include/core/SkStream.h" -#include "ui/gfx/codec/png_codec.h" namespace sky { @@ -18,15 +17,15 @@ bool PngPixelSerializer::onUseEncodedData(const void*, size_t) { } SkData* PngPixelSerializer::onEncode(const SkPixmap& pixmap) { - std::vector data; + SkBitmap bitmap; - SkBitmap bm; - if (!bm.installPixels(pixmap)) + if (!bitmap.installPixels(pixmap)) { return nullptr; - if (!gfx::PNGCodec::EncodeBGRASkBitmap(bm, false, &data)) - return nullptr; - return SkData::NewWithCopy(&data.front(), data.size()); -}; + } + + return SkImageEncoder::EncodeData(bitmap, SkImageEncoder::Type::kPNG_Type, + SkImageEncoder::kDefaultQuality); +} void SerializePicture(const base::FilePath& file_name, SkPicture* picture) { SkFILEWStream stream(file_name.AsUTF8Unsafe().c_str()); diff --git a/sky/shell/platform/android/flutter_main.cc b/sky/shell/platform/android/flutter_main.cc index 942f9d03a..ad8dec098 100644 --- a/sky/shell/platform/android/flutter_main.cc +++ b/sky/shell/platform/android/flutter_main.cc @@ -23,7 +23,6 @@ #include "mojo/edk/embedder/simple_platform_support.h" #include "sky/shell/shell.h" #include "sky/engine/core/start_up.h" -#include "ui/gl/gl_surface.h" #include "dart/runtime/include/dart_tools_api.h" using base::LazyInstance; @@ -80,7 +79,6 @@ static void Init(JNIEnv* env, mojo::embedder::Init(mojo::embedder::CreateSimplePlatformSupport()); - CHECK(gfx::GLSurface::InitializeOneOff()); Shell::InitStandalone(); InitializeTracing(); diff --git a/sky/shell/platform/android/platform_view_android.cc b/sky/shell/platform/android/platform_view_android.cc index 06d52e55f..47cb5a7fa 100644 --- a/sky/shell/platform/android/platform_view_android.cc +++ b/sky/shell/platform/android/platform_view_android.cc @@ -4,28 +4,244 @@ #include "sky/shell/platform/android/platform_view_android.h" +#include + #include #include -#include "base/android/jni_android.h" +#include + #include "base/bind.h" #include "base/location.h" #include "jni/FlutterView_jni.h" #include "sky/engine/core/script/dart_service_isolate.h" -#include "sky/shell/gpu/direct/surface_notifications_direct.h" +#include "sky/engine/wtf/MakeUnique.h" #include "sky/shell/shell.h" #include "sky/shell/shell_view.h" namespace sky { namespace shell { +class AndroidNativeWindow { + public: + using Handle = ANativeWindow*; + + explicit AndroidNativeWindow(Handle window) : window_(window) { + if (window_ != nullptr) { + ANativeWindow_acquire(window_); + } + } + + ~AndroidNativeWindow() { + if (window_ != nullptr) { + ANativeWindow_release(window_); + window_ = nullptr; + } + } + + bool IsValid() const { return window_ != nullptr; } + + Handle handle() const { return window_; } + + private: + Handle window_; + + DISALLOW_COPY_AND_ASSIGN(AndroidNativeWindow); +}; + +class AndroidGLContext { + public: + explicit AndroidGLContext(AndroidNativeWindow::Handle window_handle, + PlatformView::SurfaceConfig config) + : window_(window_handle), + display_(EGL_NO_DISPLAY), + config_(nullptr), + surface_(EGL_NO_SURFACE), + context_(EGL_NO_CONTEXT), + valid_(false) { + if (!window_.IsValid()) { + // We always require a valid window since we are only going to deal + // with window surfaces. + return; + } + + bool success = false; + + // Setup the display connection. + + std::tie(success, display_) = SetupDisplayConnection(); + + if (!success) { + return; + } + + // Choose a valid configuration. + + std::tie(success, config_) = ChooseWindowConfiguration(display_, config); + + if (!success) { + return; + } + + // Create a window surface for the configuration. + + std::tie(success, surface_) = + CreateWindowSurface(display_, config_, window_.handle()); + + if (!success) { + return; + } + + // Create a context for the configuration. + + std::tie(success, context_) = CreateContext(display_, config_); + + if (!success) { + return; + } + + // All done! + valid_ = true; + } + + ~AndroidGLContext() { + if (!TeardownContext(display_, context_)) { + LOG(INFO) + << "Could not tear down the EGL context. Possible resource leak."; + } + + if (!TeardownSurface(display_, surface_)) { + LOG(INFO) + << "Could not tear down the EGL surface. Possible resource leak."; + } + + if (!TeardownDisplayConnection(display_)) { + LOG(INFO) << "Could not tear down the EGL display connection. Possible " + "resource leak."; + } + } + + bool IsValid() const { return valid_; } + + bool ContextMakeCurrent() { + return eglMakeCurrent(display_, surface_, surface_, context_) == EGL_TRUE; + } + + bool SwapBuffers() { return eglSwapBuffers(display_, surface_); } + + private: + AndroidNativeWindow window_; + EGLDisplay display_; + EGLConfig config_; + EGLSurface surface_; + EGLContext context_; + + bool valid_; + + template + using EGLResult = std::pair; + + static EGLResult SetupDisplayConnection() { + // Get the display. + EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + + if (display == EGL_NO_DISPLAY) { + return {false, EGL_NO_DISPLAY}; + } + + // Initialize the display connection. + if (eglInitialize(display, nullptr, nullptr) != EGL_TRUE) { + return {false, EGL_NO_DISPLAY}; + } + + return {true, display}; + } + + static bool TeardownDisplayConnection(EGLDisplay display) { + if (display != EGL_NO_DISPLAY) { + return eglTerminate(display) == EGL_TRUE; + } + + return true; + } + + static bool TeardownContext(EGLDisplay display, EGLContext context) { + if (context != EGL_NO_CONTEXT) { + return eglDestroyContext(display, context) == EGL_TRUE; + } + + return true; + } + + static bool TeardownSurface(EGLDisplay display, EGLSurface surface) { + if (surface != EGL_NO_SURFACE) { + return eglDestroySurface(display, surface) == EGL_TRUE; + } + + return true; + } + + static EGLResult ChooseWindowConfiguration( + EGLDisplay display, + PlatformView::SurfaceConfig config) { + EGLint attributes[] = { + // clang-format off + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_RED_SIZE, config.red_bits, + EGL_GREEN_SIZE, config.green_bits, + EGL_BLUE_SIZE, config.blue_bits, + EGL_ALPHA_SIZE, config.alpha_bits, + EGL_DEPTH_SIZE, config.depth_bits, + EGL_STENCIL_SIZE, config.stencil_bits, + EGL_NONE, // termination sentinel + // clang-format on + }; + + EGLint config_count = 0; + EGLConfig egl_config = nullptr; + + if (eglChooseConfig(display, attributes, &egl_config, 1, &config_count) != + EGL_TRUE) { + return {false, nullptr}; + } + + bool success = config_count > 0 && egl_config != nullptr; + + return {success, success ? egl_config : nullptr}; + } + + static EGLResult CreateWindowSurface( + EGLDisplay display, + EGLConfig config, + AndroidNativeWindow::Handle window_handle) { + // The configurations are only required when dealing with extensions or VG. + // We do neither. + EGLSurface surface = eglCreateWindowSurface( + display, config, reinterpret_cast(window_handle), + nullptr); + return {surface != EGL_NO_SURFACE, surface}; + } + + static EGLResult CreateContext(EGLDisplay display, + EGLConfig config) { + EGLint attributes[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; + + EGLContext context = + eglCreateContext(display, config, EGL_NO_CONTEXT, attributes); + + return {context != EGL_NO_CONTEXT, context}; + } + + DISALLOW_COPY_AND_ASSIGN(AndroidGLContext); +}; + static jlong Attach(JNIEnv* env, jclass clazz, jint skyEngineHandle) { ShellView* shell_view = new ShellView(Shell::Shared()); auto view = static_cast(shell_view->view()); view->SetShellView(std::unique_ptr(shell_view)); - view->ConnectToEngine( - mojo::InterfaceRequest(mojo::ScopedMessagePipeHandle( - mojo::MessagePipeHandle(skyEngineHandle)))); + view->ConnectToEngine(mojo::InterfaceRequest( + mojo::ScopedMessagePipeHandle(mojo::MessagePipeHandle(skyEngineHandle)))); return reinterpret_cast(shell_view->view()); } @@ -38,17 +254,21 @@ bool PlatformViewAndroid::Register(JNIEnv* env) { return RegisterNativesImpl(env); } -PlatformView* PlatformView::Create(const Config& config) { - return new PlatformViewAndroid(config); +// Per platform implementation of PlatformView::Create +PlatformView* PlatformView::Create(const Config& config, + SurfaceConfig surface_config) { + return new PlatformViewAndroid(config, surface_config); } -PlatformViewAndroid::PlatformViewAndroid(const Config& config) - : PlatformView(config), window_(nullptr), did_draw_(false, false) { -} +PlatformViewAndroid::PlatformViewAndroid(const Config& config, + SurfaceConfig surface_config) + : PlatformView(config, surface_config), weak_factory_(this) {} -PlatformViewAndroid::~PlatformViewAndroid() { - if (window_) - ReleaseWindow(); +PlatformViewAndroid::~PlatformViewAndroid() = default; + +void PlatformViewAndroid::SetShellView(std::unique_ptr shell_view) { + DCHECK(!shell_view_); + shell_view_ = std::move(shell_view); } void PlatformViewAndroid::Detach(JNIEnv* env, jobject obj) { @@ -56,33 +276,46 @@ void PlatformViewAndroid::Detach(JNIEnv* env, jobject obj) { // Note: |this| has been destroyed at this point. } -void PlatformViewAndroid::SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface) { +void PlatformViewAndroid::SurfaceCreated(JNIEnv* env, + jobject obj, + jobject jsurface) { base::android::ScopedJavaLocalRef protector(env, jsurface); // Note: This ensures that any local references used by // ANativeWindow_fromSurface are released immediately. This is needed as a // workaround for https://code.google.com/p/android/issues/detail?id=68174 { base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); - window_ = ANativeWindow_fromSurface(env, jsurface); + ANativeWindow* window = ANativeWindow_fromSurface(env, jsurface); + auto context = WTF::MakeUnique(window, surface_config_); + if (context->IsValid()) { + context_ = std::move(context); + } + ANativeWindow_release(window); } - SurfaceNotificationsDirect::NotifyCreated(config_, window_, &did_draw_); - did_draw_.Wait(); + + NotifyCreated(); } void PlatformViewAndroid::SurfaceDestroyed(JNIEnv* env, jobject obj) { - DCHECK(window_); - SurfaceNotificationsDirect::NotifyDestroyed(config_); - ReleaseWindow(); + NotifyDestroyed(); + context_ = nullptr; } -void PlatformViewAndroid::SetShellView(std::unique_ptr shell_view) { - DCHECK(!shell_view_); - shell_view_ = std::move(shell_view); +base::WeakPtr PlatformViewAndroid::GetWeakViewPtr() { + return weak_factory_.GetWeakPtr(); } -void PlatformViewAndroid::ReleaseWindow() { - ANativeWindow_release(window_); - window_ = nullptr; +uint64_t PlatformViewAndroid::DefaultFramebuffer() const { + // FBO 0 is the default window bound framebuffer on Android. + return 0; +} + +bool PlatformViewAndroid::ContextMakeCurrent() { + return context_ != nullptr ? context_->ContextMakeCurrent() : false; +} + +bool PlatformViewAndroid::SwapBuffers() { + return context_ != nullptr ? context_->SwapBuffers() : false; } } // namespace shell diff --git a/sky/shell/platform/android/platform_view_android.h b/sky/shell/platform/android/platform_view_android.h index ec6c046c9..51f02b332 100644 --- a/sky/shell/platform/android/platform_view_android.h +++ b/sky/shell/platform/android/platform_view_android.h @@ -5,39 +5,57 @@ #ifndef SKY_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_H_ #define SKY_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_H_ +#include "base/macros.h" +#include "base/android/jni_android.h" #include "base/synchronization/waitable_event.h" #include "sky/shell/platform_view.h" -struct ANativeWindow; - namespace sky { namespace shell { + class ShellView; +class AndroidGLContext; class PlatformViewAndroid : public PlatformView { public: static bool Register(JNIEnv* env); - PlatformViewAndroid(const Config& config); + explicit PlatformViewAndroid(const Config& config, + SurfaceConfig sufrace_config); + ~PlatformViewAndroid() override; // Called from Java void Detach(JNIEnv* env, jobject obj); + + // Called from Java void SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface); + + // Called from Java void SurfaceDestroyed(JNIEnv* env, jobject obj); void SetShellView(std::unique_ptr shell_view); - private: - void ReleaseWindow(); + // sky::shell::PlatformView override + base::WeakPtr GetWeakViewPtr() override; + // sky::shell::PlatformView override + uint64_t DefaultFramebuffer() const override; + + // sky::shell::PlatformView override + bool ContextMakeCurrent() override; + + // sky::shell::PlatformView override + bool SwapBuffers() override; + + private: // In principle, the ShellView should own the PlatformView, but because our // lifetime is controlled by the Android view hierarchy, we flip around the // ownership and have the shell_view owned by Java. We reset this pointer in // |Detach|, which will eventually cause |~PlatformViewAndroid|. std::unique_ptr shell_view_; - gfx::AcceleratedWidget window_; - base::WaitableEvent did_draw_; + std::unique_ptr context_; + base::WeakPtrFactory weak_factory_; DISALLOW_COPY_AND_ASSIGN(PlatformViewAndroid); }; diff --git a/sky/shell/platform/ios/.gitignore b/sky/shell/platform/ios/.gitignore deleted file mode 100644 index 01a36b1b7..000000000 --- a/sky/shell/platform/ios/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.pbxproj -*.xcworkspace -*.xcodeproj diff --git a/sky/shell/platform/ios/Entitlements.xcent b/sky/shell/platform/ios/Entitlements.xcent deleted file mode 100644 index c99e8b705..000000000 --- a/sky/shell/platform/ios/Entitlements.xcent +++ /dev/null @@ -1,12 +0,0 @@ - - - - - application-identifier - EQHXZ8M8AV.com.google.sky - com.apple.developer.team-identifier - EQHXZ8M8AV - get-task-allow - - - diff --git a/sky/shell/platform/ios/framework/Source/FlutterViewController.mm b/sky/shell/platform/ios/framework/Source/FlutterViewController.mm index 9a56b3350..6b4897212 100644 --- a/sky/shell/platform/ios/framework/Source/FlutterViewController.mm +++ b/sky/shell/platform/ios/framework/Source/FlutterViewController.mm @@ -24,9 +24,9 @@ #include "sky/shell/platform/ios/framework/Source/FlutterDartProject_Internal.h" #include "sky/shell/platform/ios/framework/Source/FlutterDynamicServiceLoader.h" #include "sky/shell/platform/ios/framework/Source/FlutterView.h" +#include "sky/shell/platform/ios/platform_view_ios.h" #include "sky/shell/platform/mac/platform_mac.h" #include "sky/shell/platform/mac/platform_service_provider.h" -#include "sky/shell/platform/mac/platform_view_mac.h" #include "sky/shell/platform/mac/view_service_provider.h" #include "sky/shell/platform_view.h" #include "sky/shell/shell.h" @@ -461,16 +461,15 @@ static inline PointerTypeMapperPhase PointerTypePhaseFromUITouchPhase( #pragma mark - Surface creation and teardown updates - (void)surfaceUpdated:(BOOL)appeared { - auto view = - reinterpret_cast(_shellView->view()); - - // The widget is a reference to the CALayer (EAGL) of the view. - auto widget = reinterpret_cast(self.view.layer); + auto platform_view = + reinterpret_cast(_shellView->view()); if (appeared) { - view->SurfaceCreated(widget); + auto layer = reinterpret_cast(self.view.layer); + platform_view->SetEAGLLayer(layer); + platform_view->NotifyCreated(); } else { - view->SurfaceDestroyed(); + platform_view->NotifyDestroyed(); } } diff --git a/sky/shell/platform/ios/platform_view_ios.h b/sky/shell/platform/ios/platform_view_ios.h new file mode 100644 index 000000000..0836fb367 --- /dev/null +++ b/sky/shell/platform/ios/platform_view_ios.h @@ -0,0 +1,48 @@ +// Copyright 2016 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 SKY_SHELL_PLATFORM_IOS_PLATFORM_VIEW_IOS_H_ +#define SKY_SHELL_PLATFORM_IOS_PLATFORM_VIEW_IOS_H_ + +#include + +#include "base/macros.h" +#include "base/mac/scoped_nsobject.h" +#include "base/memory/weak_ptr.h" +#include "sky/shell/platform_view.h" + +@class CAEAGLLayer; + +namespace sky { +namespace shell { + +class IOSGLContext; + +class PlatformViewIOS : public PlatformView { + public: + explicit PlatformViewIOS(const Config& config, SurfaceConfig surface_config); + + ~PlatformViewIOS() override; + + void SetEAGLLayer(CAEAGLLayer* layer); + + base::WeakPtr GetWeakViewPtr() override; + + uint64_t DefaultFramebuffer() const override; + + bool ContextMakeCurrent() override; + + bool SwapBuffers() override; + + private: + std::unique_ptr context_; + base::WeakPtrFactory weak_factory_; + + DISALLOW_COPY_AND_ASSIGN(PlatformViewIOS); +}; + +} // namespace shell +} // namespace sky + +#endif // SKY_SHELL_PLATFORM_IOS_PLATFORM_VIEW_IOS_H_ diff --git a/sky/shell/platform/ios/platform_view_ios.mm b/sky/shell/platform/ios/platform_view_ios.mm new file mode 100644 index 000000000..c49638d2e --- /dev/null +++ b/sky/shell/platform/ios/platform_view_ios.mm @@ -0,0 +1,291 @@ +// Copyright 2016 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/mac/scoped_nsautorelease_pool.h" +#include "sky/engine/wtf/MakeUnique.h" +#include "sky/shell/platform/ios/platform_view_ios.h" + +#import +#import +#import +#import + +namespace sky { +namespace shell { + +struct GLintSize { + GLint width; + GLint height; + + GLintSize() : width(0), height(0) {} + + GLintSize(GLint w, GLint h) : width(w), height(h) {} + + GLintSize(CGSize size) + : width(static_cast(size.width)), + height(static_cast(size.height)) {} + + bool operator==(const GLintSize& other) const { + return width == other.width && height == other.height; + } +}; + +class IOSGLContext { + public: + IOSGLContext(PlatformView::SurfaceConfig config, CAEAGLLayer* layer) + : layer_(layer), + context_([[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]), + framebuffer_(GL_NONE), + colorbuffer_(GL_NONE), + depthbuffer_(GL_NONE), + stencilbuffer_(GL_NONE), + depth_stencil_packed_buffer_(GL_NONE) { + base::mac::ScopedNSAutoreleasePool pool; + + CHECK(layer_ != nullptr); + CHECK(context_ != nullptr); + + bool context_current = [EAGLContext setCurrentContext:context_]; + + DCHECK(context_current); + DCHECK(glGetError() == GL_NO_ERROR); + + // Generate the framebuffer + + glGenFramebuffers(1, &framebuffer_); + DCHECK(glGetError() == GL_NO_ERROR); + DCHECK(framebuffer_ != GL_NONE); + + glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_); + DCHECK(glGetError() == GL_NO_ERROR); + + // Setup color attachment + + glGenRenderbuffers(1, &colorbuffer_); + DCHECK(colorbuffer_ != GL_NONE); + + glBindRenderbuffer(GL_RENDERBUFFER, colorbuffer_); + DCHECK(glGetError() == GL_NO_ERROR); + + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_RENDERBUFFER, colorbuffer_); + DCHECK(glGetError() == GL_NO_ERROR); + + // On iOS, if both depth and stencil attachments are requested, we are + // required to create a single renderbuffer that acts as both. + + auto requires_packed = + (config.depth_bits != 0) && (config.stencil_bits != 0); + + if (requires_packed) { + glGenRenderbuffers(1, &depth_stencil_packed_buffer_); + glBindRenderbuffer(GL_RENDERBUFFER, depth_stencil_packed_buffer_); + DCHECK(depth_stencil_packed_buffer_ != GL_NONE); + + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, + GL_RENDERBUFFER, depth_stencil_packed_buffer_); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, + GL_RENDERBUFFER, depth_stencil_packed_buffer_); + DCHECK(depth_stencil_packed_buffer_ != GL_NONE); + } else { + // Setup the depth attachment if necessary + if (config.depth_bits != 0) { + glGenRenderbuffers(1, &depthbuffer_); + DCHECK(depthbuffer_ != GL_NONE); + + glBindRenderbuffer(GL_RENDERBUFFER, depthbuffer_); + DCHECK(glGetError() == GL_NO_ERROR); + + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, + GL_RENDERBUFFER, depthbuffer_); + DCHECK(glGetError() == GL_NO_ERROR); + } + + // Setup the stencil attachment if necessary + if (config.stencil_bits != 0) { + glGenRenderbuffers(1, &stencilbuffer_); + DCHECK(stencilbuffer_ != GL_NONE); + + glBindRenderbuffer(GL_RENDERBUFFER, stencilbuffer_); + DCHECK(glGetError() == GL_NO_ERROR); + + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, + GL_RENDERBUFFER, stencilbuffer_); + DCHECK(glGetError() == GL_NO_ERROR); + } + } + + // The default is RGBA + NSString* drawableColorFormat = kEAGLColorFormatRGBA8; + + if (config.red_bits <= 5 && config.green_bits <= 6 && + config.blue_bits <= 5 && config.alpha_bits == 0) { + drawableColorFormat = kEAGLColorFormatRGB565; + } + + layer_.get().drawableProperties = @{ + kEAGLDrawablePropertyColorFormat : drawableColorFormat, + kEAGLDrawablePropertyRetainedBacking : @(NO), + }; + } + + ~IOSGLContext() { + DCHECK(glGetError() == GL_NO_ERROR); + + // Deletes on GL_NONEs are ignored + glDeleteFramebuffers(1, &framebuffer_); + + glDeleteRenderbuffers(1, &colorbuffer_); + glDeleteRenderbuffers(1, &depthbuffer_); + glDeleteRenderbuffers(1, &stencilbuffer_); + glDeleteRenderbuffers(1, &depth_stencil_packed_buffer_); + + DCHECK(glGetError() == GL_NO_ERROR); + } + + bool PresentRenderBuffer() const { + base::mac::ScopedNSAutoreleasePool pool; + + const GLenum discards[] = { + GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT, + }; + + glDiscardFramebufferEXT(GL_FRAMEBUFFER, sizeof(discards) / sizeof(GLenum), + discards); + + glBindRenderbuffer(GL_RENDERBUFFER, colorbuffer_); + return [[EAGLContext currentContext] presentRenderbuffer:GL_RENDERBUFFER]; + } + + GLuint framebuffer() const { return framebuffer_; } + + bool MakeCurrent() { + base::mac::ScopedNSAutoreleasePool pool; + + return UpdateStorageSizeIfNecessary() && + [EAGLContext setCurrentContext:context_.get()]; + } + + private: + base::scoped_nsobject layer_; + base::scoped_nsobject context_; + + GLuint framebuffer_; + GLuint colorbuffer_; + GLuint depthbuffer_; + GLuint stencilbuffer_; + GLuint depth_stencil_packed_buffer_; + + GLintSize storage_size_; + + bool UpdateStorageSizeIfNecessary() { + GLintSize size([layer_.get() bounds].size); + + if (size == storage_size_) { + // Nothing to since the stoage size is already consistent with the layer. + return true; + } + + if (![EAGLContext setCurrentContext:context_]) { + return false; + } + + DCHECK(glGetError() == GL_NO_ERROR); + + glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_); + + glBindRenderbuffer(GL_RENDERBUFFER, colorbuffer_); + DCHECK(glGetError() == GL_NO_ERROR); + + if (![context_.get() renderbufferStorage:GL_RENDERBUFFER + fromDrawable:layer_.get()]) { + return false; + } + + GLint width = 0; + GLint height = 0; + bool rebind_color_buffer = false; + + if (depthbuffer_ != GL_NONE || stencilbuffer_ != GL_NONE || + depth_stencil_packed_buffer_ != GL_NONE) { + // Fetch the dimensions of the color buffer whose backing was just updated + // so that backing of the attachments can be updated + glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, + &width); + DCHECK(glGetError() == GL_NO_ERROR); + + glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, + &height); + DCHECK(glGetError() == GL_NO_ERROR); + + rebind_color_buffer = true; + } + + if (depth_stencil_packed_buffer_ != GL_NONE) { + glBindRenderbuffer(GL_RENDERBUFFER, depth_stencil_packed_buffer_); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, width, + height); + DCHECK(glGetError() == GL_NO_ERROR); + } + + if (depthbuffer_ != GL_NONE) { + glBindRenderbuffer(GL_RENDERBUFFER, depthbuffer_); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, + height); + DCHECK(glGetError() == GL_NO_ERROR); + } + + if (stencilbuffer_ != GL_NONE) { + glBindRenderbuffer(GL_RENDERBUFFER, stencilbuffer_); + glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, width, height); + DCHECK(glGetError() == GL_NO_ERROR); + } + + if (rebind_color_buffer) { + glBindRenderbuffer(GL_RENDERBUFFER, colorbuffer_); + DCHECK(glGetError() == GL_NO_ERROR); + } + + storage_size_ = GLintSize(width, height); + DCHECK(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE); + + return true; + } + + DISALLOW_COPY_AND_ASSIGN(IOSGLContext); +}; + +PlatformView* PlatformView::Create(const Config& config, + SurfaceConfig surface_config) { + return new PlatformViewIOS(config, surface_config); +} + +PlatformViewIOS::PlatformViewIOS(const Config& config, + SurfaceConfig surface_config) + : PlatformView(config, surface_config), weak_factory_(this) {} + +PlatformViewIOS::~PlatformViewIOS() = default; + +void PlatformViewIOS::SetEAGLLayer(CAEAGLLayer* layer) { + context_ = WTF::MakeUnique(surface_config_, layer); +} + +base::WeakPtr PlatformViewIOS::GetWeakViewPtr() { + return weak_factory_.GetWeakPtr(); +} + +uint64_t PlatformViewIOS::DefaultFramebuffer() const { + return context_ != nullptr ? context_->framebuffer() : GL_NONE; +} + +bool PlatformViewIOS::ContextMakeCurrent() { + return context_ != nullptr ? context_->MakeCurrent() : false; +} + +bool PlatformViewIOS::SwapBuffers() { + return context_ != nullptr ? context_->PresentRenderBuffer() : false; +} + +} // namespace shell +} // namespace sky diff --git a/sky/shell/platform/mac/platform_mac.mm b/sky/shell/platform/mac/platform_mac.mm index 6aef28ead..31f99982c 100644 --- a/sky/shell/platform/mac/platform_mac.mm +++ b/sky/shell/platform/mac/platform_mac.mm @@ -24,7 +24,6 @@ #include "sky/shell/switches.h" #include "sky/shell/tracing_controller.h" #include "sky/shell/ui_delegate.h" -#include "ui/gl/gl_surface.h" namespace sky { namespace shell { @@ -95,8 +94,6 @@ class EmbedderState { mojo::embedder::Init(mojo::embedder::CreateSimplePlatformSupport()); - CHECK(gfx::GLSurface::InitializeOneOff()); - sky::shell::Shell::InitStandalone(icu_data_path); } diff --git a/sky/shell/platform/mac/platform_view_mac.h b/sky/shell/platform/mac/platform_view_mac.h index 05e4dfb03..de191178b 100644 --- a/sky/shell/platform/mac/platform_view_mac.h +++ b/sky/shell/platform/mac/platform_view_mac.h @@ -2,23 +2,39 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_VIEW_MAC_H_ -#define SKY_SHELL_PLATFORM_VIEW_MAC_H_ +#ifndef SKY_SHELL_PLATFORM_MAC_PLATFORM_VIEW_MAC_H_ +#define SKY_SHELL_PLATFORM_MAC_PLATFORM_VIEW_MAC_H_ +#include "base/memory/weak_ptr.h" #include "sky/shell/platform_view.h" +#include "base/mac/scoped_nsobject.h" + +@class NSOpenGLView; namespace sky { namespace shell { class PlatformViewMac : public PlatformView { public: - explicit PlatformViewMac(const Config& config); + explicit PlatformViewMac(const Config& config, SurfaceConfig surface_config); + ~PlatformViewMac() override; - void SurfaceCreated(gfx::AcceleratedWidget widget); - void SurfaceDestroyed(void); + + void SetOpenGLView(NSOpenGLView* view); + + base::WeakPtr GetWeakViewPtr() override; + + uint64_t DefaultFramebuffer() const override; + + bool ContextMakeCurrent() override; + + bool SwapBuffers() override; private: - gfx::AcceleratedWidget window_; + base::scoped_nsobject opengl_view_; + base::WeakPtrFactory weak_factory_; + + bool IsValid() const; DISALLOW_COPY_AND_ASSIGN(PlatformViewMac); }; @@ -26,4 +42,4 @@ class PlatformViewMac : public PlatformView { } // namespace shell } // namespace sky -#endif // SKY_SHELL_PLATFORM_VIEW_MAC_H_ +#endif // SKY_SHELL_PLATFORM_MAC_PLATFORM_VIEW_MAC_H_ diff --git a/sky/shell/platform/mac/platform_view_mac.mm b/sky/shell/platform/mac/platform_view_mac.mm index 97229b4ce..8075e2692 100644 --- a/sky/shell/platform/mac/platform_view_mac.mm +++ b/sky/shell/platform/mac/platform_view_mac.mm @@ -4,30 +4,64 @@ #include "sky/shell/platform/mac/platform_view_mac.h" -#include "sky/shell/gpu/direct/surface_notifications_direct.h" +#include namespace sky { namespace shell { -PlatformView* PlatformView::Create(const Config& config) { - return new PlatformViewMac(config); +PlatformView* PlatformView::Create(const Config& config, + SurfaceConfig surface_config) { + return new PlatformViewMac(config, surface_config); } -PlatformViewMac::PlatformViewMac(const Config& config) - : PlatformView(config), window_(gfx::kNullAcceleratedWidget) {} +PlatformViewMac::PlatformViewMac(const Config& config, + SurfaceConfig surface_config) + : PlatformView(config, surface_config), weak_factory_(this) {} -PlatformViewMac::~PlatformViewMac() {} +PlatformViewMac::~PlatformViewMac() = default; -void PlatformViewMac::SurfaceCreated(gfx::AcceleratedWidget widget) { - DCHECK(window_ == gfx::kNullAcceleratedWidget); - window_ = widget; - SurfaceNotificationsDirect::NotifyCreated(config_, window_, nullptr); +base::WeakPtr PlatformViewMac::GetWeakViewPtr() { + return weak_factory_.GetWeakPtr(); } -void PlatformViewMac::SurfaceDestroyed() { - DCHECK(window_ != gfx::kNullAcceleratedWidget); - window_ = gfx::kNullAcceleratedWidget; - SurfaceNotificationsDirect::NotifyDestroyed(config_); +void PlatformViewMac::SetOpenGLView(NSOpenGLView* view) { + opengl_view_ = decltype(opengl_view_){view}; +} + +uint64_t PlatformViewMac::DefaultFramebuffer() const { + return 0; +} + +bool PlatformViewMac::ContextMakeCurrent() { + if (!IsValid()) { + return false; + } + + [opengl_view_.get().openGLContext makeCurrentContext]; + return true; +} + +bool PlatformViewMac::SwapBuffers() { + if (!IsValid()) { + return false; + } + + [opengl_view_.get().openGLContext flushBuffer]; + return true; +} + +bool PlatformViewMac::IsValid() const { + if (opengl_view_ == nullptr) { + return false; + } + + auto context = opengl_view_.get().openGLContext; + + if (context == nullptr) { + return false; + } + + return true; } } // namespace shell diff --git a/sky/shell/platform/mac/sky_window.mm b/sky/shell/platform/mac/sky_window.mm index 91191976b..ba58c04eb 100644 --- a/sky/shell/platform/mac/sky_window.mm +++ b/sky/shell/platform/mac/sky_window.mm @@ -70,8 +70,10 @@ static inline pointer::PointerType EventTypeFromNSEventPhase( auto shell_view = new sky::shell::ShellView(sky::shell::Shell::Shared()); _shell_view.reset(shell_view); - auto widget = reinterpret_cast(self.renderSurface); - self.platformView->SurfaceCreated(widget); + auto platformViewMac = self.platformView; + + platformViewMac->SetOpenGLView(self.renderSurface); + platformViewMac->NotifyCreated(); } // TODO(eseidel): This does not belong in sky_window! @@ -200,7 +202,7 @@ static inline pointer::PointerType EventTypeFromNSEventPhase( } - (void)dealloc { - self.platformView->SurfaceDestroyed(); + self.platformView->NotifyDestroyed(); [super dealloc]; } diff --git a/sky/shell/platform/mojo/BUILD.gn b/sky/shell/platform/mojo/BUILD.gn index 332873c74..d23240822 100644 --- a/sky/shell/platform/mojo/BUILD.gn +++ b/sky/shell/platform/mojo/BUILD.gn @@ -27,7 +27,6 @@ mojo_native_application("mojo") { "//mojo/application", "//mojo/common:tracing_impl", "//mojo/common", - "//mojo/converters/geometry", "//mojo/public/cpp/bindings", "//mojo/public/cpp/system", "//mojo/public/cpp/utility", diff --git a/sky/shell/platform/mojo/platform_view_mojo.cc b/sky/shell/platform/mojo/platform_view_mojo.cc index 6c6040cdf..48e2b1643 100644 --- a/sky/shell/platform/mojo/platform_view_mojo.cc +++ b/sky/shell/platform/mojo/platform_view_mojo.cc @@ -12,27 +12,41 @@ namespace sky { namespace shell { -PlatformView* PlatformView::Create(const Config& config) { - return new PlatformViewMojo(config); +PlatformView* PlatformView::Create(const Config& config, + SurfaceConfig surface_config) { + return new PlatformViewMojo(config, surface_config); } -PlatformViewMojo::PlatformViewMojo(const Config& config) - : PlatformView(config) { -} +PlatformViewMojo::PlatformViewMojo(const Config& config, + SurfaceConfig surface_config) + : PlatformView(config, surface_config), weak_factory_(this) {} -PlatformViewMojo::~PlatformViewMojo() { -} +PlatformViewMojo::~PlatformViewMojo() {} void PlatformViewMojo::InitRasterizer(mojo::ApplicationConnectorPtr connector, mojo::gfx::composition::ScenePtr scene) { - RasterizerMojo* rasterizer = static_cast(config_.rasterizer); - config_.ui_task_runner->PostTask(FROM_HERE, base::Bind( - &UIDelegate::OnOutputSurfaceCreated, - config_.ui_delegate, - base::Bind(&RasterizerMojo::Init, - rasterizer->GetWeakPtr(), - base::Passed(&connector), - base::Passed(&scene)))); + auto rasterizer_mojo = reinterpret_cast(config_.rasterizer); + auto continuation = + base::Bind(&RasterizerMojo::Init, // method + base::Unretained(rasterizer_mojo), // target + base::Passed(&connector), base::Passed(&scene)); + NotifyCreated(continuation); +} + +base::WeakPtr PlatformViewMojo::GetWeakViewPtr() { + return weak_factory_.GetWeakPtr(); +} + +uint64_t PlatformViewMojo::DefaultFramebuffer() const { + return 0; +} + +bool PlatformViewMojo::ContextMakeCurrent() { + return false; +} + +bool PlatformViewMojo::SwapBuffers() { + return false; } } // namespace shell diff --git a/sky/shell/platform/mojo/platform_view_mojo.h b/sky/shell/platform/mojo/platform_view_mojo.h index 7706aed61..faf22f808 100644 --- a/sky/shell/platform/mojo/platform_view_mojo.h +++ b/sky/shell/platform/mojo/platform_view_mojo.h @@ -5,22 +5,40 @@ #ifndef SKY_SHELL_PLATFORM_MOJO_PLATFORM_VIEW_MOJO_H_ #define SKY_SHELL_PLATFORM_MOJO_PLATFORM_VIEW_MOJO_H_ +#include "base/macros.h" #include "mojo/public/interfaces/application/application_connector.mojom.h" #include "mojo/services/gfx/composition/interfaces/scenes.mojom.h" #include "sky/shell/platform_view.h" +#include + namespace sky { namespace shell { class PlatformViewMojo : public PlatformView { public: - explicit PlatformViewMojo(const Config& config); + explicit PlatformViewMojo(const Config& config, SurfaceConfig surface_config); + ~PlatformViewMojo() override; void InitRasterizer(mojo::ApplicationConnectorPtr connector, mojo::gfx::composition::ScenePtr scene); + // sky::shell::PlatformView override + base::WeakPtr GetWeakViewPtr() override; + + // sky::shell::PlatformView override + uint64_t DefaultFramebuffer() const override; + + // sky::shell::PlatformView override + bool ContextMakeCurrent() override; + + // sky::shell::PlatformView override + bool SwapBuffers() override; + private: + base::WeakPtrFactory weak_factory_; + DISALLOW_COPY_AND_ASSIGN(PlatformViewMojo); }; diff --git a/sky/shell/platform_view.cc b/sky/shell/platform_view.cc index 296b51e78..30d1afda8 100644 --- a/sky/shell/platform_view.cc +++ b/sky/shell/platform_view.cc @@ -5,30 +5,71 @@ #include "sky/shell/platform_view.h" #include "base/bind.h" +#include "base/bind_helpers.h" #include "base/location.h" #include "base/single_thread_task_runner.h" +#include "sky/shell/rasterizer.h" namespace sky { namespace shell { -PlatformView::Config::Config() { -} +PlatformView::Config::Config() {} -PlatformView::Config::~Config() { -} +PlatformView::Config::~Config() {} -PlatformView::PlatformView(const PlatformView::Config& config) - : config_(config) { -} +PlatformView::PlatformView(const PlatformView::Config& config, + SurfaceConfig surface_config) + : config_(config), surface_config_(surface_config) {} -PlatformView::~PlatformView() { -} +PlatformView::~PlatformView() {} -void PlatformView::ConnectToEngine( - mojo::InterfaceRequest request) { +void PlatformView::ConnectToEngine(mojo::InterfaceRequest request) { config_.ui_task_runner->PostTask( - FROM_HERE, base::Bind(&UIDelegate::ConnectToEngine, - config_.ui_delegate, base::Passed(&request))); + FROM_HERE, base::Bind(&UIDelegate::ConnectToEngine, config_.ui_delegate, + base::Passed(&request))); +} + +void PlatformView::NotifyCreated() { + PlatformView::NotifyCreated(base::Bind(&base::DoNothing)); +} + +void PlatformView::NotifyCreated(base::Closure rasterizer_continuation) { + CHECK(config_.rasterizer != nullptr); + + auto delegate = config_.ui_delegate; + auto rasterizer = config_.rasterizer->GetWeakRasterizerPtr(); + + base::WaitableEvent latch(false, false); + + auto delegate_continuation = + base::Bind(&Rasterizer::Setup, // method + rasterizer, // target + base::Unretained(this), rasterizer_continuation, + base::Unretained(&latch)); + + config_.ui_task_runner->PostTask( + FROM_HERE, base::Bind(&UIDelegate::OnOutputSurfaceCreated, delegate, + delegate_continuation)); + + latch.Wait(); +} + +void PlatformView::NotifyDestroyed() { + CHECK(config_.rasterizer != nullptr); + + auto delegate = config_.ui_delegate; + auto rasterizer = config_.rasterizer->GetWeakRasterizerPtr(); + + base::WaitableEvent latch(false, false); + + auto delegate_continuation = + base::Bind(&Rasterizer::Teardown, rasterizer, base::Unretained(&latch)); + + config_.ui_task_runner->PostTask( + FROM_HERE, base::Bind(&UIDelegate::OnOutputSurfaceDestroyed, delegate, + delegate_continuation)); + + latch.Wait(); } } // namespace shell diff --git a/sky/shell/platform_view.h b/sky/shell/platform_view.h index 11a4ce9ca..9c7da539f 100644 --- a/sky/shell/platform_view.h +++ b/sky/shell/platform_view.h @@ -7,12 +7,14 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" +#include "base/synchronization/waitable_event.h" #include "sky/shell/ui_delegate.h" -#include "sky/shell/rasterizer.h" namespace sky { namespace shell { +class Rasterizer; + class PlatformView { public: struct Config { @@ -24,17 +26,42 @@ class PlatformView { scoped_refptr ui_task_runner; }; + struct SurfaceConfig { + uint8_t red_bits = 8; + uint8_t green_bits = 8; + uint8_t blue_bits = 8; + uint8_t alpha_bits = 8; + uint8_t depth_bits = 0; + uint8_t stencil_bits = 8; + }; + // Implemented by each platform. - static PlatformView* Create(const Config& config); + static PlatformView* Create(const Config& config, + SurfaceConfig surface_configuration); virtual ~PlatformView(); void ConnectToEngine(mojo::InterfaceRequest request); + void NotifyCreated(); + + void NotifyCreated(base::Closure continuation); + + void NotifyDestroyed(); + + virtual base::WeakPtr GetWeakViewPtr() = 0; + + virtual uint64_t DefaultFramebuffer() const = 0; + + virtual bool ContextMakeCurrent() = 0; + + virtual bool SwapBuffers() = 0; + protected: - explicit PlatformView(const Config& config); + explicit PlatformView(const Config& config, SurfaceConfig surface_config); Config config_; + SurfaceConfig surface_config_; private: DISALLOW_COPY_AND_ASSIGN(PlatformView); diff --git a/sky/shell/rasterizer.h b/sky/shell/rasterizer.h index a63adadbb..d97d65d7a 100644 --- a/sky/shell/rasterizer.h +++ b/sky/shell/rasterizer.h @@ -9,6 +9,7 @@ #include "base/callback.h" #include "base/memory/weak_ptr.h" +#include "base/synchronization/waitable_event.h" #include "flow/layers/layer_tree.h" #include "mojo/public/cpp/bindings/binding.h" #include "sky/services/rasterizer/rasterizer.mojom.h" @@ -16,12 +17,22 @@ namespace sky { namespace shell { +class PlatformView; + class Rasterizer : public rasterizer::Rasterizer { public: ~Rasterizer() override; + virtual void ConnectToRasterizer( mojo::InterfaceRequest request) = 0; - virtual base::WeakPtr<::sky::shell::Rasterizer> GetWeakRasterizerPtr() = 0; + + virtual void Setup(PlatformView* platform_view, + base::Closure rasterizer_continuation, + base::WaitableEvent* setup_completion_event) = 0; + + virtual void Teardown(base::WaitableEvent* teardown_completion_event) = 0; + + virtual base::WeakPtr GetWeakRasterizerPtr() = 0; virtual flow::LayerTree* GetLastLayerTree() = 0; diff --git a/sky/shell/shell_view.cc b/sky/shell/shell_view.cc index e190a8346..f37d7509e 100644 --- a/sky/shell/shell_view.cc +++ b/sky/shell/shell_view.cc @@ -46,7 +46,7 @@ void ShellView::CreatePlatformView() { config.ui_task_runner = shell_.ui_task_runner(); config.ui_delegate = engine_->GetWeakPtr(); config.rasterizer = rasterizer_.get(); - view_.reset(PlatformView::Create(config)); + view_.reset(PlatformView::Create(config, PlatformView::SurfaceConfig{})); } } // namespace shell diff --git a/sky/shell/ui_delegate.h b/sky/shell/ui_delegate.h index 88472aab6..5ee3c99da 100644 --- a/sky/shell/ui_delegate.h +++ b/sky/shell/ui_delegate.h @@ -7,7 +7,6 @@ #include "mojo/public/cpp/bindings/interface_request.h" #include "sky/services/engine/sky_engine.mojom.h" -#include "ui/gfx/native_widget_types.h" #include "base/callback.h" namespace sky { @@ -16,8 +15,12 @@ namespace shell { class UIDelegate { public: virtual void ConnectToEngine(mojo::InterfaceRequest request) = 0; - virtual void OnOutputSurfaceCreated(const base::Closure& gpu_continuation) = 0; - virtual void OnOutputSurfaceDestroyed(const base::Closure& gpu_continuation) = 0; + + virtual void OnOutputSurfaceCreated( + const base::Closure& gpu_continuation) = 0; + + virtual void OnOutputSurfaceDestroyed( + const base::Closure& gpu_continuation) = 0; protected: virtual ~UIDelegate(); diff --git a/sky/tools/roll/roll.py b/sky/tools/roll/roll.py index 3b19daf09..994685a42 100755 --- a/sky/tools/roll/roll.py +++ b/sky/tools/roll/roll.py @@ -63,7 +63,6 @@ dirs_from_mojo = [ 'mojo/android', 'mojo/application', 'mojo/common', - 'mojo/converters/geometry', ('mojo/dart/embedder', ['embedder.gni']), 'mojo/dart/packages/mojo', 'mojo/data_pipe_utils', diff --git a/ui/gfx/BUILD.gn b/ui/gfx/BUILD.gn deleted file mode 100644 index 237b486d9..000000000 --- a/ui/gfx/BUILD.gn +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2014 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/ui.gni") -import("//testing/test.gni") - -# Several targets want to include this header file, and some of them are -# child dependencies of "gfx". Therefore, we separate it out here so multiple -# targets can all have a dependency for header checking purposes without -# creating circular dependencies. -source_set("gfx_export") { - sources = [ - "gfx_export.h", - ] -} - -component("gfx") { - sources = [ - "codec/png_codec.cc", - "codec/png_codec.h", - "native_widget_types.h", - "skia_util.cc", - "skia_util.h", - "transform.cc", - "transform.h", - "transform_util.cc", - "transform_util.h", - "ui_gfx_exports.cc", - "vsync_provider.h", - ] - - defines = [ "GFX_IMPLEMENTATION" ] - - deps = [ - ":gfx_export", - "//base/third_party/dynamic_annotations", - "//base:base_static", - "//base:i18n", - "//skia", - "//third_party/harfbuzz-ng", - "//third_party/libpng", - "//third_party/zlib", - "//third_party:jpeg", - "//ui/gfx/geometry", - ] - public_deps = [ - "//base", - "//skia", - "//third_party/icu", - ] - - if (is_linux) { - configs += [ "//build/config/linux:fontconfig" ] - } - - if (use_x11) { - deps += [ "//ui/gfx/x" ] - } -} diff --git a/ui/gfx/codec/png_codec.cc b/ui/gfx/codec/png_codec.cc deleted file mode 100644 index ea82f13f8..000000000 --- a/ui/gfx/codec/png_codec.cc +++ /dev/null @@ -1,810 +0,0 @@ -// 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 "ui/gfx/codec/png_codec.h" - -#include "base/logging.h" -#include "base/strings/string_util.h" -#include "third_party/libpng/png.h" -#include "third_party/skia/include/core/SkBitmap.h" -#include "third_party/skia/include/core/SkColorPriv.h" -#include "third_party/skia/include/core/SkUnPreMultiply.h" -#include "third_party/zlib/zlib.h" -#include "ui/gfx/geometry/size.h" -#include "ui/gfx/skia_util.h" - -namespace gfx { - -namespace { - -// Converts BGRA->RGBA and RGBA->BGRA. -void ConvertBetweenBGRAandRGBA(const unsigned char* input, int pixel_width, - unsigned char* output, bool* is_opaque) { - for (int x = 0; x < pixel_width; x++) { - const unsigned char* pixel_in = &input[x * 4]; - unsigned char* pixel_out = &output[x * 4]; - pixel_out[0] = pixel_in[2]; - pixel_out[1] = pixel_in[1]; - pixel_out[2] = pixel_in[0]; - pixel_out[3] = pixel_in[3]; - } -} - -void ConvertRGBAtoRGB(const unsigned char* rgba, int pixel_width, - unsigned char* rgb, bool* is_opaque) { - for (int x = 0; x < pixel_width; x++) - memcpy(&rgb[x * 3], &rgba[x * 4], 3); -} - -void ConvertSkiaToRGB(const unsigned char* skia, int pixel_width, - unsigned char* rgb, bool* is_opaque) { - for (int x = 0; x < pixel_width; x++) { - const uint32_t pixel_in = *reinterpret_cast(&skia[x * 4]); - unsigned char* pixel_out = &rgb[x * 3]; - - int alpha = SkGetPackedA32(pixel_in); - if (alpha != 0 && alpha != 255) { - SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel_in); - pixel_out[0] = SkColorGetR(unmultiplied); - pixel_out[1] = SkColorGetG(unmultiplied); - pixel_out[2] = SkColorGetB(unmultiplied); - } else { - pixel_out[0] = SkGetPackedR32(pixel_in); - pixel_out[1] = SkGetPackedG32(pixel_in); - pixel_out[2] = SkGetPackedB32(pixel_in); - } - } -} - -void ConvertSkiaToRGBA(const unsigned char* skia, int pixel_width, - unsigned char* rgba, bool* is_opaque) { - gfx::ConvertSkiaToRGBA(skia, pixel_width, rgba); -} - -} // namespace - -// Decoder -------------------------------------------------------------------- -// -// This code is based on WebKit libpng interface (PNGImageDecoder), which is -// in turn based on the Mozilla png decoder. - -namespace { - -// Gamma constants: We assume we're on Windows which uses a gamma of 2.2. -const double kMaxGamma = 21474.83; // Maximum gamma accepted by png library. -const double kDefaultGamma = 2.2; -const double kInverseGamma = 1.0 / kDefaultGamma; - -class PngDecoderState { - public: - // Output is a vector. - PngDecoderState(PNGCodec::ColorFormat ofmt, std::vector* o) - : output_format(ofmt), - output_channels(0), - bitmap(NULL), - is_opaque(true), - output(o), - width(0), - height(0), - done(false) { - } - - // Output is an SkBitmap. - explicit PngDecoderState(SkBitmap* skbitmap) - : output_format(PNGCodec::FORMAT_SkBitmap), - output_channels(0), - bitmap(skbitmap), - is_opaque(true), - output(NULL), - width(0), - height(0), - done(false) { - } - - PNGCodec::ColorFormat output_format; - int output_channels; - - // An incoming SkBitmap to write to. If NULL, we write to output instead. - SkBitmap* bitmap; - - // Used during the reading of an SkBitmap. Defaults to true until we see a - // pixel with anything other than an alpha of 255. - bool is_opaque; - - // The other way to decode output, where we write into an intermediary buffer - // instead of directly to an SkBitmap. - std::vector* output; - - // Size of the image, set in the info callback. - int width; - int height; - - // Set to true when we've found the end of the data. - bool done; - - private: - DISALLOW_COPY_AND_ASSIGN(PngDecoderState); -}; - -// User transform (passed to libpng) which converts a row decoded by libpng to -// Skia format. Expects the row to have 4 channels, otherwise there won't be -// enough room in |data|. -void ConvertRGBARowToSkia(png_structp png_ptr, - png_row_infop row_info, - png_bytep data) { - const int channels = row_info->channels; - DCHECK_EQ(channels, 4); - - PngDecoderState* state = - static_cast(png_get_user_transform_ptr(png_ptr)); - DCHECK(state) << "LibPNG user transform pointer is NULL"; - - unsigned char* const end = data + row_info->rowbytes; - for (unsigned char* p = data; p < end; p += channels) { - uint32_t* sk_pixel = reinterpret_cast(p); - const unsigned char alpha = p[channels - 1]; - if (alpha != 255) { - state->is_opaque = false; - *sk_pixel = SkPreMultiplyARGB(alpha, p[0], p[1], p[2]); - } else { - *sk_pixel = SkPackARGB32(alpha, p[0], p[1], p[2]); - } - } -} - -// Called when the png header has been read. This code is based on the WebKit -// PNGImageDecoder -void DecodeInfoCallback(png_struct* png_ptr, png_info* info_ptr) { - PngDecoderState* state = static_cast( - png_get_progressive_ptr(png_ptr)); - - int bit_depth, color_type, interlace_type, compression_type; - int filter_type; - png_uint_32 w, h; - png_get_IHDR(png_ptr, info_ptr, &w, &h, &bit_depth, &color_type, - &interlace_type, &compression_type, &filter_type); - - // Bounds check. When the image is unreasonably big, we'll error out and - // end up back at the setjmp call when we set up decoding. "Unreasonably big" - // means "big enough that w * h * 32bpp might overflow an int"; we choose this - // threshold to match WebKit and because a number of places in code assume - // that an image's size (in bytes) fits in a (signed) int. - unsigned long long total_size = - static_cast(w) * static_cast(h); - if (total_size > ((1 << 29) - 1)) - longjmp(png_jmpbuf(png_ptr), 1); - state->width = static_cast(w); - state->height = static_cast(h); - - // The following png_set_* calls have to be done in the order dictated by - // the libpng docs. Please take care if you have to move any of them. This - // is also why certain things are done outside of the switch, even though - // they look like they belong there. - - // Expand to ensure we use 24-bit for RGB and 32-bit for RGBA. - if (color_type == PNG_COLOR_TYPE_PALETTE || - (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)) - png_set_expand(png_ptr); - - // The '!= 0' is for silencing a Windows compiler warning. - bool input_has_alpha = ((color_type & PNG_COLOR_MASK_ALPHA) != 0); - - // Transparency for paletted images. - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { - png_set_expand(png_ptr); - input_has_alpha = true; - } - - // Convert 16-bit to 8-bit. - if (bit_depth == 16) - png_set_strip_16(png_ptr); - - // Pick our row format converter necessary for this data. - if (!input_has_alpha) { - switch (state->output_format) { - case PNGCodec::FORMAT_RGB: - state->output_channels = 3; - break; - case PNGCodec::FORMAT_RGBA: - state->output_channels = 4; - png_set_add_alpha(png_ptr, 0xFF, PNG_FILLER_AFTER); - break; - case PNGCodec::FORMAT_BGRA: - state->output_channels = 4; - png_set_bgr(png_ptr); - png_set_add_alpha(png_ptr, 0xFF, PNG_FILLER_AFTER); - break; - case PNGCodec::FORMAT_SkBitmap: - state->output_channels = 4; - png_set_add_alpha(png_ptr, 0xFF, PNG_FILLER_AFTER); - break; - } - } else { - switch (state->output_format) { - case PNGCodec::FORMAT_RGB: - state->output_channels = 3; - png_set_strip_alpha(png_ptr); - break; - case PNGCodec::FORMAT_RGBA: - state->output_channels = 4; - break; - case PNGCodec::FORMAT_BGRA: - state->output_channels = 4; - png_set_bgr(png_ptr); - break; - case PNGCodec::FORMAT_SkBitmap: - state->output_channels = 4; - break; - } - } - - // Expand grayscale to RGB. - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - - // Deal with gamma and keep it under our control. - double gamma; - if (png_get_gAMA(png_ptr, info_ptr, &gamma)) { - if (gamma <= 0.0 || gamma > kMaxGamma) { - gamma = kInverseGamma; - png_set_gAMA(png_ptr, info_ptr, gamma); - } - png_set_gamma(png_ptr, kDefaultGamma, gamma); - } else { - png_set_gamma(png_ptr, kDefaultGamma, kInverseGamma); - } - - // Setting the user transforms here (as opposed to inside the switch above) - // because all png_set_* calls need to be done in the specific order - // mandated by libpng. - if (state->output_format == PNGCodec::FORMAT_SkBitmap) { - png_set_read_user_transform_fn(png_ptr, ConvertRGBARowToSkia); - png_set_user_transform_info(png_ptr, state, 0, 0); - } - - // Tell libpng to send us rows for interlaced pngs. - if (interlace_type == PNG_INTERLACE_ADAM7) - png_set_interlace_handling(png_ptr); - - png_read_update_info(png_ptr, info_ptr); - - if (state->bitmap) { - state->bitmap->allocN32Pixels(state->width, state->height); - } else if (state->output) { - state->output->resize( - state->width * state->output_channels * state->height); - } -} - -void DecodeRowCallback(png_struct* png_ptr, png_byte* new_row, - png_uint_32 row_num, int pass) { - if (!new_row) - return; // Interlaced image; row didn't change this pass. - - PngDecoderState* state = static_cast( - png_get_progressive_ptr(png_ptr)); - - if (static_cast(row_num) > state->height) { - NOTREACHED() << "Invalid row"; - return; - } - - unsigned char* base = NULL; - if (state->bitmap) - base = reinterpret_cast(state->bitmap->getAddr32(0, 0)); - else if (state->output) - base = &state->output->front(); - - unsigned char* dest = &base[state->width * state->output_channels * row_num]; - png_progressive_combine_row(png_ptr, dest, new_row); -} - -void DecodeEndCallback(png_struct* png_ptr, png_info* info) { - PngDecoderState* state = static_cast( - png_get_progressive_ptr(png_ptr)); - - // Mark the image as complete, this will tell the Decode function that we - // have successfully found the end of the data. - state->done = true; -} - -// Automatically destroys the given read structs on destruction to make -// cleanup and error handling code cleaner. -class PngReadStructDestroyer { - public: - PngReadStructDestroyer(png_struct** ps, png_info** pi) : ps_(ps), pi_(pi) { - } - ~PngReadStructDestroyer() { - png_destroy_read_struct(ps_, pi_, NULL); - } - private: - png_struct** ps_; - png_info** pi_; - DISALLOW_COPY_AND_ASSIGN(PngReadStructDestroyer); -}; - -// Automatically destroys the given write structs on destruction to make -// cleanup and error handling code cleaner. -class PngWriteStructDestroyer { - public: - explicit PngWriteStructDestroyer(png_struct** ps) : ps_(ps), pi_(0) { - } - ~PngWriteStructDestroyer() { - png_destroy_write_struct(ps_, pi_); - } - void SetInfoStruct(png_info** pi) { - pi_ = pi; - } - private: - png_struct** ps_; - png_info** pi_; - DISALLOW_COPY_AND_ASSIGN(PngWriteStructDestroyer); -}; - -bool BuildPNGStruct(const unsigned char* input, size_t input_size, - png_struct** png_ptr, png_info** info_ptr) { - if (input_size < 8) - return false; // Input data too small to be a png - - // Have libpng check the signature, it likes the first 8 bytes. - if (png_sig_cmp(const_cast(input), 0, 8) != 0) - return false; - - *png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!*png_ptr) - return false; - - *info_ptr = png_create_info_struct(*png_ptr); - if (!*info_ptr) { - png_destroy_read_struct(png_ptr, NULL, NULL); - return false; - } - - return true; -} - -// Libpng user error and warning functions which allows us to print libpng -// errors and warnings using Chrome's logging facilities instead of stderr. - -void LogLibPNGDecodeError(png_structp png_ptr, png_const_charp error_msg) { - DLOG(ERROR) << "libpng decode error: " << error_msg; - longjmp(png_jmpbuf(png_ptr), 1); -} - -void LogLibPNGDecodeWarning(png_structp png_ptr, png_const_charp warning_msg) { - DLOG(ERROR) << "libpng decode warning: " << warning_msg; -} - -void LogLibPNGEncodeError(png_structp png_ptr, png_const_charp error_msg) { - DLOG(ERROR) << "libpng encode error: " << error_msg; - longjmp(png_jmpbuf(png_ptr), 1); -} - -void LogLibPNGEncodeWarning(png_structp png_ptr, png_const_charp warning_msg) { - DLOG(ERROR) << "libpng encode warning: " << warning_msg; -} - -} // namespace - -// static -bool PNGCodec::Decode(const unsigned char* input, size_t input_size, - ColorFormat format, std::vector* output, - int* w, int* h) { - png_struct* png_ptr = NULL; - png_info* info_ptr = NULL; - if (!BuildPNGStruct(input, input_size, &png_ptr, &info_ptr)) - return false; - - PngReadStructDestroyer destroyer(&png_ptr, &info_ptr); - if (setjmp(png_jmpbuf(png_ptr))) { - // The destroyer will ensure that the structures are cleaned up in this - // case, even though we may get here as a jump from random parts of the - // PNG library called below. - return false; - } - - PngDecoderState state(format, output); - - png_set_error_fn(png_ptr, NULL, LogLibPNGDecodeError, LogLibPNGDecodeWarning); - png_set_progressive_read_fn(png_ptr, &state, &DecodeInfoCallback, - &DecodeRowCallback, &DecodeEndCallback); - png_process_data(png_ptr, - info_ptr, - const_cast(input), - input_size); - - if (!state.done) { - // Fed it all the data but the library didn't think we got all the data, so - // this file must be truncated. - output->clear(); - return false; - } - - *w = state.width; - *h = state.height; - return true; -} - -// static -bool PNGCodec::Decode(const unsigned char* input, size_t input_size, - SkBitmap* bitmap) { - DCHECK(bitmap); - png_struct* png_ptr = NULL; - png_info* info_ptr = NULL; - if (!BuildPNGStruct(input, input_size, &png_ptr, &info_ptr)) - return false; - - PngReadStructDestroyer destroyer(&png_ptr, &info_ptr); - if (setjmp(png_jmpbuf(png_ptr))) { - // The destroyer will ensure that the structures are cleaned up in this - // case, even though we may get here as a jump from random parts of the - // PNG library called below. - return false; - } - - PngDecoderState state(bitmap); - - png_set_progressive_read_fn(png_ptr, &state, &DecodeInfoCallback, - &DecodeRowCallback, &DecodeEndCallback); - png_process_data(png_ptr, - info_ptr, - const_cast(input), - input_size); - - if (!state.done) { - return false; - } - - // Set the bitmap's opaqueness based on what we saw. - bitmap->setAlphaType(state.is_opaque ? - kOpaque_SkAlphaType : kPremul_SkAlphaType); - - return true; -} - -// Encoder -------------------------------------------------------------------- -// -// This section of the code is based on nsPNGEncoder.cpp in Mozilla -// (Copyright 2005 Google Inc.) - -namespace { - -// Passed around as the io_ptr in the png structs so our callbacks know where -// to write data. -struct PngEncoderState { - explicit PngEncoderState(std::vector* o) : out(o) {} - std::vector* out; -}; - -// Called by libpng to flush its internal buffer to ours. -void EncoderWriteCallback(png_structp png, png_bytep data, png_size_t size) { - PngEncoderState* state = static_cast(png_get_io_ptr(png)); - DCHECK(state->out); - - size_t old_size = state->out->size(); - state->out->resize(old_size + size); - memcpy(&(*state->out)[old_size], data, size); -} - -void FakeFlushCallback(png_structp png) { - // We don't need to perform any flushing since we aren't doing real IO, but - // we're required to provide this function by libpng. -} - -void ConvertBGRAtoRGB(const unsigned char* bgra, int pixel_width, - unsigned char* rgb, bool* is_opaque) { - for (int x = 0; x < pixel_width; x++) { - const unsigned char* pixel_in = &bgra[x * 4]; - unsigned char* pixel_out = &rgb[x * 3]; - pixel_out[0] = pixel_in[2]; - pixel_out[1] = pixel_in[1]; - pixel_out[2] = pixel_in[0]; - } -} - -#ifdef PNG_TEXT_SUPPORTED -class CommentWriter { - public: - explicit CommentWriter(const std::vector& comments) - : comments_(comments), - png_text_(new png_text[comments.size()]) { - for (size_t i = 0; i < comments.size(); ++i) - AddComment(i, comments[i]); - } - - ~CommentWriter() { - for (size_t i = 0; i < comments_.size(); ++i) { - free(png_text_[i].key); - free(png_text_[i].text); - } - delete [] png_text_; - } - - bool HasComments() { - return !comments_.empty(); - } - - png_text* get_png_text() { - return png_text_; - } - - int size() { - return static_cast(comments_.size()); - } - - private: - void AddComment(size_t pos, const PNGCodec::Comment& comment) { - png_text_[pos].compression = PNG_TEXT_COMPRESSION_NONE; - // A PNG comment's key can only be 79 characters long. - DCHECK(comment.key.length() < 79); - png_text_[pos].key = base::strdup(comment.key.substr(0, 78).c_str()); - png_text_[pos].text = base::strdup(comment.text.c_str()); - png_text_[pos].text_length = comment.text.length(); -#ifdef PNG_iTXt_SUPPORTED - png_text_[pos].itxt_length = 0; - png_text_[pos].lang = 0; - png_text_[pos].lang_key = 0; -#endif - } - - DISALLOW_COPY_AND_ASSIGN(CommentWriter); - - const std::vector comments_; - png_text* png_text_; -}; -#endif // PNG_TEXT_SUPPORTED - -// The type of functions usable for converting between pixel formats. -typedef void (*FormatConverter)(const unsigned char* in, int w, - unsigned char* out, bool* is_opaque); - -// libpng uses a wacky setjmp-based API, which makes the compiler nervous. -// We constrain all of the calls we make to libpng where the setjmp() is in -// place to this function. -// Returns true on success. -bool DoLibpngWrite(png_struct* png_ptr, png_info* info_ptr, - PngEncoderState* state, - int width, int height, int row_byte_width, - const unsigned char* input, int compression_level, - int png_output_color_type, int output_color_components, - FormatConverter converter, - const std::vector& comments) { -#ifdef PNG_TEXT_SUPPORTED - CommentWriter comment_writer(comments); -#endif - unsigned char* row_buffer = NULL; - - // Make sure to not declare any locals here -- locals in the presence - // of setjmp() in C++ code makes gcc complain. - - if (setjmp(png_jmpbuf(png_ptr))) { - delete[] row_buffer; - return false; - } - - png_set_compression_level(png_ptr, compression_level); - - // Set our callback for libpng to give us the data. - png_set_write_fn(png_ptr, state, EncoderWriteCallback, FakeFlushCallback); - png_set_error_fn(png_ptr, NULL, LogLibPNGEncodeError, LogLibPNGEncodeWarning); - - png_set_IHDR(png_ptr, info_ptr, width, height, 8, png_output_color_type, - PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT); - -#ifdef PNG_TEXT_SUPPORTED - if (comment_writer.HasComments()) { - png_set_text(png_ptr, info_ptr, comment_writer.get_png_text(), - comment_writer.size()); - } -#endif - - png_write_info(png_ptr, info_ptr); - - if (!converter) { - // No conversion needed, give the data directly to libpng. - for (int y = 0; y < height; y ++) { - png_write_row(png_ptr, - const_cast(&input[y * row_byte_width])); - } - } else { - // Needs conversion using a separate buffer. - row_buffer = new unsigned char[width * output_color_components]; - for (int y = 0; y < height; y ++) { - converter(&input[y * row_byte_width], width, row_buffer, NULL); - png_write_row(png_ptr, row_buffer); - } - delete[] row_buffer; - } - - png_write_end(png_ptr, info_ptr); - return true; -} - -bool EncodeWithCompressionLevel(const unsigned char* input, - PNGCodec::ColorFormat format, - const Size& size, - int row_byte_width, - bool discard_transparency, - const std::vector& comments, - int compression_level, - std::vector* output) { - // Run to convert an input row into the output row format, NULL means no - // conversion is necessary. - FormatConverter converter = NULL; - - int input_color_components, output_color_components; - int png_output_color_type; - switch (format) { - case PNGCodec::FORMAT_RGB: - input_color_components = 3; - output_color_components = 3; - png_output_color_type = PNG_COLOR_TYPE_RGB; - break; - - case PNGCodec::FORMAT_RGBA: - input_color_components = 4; - if (discard_transparency) { - output_color_components = 3; - png_output_color_type = PNG_COLOR_TYPE_RGB; - converter = ConvertRGBAtoRGB; - } else { - output_color_components = 4; - png_output_color_type = PNG_COLOR_TYPE_RGB_ALPHA; - converter = NULL; - } - break; - - case PNGCodec::FORMAT_BGRA: - input_color_components = 4; - if (discard_transparency) { - output_color_components = 3; - png_output_color_type = PNG_COLOR_TYPE_RGB; - converter = ConvertBGRAtoRGB; - } else { - output_color_components = 4; - png_output_color_type = PNG_COLOR_TYPE_RGB_ALPHA; - converter = ConvertBetweenBGRAandRGBA; - } - break; - - case PNGCodec::FORMAT_SkBitmap: - // Compare row_byte_width and size.width() to detect the format of - // SkBitmap. kA8_Config (1bpp) and kARGB_8888_Config (4bpp) are the two - // supported formats. - if (row_byte_width < 4 * size.width()) { - // Not 4bpp, so must be 1bpp. - // Ignore discard_transparency - it doesn't make sense in this context, - // since alpha is the only thing we have and it needs to be used for - // color intensity. - input_color_components = 1; - output_color_components = 1; - png_output_color_type = PNG_COLOR_TYPE_GRAY; - // |converter| is left as null - } else { - input_color_components = 4; - if (discard_transparency) { - output_color_components = 3; - png_output_color_type = PNG_COLOR_TYPE_RGB; - converter = ConvertSkiaToRGB; - } else { - output_color_components = 4; - png_output_color_type = PNG_COLOR_TYPE_RGB_ALPHA; - converter = ConvertSkiaToRGBA; - } - } - break; - - default: - NOTREACHED() << "Unknown pixel format"; - return false; - } - - // Row stride should be at least as long as the length of the data. - DCHECK(input_color_components * size.width() <= row_byte_width); - - png_struct* png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, - NULL, NULL, NULL); - if (!png_ptr) - return false; - PngWriteStructDestroyer destroyer(&png_ptr); - png_info* info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - return false; - destroyer.SetInfoStruct(&info_ptr); - - output->clear(); - - PngEncoderState state(output); - bool success = DoLibpngWrite(png_ptr, info_ptr, &state, - size.width(), size.height(), row_byte_width, - input, compression_level, png_output_color_type, - output_color_components, converter, comments); - - return success; -} - -bool InternalEncodeSkBitmap(const SkBitmap& input, - bool discard_transparency, - int compression_level, - std::vector* output) { - if (input.empty() || input.isNull()) - return false; - int bpp = input.bytesPerPixel(); - DCHECK(bpp == 1 || bpp == 4); // We support kA8_Config and kARGB_8888_Config. - - SkAutoLockPixels lock_input(input); - unsigned char* inputAddr = bpp == 1 ? - reinterpret_cast(input.getAddr8(0, 0)) : - reinterpret_cast(input.getAddr32(0, 0)); // bpp = 4 - return EncodeWithCompressionLevel( - inputAddr, - PNGCodec::FORMAT_SkBitmap, - Size(input.width(), input.height()), - static_cast(input.rowBytes()), - discard_transparency, - std::vector(), - compression_level, - output); -} - - -} // namespace - -// static -bool PNGCodec::Encode(const unsigned char* input, - ColorFormat format, - const Size& size, - int row_byte_width, - bool discard_transparency, - const std::vector& comments, - std::vector* output) { - return EncodeWithCompressionLevel(input, - format, - size, - row_byte_width, - discard_transparency, - comments, - Z_DEFAULT_COMPRESSION, - output); -} - -// static -bool PNGCodec::EncodeBGRASkBitmap(const SkBitmap& input, - bool discard_transparency, - std::vector* output) { - return InternalEncodeSkBitmap(input, - discard_transparency, - Z_DEFAULT_COMPRESSION, - output); -} - -// static -bool PNGCodec::EncodeA8SkBitmap(const SkBitmap& input, - std::vector* output) { - return InternalEncodeSkBitmap(input, - false, - Z_DEFAULT_COMPRESSION, - output); -} - -// static -bool PNGCodec::FastEncodeBGRASkBitmap(const SkBitmap& input, - bool discard_transparency, - std::vector* output) { - return InternalEncodeSkBitmap(input, - discard_transparency, - Z_BEST_SPEED, - output); -} - -PNGCodec::Comment::Comment(const std::string& k, const std::string& t) - : key(k), text(t) { -} - -PNGCodec::Comment::~Comment() { -} - -} // namespace gfx diff --git a/ui/gfx/codec/png_codec.h b/ui/gfx/codec/png_codec.h deleted file mode 100644 index 5f849c462..000000000 --- a/ui/gfx/codec/png_codec.h +++ /dev/null @@ -1,134 +0,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. - -#ifndef UI_GFX_CODEC_PNG_CODEC_H_ -#define UI_GFX_CODEC_PNG_CODEC_H_ - -#include -#include - -#include "base/basictypes.h" -#include "ui/gfx/gfx_export.h" - -class SkBitmap; - -namespace gfx { - -class Size; - -// Interface for encoding and decoding PNG data. This is a wrapper around -// libpng, which has an inconvenient interface for callers. This is currently -// designed for use in tests only (where we control the files), so the handling -// isn't as robust as would be required for a browser (see Decode() for more). -// WebKit has its own more complicated PNG decoder which handles, among other -// things, partially downloaded data. -class GFX_EXPORT PNGCodec { - public: - enum ColorFormat { - // 3 bytes per pixel (packed), in RGB order regardless of endianness. - // This is the native JPEG format. - FORMAT_RGB, - - // 4 bytes per pixel, in RGBA order in memory regardless of endianness. - FORMAT_RGBA, - - // 4 bytes per pixel, in BGRA order in memory regardless of endianness. - // This is the default Windows DIB order. - FORMAT_BGRA, - - // SkBitmap format. For Encode() kARGB_8888_Config (4 bytes per pixel) and - // kA8_Config (1 byte per pixel) formats are supported. kA8_Config gets - // encoded into a grayscale PNG treating alpha as the color intensity. - // For Decode() kARGB_8888_Config is always used. - FORMAT_SkBitmap - }; - - // Represents a comment in the tEXt ancillary chunk of the png. - struct GFX_EXPORT Comment { - Comment(const std::string& k, const std::string& t); - ~Comment(); - - std::string key; - std::string text; - }; - - // Encodes the given raw 'input' data, with each pixel being represented as - // given in 'format'. The encoded PNG data will be written into the supplied - // vector and true will be returned on success. On failure (false), the - // contents of the output buffer are undefined. - // - // When writing alpha values, the input colors are assumed to be post - // multiplied. - // - // size: dimensions of the image - // row_byte_width: the width in bytes of each row. This may be greater than - // w * bytes_per_pixel if there is extra padding at the end of each row - // (often, each row is padded to the next machine word). - // discard_transparency: when true, and when the input data format includes - // alpha values, these alpha values will be discarded and only RGB will be - // written to the resulting file. Otherwise, alpha values in the input - // will be preserved. - // comments: comments to be written in the png's metadata. - static bool Encode(const unsigned char* input, - ColorFormat format, - const Size& size, - int row_byte_width, - bool discard_transparency, - const std::vector& comments, - std::vector* output); - - // Call PNGCodec::Encode on the supplied SkBitmap |input|, which is assumed - // to be kARGB_8888_Config, 32 bits per pixel. The params - // |discard_transparency| and |output| are passed directly to Encode; refer to - // Encode for more information. During the call, an SkAutoLockPixels lock - // is held on |input|. - static bool EncodeBGRASkBitmap(const SkBitmap& input, - bool discard_transparency, - std::vector* output); - - // Call PNGCodec::Encode on the supplied SkBitmap |input|. The difference - // between this and the previous method is that this restricts compression to - // zlib q1, which is just rle encoding. - static bool FastEncodeBGRASkBitmap(const SkBitmap& input, - bool discard_transparency, - std::vector* output); - - // Call PNGCodec::Encode on the supplied SkBitmap |input|, which is assumed - // to be kA8_Config, 8 bits per pixel. The bitmap is encoded as a grayscale - // PNG with alpha used for color intensity. The |output| param is passed - // directly to Encode; refer to Encode for more information. During the call, - // an SkAutoLockPixels lock is held on |input|. - static bool EncodeA8SkBitmap(const SkBitmap& input, - std::vector* output); - - // Decodes the PNG data contained in input of length input_size. The - // decoded data will be placed in *output with the dimensions in *w and *h - // on success (returns true). This data will be written in the 'format' - // format. On failure, the values of these output variables are undefined. - // - // This function may not support all PNG types, and it hasn't been tested - // with a large number of images, so assume a new format may not work. It's - // really designed to be able to read in something written by Encode() above. - static bool Decode(const unsigned char* input, size_t input_size, - ColorFormat format, std::vector* output, - int* w, int* h); - - // Decodes the PNG data directly into the passed in SkBitmap. This is - // significantly faster than the vector version of Decode() - // above when dealing with PNG files that are >500K, which a lot of theme - // images are. (There are a lot of themes that have a NTP image of about ~1 - // megabyte, and those require a 7-10 megabyte side buffer.) - // - // Returns true if data is non-null and can be decoded as a png, false - // otherwise. - static bool Decode(const unsigned char* input, size_t input_size, - SkBitmap* bitmap); - - private: - DISALLOW_COPY_AND_ASSIGN(PNGCodec); -}; - -} // namespace gfx - -#endif // UI_GFX_CODEC_PNG_CODEC_H_ diff --git a/ui/gfx/codec/png_codec_unittest.cc b/ui/gfx/codec/png_codec_unittest.cc deleted file mode 100644 index 6613a63c6..000000000 --- a/ui/gfx/codec/png_codec_unittest.cc +++ /dev/null @@ -1,1188 +0,0 @@ -// 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 -#include - -#include "base/logging.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/libpng/png.h" -#include "third_party/skia/include/core/SkBitmap.h" -#include "third_party/skia/include/core/SkColorPriv.h" -#include "third_party/skia/include/core/SkUnPreMultiply.h" -#include "third_party/zlib/zlib.h" -#include "ui/gfx/codec/png_codec.h" -#include "ui/gfx/size.h" -#include "ui/gfx/skia_util.h" - -namespace gfx { - -namespace { - -void MakeRGBImage(int w, int h, std::vector* data) { - data->resize(w * h * 3); - for (int y = 0; y < h; y++) { - for (int x = 0; x < w; x++) { - unsigned char* org_px = &(*data)[(y * w + x) * 3]; - org_px[0] = x * 3; // r - org_px[1] = x * 3 + 1; // g - org_px[2] = x * 3 + 2; // b - } - } -} - -// Set use_transparency to write data into the alpha channel, otherwise it will -// be filled with 0xff. With the alpha channel stripped, this should yield the -// same image as MakeRGBImage above, so the code below can make reference -// images for conversion testing. -void MakeRGBAImage(int w, int h, bool use_transparency, - std::vector* data) { - data->resize(w * h * 4); - for (int y = 0; y < h; y++) { - for (int x = 0; x < w; x++) { - unsigned char* org_px = &(*data)[(y * w + x) * 4]; - org_px[0] = x * 3; // r - org_px[1] = x * 3 + 1; // g - org_px[2] = x * 3 + 2; // b - if (use_transparency) - org_px[3] = x*3 + 3; // a - else - org_px[3] = 0xFF; // a (opaque) - } - } -} - -// Creates a palette-based image. -void MakePaletteImage(int w, int h, - std::vector* data, - std::vector* palette, - std::vector* trans_chunk = 0) { - data->resize(w * h); - palette->resize(w); - for (int i = 0; i < w; ++i) { - png_color& color = (*palette)[i]; - color.red = i * 3; - color.green = color.red + 1; - color.blue = color.red + 2; - } - for (int y = 0; y < h; y++) { - for (int x = 0; x < w; x++) { - (*data)[y * w + x] = x; // palette index - } - } - if (trans_chunk) { - trans_chunk->resize(palette->size()); - for (std::size_t i = 0; i < trans_chunk->size(); ++i) { - (*trans_chunk)[i] = i % 256; - } - } -} - -// Creates a grayscale image without an alpha channel. -void MakeGrayscaleImage(int w, int h, - std::vector* data) { - data->resize(w * h); - for (int y = 0; y < h; y++) { - for (int x = 0; x < w; x++) { - (*data)[y * w + x] = x; // gray value - } - } -} - -// Creates a grayscale image with an alpha channel. -void MakeGrayscaleAlphaImage(int w, int h, - std::vector* data) { - data->resize(w * h * 2); - for (int y = 0; y < h; y++) { - for (int x = 0; x < w; x++) { - unsigned char* px = &(*data)[(y * w + x) * 2]; - px[0] = x; // gray value - px[1] = x % 256; // alpha - } - } -} - -// User write function (to be passed to libpng by EncodeImage) which writes -// into a buffer instead of to a file. -void WriteImageData(png_structp png_ptr, - png_bytep data, - png_size_t length) { - std::vector& v = - *static_cast*>(png_get_io_ptr(png_ptr)); - v.resize(v.size() + length); - memcpy(&v[v.size() - length], data, length); -} - -// User flush function; goes with WriteImageData, above. -void FlushImageData(png_structp /*png_ptr*/) { -} - -// Libpng user error function which allows us to print libpng errors using -// Chrome's logging facilities instead of stderr. -void LogLibPNGError(png_structp png_ptr, - png_const_charp error_msg) { - DLOG(ERROR) << "libpng encode error: " << error_msg; - longjmp(png_jmpbuf(png_ptr), 1); -} - -// Goes with LogLibPNGError, above. -void LogLibPNGWarning(png_structp png_ptr, - png_const_charp warning_msg) { - DLOG(ERROR) << "libpng encode warning: " << warning_msg; -} - -// Color types supported by EncodeImage. Required because neither libpng nor -// PNGCodec::Encode supports all of the required values. -enum ColorType { - COLOR_TYPE_GRAY = PNG_COLOR_TYPE_GRAY, - COLOR_TYPE_GRAY_ALPHA = PNG_COLOR_TYPE_GRAY_ALPHA, - COLOR_TYPE_PALETTE = PNG_COLOR_TYPE_PALETTE, - COLOR_TYPE_RGB = PNG_COLOR_TYPE_RGB, - COLOR_TYPE_RGBA = PNG_COLOR_TYPE_RGBA, - COLOR_TYPE_BGR, - COLOR_TYPE_BGRA -}; - -// PNG encoder used for testing. Required because PNGCodec::Encode doesn't do -// interlaced, palette-based, or grayscale images, but PNGCodec::Decode is -// actually asked to decode these types of images by Chrome. -bool EncodeImage(const std::vector& input, - const int width, - const int height, - ColorType output_color_type, - std::vector* output, - const int interlace_type = PNG_INTERLACE_NONE, - std::vector* palette = 0, - std::vector* palette_alpha = 0) { - DCHECK(output); - - int input_rowbytes = 0; - int transforms = PNG_TRANSFORM_IDENTITY; - - switch (output_color_type) { - case COLOR_TYPE_GRAY: - input_rowbytes = width; - break; - case COLOR_TYPE_GRAY_ALPHA: - input_rowbytes = width * 2; - break; - case COLOR_TYPE_PALETTE: - if (!palette) - return false; - input_rowbytes = width; - break; - case COLOR_TYPE_RGB: - input_rowbytes = width * 3; - break; - case COLOR_TYPE_RGBA: - input_rowbytes = width * 4; - break; - case COLOR_TYPE_BGR: - input_rowbytes = width * 3; - output_color_type = static_cast(PNG_COLOR_TYPE_RGB); - transforms |= PNG_TRANSFORM_BGR; - break; - case COLOR_TYPE_BGRA: - input_rowbytes = width * 4; - output_color_type = static_cast(PNG_COLOR_TYPE_RGBA); - transforms |= PNG_TRANSFORM_BGR; - break; - }; - - png_struct* png_ptr = - png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!png_ptr) - return false; - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) { - png_destroy_write_struct(&png_ptr, NULL); - return false; - } - - std::vector row_pointers(height); - for (int y = 0 ; y < height; ++y) { - row_pointers[y] = const_cast(&input[y * input_rowbytes]); - } - - if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_write_struct(&png_ptr, &info_ptr); - return false; - } - - png_set_error_fn(png_ptr, NULL, LogLibPNGError, LogLibPNGWarning); - png_set_rows(png_ptr, info_ptr, &row_pointers[0]); - png_set_write_fn(png_ptr, output, WriteImageData, FlushImageData); - png_set_IHDR(png_ptr, info_ptr, width, height, 8, output_color_type, - interlace_type, PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT); - if (output_color_type == COLOR_TYPE_PALETTE) { - png_set_PLTE(png_ptr, info_ptr, &palette->front(), palette->size()); - if (palette_alpha) { - unsigned char* alpha_data = &palette_alpha->front(); - size_t alpha_size = palette_alpha->size(); - png_set_tRNS(png_ptr, info_ptr, alpha_data, alpha_size, NULL); - } - } - - png_write_png(png_ptr, info_ptr, transforms, NULL); - - png_destroy_write_struct(&png_ptr, &info_ptr); - return true; -} - -} // namespace - -// Returns true if each channel of the given two colors are "close." This is -// used for comparing colors where rounding errors may cause off-by-one. -bool ColorsClose(uint32_t a, uint32_t b) { - return abs(static_cast(SkColorGetB(a) - SkColorGetB(b))) < 2 && - abs(static_cast(SkColorGetG(a) - SkColorGetG(b))) < 2 && - abs(static_cast(SkColorGetR(a) - SkColorGetR(b))) < 2 && - abs(static_cast(SkColorGetA(a) - SkColorGetA(b))) < 2; -} - -// Returns true if the RGB components are "close." -bool NonAlphaColorsClose(uint32_t a, uint32_t b) { - return abs(static_cast(SkColorGetB(a) - SkColorGetB(b))) < 2 && - abs(static_cast(SkColorGetG(a) - SkColorGetG(b))) < 2 && - abs(static_cast(SkColorGetR(a) - SkColorGetR(b))) < 2; -} - -// Returns true if the BGRA 32-bit SkColor specified by |a| is equivalent to the -// 8-bit Gray color specified by |b|. -bool BGRAGrayEqualsA8Gray(uint32_t a, uint8_t b) { - return SkColorGetB(a) == b && SkColorGetG(a) == b && - SkColorGetR(a) == b && SkColorGetA(a) == 255; -} - -void MakeTestBGRASkBitmap(int w, int h, SkBitmap* bmp) { - bmp->allocN32Pixels(w, h); - - uint32_t* src_data = bmp->getAddr32(0, 0); - for (int i = 0; i < w * h; i++) - src_data[i] = SkPreMultiplyARGB(i % 255, i % 250, i % 245, i % 240); -} - -void MakeTestA8SkBitmap(int w, int h, SkBitmap* bmp) { - bmp->allocPixels(SkImageInfo::MakeA8(w, h)); - - uint8_t* src_data = bmp->getAddr8(0, 0); - for (int i = 0; i < w * h; i++) - src_data[i] = i % 255; -} - -TEST(PNGCodec, EncodeDecodeRGB) { - const int w = 20, h = 20; - - // create an image with known values - std::vector original; - MakeRGBImage(w, h, &original); - - // encode - std::vector encoded; - ASSERT_TRUE(PNGCodec::Encode(&original[0], PNGCodec::FORMAT_RGB, - Size(w, h), w * 3, false, - std::vector(), - &encoded)); - - // decode, it should have the same size as the original - std::vector decoded; - int outw, outh; - ASSERT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_RGB, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(original.size(), decoded.size()); - - // Images must be equal - ASSERT_TRUE(original == decoded); -} - -TEST(PNGCodec, EncodeDecodeRGBA) { - const int w = 20, h = 20; - - // create an image with known values, a must be opaque because it will be - // lost during encoding - std::vector original; - MakeRGBAImage(w, h, true, &original); - - // encode - std::vector encoded; - ASSERT_TRUE(PNGCodec::Encode(&original[0], PNGCodec::FORMAT_RGBA, - Size(w, h), w * 4, false, - std::vector(), - &encoded)); - - // decode, it should have the same size as the original - std::vector decoded; - int outw, outh; - ASSERT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_RGBA, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(original.size(), decoded.size()); - - // Images must be exactly equal - ASSERT_TRUE(original == decoded); -} - -TEST(PNGCodec, EncodeDecodeBGRA) { - const int w = 20, h = 20; - - // Create an image with known values, alpha must be opaque because it will be - // lost during encoding. - std::vector original; - MakeRGBAImage(w, h, true, &original); - - // Encode. - std::vector encoded; - ASSERT_TRUE(PNGCodec::Encode(&original[0], PNGCodec::FORMAT_BGRA, - Size(w, h), w * 4, false, - std::vector(), - &encoded)); - - // Decode, it should have the same size as the original. - std::vector decoded; - int outw, outh; - ASSERT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_BGRA, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(original.size(), decoded.size()); - - // Images must be exactly equal. - ASSERT_TRUE(original == decoded); -} - -TEST(PNGCodec, DecodePalette) { - const int w = 20, h = 20; - - // create an image with known values - std::vector original; - std::vector original_palette; - std::vector original_trans_chunk; - MakePaletteImage(w, h, &original, &original_palette, &original_trans_chunk); - - // encode - std::vector encoded; - ASSERT_TRUE(EncodeImage(original, - w, h, - COLOR_TYPE_PALETTE, - &encoded, - PNG_INTERLACE_NONE, - &original_palette, - &original_trans_chunk)); - - // decode - std::vector decoded; - int outw, outh; - ASSERT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_RGBA, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(decoded.size(), w * h * 4U); - - // Images must be equal - for (int y = 0; y < h; ++y) { - for (int x = 0; x < w; ++x) { - unsigned char palette_pixel = original[y * w + x]; - png_color& palette_color = original_palette[palette_pixel]; - int alpha = original_trans_chunk[palette_pixel]; - unsigned char* rgba_pixel = &decoded[(y * w + x) * 4]; - - EXPECT_EQ(palette_color.red, rgba_pixel[0]); - EXPECT_EQ(palette_color.green, rgba_pixel[1]); - EXPECT_EQ(palette_color.blue, rgba_pixel[2]); - EXPECT_EQ(alpha, rgba_pixel[3]); - } - } -} - -TEST(PNGCodec, DecodePaletteDiscardAlpha) { - const int w = 20, h = 20; - - // create an image with known values - std::vector original; - std::vector original_palette; - std::vector original_trans_chunk; - MakePaletteImage(w, h, &original, &original_palette, &original_trans_chunk); - - // encode - std::vector encoded; - ASSERT_TRUE(EncodeImage(original, - w, h, - COLOR_TYPE_PALETTE, - &encoded, - PNG_INTERLACE_NONE, - &original_palette, - &original_trans_chunk)); - - // decode - std::vector decoded; - int outw, outh; - ASSERT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_RGB, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(decoded.size(), w * h * 3U); - - // Images must be equal - for (int y = 0; y < h; ++y) { - for (int x = 0; x < w; ++x) { - unsigned char palette_pixel = original[y * w + x]; - png_color& palette_color = original_palette[palette_pixel]; - unsigned char* rgba_pixel = &decoded[(y * w + x) * 3]; - - EXPECT_EQ(palette_color.red, rgba_pixel[0]); - EXPECT_EQ(palette_color.green, rgba_pixel[1]); - EXPECT_EQ(palette_color.blue, rgba_pixel[2]); - } - } -} - -TEST(PNGCodec, DecodeInterlacedPalette) { - const int w = 20, h = 20; - - // create an image with known values - std::vector original; - std::vector original_palette; - std::vector original_trans_chunk; - MakePaletteImage(w, h, &original, &original_palette, &original_trans_chunk); - - // encode - std::vector encoded; - ASSERT_TRUE(EncodeImage(original, - w, h, - COLOR_TYPE_PALETTE, - &encoded, - PNG_INTERLACE_ADAM7, - &original_palette, - &original_trans_chunk)); - - // decode - std::vector decoded; - int outw, outh; - ASSERT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_RGBA, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(decoded.size(), w * h * 4U); - - // Images must be equal - for (int y = 0; y < h; ++y) { - for (int x = 0; x < w; ++x) { - unsigned char palette_pixel = original[y * w + x]; - png_color& palette_color = original_palette[palette_pixel]; - int alpha = original_trans_chunk[palette_pixel]; - unsigned char* rgba_pixel = &decoded[(y * w + x) * 4]; - - EXPECT_EQ(palette_color.red, rgba_pixel[0]); - EXPECT_EQ(palette_color.green, rgba_pixel[1]); - EXPECT_EQ(palette_color.blue, rgba_pixel[2]); - EXPECT_EQ(alpha, rgba_pixel[3]); - } - } -} - -TEST(PNGCodec, DecodeGrayscale) { - const int w = 20, h = 20; - - // create an image with known values - std::vector original; - MakeGrayscaleImage(w, h, &original); - - // encode - std::vector encoded; - ASSERT_TRUE(EncodeImage(original, w, h, COLOR_TYPE_GRAY, &encoded)); - - // decode - std::vector decoded; - int outw, outh; - ASSERT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_RGB, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(decoded.size(), original.size() * 3); - - // Images must be equal - for (int y = 0; y < h; ++y) { - for (int x = 0; x < w; ++x) { - unsigned char gray_pixel = original[(y * w + x)]; - unsigned char* rgba_pixel = &decoded[(y * w + x) * 3]; - EXPECT_EQ(rgba_pixel[0], gray_pixel); - EXPECT_EQ(rgba_pixel[1], gray_pixel); - EXPECT_EQ(rgba_pixel[2], gray_pixel); - } - } -} - -TEST(PNGCodec, DecodeGrayscaleWithAlpha) { - const int w = 20, h = 20; - - // create an image with known values - std::vector original; - MakeGrayscaleAlphaImage(w, h, &original); - - // encode - std::vector encoded; - ASSERT_TRUE(EncodeImage(original, - w, h, - COLOR_TYPE_GRAY_ALPHA, - &encoded)); - - // decode - std::vector decoded; - int outw, outh; - ASSERT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_RGBA, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(decoded.size(), original.size() * 2); - - // Images must be equal - for (int y = 0; y < h; ++y) { - for (int x = 0; x < w; ++x) { - unsigned char* gray_pixel = &original[(y * w + x) * 2]; - unsigned char* rgba_pixel = &decoded[(y * w + x) * 4]; - EXPECT_EQ(rgba_pixel[0], gray_pixel[0]); - EXPECT_EQ(rgba_pixel[1], gray_pixel[0]); - EXPECT_EQ(rgba_pixel[2], gray_pixel[0]); - EXPECT_EQ(rgba_pixel[3], gray_pixel[1]); - } - } -} - -TEST(PNGCodec, DecodeGrayscaleWithAlphaDiscardAlpha) { - const int w = 20, h = 20; - - // create an image with known values - std::vector original; - MakeGrayscaleAlphaImage(w, h, &original); - - // encode - std::vector encoded; - ASSERT_TRUE(EncodeImage(original, - w, h, - COLOR_TYPE_GRAY_ALPHA, - &encoded)); - - // decode - std::vector decoded; - int outw, outh; - ASSERT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_RGB, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(decoded.size(), w * h * 3U); - - // Images must be equal - for (int y = 0; y < h; ++y) { - for (int x = 0; x < w; ++x) { - unsigned char* gray_pixel = &original[(y * w + x) * 2]; - unsigned char* rgba_pixel = &decoded[(y * w + x) * 3]; - EXPECT_EQ(rgba_pixel[0], gray_pixel[0]); - EXPECT_EQ(rgba_pixel[1], gray_pixel[0]); - EXPECT_EQ(rgba_pixel[2], gray_pixel[0]); - } - } -} - -TEST(PNGCodec, DecodeInterlacedGrayscale) { - const int w = 20, h = 20; - - // create an image with known values - std::vector original; - MakeGrayscaleImage(w, h, &original); - - // encode - std::vector encoded; - ASSERT_TRUE(EncodeImage(original, - w, h, - COLOR_TYPE_GRAY, - &encoded, - PNG_INTERLACE_ADAM7)); - - // decode - std::vector decoded; - int outw, outh; - ASSERT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_RGBA, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(decoded.size(), original.size() * 4); - - // Images must be equal - for (int y = 0; y < h; ++y) { - for (int x = 0; x < w; ++x) { - unsigned char gray_pixel = original[(y * w + x)]; - unsigned char* rgba_pixel = &decoded[(y * w + x) * 4]; - EXPECT_EQ(rgba_pixel[0], gray_pixel); - EXPECT_EQ(rgba_pixel[1], gray_pixel); - EXPECT_EQ(rgba_pixel[2], gray_pixel); - EXPECT_EQ(rgba_pixel[3], 0xFF); - } - } -} - -TEST(PNGCodec, DecodeInterlacedGrayscaleWithAlpha) { - const int w = 20, h = 20; - - // create an image with known values - std::vector original; - MakeGrayscaleAlphaImage(w, h, &original); - - // encode - std::vector encoded; - ASSERT_TRUE(EncodeImage(original, - w, h, - COLOR_TYPE_GRAY_ALPHA, - &encoded, - PNG_INTERLACE_ADAM7)); - - // decode - std::vector decoded; - int outw, outh; - ASSERT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_RGBA, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(decoded.size(), original.size() * 2); - - // Images must be equal - for (int y = 0; y < h; ++y) { - for (int x = 0; x < w; ++x) { - unsigned char* gray_pixel = &original[(y * w + x) * 2]; - unsigned char* rgba_pixel = &decoded[(y * w + x) * 4]; - EXPECT_EQ(rgba_pixel[0], gray_pixel[0]); - EXPECT_EQ(rgba_pixel[1], gray_pixel[0]); - EXPECT_EQ(rgba_pixel[2], gray_pixel[0]); - EXPECT_EQ(rgba_pixel[3], gray_pixel[1]); - } - } -} - -TEST(PNGCodec, DecodeInterlacedRGB) { - const int w = 20, h = 20; - - // create an image with known values - std::vector original; - MakeRGBImage(w, h, &original); - - // encode - std::vector encoded; - ASSERT_TRUE(EncodeImage(original, - w, h, - COLOR_TYPE_RGB, - &encoded, - PNG_INTERLACE_ADAM7)); - - // decode, it should have the same size as the original - std::vector decoded; - int outw, outh; - ASSERT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_RGB, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(original.size(), decoded.size()); - - // Images must be equal - ASSERT_EQ(original, decoded); -} - -TEST(PNGCodec, DecodeInterlacedRGBA) { - const int w = 20, h = 20; - - // create an image with known values - std::vector original; - MakeRGBAImage(w, h, false, &original); - - // encode - std::vector encoded; - ASSERT_TRUE(EncodeImage(original, - w, h, - COLOR_TYPE_RGBA, - &encoded, - PNG_INTERLACE_ADAM7)); - - // decode, it should have the same size as the original - std::vector decoded; - int outw, outh; - ASSERT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_RGBA, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(original.size(), decoded.size()); - - // Images must be equal - ASSERT_EQ(original, decoded); -} - -TEST(PNGCodec, DecodeInterlacedRGBADiscardAlpha) { - const int w = 20, h = 20; - - // create an image with known values - std::vector original; - MakeRGBAImage(w, h, false, &original); - - // encode - std::vector encoded; - ASSERT_TRUE(EncodeImage(original, - w, h, - COLOR_TYPE_RGBA, - &encoded, - PNG_INTERLACE_ADAM7)); - - // decode - std::vector decoded; - int outw, outh; - ASSERT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_RGB, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(decoded.size(), w * h * 3U); - - // Images must be equal - for (int x = 0; x < w; x++) { - for (int y = 0; y < h; y++) { - unsigned char* orig_px = &original[(y * w + x) * 4]; - unsigned char* dec_px = &decoded[(y * w + x) * 3]; - EXPECT_EQ(dec_px[0], orig_px[0]); - EXPECT_EQ(dec_px[1], orig_px[1]); - EXPECT_EQ(dec_px[2], orig_px[2]); - } - } -} - -TEST(PNGCodec, DecodeInterlacedBGR) { - const int w = 20, h = 20; - - // create an image with known values - std::vector original; - MakeRGBImage(w, h, &original); - - // encode - std::vector encoded; - ASSERT_TRUE(EncodeImage(original, - w, h, - COLOR_TYPE_BGR, - &encoded, - PNG_INTERLACE_ADAM7)); - - // decode, it should have the same size as the original - std::vector decoded; - int outw, outh; - ASSERT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_BGRA, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(decoded.size(), w * h * 4U); - - // Images must be equal - for (int x = 0; x < w; x++) { - for (int y = 0; y < h; y++) { - unsigned char* orig_px = &original[(y * w + x) * 3]; - unsigned char* dec_px = &decoded[(y * w + x) * 4]; - EXPECT_EQ(dec_px[0], orig_px[0]); - EXPECT_EQ(dec_px[1], orig_px[1]); - EXPECT_EQ(dec_px[2], orig_px[2]); - } - } -} - -TEST(PNGCodec, DecodeInterlacedBGRA) { - const int w = 20, h = 20; - - // create an image with known values - std::vector original; - MakeRGBAImage(w, h, false, &original); - - // encode - std::vector encoded; - ASSERT_TRUE(EncodeImage(original, - w, h, - COLOR_TYPE_BGRA, - &encoded, - PNG_INTERLACE_ADAM7)); - - // decode, it should have the same size as the original - std::vector decoded; - int outw, outh; - ASSERT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_BGRA, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(original.size(), decoded.size()); - - // Images must be equal - ASSERT_EQ(original, decoded); -} - -// Not encoding an interlaced PNG from SkBitmap because we don't do it -// anywhere, and the ability to do that requires more code changes. -TEST(PNGCodec, DecodeInterlacedRGBtoSkBitmap) { - const int w = 20, h = 20; - - // create an image with known values - std::vector original; - MakeRGBImage(w, h, &original); - - // encode - std::vector encoded; - ASSERT_TRUE(EncodeImage(original, - w, h, - COLOR_TYPE_RGB, - &encoded, - PNG_INTERLACE_ADAM7)); - - // Decode the encoded string. - SkBitmap decoded_bitmap; - ASSERT_TRUE(PNGCodec::Decode(&encoded.front(), encoded.size(), - &decoded_bitmap)); - - for (int x = 0; x < w; x++) { - for (int y = 0; y < h; y++) { - const unsigned char* original_pixel = &original[(y * w + x) * 3]; - const uint32_t original_pixel_sk = SkPackARGB32(0xFF, - original_pixel[0], - original_pixel[1], - original_pixel[2]); - const uint32_t decoded_pixel = decoded_bitmap.getAddr32(0, y)[x]; - EXPECT_EQ(original_pixel_sk, decoded_pixel); - } - } -} - -TEST(PNGCodec, DecodeInterlacedRGBAtoSkBitmap) { - const int w = 20, h = 20; - - // create an image with known values - std::vector original; - MakeRGBAImage(w, h, false, &original); - - // encode - std::vector encoded; - ASSERT_TRUE(EncodeImage(original, - w, h, - COLOR_TYPE_RGBA, - &encoded, - PNG_INTERLACE_ADAM7)); - - // Decode the encoded string. - SkBitmap decoded_bitmap; - ASSERT_TRUE(PNGCodec::Decode(&encoded.front(), encoded.size(), - &decoded_bitmap)); - - for (int x = 0; x < w; x++) { - for (int y = 0; y < h; y++) { - const unsigned char* original_pixel = &original[(y * w + x) * 4]; - const uint32_t original_pixel_sk = SkPackARGB32(original_pixel[3], - original_pixel[0], - original_pixel[1], - original_pixel[2]); - const uint32_t decoded_pixel = decoded_bitmap.getAddr32(0, y)[x]; - EXPECT_EQ(original_pixel_sk, decoded_pixel); - } - } -} - -// Test that corrupted data decompression causes failures. -TEST(PNGCodec, DecodeCorrupted) { - int w = 20, h = 20; - - // Make some random data (an uncompressed image). - std::vector original; - MakeRGBImage(w, h, &original); - - // It should fail when given non-JPEG compressed data. - std::vector output; - int outw, outh; - EXPECT_FALSE(PNGCodec::Decode(&original[0], original.size(), - PNGCodec::FORMAT_RGB, &output, - &outw, &outh)); - - // Make some compressed data. - std::vector compressed; - ASSERT_TRUE(PNGCodec::Encode(&original[0], PNGCodec::FORMAT_RGB, - Size(w, h), w * 3, false, - std::vector(), - &compressed)); - - // Try decompressing a truncated version. - EXPECT_FALSE(PNGCodec::Decode(&compressed[0], compressed.size() / 2, - PNGCodec::FORMAT_RGB, &output, - &outw, &outh)); - - // Corrupt it and try decompressing that. - for (int i = 10; i < 30; i++) - compressed[i] = i; - EXPECT_FALSE(PNGCodec::Decode(&compressed[0], compressed.size(), - PNGCodec::FORMAT_RGB, &output, - &outw, &outh)); -} - -TEST(PNGCodec, StripAddAlpha) { - const int w = 20, h = 20; - - // These should be the same except one has a 0xff alpha channel. - std::vector original_rgb; - MakeRGBImage(w, h, &original_rgb); - std::vector original_rgba; - MakeRGBAImage(w, h, false, &original_rgba); - - // Encode RGBA data as RGB. - std::vector encoded; - EXPECT_TRUE(PNGCodec::Encode(&original_rgba[0], PNGCodec::FORMAT_RGBA, - Size(w, h), w * 4, true, - std::vector(), - &encoded)); - - // Decode the RGB to RGBA. - std::vector decoded; - int outw, outh; - EXPECT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_RGBA, &decoded, - &outw, &outh)); - - // Decoded and reference should be the same (opaque alpha). - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(original_rgba.size(), decoded.size()); - ASSERT_EQ(original_rgba, decoded); - - // Encode RGBA to RGBA. - EXPECT_TRUE(PNGCodec::Encode(&original_rgba[0], PNGCodec::FORMAT_RGBA, - Size(w, h), w * 4, false, - std::vector(), - &encoded)); - - // Decode the RGBA to RGB. - EXPECT_TRUE(PNGCodec::Decode(&encoded[0], encoded.size(), - PNGCodec::FORMAT_RGB, &decoded, - &outw, &outh)); - - // It should be the same as our non-alpha-channel reference. - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(original_rgb.size(), decoded.size()); - ASSERT_EQ(original_rgb, decoded); -} - -TEST(PNGCodec, EncodeBGRASkBitmapStridePadded) { - const int kWidth = 20; - const int kHeight = 20; - const int kPaddedWidth = 32; - const int kBytesPerPixel = 4; - const int kPaddedSize = kPaddedWidth * kHeight; - const int kRowBytes = kPaddedWidth * kBytesPerPixel; - - SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight); - SkBitmap original_bitmap; - original_bitmap.setInfo(info, kRowBytes); - original_bitmap.allocPixels(); - - // Write data over the source bitmap. - // We write on the pad area here too. - // The encoder should ignore the pad area. - uint32_t* src_data = original_bitmap.getAddr32(0, 0); - for (int i = 0; i < kPaddedSize; i++) { - src_data[i] = SkPreMultiplyARGB(i % 255, i % 250, i % 245, i % 240); - } - - // Encode the bitmap. - std::vector encoded; - PNGCodec::EncodeBGRASkBitmap(original_bitmap, false, &encoded); - - // Decode the encoded string. - SkBitmap decoded_bitmap; - EXPECT_TRUE(PNGCodec::Decode(&encoded.front(), encoded.size(), - &decoded_bitmap)); - - // Compare the original bitmap and the output bitmap. We use ColorsClose - // as SkBitmaps are considered to be pre-multiplied, the unpremultiplication - // (in Encode) and repremultiplication (in Decode) can be lossy. - for (int x = 0; x < kWidth; x++) { - for (int y = 0; y < kHeight; y++) { - uint32_t original_pixel = original_bitmap.getAddr32(0, y)[x]; - uint32_t decoded_pixel = decoded_bitmap.getAddr32(0, y)[x]; - EXPECT_TRUE(ColorsClose(original_pixel, decoded_pixel)); - } - } -} - -TEST(PNGCodec, EncodeBGRASkBitmap) { - const int w = 20, h = 20; - - SkBitmap original_bitmap; - MakeTestBGRASkBitmap(w, h, &original_bitmap); - - // Encode the bitmap. - std::vector encoded; - PNGCodec::EncodeBGRASkBitmap(original_bitmap, false, &encoded); - - // Decode the encoded string. - SkBitmap decoded_bitmap; - EXPECT_TRUE(PNGCodec::Decode(&encoded.front(), encoded.size(), - &decoded_bitmap)); - - // Compare the original bitmap and the output bitmap. We use ColorsClose - // as SkBitmaps are considered to be pre-multiplied, the unpremultiplication - // (in Encode) and repremultiplication (in Decode) can be lossy. - for (int x = 0; x < w; x++) { - for (int y = 0; y < h; y++) { - uint32_t original_pixel = original_bitmap.getAddr32(0, y)[x]; - uint32_t decoded_pixel = decoded_bitmap.getAddr32(0, y)[x]; - EXPECT_TRUE(ColorsClose(original_pixel, decoded_pixel)); - } - } -} - -TEST(PNGCodec, EncodeA8SkBitmap) { - const int w = 20, h = 20; - - SkBitmap original_bitmap; - MakeTestA8SkBitmap(w, h, &original_bitmap); - - // Encode the bitmap. - std::vector encoded; - EXPECT_TRUE(PNGCodec::EncodeA8SkBitmap(original_bitmap, &encoded)); - - // Decode the encoded string. - SkBitmap decoded_bitmap; - EXPECT_TRUE(PNGCodec::Decode(&encoded.front(), encoded.size(), - &decoded_bitmap)); - - for (int x = 0; x < w; x++) { - for (int y = 0; y < h; y++) { - uint8_t original_pixel = *original_bitmap.getAddr8(x, y); - uint32_t decoded_pixel = *decoded_bitmap.getAddr32(x, y); - EXPECT_TRUE(BGRAGrayEqualsA8Gray(decoded_pixel, original_pixel)); - } - } -} - -TEST(PNGCodec, EncodeBGRASkBitmapDiscardTransparency) { - const int w = 20, h = 20; - - SkBitmap original_bitmap; - MakeTestBGRASkBitmap(w, h, &original_bitmap); - - // Encode the bitmap. - std::vector encoded; - PNGCodec::EncodeBGRASkBitmap(original_bitmap, true, &encoded); - - // Decode the encoded string. - SkBitmap decoded_bitmap; - EXPECT_TRUE(PNGCodec::Decode(&encoded.front(), encoded.size(), - &decoded_bitmap)); - - // Compare the original bitmap and the output bitmap. We need to - // unpremultiply original_pixel, as the decoded bitmap doesn't have an alpha - // channel. - for (int x = 0; x < w; x++) { - for (int y = 0; y < h; y++) { - uint32_t original_pixel = original_bitmap.getAddr32(0, y)[x]; - uint32_t unpremultiplied = - SkUnPreMultiply::PMColorToColor(original_pixel); - uint32_t decoded_pixel = decoded_bitmap.getAddr32(0, y)[x]; - uint32_t unpremultiplied_decoded = - SkUnPreMultiply::PMColorToColor(decoded_pixel); - - EXPECT_TRUE(NonAlphaColorsClose(unpremultiplied, unpremultiplied_decoded)) - << "Original_pixel: (" - << SkColorGetR(unpremultiplied) << ", " - << SkColorGetG(unpremultiplied) << ", " - << SkColorGetB(unpremultiplied) << "), " - << "Decoded pixel: (" - << SkColorGetR(unpremultiplied_decoded) << ", " - << SkColorGetG(unpremultiplied_decoded) << ", " - << SkColorGetB(unpremultiplied_decoded) << ")"; - } - } -} - -TEST(PNGCodec, EncodeWithComment) { - const int w = 10, h = 10; - - std::vector original; - MakeRGBImage(w, h, &original); - - std::vector encoded; - std::vector comments; - comments.push_back(PNGCodec::Comment("key", "text")); - comments.push_back(PNGCodec::Comment("test", "something")); - comments.push_back(PNGCodec::Comment("have some", "spaces in both")); - EXPECT_TRUE(PNGCodec::Encode(&original[0], PNGCodec::FORMAT_RGB, - Size(w, h), w * 3, false, comments, &encoded)); - - // Each chunk is of the form length (4 bytes), chunk type (tEXt), data, - // checksum (4 bytes). Make sure we find all of them in the encoded - // results. - const unsigned char kExpected1[] = - "\x00\x00\x00\x08tEXtkey\x00text\x9e\xe7\x66\x51"; - const unsigned char kExpected2[] = - "\x00\x00\x00\x0etEXttest\x00something\x29\xba\xef\xac"; - const unsigned char kExpected3[] = - "\x00\x00\x00\x18tEXthave some\x00spaces in both\x8d\x69\x34\x2d"; - - EXPECT_NE(std::search(encoded.begin(), encoded.end(), kExpected1, - kExpected1 + arraysize(kExpected1)), - encoded.end()); - EXPECT_NE(std::search(encoded.begin(), encoded.end(), kExpected2, - kExpected2 + arraysize(kExpected2)), - encoded.end()); - EXPECT_NE(std::search(encoded.begin(), encoded.end(), kExpected3, - kExpected3 + arraysize(kExpected3)), - encoded.end()); -} - -TEST(PNGCodec, EncodeDecodeWithVaryingCompressionLevels) { - const int w = 20, h = 20; - - // create an image with known values, a must be opaque because it will be - // lost during encoding - SkBitmap original_bitmap; - MakeTestBGRASkBitmap(w, h, &original_bitmap); - - // encode - std::vector encoded_normal; - EXPECT_TRUE( - PNGCodec::EncodeBGRASkBitmap(original_bitmap, false, &encoded_normal)); - - std::vector encoded_fast; - EXPECT_TRUE( - PNGCodec::FastEncodeBGRASkBitmap(original_bitmap, false, &encoded_fast)); - - // Make sure the different compression settings actually do something; the - // sizes should be different. - EXPECT_NE(encoded_normal.size(), encoded_fast.size()); - - // decode, they should be identical to the original. - SkBitmap decoded; - EXPECT_TRUE( - PNGCodec::Decode(&encoded_normal[0], encoded_normal.size(), &decoded)); - EXPECT_TRUE(BitmapsAreEqual(decoded, original_bitmap)); - - EXPECT_TRUE( - PNGCodec::Decode(&encoded_fast[0], encoded_fast.size(), &decoded)); - EXPECT_TRUE(BitmapsAreEqual(decoded, original_bitmap)); -} - - -} // namespace gfx diff --git a/ui/gfx/geometry/BUILD.gn b/ui/gfx/geometry/BUILD.gn deleted file mode 100644 index 086333036..000000000 --- a/ui/gfx/geometry/BUILD.gn +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright 2014 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. - -component("geometry") { - sources = [ - "../gfx_export.h", - "box_f.cc", - "box_f.h", - "cubic_bezier.h", - "cubic_bezier.cc", - "insets.cc", - "insets.h", - "insets_base.h", - "insets_f.cc", - "insets_f.h", - "matrix3_f.cc", - "matrix3_f.h", - "point.cc", - "point.h", - "point3_f.cc", - "point3_f.h", - "point_conversions.cc", - "point_conversions.h", - "point_f.cc", - "point_f.h", - "quad_f.cc", - "quad_f.h", - "rect.cc", - "rect.h", - "rect_conversions.cc", - "rect_conversions.h", - "rect_f.cc", - "rect_f.h", - "r_tree.h", - "r_tree_base.cc", - "r_tree_base.h", - "safe_integer_conversions.h", - "scroll_offset.cc", - "scroll_offset.h", - "size.cc", - "size.h", - "size_conversions.cc", - "size_conversions.h", - "size_f.cc", - "size_f.h", - "vector2d.cc", - "vector2d.h", - "vector2d_conversions.cc", - "vector2d_conversions.h", - "vector2d_f.cc", - "vector2d_f.h", - "vector3d_f.cc", - "vector3d_f.h", - ] - - defines = [ "GFX_IMPLEMENTATION" ] - - deps = [ - "//base", - "//ui/gfx:gfx_export", - ] - - # TODO(jdduke): Revisit optimization after gauging benefit, crbug/419051. - if (is_android && !is_debug) { - configs -= [ "//build/config/compiler:optimize" ] - configs += [ "//build/config/compiler:optimize_max" ] - } -} diff --git a/ui/gfx/geometry/box_f.cc b/ui/gfx/geometry/box_f.cc deleted file mode 100644 index 674bb509c..000000000 --- a/ui/gfx/geometry/box_f.cc +++ /dev/null @@ -1,70 +0,0 @@ -// 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. - -#include "ui/gfx/geometry/box_f.h" - -#include - -#include "base/logging.h" -#include "base/strings/stringprintf.h" - -namespace gfx { - -std::string BoxF::ToString() const { - return base::StringPrintf("%s %fx%fx%f", - origin().ToString().c_str(), - width_, - height_, - depth_); -} - -bool BoxF::IsEmpty() const { - return (width_ == 0 && height_ == 0) || - (width_ == 0 && depth_ == 0) || - (height_ == 0 && depth_ == 0); -} - -void BoxF::ExpandTo(const Point3F& min, const Point3F& max) { - DCHECK_LE(min.x(), max.x()); - DCHECK_LE(min.y(), max.y()); - DCHECK_LE(min.z(), max.z()); - - float min_x = std::min(x(), min.x()); - float min_y = std::min(y(), min.y()); - float min_z = std::min(z(), min.z()); - float max_x = std::max(right(), max.x()); - float max_y = std::max(bottom(), max.y()); - float max_z = std::max(front(), max.z()); - - origin_.SetPoint(min_x, min_y, min_z); - width_ = max_x - min_x; - height_ = max_y - min_y; - depth_ = max_z - min_z; -} - -void BoxF::Union(const BoxF& box) { - if (IsEmpty()) { - *this = box; - return; - } - if (box.IsEmpty()) - return; - ExpandTo(box); -} - -void BoxF::ExpandTo(const Point3F& point) { - ExpandTo(point, point); -} - -void BoxF::ExpandTo(const BoxF& box) { - ExpandTo(box.origin(), gfx::Point3F(box.right(), box.bottom(), box.front())); -} - -BoxF UnionBoxes(const BoxF& a, const BoxF& b) { - BoxF result = a; - result.Union(b); - return result; -} - -} // namespace gfx diff --git a/ui/gfx/geometry/box_f.h b/ui/gfx/geometry/box_f.h deleted file mode 100644 index deb359abd..000000000 --- a/ui/gfx/geometry/box_f.h +++ /dev/null @@ -1,168 +0,0 @@ -// 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. - -#ifndef UI_GFX_GEOMETRY_BOX_F_H_ -#define UI_GFX_GEOMETRY_BOX_F_H_ - -#include -#include - -#include "ui/gfx/geometry/point3_f.h" -#include "ui/gfx/geometry/vector3d_f.h" - -namespace gfx { - -// A 3d version of gfx::RectF, with the positive z-axis pointed towards -// the camera. -class GFX_EXPORT BoxF { - public: - BoxF() - : width_(0.f), - height_(0.f), - depth_(0.f) {} - - BoxF(float width, float height, float depth) - : width_(width < 0 ? 0 : width), - height_(height < 0 ? 0 : height), - depth_(depth < 0 ? 0 : depth) {} - - BoxF(float x, float y, float z, float width, float height, float depth) - : origin_(x, y, z), - width_(width < 0 ? 0 : width), - height_(height < 0 ? 0 : height), - depth_(depth < 0 ? 0 : depth) {} - - BoxF(const Point3F& origin, float width, float height, float depth) - : origin_(origin), - width_(width < 0 ? 0 : width), - height_(height < 0 ? 0 : height), - depth_(depth < 0 ? 0 : depth) {} - - ~BoxF() {} - - // Scales all three axes by the given scale. - void Scale(float scale) { - Scale(scale, scale, scale); - } - - // Scales each axis by the corresponding given scale. - void Scale(float x_scale, float y_scale, float z_scale) { - origin_.Scale(x_scale, y_scale, z_scale); - set_size(width_ * x_scale, height_ * y_scale, depth_ * z_scale); - } - - // Moves the box by the specified distance in each dimension. - void operator+=(const Vector3dF& offset) { - origin_ += offset; - } - - // Returns true if the box has no interior points. - bool IsEmpty() const; - - // Computes the union of this box with the given box. The union is the - // smallest box that contains both boxes. - void Union(const BoxF& box); - - std::string ToString() const; - - float x() const { return origin_.x(); } - void set_x(float x) { origin_.set_x(x); } - - float y() const { return origin_.y(); } - void set_y(float y) { origin_.set_y(y); } - - float z() const { return origin_.z(); } - void set_z(float z) { origin_.set_z(z); } - - float width() const { return width_; } - void set_width(float width) { width_ = width < 0 ? 0 : width; } - - float height() const { return height_; } - void set_height(float height) { height_ = height < 0 ? 0 : height; } - - float depth() const { return depth_; } - void set_depth(float depth) { depth_ = depth < 0 ? 0 : depth; } - - float right() const { return x() + width(); } - float bottom() const { return y() + height(); } - float front() const { return z() + depth(); } - - void set_size(float width, float height, float depth) { - width_ = width < 0 ? 0 : width; - height_ = height < 0 ? 0 : height; - depth_ = depth < 0 ? 0 : depth; - } - - const Point3F& origin() const { return origin_; } - void set_origin(const Point3F& origin) { origin_ = origin; } - - // Expands |this| to contain the given point, if necessary. Please note, even - // if |this| is empty, after the function |this| will continue to contain its - // |origin_|. - void ExpandTo(const Point3F& point); - - // Expands |this| to contain the given box, if necessary. Please note, even - // if |this| is empty, after the function |this| will continue to contain its - // |origin_|. - void ExpandTo(const BoxF& box); - - private: - // Expands the box to contain the two given points. It is required that each - // component of |min| is less than or equal to the corresponding component in - // |max|. Precisely, what this function does is ensure that after the function - // completes, |this| contains origin_, min, max, and origin_ + (width_, - // height_, depth_), even if the box is empty. Emptiness checks are handled in - // the public function Union. - void ExpandTo(const Point3F& min, const Point3F& max); - - Point3F origin_; - float width_; - float height_; - float depth_; -}; - -GFX_EXPORT BoxF UnionBoxes(const BoxF& a, const BoxF& b); - -inline BoxF ScaleBox(const BoxF& b, - float x_scale, - float y_scale, - float z_scale) { - return BoxF(b.x() * x_scale, - b.y() * y_scale, - b.z() * z_scale, - b.width() * x_scale, - b.height() * y_scale, - b.depth() * z_scale); -} - -inline BoxF ScaleBox(const BoxF& b, float scale) { - return ScaleBox(b, scale, scale, scale); -} - -inline bool operator==(const BoxF& a, const BoxF& b) { - return a.origin() == b.origin() && a.width() == b.width() && - a.height() == b.height() && a.depth() == b.depth(); -} - -inline bool operator!=(const BoxF& a, const BoxF& b) { - return !(a == b); -} - -inline BoxF operator+(const BoxF& b, const Vector3dF& v) { - return BoxF(b.x() + v.x(), - b.y() + v.y(), - b.z() + v.z(), - b.width(), - b.height(), - b.depth()); -} - -// This is declared here for use in gtest-based unit tests but is defined in -// the gfx_test_support target. Depend on that to use this in your unit test. -// This should not be used in production code - call ToString() instead. -void PrintTo(const BoxF& box, ::std::ostream* os); - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_BOX_F_H_ diff --git a/ui/gfx/geometry/box_unittest.cc b/ui/gfx/geometry/box_unittest.cc deleted file mode 100644 index 449c50f9a..000000000 --- a/ui/gfx/geometry/box_unittest.cc +++ /dev/null @@ -1,176 +0,0 @@ -// 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. - -#include "base/basictypes.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/gfx/geometry/box_f.h" - -namespace gfx { - -TEST(BoxTest, Constructors) { - EXPECT_EQ(BoxF(0.f, 0.f, 0.f, 0.f, 0.f, 0.f).ToString(), - BoxF().ToString()); - EXPECT_EQ(BoxF(0.f, 0.f, 0.f, -3.f, -5.f, -7.f).ToString(), - BoxF().ToString()); - - EXPECT_EQ(BoxF(0.f, 0.f, 0.f, 3.f, 5.f, 7.f).ToString(), - BoxF(3.f, 5.f, 7.f).ToString()); - EXPECT_EQ(BoxF(0.f, 0.f, 0.f, 0.f, 0.f, 0.f).ToString(), - BoxF(-3.f, -5.f, -7.f).ToString()); - - EXPECT_EQ(BoxF(2.f, 4.f, 6.f, 3.f, 5.f, 7.f).ToString(), - BoxF(Point3F(2.f, 4.f, 6.f), 3.f, 5.f, 7.f).ToString()); - EXPECT_EQ(BoxF(2.f, 4.f, 6.f, 0.f, 0.f, 0.f).ToString(), - BoxF(Point3F(2.f, 4.f, 6.f), -3.f, -5.f, -7.f).ToString()); -} - -TEST(BoxTest, IsEmpty) { - EXPECT_TRUE(BoxF(0.f, 0.f, 0.f, 0.f, 0.f, 0.f).IsEmpty()); - EXPECT_TRUE(BoxF(1.f, 2.f, 3.f, 0.f, 0.f, 0.f).IsEmpty()); - - EXPECT_TRUE(BoxF(0.f, 0.f, 0.f, 2.f, 0.f, 0.f).IsEmpty()); - EXPECT_TRUE(BoxF(1.f, 2.f, 3.f, 2.f, 0.f, 0.f).IsEmpty()); - EXPECT_TRUE(BoxF(0.f, 0.f, 0.f, 0.f, 2.f, 0.f).IsEmpty()); - EXPECT_TRUE(BoxF(1.f, 2.f, 3.f, 0.f, 2.f, 0.f).IsEmpty()); - EXPECT_TRUE(BoxF(0.f, 0.f, 0.f, 0.f, 0.f, 2.f).IsEmpty()); - EXPECT_TRUE(BoxF(1.f, 2.f, 3.f, 0.f, 0.f, 2.f).IsEmpty()); - - EXPECT_FALSE(BoxF(0.f, 0.f, 0.f, 0.f, 2.f, 2.f).IsEmpty()); - EXPECT_FALSE(BoxF(1.f, 2.f, 3.f, 0.f, 2.f, 2.f).IsEmpty()); - EXPECT_FALSE(BoxF(0.f, 0.f, 0.f, 2.f, 0.f, 2.f).IsEmpty()); - EXPECT_FALSE(BoxF(1.f, 2.f, 3.f, 2.f, 0.f, 2.f).IsEmpty()); - EXPECT_FALSE(BoxF(0.f, 0.f, 0.f, 2.f, 2.f, 0.f).IsEmpty()); - EXPECT_FALSE(BoxF(1.f, 2.f, 3.f, 2.f, 2.f, 0.f).IsEmpty()); - - EXPECT_FALSE(BoxF(0.f, 0.f, 0.f, 2.f, 2.f, 2.f).IsEmpty()); - EXPECT_FALSE(BoxF(1.f, 2.f, 3.f, 2.f, 2.f, 2.f).IsEmpty()); -} - -TEST(BoxTest, Union) { - BoxF empty_box; - BoxF box1(0.f, 0.f, 0.f, 1.f, 1.f, 1.f); - BoxF box2(0.f, 0.f, 0.f, 4.f, 6.f, 8.f); - BoxF box3(3.f, 4.f, 5.f, 6.f, 4.f, 0.f); - - EXPECT_EQ(empty_box.ToString(), UnionBoxes(empty_box, empty_box).ToString()); - EXPECT_EQ(box1.ToString(), UnionBoxes(empty_box, box1).ToString()); - EXPECT_EQ(box1.ToString(), UnionBoxes(box1, empty_box).ToString()); - EXPECT_EQ(box2.ToString(), UnionBoxes(empty_box, box2).ToString()); - EXPECT_EQ(box2.ToString(), UnionBoxes(box2, empty_box).ToString()); - EXPECT_EQ(box3.ToString(), UnionBoxes(empty_box, box3).ToString()); - EXPECT_EQ(box3.ToString(), UnionBoxes(box3, empty_box).ToString()); - - // box_1 is contained in box_2 - EXPECT_EQ(box2.ToString(), UnionBoxes(box1, box2).ToString()); - EXPECT_EQ(box2.ToString(), UnionBoxes(box2, box1).ToString()); - - // box_1 and box_3 are disjoint - EXPECT_EQ(BoxF(0.f, 0.f, 0.f, 9.f, 8.f, 5.f).ToString(), - UnionBoxes(box1, box3).ToString()); - EXPECT_EQ(BoxF(0.f, 0.f, 0.f, 9.f, 8.f, 5.f).ToString(), - UnionBoxes(box3, box1).ToString()); - - // box_2 and box_3 intersect, but neither contains the other - EXPECT_EQ(BoxF(0.f, 0.f, 0.f, 9.f, 8.f, 8.f).ToString(), - UnionBoxes(box2, box3).ToString()); - EXPECT_EQ(BoxF(0.f, 0.f, 0.f, 9.f, 8.f, 8.f).ToString(), - UnionBoxes(box3, box2).ToString()); -} - -TEST(BoxTest, ExpandTo) { - BoxF box1; - BoxF box2(0.f, 0.f, 0.f, 1.f, 1.f, 1.f); - BoxF box3(1.f, 1.f, 1.f, 0.f, 0.f, 0.f); - - Point3F point1(0.5f, 0.5f, 0.5f); - Point3F point2(-0.5f, -0.5f, -0.5f); - - BoxF expected1_1(0.f, 0.f, 0.f, 0.5f, 0.5f, 0.5f); - BoxF expected1_2(-0.5f, -0.5f, -0.5f, 1.f, 1.f, 1.f); - - BoxF expected2_1 = box2; - BoxF expected2_2(-0.5f, -0.5f, -0.5f, 1.5f, 1.5f, 1.5f); - - BoxF expected3_1(0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f); - BoxF expected3_2(-0.5f, -0.5f, -0.5f, 1.5f, 1.5f, 1.5f); - - box1.ExpandTo(point1); - EXPECT_EQ(expected1_1.ToString(), box1.ToString()); - box1.ExpandTo(point2); - EXPECT_EQ(expected1_2.ToString(), box1.ToString()); - - box2.ExpandTo(point1); - EXPECT_EQ(expected2_1.ToString(), box2.ToString()); - box2.ExpandTo(point2); - EXPECT_EQ(expected2_2.ToString(), box2.ToString()); - - box3.ExpandTo(point1); - EXPECT_EQ(expected3_1.ToString(), box3.ToString()); - box3.ExpandTo(point2); - EXPECT_EQ(expected3_2.ToString(), box3.ToString()); -} - -TEST(BoxTest, Scale) { - BoxF box1(2.f, 3.f, 4.f, 5.f, 6.f, 7.f); - - EXPECT_EQ(BoxF().ToString(), ScaleBox(box1, 0.f).ToString()); - EXPECT_EQ(box1.ToString(), ScaleBox(box1, 1.f).ToString()); - EXPECT_EQ(BoxF(4.f, 12.f, 24.f, 10.f, 24.f, 42.f).ToString(), - ScaleBox(box1, 2.f, 4.f, 6.f).ToString()); - - BoxF box2 = box1; - box2.Scale(0.f); - EXPECT_EQ(BoxF().ToString(), box2.ToString()); - - box2 = box1; - box2.Scale(1.f); - EXPECT_EQ(box1.ToString(), box2.ToString()); - - box2.Scale(2.f, 4.f, 6.f); - EXPECT_EQ(BoxF(4.f, 12.f, 24.f, 10.f, 24.f, 42.f).ToString(), - box2.ToString()); -} - -TEST(BoxTest, Equals) { - EXPECT_TRUE(BoxF() == BoxF()); - EXPECT_TRUE(BoxF(2.f, 3.f, 4.f, 6.f, 8.f, 10.f) == - BoxF(2.f, 3.f, 4.f, 6.f, 8.f, 10.f)); - EXPECT_FALSE(BoxF() == BoxF(0.f, 0.f, 0.f, 0.f, 0.f, 1.f)); - EXPECT_FALSE(BoxF() == BoxF(0.f, 0.f, 0.f, 0.f, 1.f, 0.f)); - EXPECT_FALSE(BoxF() == BoxF(0.f, 0.f, 0.f, 1.f, 0.f, 0.f)); - EXPECT_FALSE(BoxF() == BoxF(0.f, 0.f, 1.f, 0.f, 0.f, 0.f)); - EXPECT_FALSE(BoxF() == BoxF(0.f, 1.f, 0.f, 0.f, 0.f, 0.f)); - EXPECT_FALSE(BoxF() == BoxF(1.f, 0.f, 0.f, 0.f, 0.f, 0.f)); -} - -TEST(BoxTest, NotEquals) { - EXPECT_FALSE(BoxF() != BoxF()); - EXPECT_FALSE(BoxF(2.f, 3.f, 4.f, 6.f, 8.f, 10.f) != - BoxF(2.f, 3.f, 4.f, 6.f, 8.f, 10.f)); - EXPECT_TRUE(BoxF() != BoxF(0.f, 0.f, 0.f, 0.f, 0.f, 1.f)); - EXPECT_TRUE(BoxF() != BoxF(0.f, 0.f, 0.f, 0.f, 1.f, 0.f)); - EXPECT_TRUE(BoxF() != BoxF(0.f, 0.f, 0.f, 1.f, 0.f, 0.f)); - EXPECT_TRUE(BoxF() != BoxF(0.f, 0.f, 1.f, 0.f, 0.f, 0.f)); - EXPECT_TRUE(BoxF() != BoxF(0.f, 1.f, 0.f, 0.f, 0.f, 0.f)); - EXPECT_TRUE(BoxF() != BoxF(1.f, 0.f, 0.f, 0.f, 0.f, 0.f)); -} - - -TEST(BoxTest, Offset) { - BoxF box1(2.f, 3.f, 4.f, 5.f, 6.f, 7.f); - - EXPECT_EQ(box1.ToString(), (box1 + Vector3dF(0.f, 0.f, 0.f)).ToString()); - EXPECT_EQ(BoxF(3.f, 1.f, 0.f, 5.f, 6.f, 7.f).ToString(), - (box1 + Vector3dF(1.f, -2.f, -4.f)).ToString()); - - BoxF box2 = box1; - box2 += Vector3dF(0.f, 0.f, 0.f); - EXPECT_EQ(box1.ToString(), box2.ToString()); - - box2 += Vector3dF(1.f, -2.f, -4.f); - EXPECT_EQ(BoxF(3.f, 1.f, 0.f, 5.f, 6.f, 7.f).ToString(), - box2.ToString()); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/cubic_bezier.cc b/ui/gfx/geometry/cubic_bezier.cc deleted file mode 100644 index f9f786e73..000000000 --- a/ui/gfx/geometry/cubic_bezier.cc +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2014 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 "ui/gfx/geometry/cubic_bezier.h" - -#include -#include - -#include "base/logging.h" - -namespace gfx { - -namespace { - -static const double kBezierEpsilon = 1e-7; -static const int MAX_STEPS = 30; - -static double eval_bezier(double p1, double p2, double t) { - const double p1_times_3 = 3.0 * p1; - const double p2_times_3 = 3.0 * p2; - const double h3 = p1_times_3; - const double h1 = p1_times_3 - p2_times_3 + 1.0; - const double h2 = p2_times_3 - 6.0 * p1; - return t * (t * (t * h1 + h2) + h3); -} - -static double eval_bezier_derivative(double p1, double p2, double t) { - const double h1 = 9.0 * p1 - 9.0 * p2 + 3.0; - const double h2 = 6.0 * p2 - 12.0 * p1; - const double h3 = 3.0 * p1; - return t * (t * h1 + h2) + h3; -} - -// Finds t such that eval_bezier(x1, x2, t) = x. -// There is a unique solution if x1 and x2 lie within (0, 1). -static double bezier_interp(double x1, - double x2, - double x) { - DCHECK_GE(1.0, x1); - DCHECK_LE(0.0, x1); - DCHECK_GE(1.0, x2); - DCHECK_LE(0.0, x2); - - x1 = std::min(std::max(x1, 0.0), 1.0); - x2 = std::min(std::max(x2, 0.0), 1.0); - x = std::min(std::max(x, 0.0), 1.0); - - // We're just going to do bisection for now (for simplicity), but we could - // easily do some newton steps if this turns out to be a bottleneck. - double t = 0.0; - double step = 1.0; - for (int i = 0; i < MAX_STEPS; ++i, step *= 0.5) { - const double error = eval_bezier(x1, x2, t) - x; - if (std::abs(error) < kBezierEpsilon) - break; - t += error > 0.0 ? -step : step; - } - - // We should have terminated the above loop because we got close to x, not - // because we exceeded MAX_STEPS. Do a DCHECK here to confirm. - DCHECK_GT(kBezierEpsilon, std::abs(eval_bezier(x1, x2, t) - x)); - - return t; -} - -} // namespace - -CubicBezier::CubicBezier(double x1, double y1, double x2, double y2) - : x1_(x1), - y1_(y1), - x2_(x2), - y2_(y2) { -} - -CubicBezier::~CubicBezier() { -} - -double CubicBezier::Solve(double x) const { - return eval_bezier(y1_, y2_, bezier_interp(x1_, x2_, x)); -} - -double CubicBezier::Slope(double x) const { - double t = bezier_interp(x1_, x2_, x); - double dx_dt = eval_bezier_derivative(x1_, x2_, t); - double dy_dt = eval_bezier_derivative(y1_, y2_, t); - return dy_dt / dx_dt; -} - -void CubicBezier::Range(double* min, double* max) const { - *min = 0; - *max = 1; - if (0 <= y1_ && y1_ < 1 && 0 <= y2_ && y2_ <= 1) - return; - - // Represent the function's derivative in the form at^2 + bt + c. - // (Technically this is (dy/dt)*(1/3), which is suitable for finding zeros - // but does not actually give the slope of the curve.) - double a = 3 * (y1_ - y2_) + 1; - double b = 2 * (y2_ - 2 * y1_); - double c = y1_; - - // Check if the derivative is constant. - if (std::abs(a) < kBezierEpsilon && - std::abs(b) < kBezierEpsilon) - return; - - // Zeros of the function's derivative. - double t_1 = 0; - double t_2 = 0; - - if (std::abs(a) < kBezierEpsilon) { - // The function's derivative is linear. - t_1 = -c / b; - } else { - // The function's derivative is a quadratic. We find the zeros of this - // quadratic using the quadratic formula. - double discriminant = b * b - 4 * a * c; - if (discriminant < 0) - return; - double discriminant_sqrt = sqrt(discriminant); - t_1 = (-b + discriminant_sqrt) / (2 * a); - t_2 = (-b - discriminant_sqrt) / (2 * a); - } - - double sol_1 = 0; - double sol_2 = 0; - - if (0 < t_1 && t_1 < 1) - sol_1 = eval_bezier(y1_, y2_, t_1); - - if (0 < t_2 && t_2 < 1) - sol_2 = eval_bezier(y1_, y2_, t_2); - - *min = std::min(std::min(*min, sol_1), sol_2); - *max = std::max(std::max(*max, sol_1), sol_2); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/cubic_bezier.h b/ui/gfx/geometry/cubic_bezier.h deleted file mode 100644 index 66d5e8a51..000000000 --- a/ui/gfx/geometry/cubic_bezier.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 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 UI_GFX_GEOMETRY_CUBIC_BEZIER_H_ -#define UI_GFX_GEOMETRY_CUBIC_BEZIER_H_ - -#include "base/macros.h" -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -class GFX_EXPORT CubicBezier { - public: - CubicBezier(double x1, double y1, double x2, double y2); - ~CubicBezier(); - - // Returns an approximation of y at the given x. - double Solve(double x) const; - - // Returns an approximation of dy/dx at the given x. - double Slope(double x) const; - - // Sets |min| and |max| to the bezier's minimum and maximium y values in the - // interval [0, 1]. - void Range(double* min, double* max) const; - - private: - double x1_; - double y1_; - double x2_; - double y2_; - - DISALLOW_ASSIGN(CubicBezier); -}; - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_CUBIC_BEZIER_H_ diff --git a/ui/gfx/geometry/cubic_bezier_unittest.cc b/ui/gfx/geometry/cubic_bezier_unittest.cc deleted file mode 100644 index 168817c64..000000000 --- a/ui/gfx/geometry/cubic_bezier_unittest.cc +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright 2014 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 "ui/gfx/geometry/cubic_bezier.h" - -#include "base/memory/scoped_ptr.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace gfx { -namespace { - -TEST(CubicBezierTest, Basic) { - CubicBezier function(0.25, 0.0, 0.75, 1.0); - - double epsilon = 0.00015; - - EXPECT_NEAR(function.Solve(0), 0, epsilon); - EXPECT_NEAR(function.Solve(0.05), 0.01136, epsilon); - EXPECT_NEAR(function.Solve(0.1), 0.03978, epsilon); - EXPECT_NEAR(function.Solve(0.15), 0.079780, epsilon); - EXPECT_NEAR(function.Solve(0.2), 0.12803, epsilon); - EXPECT_NEAR(function.Solve(0.25), 0.18235, epsilon); - EXPECT_NEAR(function.Solve(0.3), 0.24115, epsilon); - EXPECT_NEAR(function.Solve(0.35), 0.30323, epsilon); - EXPECT_NEAR(function.Solve(0.4), 0.36761, epsilon); - EXPECT_NEAR(function.Solve(0.45), 0.43345, epsilon); - EXPECT_NEAR(function.Solve(0.5), 0.5, epsilon); - EXPECT_NEAR(function.Solve(0.6), 0.63238, epsilon); - EXPECT_NEAR(function.Solve(0.65), 0.69676, epsilon); - EXPECT_NEAR(function.Solve(0.7), 0.75884, epsilon); - EXPECT_NEAR(function.Solve(0.75), 0.81764, epsilon); - EXPECT_NEAR(function.Solve(0.8), 0.87196, epsilon); - EXPECT_NEAR(function.Solve(0.85), 0.92021, epsilon); - EXPECT_NEAR(function.Solve(0.9), 0.96021, epsilon); - EXPECT_NEAR(function.Solve(0.95), 0.98863, epsilon); - EXPECT_NEAR(function.Solve(1), 1, epsilon); -} - -// Tests that solving the bezier works with knots with y not in (0, 1). -TEST(CubicBezierTest, UnclampedYValues) { - CubicBezier function(0.5, -1.0, 0.5, 2.0); - - double epsilon = 0.00015; - - EXPECT_NEAR(function.Solve(0.0), 0.0, epsilon); - EXPECT_NEAR(function.Solve(0.05), -0.08954, epsilon); - EXPECT_NEAR(function.Solve(0.1), -0.15613, epsilon); - EXPECT_NEAR(function.Solve(0.15), -0.19641, epsilon); - EXPECT_NEAR(function.Solve(0.2), -0.20651, epsilon); - EXPECT_NEAR(function.Solve(0.25), -0.18232, epsilon); - EXPECT_NEAR(function.Solve(0.3), -0.11992, epsilon); - EXPECT_NEAR(function.Solve(0.35), -0.01672, epsilon); - EXPECT_NEAR(function.Solve(0.4), 0.12660, epsilon); - EXPECT_NEAR(function.Solve(0.45), 0.30349, epsilon); - EXPECT_NEAR(function.Solve(0.5), 0.50000, epsilon); - EXPECT_NEAR(function.Solve(0.55), 0.69651, epsilon); - EXPECT_NEAR(function.Solve(0.6), 0.87340, epsilon); - EXPECT_NEAR(function.Solve(0.65), 1.01672, epsilon); - EXPECT_NEAR(function.Solve(0.7), 1.11992, epsilon); - EXPECT_NEAR(function.Solve(0.75), 1.18232, epsilon); - EXPECT_NEAR(function.Solve(0.8), 1.20651, epsilon); - EXPECT_NEAR(function.Solve(0.85), 1.19641, epsilon); - EXPECT_NEAR(function.Solve(0.9), 1.15613, epsilon); - EXPECT_NEAR(function.Solve(0.95), 1.08954, epsilon); - EXPECT_NEAR(function.Solve(1.0), 1.0, epsilon); -} - -TEST(CubicBezierTest, Range) { - double epsilon = 0.00015; - double min, max; - - // Derivative is a constant. - scoped_ptr function( - new CubicBezier(0.25, (1.0 / 3.0), 0.75, (2.0 / 3.0))); - function->Range(&min, &max); - EXPECT_EQ(0, min); - EXPECT_EQ(1, max); - - // Derivative is linear. - function.reset(new CubicBezier(0.25, -0.5, 0.75, (-1.0 / 6.0))); - function->Range(&min, &max); - EXPECT_NEAR(min, -0.225, epsilon); - EXPECT_EQ(1, max); - - // Derivative has no real roots. - function.reset(new CubicBezier(0.25, 0.25, 0.75, 0.5)); - function->Range(&min, &max); - EXPECT_EQ(0, min); - EXPECT_EQ(1, max); - - // Derivative has exactly one real root. - function.reset(new CubicBezier(0.0, 1.0, 1.0, 0.0)); - function->Range(&min, &max); - EXPECT_EQ(0, min); - EXPECT_EQ(1, max); - - // Derivative has one root < 0 and one root > 1. - function.reset(new CubicBezier(0.25, 0.1, 0.75, 0.9)); - function->Range(&min, &max); - EXPECT_EQ(0, min); - EXPECT_EQ(1, max); - - // Derivative has two roots in [0,1]. - function.reset(new CubicBezier(0.25, 2.5, 0.75, 0.5)); - function->Range(&min, &max); - EXPECT_EQ(0, min); - EXPECT_NEAR(max, 1.28818, epsilon); - function.reset(new CubicBezier(0.25, 0.5, 0.75, -1.5)); - function->Range(&min, &max); - EXPECT_NEAR(min, -0.28818, epsilon); - EXPECT_EQ(1, max); - - // Derivative has one root < 0 and one root in [0,1]. - function.reset(new CubicBezier(0.25, 0.1, 0.75, 1.5)); - function->Range(&min, &max); - EXPECT_EQ(0, min); - EXPECT_NEAR(max, 1.10755, epsilon); - - // Derivative has one root in [0,1] and one root > 1. - function.reset(new CubicBezier(0.25, -0.5, 0.75, 0.9)); - function->Range(&min, &max); - EXPECT_NEAR(min, -0.10755, epsilon); - EXPECT_EQ(1, max); - - // Derivative has two roots < 0. - function.reset(new CubicBezier(0.25, 0.3, 0.75, 0.633)); - function->Range(&min, &max); - EXPECT_EQ(0, min); - EXPECT_EQ(1, max); - - // Derivative has two roots > 1. - function.reset(new CubicBezier(0.25, 0.367, 0.75, 0.7)); - function->Range(&min, &max); - EXPECT_EQ(0.f, min); - EXPECT_EQ(1.f, max); -} - -TEST(CubicBezierTest, Slope) { - CubicBezier function(0.25, 0.0, 0.75, 1.0); - - double epsilon = 0.00015; - - EXPECT_NEAR(function.Slope(0), 0, epsilon); - EXPECT_NEAR(function.Slope(0.05), 0.42170, epsilon); - EXPECT_NEAR(function.Slope(0.1), 0.69778, epsilon); - EXPECT_NEAR(function.Slope(0.15), 0.89121, epsilon); - EXPECT_NEAR(function.Slope(0.2), 1.03184, epsilon); - EXPECT_NEAR(function.Slope(0.25), 1.13576, epsilon); - EXPECT_NEAR(function.Slope(0.3), 1.21239, epsilon); - EXPECT_NEAR(function.Slope(0.35), 1.26751, epsilon); - EXPECT_NEAR(function.Slope(0.4), 1.30474, epsilon); - EXPECT_NEAR(function.Slope(0.45), 1.32628, epsilon); - EXPECT_NEAR(function.Slope(0.5), 1.33333, epsilon); - EXPECT_NEAR(function.Slope(0.55), 1.32628, epsilon); - EXPECT_NEAR(function.Slope(0.6), 1.30474, epsilon); - EXPECT_NEAR(function.Slope(0.65), 1.26751, epsilon); - EXPECT_NEAR(function.Slope(0.7), 1.21239, epsilon); - EXPECT_NEAR(function.Slope(0.75), 1.13576, epsilon); - EXPECT_NEAR(function.Slope(0.8), 1.03184, epsilon); - EXPECT_NEAR(function.Slope(0.85), 0.89121, epsilon); - EXPECT_NEAR(function.Slope(0.9), 0.69778, epsilon); - EXPECT_NEAR(function.Slope(0.95), 0.42170, epsilon); - EXPECT_NEAR(function.Slope(1), 0, epsilon); -} - -} // namespace -} // namespace gfx diff --git a/ui/gfx/geometry/insets.cc b/ui/gfx/geometry/insets.cc deleted file mode 100644 index c29368e1b..000000000 --- a/ui/gfx/geometry/insets.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2009 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 "ui/gfx/geometry/insets.h" - -#include "base/strings/stringprintf.h" - -namespace gfx { - -template class InsetsBase; - -Insets::Insets() : InsetsBase(0, 0, 0, 0) {} - -Insets::Insets(int top, int left, int bottom, int right) - : InsetsBase(top, left, bottom, right) {} - -Insets::~Insets() {} - -std::string Insets::ToString() const { - // Print members in the same order of the constructor parameters. - return base::StringPrintf("%d,%d,%d,%d", top(), left(), bottom(), right()); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/insets.h b/ui/gfx/geometry/insets.h deleted file mode 100644 index 013791931..000000000 --- a/ui/gfx/geometry/insets.h +++ /dev/null @@ -1,50 +0,0 @@ -// 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 UI_GFX_GEOMETRY_INSETS_H_ -#define UI_GFX_GEOMETRY_INSETS_H_ - -#include - -#include "build/build_config.h" -#include "ui/gfx/geometry/insets_base.h" -#include "ui/gfx/geometry/insets_f.h" -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -// An integer version of gfx::Insets. -class GFX_EXPORT Insets : public InsetsBase { - public: - Insets(); - Insets(int top, int left, int bottom, int right); - - ~Insets(); - - Insets Scale(float scale) const { - return Scale(scale, scale); - } - - Insets Scale(float x_scale, float y_scale) const { - return Insets(static_cast(top() * y_scale), - static_cast(left() * x_scale), - static_cast(bottom() * y_scale), - static_cast(right() * x_scale)); - } - - operator InsetsF() const { - return InsetsF(top(), left(), bottom(), right()); - } - - // Returns a string representation of the insets. - std::string ToString() const; -}; - -#if !defined(COMPILER_MSVC) && !defined(__native_client__) -extern template class InsetsBase; -#endif - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_INSETS_H_ diff --git a/ui/gfx/geometry/insets_base.h b/ui/gfx/geometry/insets_base.h deleted file mode 100644 index 751d5c11d..000000000 --- a/ui/gfx/geometry/insets_base.h +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 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 UI_GFX_GEOMETRY_INSETS_BASE_H_ -#define UI_GFX_GEOMETRY_INSETS_BASE_H_ - -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -// An insets represents the borders of a container (the space the container must -// leave at each of its edges). -template -class GFX_EXPORT InsetsBase { - public: - Type top() const { return top_; } - Type left() const { return left_; } - Type bottom() const { return bottom_; } - Type right() const { return right_; } - - // Returns the total width taken up by the insets, which is the sum of the - // left and right insets. - Type width() const { return left_ + right_; } - - // Returns the total height taken up by the insets, which is the sum of the - // top and bottom insets. - Type height() const { return top_ + bottom_; } - - // Returns true if the insets are empty. - bool empty() const { return width() == 0 && height() == 0; } - - void Set(Type top, Type left, Type bottom, Type right) { - top_ = top; - left_ = left; - bottom_ = bottom; - right_ = right; - } - - bool operator==(const Class& insets) const { - return top_ == insets.top_ && left_ == insets.left_ && - bottom_ == insets.bottom_ && right_ == insets.right_; - } - - bool operator!=(const Class& insets) const { - return !(*this == insets); - } - - void operator+=(const Class& insets) { - top_ += insets.top_; - left_ += insets.left_; - bottom_ += insets.bottom_; - right_ += insets.right_; - } - - Class operator-() const { - return Class(-top_, -left_, -bottom_, -right_); - } - - protected: - InsetsBase(Type top, Type left, Type bottom, Type right) - : top_(top), - left_(left), - bottom_(bottom), - right_(right) {} - - // Destructor is intentionally made non virtual and protected. - // Do not make this public. - ~InsetsBase() {} - - private: - Type top_; - Type left_; - Type bottom_; - Type right_; -}; - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_INSETS_BASE_H_ diff --git a/ui/gfx/geometry/insets_f.cc b/ui/gfx/geometry/insets_f.cc deleted file mode 100644 index 774b4ab8c..000000000 --- a/ui/gfx/geometry/insets_f.cc +++ /dev/null @@ -1,25 +0,0 @@ -// 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 "ui/gfx/geometry/insets_f.h" - -#include "base/strings/stringprintf.h" - -namespace gfx { - -template class InsetsBase; - -InsetsF::InsetsF() : InsetsBase(0, 0, 0, 0) {} - -InsetsF::InsetsF(float top, float left, float bottom, float right) - : InsetsBase(top, left, bottom, right) {} - -InsetsF::~InsetsF() {} - -std::string InsetsF::ToString() const { - // Print members in the same order of the constructor parameters. - return base::StringPrintf("%f,%f,%f,%f", top(), left(), bottom(), right()); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/insets_f.h b/ui/gfx/geometry/insets_f.h deleted file mode 100644 index e325a7716..000000000 --- a/ui/gfx/geometry/insets_f.h +++ /dev/null @@ -1,33 +0,0 @@ -// 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 UI_GFX_GEOMETRY_INSETS_F_H_ -#define UI_GFX_GEOMETRY_INSETS_F_H_ - -#include - -#include "build/build_config.h" -#include "ui/gfx/geometry/insets_base.h" -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -// A floating versin of gfx::Insets. -class GFX_EXPORT InsetsF : public InsetsBase { - public: - InsetsF(); - InsetsF(float top, float left, float bottom, float right); - ~InsetsF(); - - // Returns a string representation of the insets. - std::string ToString() const; -}; - -#if !defined(COMPILER_MSVC) && !defined(__native_client__) -extern template class InsetsBase; -#endif - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_INSETS_F_H_ diff --git a/ui/gfx/geometry/insets_unittest.cc b/ui/gfx/geometry/insets_unittest.cc deleted file mode 100644 index b20a9d36f..000000000 --- a/ui/gfx/geometry/insets_unittest.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2009 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 "ui/gfx/geometry/insets.h" - -#include "testing/gtest/include/gtest/gtest.h" - -TEST(InsetsTest, InsetsDefault) { - gfx::Insets insets; - EXPECT_EQ(0, insets.top()); - EXPECT_EQ(0, insets.left()); - EXPECT_EQ(0, insets.bottom()); - EXPECT_EQ(0, insets.right()); - EXPECT_EQ(0, insets.width()); - EXPECT_EQ(0, insets.height()); - EXPECT_TRUE(insets.empty()); -} - -TEST(InsetsTest, Insets) { - gfx::Insets insets(1, 2, 3, 4); - EXPECT_EQ(1, insets.top()); - EXPECT_EQ(2, insets.left()); - EXPECT_EQ(3, insets.bottom()); - EXPECT_EQ(4, insets.right()); - EXPECT_EQ(6, insets.width()); // Left + right. - EXPECT_EQ(4, insets.height()); // Top + bottom. - EXPECT_FALSE(insets.empty()); -} - -TEST(InsetsTest, Set) { - gfx::Insets insets; - insets.Set(1, 2, 3, 4); - EXPECT_EQ(1, insets.top()); - EXPECT_EQ(2, insets.left()); - EXPECT_EQ(3, insets.bottom()); - EXPECT_EQ(4, insets.right()); -} - -TEST(InsetsTest, Add) { - gfx::Insets insets; - insets.Set(1, 2, 3, 4); - insets += gfx::Insets(5, 6, 7, 8); - EXPECT_EQ(6, insets.top()); - EXPECT_EQ(8, insets.left()); - EXPECT_EQ(10, insets.bottom()); - EXPECT_EQ(12, insets.right()); -} - -TEST(InsetsTest, Equality) { - gfx::Insets insets1; - insets1.Set(1, 2, 3, 4); - gfx::Insets insets2; - // Test operator== and operator!=. - EXPECT_FALSE(insets1 == insets2); - EXPECT_TRUE(insets1 != insets2); - - insets2.Set(1, 2, 3, 4); - EXPECT_TRUE(insets1 == insets2); - EXPECT_FALSE(insets1 != insets2); -} - -TEST(InsetsTest, ToString) { - gfx::Insets insets(1, 2, 3, 4); - EXPECT_EQ("1,2,3,4", insets.ToString()); -} diff --git a/ui/gfx/geometry/matrix3_f.cc b/ui/gfx/geometry/matrix3_f.cc deleted file mode 100644 index 5836ae677..000000000 --- a/ui/gfx/geometry/matrix3_f.cc +++ /dev/null @@ -1,237 +0,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 "ui/gfx/geometry/matrix3_f.h" - -#include -#include -#include - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -namespace { - -// This is only to make accessing indices self-explanatory. -enum MatrixCoordinates { - M00, - M01, - M02, - M10, - M11, - M12, - M20, - M21, - M22, - M_END -}; - -template -double Determinant3x3(T data[M_END]) { - // This routine is separated from the Matrix3F::Determinant because in - // computing inverse we do want higher precision afforded by the explicit - // use of 'double'. - return - static_cast(data[M00]) * ( - static_cast(data[M11]) * data[M22] - - static_cast(data[M12]) * data[M21]) + - static_cast(data[M01]) * ( - static_cast(data[M12]) * data[M20] - - static_cast(data[M10]) * data[M22]) + - static_cast(data[M02]) * ( - static_cast(data[M10]) * data[M21] - - static_cast(data[M11]) * data[M20]); -} - -} // namespace - -namespace gfx { - -Matrix3F::Matrix3F() { -} - -Matrix3F::~Matrix3F() { -} - -// static -Matrix3F Matrix3F::Zeros() { - Matrix3F matrix; - matrix.set(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); - return matrix; -} - -// static -Matrix3F Matrix3F::Ones() { - Matrix3F matrix; - matrix.set(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); - return matrix; -} - -// static -Matrix3F Matrix3F::Identity() { - Matrix3F matrix; - matrix.set(1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f); - return matrix; -} - -// static -Matrix3F Matrix3F::FromOuterProduct(const Vector3dF& a, const Vector3dF& bt) { - Matrix3F matrix; - matrix.set(a.x() * bt.x(), a.x() * bt.y(), a.x() * bt.z(), - a.y() * bt.x(), a.y() * bt.y(), a.y() * bt.z(), - a.z() * bt.x(), a.z() * bt.y(), a.z() * bt.z()); - return matrix; -} - -bool Matrix3F::IsEqual(const Matrix3F& rhs) const { - return 0 == memcmp(data_, rhs.data_, sizeof(data_)); -} - -bool Matrix3F::IsNear(const Matrix3F& rhs, float precision) const { - DCHECK(precision >= 0); - for (int i = 0; i < M_END; ++i) { - if (std::abs(data_[i] - rhs.data_[i]) > precision) - return false; - } - return true; -} - -Matrix3F Matrix3F::Inverse() const { - Matrix3F inverse = Matrix3F::Zeros(); - double determinant = Determinant3x3(data_); - if (std::numeric_limits::epsilon() > std::abs(determinant)) - return inverse; // Singular matrix. Return Zeros(). - - inverse.set( - (data_[M11] * data_[M22] - data_[M12] * data_[M21]) / determinant, - (data_[M02] * data_[M21] - data_[M01] * data_[M22]) / determinant, - (data_[M01] * data_[M12] - data_[M02] * data_[M11]) / determinant, - (data_[M12] * data_[M20] - data_[M10] * data_[M22]) / determinant, - (data_[M00] * data_[M22] - data_[M02] * data_[M20]) / determinant, - (data_[M02] * data_[M10] - data_[M00] * data_[M12]) / determinant, - (data_[M10] * data_[M21] - data_[M11] * data_[M20]) / determinant, - (data_[M01] * data_[M20] - data_[M00] * data_[M21]) / determinant, - (data_[M00] * data_[M11] - data_[M01] * data_[M10]) / determinant); - return inverse; -} - -float Matrix3F::Determinant() const { - return static_cast(Determinant3x3(data_)); -} - -Vector3dF Matrix3F::SolveEigenproblem(Matrix3F* eigenvectors) const { - // The matrix must be symmetric. - const float epsilon = std::numeric_limits::epsilon(); - if (std::abs(data_[M01] - data_[M10]) > epsilon || - std::abs(data_[M02] - data_[M20]) > epsilon || - std::abs(data_[M12] - data_[M21]) > epsilon) { - NOTREACHED(); - return Vector3dF(); - } - - float eigenvalues[3]; - float p = - data_[M01] * data_[M01] + - data_[M02] * data_[M02] + - data_[M12] * data_[M12]; - - bool diagonal = std::abs(p) < epsilon; - if (diagonal) { - eigenvalues[0] = data_[M00]; - eigenvalues[1] = data_[M11]; - eigenvalues[2] = data_[M22]; - } else { - float q = Trace() / 3.0f; - p = (data_[M00] - q) * (data_[M00] - q) + - (data_[M11] - q) * (data_[M11] - q) + - (data_[M22] - q) * (data_[M22] - q) + - 2 * p; - p = std::sqrt(p / 6); - - // The computation below puts B as (A - qI) / p, where A is *this. - Matrix3F matrix_b(*this); - matrix_b.data_[M00] -= q; - matrix_b.data_[M11] -= q; - matrix_b.data_[M22] -= q; - for (int i = 0; i < M_END; ++i) - matrix_b.data_[i] /= p; - - double half_det_b = Determinant3x3(matrix_b.data_) / 2.0; - // half_det_b should be in <-1, 1>, but beware of rounding error. - double phi = 0.0f; - if (half_det_b <= -1.0) - phi = M_PI / 3; - else if (half_det_b < 1.0) - phi = acos(half_det_b) / 3; - - eigenvalues[0] = q + 2 * p * static_cast(cos(phi)); - eigenvalues[2] = q + 2 * p * - static_cast(cos(phi + 2.0 * M_PI / 3.0)); - eigenvalues[1] = 3 * q - eigenvalues[0] - eigenvalues[2]; - } - - // Put eigenvalues in the descending order. - int indices[3] = {0, 1, 2}; - if (eigenvalues[2] > eigenvalues[1]) { - std::swap(eigenvalues[2], eigenvalues[1]); - std::swap(indices[2], indices[1]); - } - - if (eigenvalues[1] > eigenvalues[0]) { - std::swap(eigenvalues[1], eigenvalues[0]); - std::swap(indices[1], indices[0]); - } - - if (eigenvalues[2] > eigenvalues[1]) { - std::swap(eigenvalues[2], eigenvalues[1]); - std::swap(indices[2], indices[1]); - } - - if (eigenvectors != NULL && diagonal) { - // Eigenvectors are e-vectors, just need to be sorted accordingly. - *eigenvectors = Zeros(); - for (int i = 0; i < 3; ++i) - eigenvectors->set(indices[i], i, 1.0f); - } else if (eigenvectors != NULL) { - // Consult the following for a detailed discussion: - // Joachim Kopp - // Numerical diagonalization of hermitian 3x3 matrices - // arXiv.org preprint: physics/0610206 - // Int. J. Mod. Phys. C19 (2008) 523-548 - - // TODO(motek): expand to handle correctly negative and multiple - // eigenvalues. - for (int i = 0; i < 3; ++i) { - float l = eigenvalues[i]; - // B = A - l * I - Matrix3F matrix_b(*this); - matrix_b.data_[M00] -= l; - matrix_b.data_[M11] -= l; - matrix_b.data_[M22] -= l; - Vector3dF e1 = CrossProduct(matrix_b.get_column(0), - matrix_b.get_column(1)); - Vector3dF e2 = CrossProduct(matrix_b.get_column(1), - matrix_b.get_column(2)); - Vector3dF e3 = CrossProduct(matrix_b.get_column(2), - matrix_b.get_column(0)); - - // e1, e2 and e3 should point in the same direction. - if (DotProduct(e1, e2) < 0) - e2 = -e2; - - if (DotProduct(e1, e3) < 0) - e3 = -e3; - - Vector3dF eigvec = e1 + e2 + e3; - // Normalize. - eigvec.Scale(1.0f / eigvec.Length()); - eigenvectors->set_column(i, eigvec); - } - } - - return Vector3dF(eigenvalues[0], eigenvalues[1], eigenvalues[2]); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/matrix3_f.h b/ui/gfx/geometry/matrix3_f.h deleted file mode 100644 index 7e43496fd..000000000 --- a/ui/gfx/geometry/matrix3_f.h +++ /dev/null @@ -1,108 +0,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. - -#ifndef UI_GFX_GEOMETRY_MATRIX3_F_H_ -#define UI_GFX_GEOMETRY_MATRIX3_F_H_ - -#include "base/logging.h" -#include "ui/gfx/geometry/vector3d_f.h" - -namespace gfx { - -class GFX_EXPORT Matrix3F { - public: - ~Matrix3F(); - - static Matrix3F Zeros(); - static Matrix3F Ones(); - static Matrix3F Identity(); - static Matrix3F FromOuterProduct(const Vector3dF& a, const Vector3dF& bt); - - bool IsEqual(const Matrix3F& rhs) const; - - // Element-wise comparison with given precision. - bool IsNear(const Matrix3F& rhs, float precision) const; - - float get(int i, int j) const { - return data_[MatrixToArrayCoords(i, j)]; - } - - void set(int i, int j, float v) { - data_[MatrixToArrayCoords(i, j)] = v; - } - - void set(float m00, float m01, float m02, - float m10, float m11, float m12, - float m20, float m21, float m22) { - data_[0] = m00; - data_[1] = m01; - data_[2] = m02; - data_[3] = m10; - data_[4] = m11; - data_[5] = m12; - data_[6] = m20; - data_[7] = m21; - data_[8] = m22; - } - - Vector3dF get_column(int i) const { - return Vector3dF( - data_[MatrixToArrayCoords(0, i)], - data_[MatrixToArrayCoords(1, i)], - data_[MatrixToArrayCoords(2, i)]); - } - - void set_column(int i, const Vector3dF& c) { - data_[MatrixToArrayCoords(0, i)] = c.x(); - data_[MatrixToArrayCoords(1, i)] = c.y(); - data_[MatrixToArrayCoords(2, i)] = c.z(); - } - - // Returns an inverse of this if the matrix is non-singular, zero (== Zero()) - // otherwise. - Matrix3F Inverse() const; - - // Value of the determinant of the matrix. - float Determinant() const; - - // Trace (sum of diagonal elements) of the matrix. - float Trace() const { - return data_[MatrixToArrayCoords(0, 0)] + - data_[MatrixToArrayCoords(1, 1)] + - data_[MatrixToArrayCoords(2, 2)]; - } - - // Compute eigenvalues and (optionally) normalized eigenvectors of - // a positive defnite matrix *this. Eigenvectors are computed only if - // non-null |eigenvectors| matrix is passed. If it is NULL, the routine - // will not attempt to compute eigenvectors but will still return eigenvalues - // if they can be computed. - // If eigenvalues cannot be computed (the matrix does not meet constraints) - // the 0-vector is returned. Note that to retrieve eigenvalues, the matrix - // only needs to be symmetric while eigenvectors require it to be - // positive-definite. Passing a non-positive definite matrix will result in - // NaNs in vectors which cannot be computed. - // Eigenvectors are placed as column in |eigenvectors| in order corresponding - // to eigenvalues. - Vector3dF SolveEigenproblem(Matrix3F* eigenvectors) const; - - private: - Matrix3F(); // Uninitialized default. - - static int MatrixToArrayCoords(int i, int j) { - DCHECK(i >= 0 && i < 3); - DCHECK(j >= 0 && j < 3); - return i * 3 + j; - } - - float data_[9]; -}; - -inline bool operator==(const Matrix3F& lhs, const Matrix3F& rhs) { - return lhs.IsEqual(rhs); -} - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_MATRIX3_F_H_ diff --git a/ui/gfx/geometry/matrix3_unittest.cc b/ui/gfx/geometry/matrix3_unittest.cc deleted file mode 100644 index 0f57e8e7a..000000000 --- a/ui/gfx/geometry/matrix3_unittest.cc +++ /dev/null @@ -1,148 +0,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 -#include - -#include "base/basictypes.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/gfx/geometry/matrix3_f.h" - -namespace gfx { -namespace { - -TEST(Matrix3fTest, Constructors) { - Matrix3F zeros = Matrix3F::Zeros(); - Matrix3F ones = Matrix3F::Ones(); - Matrix3F identity = Matrix3F::Identity(); - - Matrix3F product_ones = Matrix3F::FromOuterProduct( - Vector3dF(1.0f, 1.0f, 1.0f), Vector3dF(1.0f, 1.0f, 1.0f)); - Matrix3F product_zeros = Matrix3F::FromOuterProduct( - Vector3dF(1.0f, 1.0f, 1.0f), Vector3dF(0.0f, 0.0f, 0.0f)); - EXPECT_EQ(ones, product_ones); - EXPECT_EQ(zeros, product_zeros); - - for (int i = 0; i < 3; ++i) { - for (int j = 0; j < 3; ++j) - EXPECT_EQ(i == j ? 1.0f : 0.0f, identity.get(i, j)); - } -} - -TEST(Matrix3fTest, DataAccess) { - Matrix3F matrix = Matrix3F::Ones(); - Matrix3F identity = Matrix3F::Identity(); - - EXPECT_EQ(Vector3dF(0.0f, 1.0f, 0.0f), identity.get_column(1)); - matrix.set(0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f); - EXPECT_EQ(Vector3dF(2.0f, 5.0f, 8.0f), matrix.get_column(2)); - matrix.set_column(0, Vector3dF(0.1f, 0.2f, 0.3f)); - EXPECT_EQ(Vector3dF(0.1f, 0.2f, 0.3f), matrix.get_column(0)); - - EXPECT_EQ(0.1f, matrix.get(0, 0)); - EXPECT_EQ(5.0f, matrix.get(1, 2)); -} - -TEST(Matrix3fTest, Determinant) { - EXPECT_EQ(1.0f, Matrix3F::Identity().Determinant()); - EXPECT_EQ(0.0f, Matrix3F::Zeros().Determinant()); - EXPECT_EQ(0.0f, Matrix3F::Ones().Determinant()); - - // Now for something non-trivial... - Matrix3F matrix = Matrix3F::Zeros(); - matrix.set(0, 5, 6, 8, 7, 0, 1, 9, 0); - EXPECT_EQ(390.0f, matrix.Determinant()); - matrix.set(2, 0, 3 * matrix.get(0, 0)); - matrix.set(2, 1, 3 * matrix.get(0, 1)); - matrix.set(2, 2, 3 * matrix.get(0, 2)); - EXPECT_EQ(0, matrix.Determinant()); - - matrix.set(0.57f, 0.205f, 0.942f, - 0.314f, 0.845f, 0.826f, - 0.131f, 0.025f, 0.962f); - EXPECT_NEAR(0.3149f, matrix.Determinant(), 0.0001f); -} - -TEST(Matrix3fTest, Inverse) { - Matrix3F identity = Matrix3F::Identity(); - Matrix3F inv_identity = identity.Inverse(); - EXPECT_EQ(identity, inv_identity); - - Matrix3F singular = Matrix3F::Zeros(); - singular.set(1.0f, 3.0f, 4.0f, - 2.0f, 11.0f, 5.0f, - 0.5f, 1.5f, 2.0f); - EXPECT_EQ(0, singular.Determinant()); - EXPECT_EQ(Matrix3F::Zeros(), singular.Inverse()); - - Matrix3F regular = Matrix3F::Zeros(); - regular.set(0.57f, 0.205f, 0.942f, - 0.314f, 0.845f, 0.826f, - 0.131f, 0.025f, 0.962f); - Matrix3F inv_regular = regular.Inverse(); - regular.set(2.51540616f, -0.55138018f, -1.98968043f, - -0.61552266f, 1.34920184f, -0.55573636f, - -0.32653861f, 0.04002158f, 1.32488726f); - EXPECT_TRUE(regular.IsNear(inv_regular, 0.00001f)); -} - -TEST(Matrix3fTest, EigenvectorsIdentity) { - // This block tests the trivial case of eigenvalues of the identity matrix. - Matrix3F identity = Matrix3F::Identity(); - Vector3dF eigenvals = identity.SolveEigenproblem(NULL); - EXPECT_EQ(Vector3dF(1.0f, 1.0f, 1.0f), eigenvals); -} - -TEST(Matrix3fTest, EigenvectorsDiagonal) { - // This block tests the another trivial case of eigenvalues of a diagonal - // matrix. Here we expect values to be sorted. - Matrix3F matrix = Matrix3F::Zeros(); - matrix.set(0, 0, 1.0f); - matrix.set(1, 1, -2.5f); - matrix.set(2, 2, 3.14f); - Matrix3F eigenvectors = Matrix3F::Zeros(); - Vector3dF eigenvals = matrix.SolveEigenproblem(&eigenvectors); - EXPECT_EQ(Vector3dF(3.14f, 1.0f, -2.5f), eigenvals); - - EXPECT_EQ(Vector3dF(0.0f, 0.0f, 1.0f), eigenvectors.get_column(0)); - EXPECT_EQ(Vector3dF(1.0f, 0.0f, 0.0f), eigenvectors.get_column(1)); - EXPECT_EQ(Vector3dF(0.0f, 1.0f, 0.0f), eigenvectors.get_column(2)); -} - -TEST(Matrix3fTest, EigenvectorsNiceNotPositive) { - // This block tests computation of eigenvectors of a matrix where nice - // round values are expected. - Matrix3F matrix = Matrix3F::Zeros(); - // This is not a positive-definite matrix but eigenvalues and the first - // eigenvector should nonetheless be computed correctly. - matrix.set(3, 2, 4, 2, 0, 2, 4, 2, 3); - Matrix3F eigenvectors = Matrix3F::Zeros(); - Vector3dF eigenvals = matrix.SolveEigenproblem(&eigenvectors); - EXPECT_EQ(Vector3dF(8.0f, -1.0f, -1.0f), eigenvals); - - Vector3dF expected_principal(0.66666667f, 0.33333333f, 0.66666667f); - EXPECT_NEAR(0.0f, - (expected_principal - eigenvectors.get_column(0)).Length(), - 0.000001f); -} - -TEST(Matrix3fTest, EigenvectorsPositiveDefinite) { - // This block tests computation of eigenvectors of a matrix where output - // is not as nice as above, but it actually meets the definition. - Matrix3F matrix = Matrix3F::Zeros(); - Matrix3F eigenvectors = Matrix3F::Zeros(); - Matrix3F expected_eigenvectors = Matrix3F::Zeros(); - matrix.set(1, -1, 2, -1, 4, 5, 2, 5, 0); - Vector3dF eigenvals = matrix.SolveEigenproblem(&eigenvectors); - Vector3dF expected_eigv(7.3996266f, 1.91197255f, -4.31159915f); - expected_eigv -= eigenvals; - EXPECT_NEAR(0, expected_eigv.LengthSquared(), 0.00001f); - expected_eigenvectors.set(0.04926317f, -0.92135662f, -0.38558414f, - 0.82134249f, 0.25703273f, -0.50924521f, - 0.56830419f, -0.2916096f, 0.76941158f); - EXPECT_TRUE(expected_eigenvectors.IsNear(eigenvectors, 0.00001f)); -} - -} -} diff --git a/ui/gfx/geometry/point.cc b/ui/gfx/geometry/point.cc deleted file mode 100644 index 4eeb216a3..000000000 --- a/ui/gfx/geometry/point.cc +++ /dev/null @@ -1,25 +0,0 @@ -// 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 "ui/gfx/geometry/point.h" - -#include "base/strings/stringprintf.h" - -namespace gfx { - -void Point::SetToMin(const Point& other) { - x_ = x_ <= other.x_ ? x_ : other.x_; - y_ = y_ <= other.y_ ? y_ : other.y_; -} - -void Point::SetToMax(const Point& other) { - x_ = x_ >= other.x_ ? x_ : other.x_; - y_ = y_ >= other.y_ ? y_ : other.y_; -} - -std::string Point::ToString() const { - return base::StringPrintf("%d,%d", x(), y()); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/point.h b/ui/gfx/geometry/point.h deleted file mode 100644 index 05cf24a2c..000000000 --- a/ui/gfx/geometry/point.h +++ /dev/null @@ -1,114 +0,0 @@ -// 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 UI_GFX_GEOMETRY_POINT_H_ -#define UI_GFX_GEOMETRY_POINT_H_ - -#include -#include - -#include "ui/gfx/geometry/point_f.h" -#include "ui/gfx/geometry/vector2d.h" -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -// A point has an x and y coordinate. -class GFX_EXPORT Point { - public: - Point() : x_(0), y_(0) {} - Point(int x, int y) : x_(x), y_(y) {} - - ~Point() {} - - int x() const { return x_; } - int y() const { return y_; } - void set_x(int x) { x_ = x; } - void set_y(int y) { y_ = y; } - - void SetPoint(int x, int y) { - x_ = x; - y_ = y; - } - - void Offset(int delta_x, int delta_y) { - x_ += delta_x; - y_ += delta_y; - } - - void operator+=(const Vector2d& vector) { - x_ += vector.x(); - y_ += vector.y(); - } - - void operator-=(const Vector2d& vector) { - x_ -= vector.x(); - y_ -= vector.y(); - } - - void SetToMin(const Point& other); - void SetToMax(const Point& other); - - bool IsOrigin() const { return x_ == 0 && y_ == 0; } - - Vector2d OffsetFromOrigin() const { return Vector2d(x_, y_); } - - // A point is less than another point if its y-value is closer - // to the origin. If the y-values are the same, then point with - // the x-value closer to the origin is considered less than the - // other. - // This comparison is required to use Point in sets, or sorted - // vectors. - bool operator<(const Point& rhs) const { - return (y_ == rhs.y_) ? (x_ < rhs.x_) : (y_ < rhs.y_); - } - - operator PointF() const { - return PointF(x(), y()); - } - - // Returns a string representation of point. - std::string ToString() const; - - private: - int x_; - int y_; -}; - -inline bool operator==(const Point& lhs, const Point& rhs) { - return lhs.x() == rhs.x() && lhs.y() == rhs.y(); -} - -inline bool operator!=(const Point& lhs, const Point& rhs) { - return !(lhs == rhs); -} - -inline Point operator+(const Point& lhs, const Vector2d& rhs) { - Point result(lhs); - result += rhs; - return result; -} - -inline Point operator-(const Point& lhs, const Vector2d& rhs) { - Point result(lhs); - result -= rhs; - return result; -} - -inline Vector2d operator-(const Point& lhs, const Point& rhs) { - return Vector2d(lhs.x() - rhs.x(), lhs.y() - rhs.y()); -} - -inline Point PointAtOffsetFromOrigin(const Vector2d& offset_from_origin) { - return Point(offset_from_origin.x(), offset_from_origin.y()); -} - -// This is declared here for use in gtest-based unit tests but is defined in -// the gfx_test_support target. Depend on that to use this in your unit test. -// This should not be used in production code - call ToString() instead. -void PrintTo(const Point& point, ::std::ostream* os); - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_POINT_H_ diff --git a/ui/gfx/geometry/point3_f.cc b/ui/gfx/geometry/point3_f.cc deleted file mode 100644 index 465376e55..000000000 --- a/ui/gfx/geometry/point3_f.cc +++ /dev/null @@ -1,40 +0,0 @@ -// 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 "ui/gfx/geometry/point3_f.h" - -#include "base/strings/stringprintf.h" - -namespace gfx { - -std::string Point3F::ToString() const { - return base::StringPrintf("%f,%f,%f", x_, y_, z_); -} - -Point3F operator+(const Point3F& lhs, const Vector3dF& rhs) { - float x = lhs.x() + rhs.x(); - float y = lhs.y() + rhs.y(); - float z = lhs.z() + rhs.z(); - return Point3F(x, y, z); -} - -// Subtract a vector from a point, producing a new point offset by the vector's -// inverse. -Point3F operator-(const Point3F& lhs, const Vector3dF& rhs) { - float x = lhs.x() - rhs.x(); - float y = lhs.y() - rhs.y(); - float z = lhs.z() - rhs.z(); - return Point3F(x, y, z); -} - -// Subtract one point from another, producing a vector that represents the -// distances between the two points along each axis. -Vector3dF operator-(const Point3F& lhs, const Point3F& rhs) { - float x = lhs.x() - rhs.x(); - float y = lhs.y() - rhs.y(); - float z = lhs.z() - rhs.z(); - return Vector3dF(x, y, z); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/point3_f.h b/ui/gfx/geometry/point3_f.h deleted file mode 100644 index 262e3555d..000000000 --- a/ui/gfx/geometry/point3_f.h +++ /dev/null @@ -1,126 +0,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. - -#ifndef UI_GFX_GEOMETRY_POINT3_F_H_ -#define UI_GFX_GEOMETRY_POINT3_F_H_ - -#include -#include - -#include "ui/gfx/geometry/point_f.h" -#include "ui/gfx/geometry/vector3d_f.h" -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -// A point has an x, y and z coordinate. -class GFX_EXPORT Point3F { - public: - Point3F() : x_(0), y_(0), z_(0) {} - - Point3F(float x, float y, float z) : x_(x), y_(y), z_(z) {} - - explicit Point3F(const PointF& point) : x_(point.x()), y_(point.y()), z_(0) {} - - ~Point3F() {} - - void Scale(float scale) { - Scale(scale, scale, scale); - } - - void Scale(float x_scale, float y_scale, float z_scale) { - SetPoint(x() * x_scale, y() * y_scale, z() * z_scale); - } - - float x() const { return x_; } - float y() const { return y_; } - float z() const { return z_; } - - void set_x(float x) { x_ = x; } - void set_y(float y) { y_ = y; } - void set_z(float z) { z_ = z; } - - void SetPoint(float x, float y, float z) { - x_ = x; - y_ = y; - z_ = z; - } - - // Offset the point by the given vector. - void operator+=(const Vector3dF& v) { - x_ += v.x(); - y_ += v.y(); - z_ += v.z(); - } - - // Offset the point by the given vector's inverse. - void operator-=(const Vector3dF& v) { - x_ -= v.x(); - y_ -= v.y(); - z_ -= v.z(); - } - - // Returns the squared euclidean distance between two points. - float SquaredDistanceTo(const Point3F& other) const { - float dx = x_ - other.x_; - float dy = y_ - other.y_; - float dz = z_ - other.z_; - return dx * dx + dy * dy + dz * dz; - } - - PointF AsPointF() const { return PointF(x_, y_); } - - // Returns a string representation of 3d point. - std::string ToString() const; - - private: - float x_; - float y_; - float z_; - - // copy/assign are allowed. -}; - -inline bool operator==(const Point3F& lhs, const Point3F& rhs) { - return lhs.x() == rhs.x() && lhs.y() == rhs.y() && lhs.z() == rhs.z(); -} - -inline bool operator!=(const Point3F& lhs, const Point3F& rhs) { - return !(lhs == rhs); -} - -// Add a vector to a point, producing a new point offset by the vector. -GFX_EXPORT Point3F operator+(const Point3F& lhs, const Vector3dF& rhs); - -// Subtract a vector from a point, producing a new point offset by the vector's -// inverse. -GFX_EXPORT Point3F operator-(const Point3F& lhs, const Vector3dF& rhs); - -// Subtract one point from another, producing a vector that represents the -// distances between the two points along each axis. -GFX_EXPORT Vector3dF operator-(const Point3F& lhs, const Point3F& rhs); - -inline Point3F PointAtOffsetFromOrigin(const Vector3dF& offset) { - return Point3F(offset.x(), offset.y(), offset.z()); -} - -inline Point3F ScalePoint(const Point3F& p, - float x_scale, - float y_scale, - float z_scale) { - return Point3F(p.x() * x_scale, p.y() * y_scale, p.z() * z_scale); -} - -inline Point3F ScalePoint(const Point3F& p, float scale) { - return ScalePoint(p, scale, scale, scale); -} - -// This is declared here for use in gtest-based unit tests but is defined in -// the gfx_test_support target. Depend on that to use this in your unit test. -// This should not be used in production code - call ToString() instead. -void PrintTo(const Point3F& point, ::std::ostream* os); - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_POINT3_F_H_ diff --git a/ui/gfx/geometry/point3_unittest.cc b/ui/gfx/geometry/point3_unittest.cc deleted file mode 100644 index d8a7f19b2..000000000 --- a/ui/gfx/geometry/point3_unittest.cc +++ /dev/null @@ -1,69 +0,0 @@ -// 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/basictypes.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/gfx/geometry/point3_f.h" - -namespace gfx { - -TEST(Point3Test, VectorArithmetic) { - gfx::Point3F a(1.6f, 5.1f, 3.2f); - gfx::Vector3dF v1(3.1f, -3.2f, 9.3f); - gfx::Vector3dF v2(-8.1f, 1.2f, 3.3f); - - static const struct { - gfx::Point3F expected; - gfx::Point3F actual; - } tests[] = { - { gfx::Point3F(4.7f, 1.9f, 12.5f), a + v1 }, - { gfx::Point3F(-1.5f, 8.3f, -6.1f), a - v1 }, - { a, a - v1 + v1 }, - { a, a + v1 - v1 }, - { a, a + gfx::Vector3dF() }, - { gfx::Point3F(12.8f, 0.7f, 9.2f), a + v1 - v2 }, - { gfx::Point3F(-9.6f, 9.5f, -2.8f), a - v1 + v2 } - }; - - for (size_t i = 0; i < arraysize(tests); ++i) - EXPECT_EQ(tests[i].expected.ToString(), - tests[i].actual.ToString()); - - a += v1; - EXPECT_EQ(Point3F(4.7f, 1.9f, 12.5f).ToString(), a.ToString()); - - a -= v2; - EXPECT_EQ(Point3F(12.8f, 0.7f, 9.2f).ToString(), a.ToString()); -} - -TEST(Point3Test, VectorFromPoints) { - gfx::Point3F a(1.6f, 5.2f, 3.2f); - gfx::Vector3dF v1(3.1f, -3.2f, 9.3f); - - gfx::Point3F b(a + v1); - EXPECT_EQ((b - a).ToString(), v1.ToString()); -} - -TEST(Point3Test, Scale) { - EXPECT_EQ(Point3F().ToString(), ScalePoint(Point3F(), 2.f).ToString()); - EXPECT_EQ(Point3F().ToString(), - ScalePoint(Point3F(), 2.f, 2.f, 2.f).ToString()); - - EXPECT_EQ(Point3F(2.f, -2.f, 4.f).ToString(), - ScalePoint(Point3F(1.f, -1.f, 2.f), 2.f).ToString()); - EXPECT_EQ(Point3F(2.f, -3.f, 8.f).ToString(), - ScalePoint(Point3F(1.f, -1.f, 2.f), 2.f, 3.f, 4.f).ToString()); - - Point3F zero; - zero.Scale(2.f); - zero.Scale(6.f, 3.f, 1.5f); - EXPECT_EQ(Point3F().ToString(), zero.ToString()); - - Point3F point(1.f, -1.f, 2.f); - point.Scale(2.f); - point.Scale(6.f, 3.f, 1.5f); - EXPECT_EQ(Point3F(12.f, -6.f, 6.f).ToString(), point.ToString()); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/point_conversions.cc b/ui/gfx/geometry/point_conversions.cc deleted file mode 100644 index 0613e7a9d..000000000 --- a/ui/gfx/geometry/point_conversions.cc +++ /dev/null @@ -1,30 +0,0 @@ -// 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 "ui/gfx/geometry/point_conversions.h" - -#include "ui/gfx/geometry/safe_integer_conversions.h" - -namespace gfx { - -Point ToFlooredPoint(const PointF& point) { - int x = ToFlooredInt(point.x()); - int y = ToFlooredInt(point.y()); - return Point(x, y); -} - -Point ToCeiledPoint(const PointF& point) { - int x = ToCeiledInt(point.x()); - int y = ToCeiledInt(point.y()); - return Point(x, y); -} - -Point ToRoundedPoint(const PointF& point) { - int x = ToRoundedInt(point.x()); - int y = ToRoundedInt(point.y()); - return Point(x, y); -} - -} // namespace gfx - diff --git a/ui/gfx/geometry/point_conversions.h b/ui/gfx/geometry/point_conversions.h deleted file mode 100644 index bfab9e4e4..000000000 --- a/ui/gfx/geometry/point_conversions.h +++ /dev/null @@ -1,24 +0,0 @@ -// 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 UI_GFX_GEOMETRY_POINT_CONVERSIONS_H_ -#define UI_GFX_GEOMETRY_POINT_CONVERSIONS_H_ - -#include "ui/gfx/geometry/point.h" -#include "ui/gfx/geometry/point_f.h" - -namespace gfx { - -// Returns a Point with each component from the input PointF floored. -GFX_EXPORT Point ToFlooredPoint(const PointF& point); - -// Returns a Point with each component from the input PointF ceiled. -GFX_EXPORT Point ToCeiledPoint(const PointF& point); - -// Returns a Point with each component from the input PointF rounded. -GFX_EXPORT Point ToRoundedPoint(const PointF& point); - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_POINT_CONVERSIONS_H_ diff --git a/ui/gfx/geometry/point_f.cc b/ui/gfx/geometry/point_f.cc deleted file mode 100644 index 0d1539459..000000000 --- a/ui/gfx/geometry/point_f.cc +++ /dev/null @@ -1,32 +0,0 @@ -// 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 "ui/gfx/geometry/point_f.h" - -#include "base/strings/stringprintf.h" - -namespace gfx { - -void PointF::SetToMin(const PointF& other) { - x_ = x_ <= other.x_ ? x_ : other.x_; - y_ = y_ <= other.y_ ? y_ : other.y_; -} - -void PointF::SetToMax(const PointF& other) { - x_ = x_ >= other.x_ ? x_ : other.x_; - y_ = y_ >= other.y_ ? y_ : other.y_; -} - -std::string PointF::ToString() const { - return base::StringPrintf("%f,%f", x(), y()); -} - -PointF ScalePoint(const PointF& p, float x_scale, float y_scale) { - PointF scaled_p(p); - scaled_p.Scale(x_scale, y_scale); - return scaled_p; -} - - -} // namespace gfx diff --git a/ui/gfx/geometry/point_f.h b/ui/gfx/geometry/point_f.h deleted file mode 100644 index f900c1cea..000000000 --- a/ui/gfx/geometry/point_f.h +++ /dev/null @@ -1,122 +0,0 @@ -// 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 UI_GFX_GEOMETRY_POINT_F_H_ -#define UI_GFX_GEOMETRY_POINT_F_H_ - -#include -#include - -#include "ui/gfx/geometry/vector2d_f.h" -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -// A floating version of gfx::Point. -class GFX_EXPORT PointF { - public: - PointF() : x_(0.f), y_(0.f) {} - PointF(float x, float y) : x_(x), y_(y) {} - ~PointF() {} - - float x() const { return x_; } - float y() const { return y_; } - void set_x(float x) { x_ = x; } - void set_y(float y) { y_ = y; } - - void SetPoint(float x, float y) { - x_ = x; - y_ = y; - } - - void Offset(float delta_x, float delta_y) { - x_ += delta_x; - y_ += delta_y; - } - - void operator+=(const Vector2dF& vector) { - x_ += vector.x(); - y_ += vector.y(); - } - - void operator-=(const Vector2dF& vector) { - x_ -= vector.x(); - y_ -= vector.y(); - } - - void SetToMin(const PointF& other); - void SetToMax(const PointF& other); - - bool IsOrigin() const { return x_ == 0 && y_ == 0; } - - Vector2dF OffsetFromOrigin() const { return Vector2dF(x_, y_); } - - // A point is less than another point if its y-value is closer - // to the origin. If the y-values are the same, then point with - // the x-value closer to the origin is considered less than the - // other. - // This comparison is required to use PointF in sets, or sorted - // vectors. - bool operator<(const PointF& rhs) const { - return (y_ == rhs.y_) ? (x_ < rhs.x_) : (y_ < rhs.y_); - } - - void Scale(float scale) { - Scale(scale, scale); - } - - void Scale(float x_scale, float y_scale) { - SetPoint(x() * x_scale, y() * y_scale); - } - - // Returns a string representation of point. - std::string ToString() const; - - private: - float x_; - float y_; -}; - -inline bool operator==(const PointF& lhs, const PointF& rhs) { - return lhs.x() == rhs.x() && lhs.y() == rhs.y(); -} - -inline bool operator!=(const PointF& lhs, const PointF& rhs) { - return !(lhs == rhs); -} - -inline PointF operator+(const PointF& lhs, const Vector2dF& rhs) { - PointF result(lhs); - result += rhs; - return result; -} - -inline PointF operator-(const PointF& lhs, const Vector2dF& rhs) { - PointF result(lhs); - result -= rhs; - return result; -} - -inline Vector2dF operator-(const PointF& lhs, const PointF& rhs) { - return Vector2dF(lhs.x() - rhs.x(), lhs.y() - rhs.y()); -} - -inline PointF PointAtOffsetFromOrigin(const Vector2dF& offset_from_origin) { - return PointF(offset_from_origin.x(), offset_from_origin.y()); -} - -GFX_EXPORT PointF ScalePoint(const PointF& p, float x_scale, float y_scale); - -inline PointF ScalePoint(const PointF& p, float scale) { - return ScalePoint(p, scale, scale); -} - -// This is declared here for use in gtest-based unit tests but is defined in -// the gfx_test_support target. Depend on that to use this in your unit test. -// This should not be used in production code - call ToString() instead. -void PrintTo(const PointF& point, ::std::ostream* os); - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_POINT_F_H_ diff --git a/ui/gfx/geometry/point_unittest.cc b/ui/gfx/geometry/point_unittest.cc deleted file mode 100644 index 07a5d5b25..000000000 --- a/ui/gfx/geometry/point_unittest.cc +++ /dev/null @@ -1,172 +0,0 @@ -// 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/basictypes.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/gfx/geometry/point.h" -#include "ui/gfx/geometry/point_conversions.h" -#include "ui/gfx/geometry/point_f.h" - -namespace gfx { - -namespace { - -int TestPointF(const PointF& p) { - return p.x(); -} - -} // namespace - -TEST(PointTest, ToPointF) { - // Check that implicit conversion from integer to float compiles. - Point a(10, 20); - float x = TestPointF(a); - EXPECT_EQ(x, a.x()); - - PointF b(10, 20); - EXPECT_EQ(a, b); - EXPECT_EQ(b, a); -} - -TEST(PointTest, IsOrigin) { - EXPECT_FALSE(Point(1, 0).IsOrigin()); - EXPECT_FALSE(Point(0, 1).IsOrigin()); - EXPECT_FALSE(Point(1, 2).IsOrigin()); - EXPECT_FALSE(Point(-1, 0).IsOrigin()); - EXPECT_FALSE(Point(0, -1).IsOrigin()); - EXPECT_FALSE(Point(-1, -2).IsOrigin()); - EXPECT_TRUE(Point(0, 0).IsOrigin()); - - EXPECT_FALSE(PointF(0.1f, 0).IsOrigin()); - EXPECT_FALSE(PointF(0, 0.1f).IsOrigin()); - EXPECT_FALSE(PointF(0.1f, 2).IsOrigin()); - EXPECT_FALSE(PointF(-0.1f, 0).IsOrigin()); - EXPECT_FALSE(PointF(0, -0.1f).IsOrigin()); - EXPECT_FALSE(PointF(-0.1f, -2).IsOrigin()); - EXPECT_TRUE(PointF(0, 0).IsOrigin()); -} - -TEST(PointTest, VectorArithmetic) { - Point a(1, 5); - Vector2d v1(3, -3); - Vector2d v2(-8, 1); - - static const struct { - Point expected; - Point actual; - } tests[] = { - { Point(4, 2), a + v1 }, - { Point(-2, 8), a - v1 }, - { a, a - v1 + v1 }, - { a, a + v1 - v1 }, - { a, a + Vector2d() }, - { Point(12, 1), a + v1 - v2 }, - { Point(-10, 9), a - v1 + v2 } - }; - - for (size_t i = 0; i < arraysize(tests); ++i) - EXPECT_EQ(tests[i].expected.ToString(), tests[i].actual.ToString()); -} - -TEST(PointTest, OffsetFromPoint) { - Point a(1, 5); - Point b(-20, 8); - EXPECT_EQ(Vector2d(-20 - 1, 8 - 5).ToString(), (b - a).ToString()); -} - -TEST(PointTest, ToRoundedPoint) { - EXPECT_EQ(Point(0, 0), ToRoundedPoint(PointF(0, 0))); - EXPECT_EQ(Point(0, 0), ToRoundedPoint(PointF(0.0001f, 0.0001f))); - EXPECT_EQ(Point(0, 0), ToRoundedPoint(PointF(0.4999f, 0.4999f))); - EXPECT_EQ(Point(1, 1), ToRoundedPoint(PointF(0.5f, 0.5f))); - EXPECT_EQ(Point(1, 1), ToRoundedPoint(PointF(0.9999f, 0.9999f))); - - EXPECT_EQ(Point(10, 10), ToRoundedPoint(PointF(10, 10))); - EXPECT_EQ(Point(10, 10), ToRoundedPoint(PointF(10.0001f, 10.0001f))); - EXPECT_EQ(Point(10, 10), ToRoundedPoint(PointF(10.4999f, 10.4999f))); - EXPECT_EQ(Point(11, 11), ToRoundedPoint(PointF(10.5f, 10.5f))); - EXPECT_EQ(Point(11, 11), ToRoundedPoint(PointF(10.9999f, 10.9999f))); - - EXPECT_EQ(Point(-10, -10), ToRoundedPoint(PointF(-10, -10))); - EXPECT_EQ(Point(-10, -10), ToRoundedPoint(PointF(-10.0001f, -10.0001f))); - EXPECT_EQ(Point(-10, -10), ToRoundedPoint(PointF(-10.4999f, -10.4999f))); - EXPECT_EQ(Point(-11, -11), ToRoundedPoint(PointF(-10.5f, -10.5f))); - EXPECT_EQ(Point(-11, -11), ToRoundedPoint(PointF(-10.9999f, -10.9999f))); -} - -TEST(PointTest, Scale) { - EXPECT_EQ(PointF().ToString(), ScalePoint(Point(), 2).ToString()); - EXPECT_EQ(PointF().ToString(), ScalePoint(Point(), 2, 2).ToString()); - - EXPECT_EQ(PointF(2, -2).ToString(), - ScalePoint(Point(1, -1), 2).ToString()); - EXPECT_EQ(PointF(2, -2).ToString(), - ScalePoint(Point(1, -1), 2, 2).ToString()); - - PointF zero; - PointF one(1, -1); - - zero.Scale(2); - zero.Scale(3, 1.5); - - one.Scale(2); - one.Scale(3, 1.5); - - EXPECT_EQ(PointF().ToString(), zero.ToString()); - EXPECT_EQ(PointF(6, -3).ToString(), one.ToString()); -} - -TEST(PointTest, ClampPoint) { - Point a; - - a = Point(3, 5); - EXPECT_EQ(Point(3, 5).ToString(), a.ToString()); - a.SetToMax(Point(2, 4)); - EXPECT_EQ(Point(3, 5).ToString(), a.ToString()); - a.SetToMax(Point(3, 5)); - EXPECT_EQ(Point(3, 5).ToString(), a.ToString()); - a.SetToMax(Point(4, 2)); - EXPECT_EQ(Point(4, 5).ToString(), a.ToString()); - a.SetToMax(Point(8, 10)); - EXPECT_EQ(Point(8, 10).ToString(), a.ToString()); - - a.SetToMin(Point(9, 11)); - EXPECT_EQ(Point(8, 10).ToString(), a.ToString()); - a.SetToMin(Point(8, 10)); - EXPECT_EQ(Point(8, 10).ToString(), a.ToString()); - a.SetToMin(Point(11, 9)); - EXPECT_EQ(Point(8, 9).ToString(), a.ToString()); - a.SetToMin(Point(7, 11)); - EXPECT_EQ(Point(7, 9).ToString(), a.ToString()); - a.SetToMin(Point(3, 5)); - EXPECT_EQ(Point(3, 5).ToString(), a.ToString()); -} - -TEST(PointTest, ClampPointF) { - PointF a; - - a = PointF(3.5f, 5.5f); - EXPECT_EQ(PointF(3.5f, 5.5f).ToString(), a.ToString()); - a.SetToMax(PointF(2.5f, 4.5f)); - EXPECT_EQ(PointF(3.5f, 5.5f).ToString(), a.ToString()); - a.SetToMax(PointF(3.5f, 5.5f)); - EXPECT_EQ(PointF(3.5f, 5.5f).ToString(), a.ToString()); - a.SetToMax(PointF(4.5f, 2.5f)); - EXPECT_EQ(PointF(4.5f, 5.5f).ToString(), a.ToString()); - a.SetToMax(PointF(8.5f, 10.5f)); - EXPECT_EQ(PointF(8.5f, 10.5f).ToString(), a.ToString()); - - a.SetToMin(PointF(9.5f, 11.5f)); - EXPECT_EQ(PointF(8.5f, 10.5f).ToString(), a.ToString()); - a.SetToMin(PointF(8.5f, 10.5f)); - EXPECT_EQ(PointF(8.5f, 10.5f).ToString(), a.ToString()); - a.SetToMin(PointF(11.5f, 9.5f)); - EXPECT_EQ(PointF(8.5f, 9.5f).ToString(), a.ToString()); - a.SetToMin(PointF(7.5f, 11.5f)); - EXPECT_EQ(PointF(7.5f, 9.5f).ToString(), a.ToString()); - a.SetToMin(PointF(3.5f, 5.5f)); - EXPECT_EQ(PointF(3.5f, 5.5f).ToString(), a.ToString()); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/quad_f.cc b/ui/gfx/geometry/quad_f.cc deleted file mode 100644 index b35c3b3ea..000000000 --- a/ui/gfx/geometry/quad_f.cc +++ /dev/null @@ -1,123 +0,0 @@ -// 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 "ui/gfx/geometry/quad_f.h" - -#include - -#include "base/strings/stringprintf.h" - -namespace gfx { - -void QuadF::operator=(const RectF& rect) { - p1_ = PointF(rect.x(), rect.y()); - p2_ = PointF(rect.right(), rect.y()); - p3_ = PointF(rect.right(), rect.bottom()); - p4_ = PointF(rect.x(), rect.bottom()); -} - -std::string QuadF::ToString() const { - return base::StringPrintf("%s;%s;%s;%s", - p1_.ToString().c_str(), - p2_.ToString().c_str(), - p3_.ToString().c_str(), - p4_.ToString().c_str()); -} - -static inline bool WithinEpsilon(float a, float b) { - return std::abs(a - b) < std::numeric_limits::epsilon(); -} - -bool QuadF::IsRectilinear() const { - return - (WithinEpsilon(p1_.x(), p2_.x()) && WithinEpsilon(p2_.y(), p3_.y()) && - WithinEpsilon(p3_.x(), p4_.x()) && WithinEpsilon(p4_.y(), p1_.y())) || - (WithinEpsilon(p1_.y(), p2_.y()) && WithinEpsilon(p2_.x(), p3_.x()) && - WithinEpsilon(p3_.y(), p4_.y()) && WithinEpsilon(p4_.x(), p1_.x())); -} - -bool QuadF::IsCounterClockwise() const { - // This math computes the signed area of the quad. Positive area - // indicates the quad is clockwise; negative area indicates the quad is - // counter-clockwise. Note carefully: this is backwards from conventional - // math because our geometric space uses screen coordiantes with y-axis - // pointing downards. - // Reference: http://mathworld.wolfram.com/PolygonArea.html. - // The equation can be written: - // Signed area = determinant1 + determinant2 + determinant3 + determinant4 - // In practise, Refactoring the computation of adding determinants so that - // reducing the number of operations. The equation is: - // Signed area = element1 + element2 - element3 - element4 - - float p24 = p2_.y() - p4_.y(); - float p31 = p3_.y() - p1_.y(); - - // Up-cast to double so this cannot overflow. - double element1 = static_cast(p1_.x()) * p24; - double element2 = static_cast(p2_.x()) * p31; - double element3 = static_cast(p3_.x()) * p24; - double element4 = static_cast(p4_.x()) * p31; - - return element1 + element2 < element3 + element4; -} - -static inline bool PointIsInTriangle(const PointF& point, - const PointF& r1, - const PointF& r2, - const PointF& r3) { - // Translate point and triangle so that point lies at origin. - // Then checking if the origin is contained in the translated triangle. - // The origin O lies inside ABC if and only if the triangles OAB, OBC, - // and OCA are all either clockwise or counterclockwise. - // This algorithm is from Real-Time Collision Detection (Chaper 5.4.2). - - Vector2dF a = r1 - point; - Vector2dF b = r2 - point; - Vector2dF c = r3 - point; - - double u = CrossProduct(b, c); - double v = CrossProduct(c, a); - double w = CrossProduct(a, b); - return ((u * v < 0) || ((u * w) < 0) || ((v * w) < 0)) ? false : true; -} - -bool QuadF::Contains(const PointF& point) const { - return PointIsInTriangle(point, p1_, p2_, p3_) - || PointIsInTriangle(point, p1_, p3_, p4_); -} - -void QuadF::Scale(float x_scale, float y_scale) { - p1_.Scale(x_scale, y_scale); - p2_.Scale(x_scale, y_scale); - p3_.Scale(x_scale, y_scale); - p4_.Scale(x_scale, y_scale); -} - -void QuadF::operator+=(const Vector2dF& rhs) { - p1_ += rhs; - p2_ += rhs; - p3_ += rhs; - p4_ += rhs; -} - -void QuadF::operator-=(const Vector2dF& rhs) { - p1_ -= rhs; - p2_ -= rhs; - p3_ -= rhs; - p4_ -= rhs; -} - -QuadF operator+(const QuadF& lhs, const Vector2dF& rhs) { - QuadF result = lhs; - result += rhs; - return result; -} - -QuadF operator-(const QuadF& lhs, const Vector2dF& rhs) { - QuadF result = lhs; - result -= rhs; - return result; -} - -} // namespace gfx diff --git a/ui/gfx/geometry/quad_f.h b/ui/gfx/geometry/quad_f.h deleted file mode 100644 index d7950645c..000000000 --- a/ui/gfx/geometry/quad_f.h +++ /dev/null @@ -1,128 +0,0 @@ -// 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 UI_GFX_GEOMETRY_QUAD_F_H_ -#define UI_GFX_GEOMETRY_QUAD_F_H_ - -#include -#include -#include -#include - -#include "base/logging.h" -#include "ui/gfx/geometry/point_f.h" -#include "ui/gfx/geometry/rect_f.h" -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -// A Quad is defined by four corners, allowing it to have edges that are not -// axis-aligned, unlike a Rect. -class GFX_EXPORT QuadF { - public: - QuadF() {} - QuadF(const PointF& p1, const PointF& p2, const PointF& p3, const PointF& p4) - : p1_(p1), - p2_(p2), - p3_(p3), - p4_(p4) {} - - explicit QuadF(const RectF& rect) - : p1_(rect.x(), rect.y()), - p2_(rect.right(), rect.y()), - p3_(rect.right(), rect.bottom()), - p4_(rect.x(), rect.bottom()) {} - - void operator=(const RectF& rect); - - void set_p1(const PointF& p) { p1_ = p; } - void set_p2(const PointF& p) { p2_ = p; } - void set_p3(const PointF& p) { p3_ = p; } - void set_p4(const PointF& p) { p4_ = p; } - - const PointF& p1() const { return p1_; } - const PointF& p2() const { return p2_; } - const PointF& p3() const { return p3_; } - const PointF& p4() const { return p4_; } - - // Returns true if the quad is an axis-aligned rectangle. - bool IsRectilinear() const; - - // Returns true if the points of the quad are in counter-clockwise order. This - // assumes that the quad is convex, and that no three points are collinear. - bool IsCounterClockwise() const; - - // Returns true if the |point| is contained within the quad, or lies on on - // edge of the quad. This assumes that the quad is convex. - bool Contains(const gfx::PointF& point) const; - - // Returns a rectangle that bounds the four points of the quad. The points of - // the quad may lie on the right/bottom edge of the resulting rectangle, - // rather than being strictly inside it. - RectF BoundingBox() const { - float rl = std::min(std::min(p1_.x(), p2_.x()), std::min(p3_.x(), p4_.x())); - float rr = std::max(std::max(p1_.x(), p2_.x()), std::max(p3_.x(), p4_.x())); - float rt = std::min(std::min(p1_.y(), p2_.y()), std::min(p3_.y(), p4_.y())); - float rb = std::max(std::max(p1_.y(), p2_.y()), std::max(p3_.y(), p4_.y())); - return RectF(rl, rt, rr - rl, rb - rt); - } - - // Realigns the corners in the quad by rotating them n corners to the right. - void Realign(size_t times) { - DCHECK_LE(times, 4u); - for (size_t i = 0; i < times; ++i) { - PointF temp = p1_; - p1_ = p2_; - p2_ = p3_; - p3_ = p4_; - p4_ = temp; - } - } - - // Add a vector to the quad, offseting each point in the quad by the vector. - void operator+=(const Vector2dF& rhs); - // Subtract a vector from the quad, offseting each point in the quad by the - // inverse of the vector. - void operator-=(const Vector2dF& rhs); - - // Scale each point in the quad by the |scale| factor. - void Scale(float scale) { Scale(scale, scale); } - - // Scale each point in the quad by the scale factors along each axis. - void Scale(float x_scale, float y_scale); - - // Returns a string representation of quad. - std::string ToString() const; - - private: - PointF p1_; - PointF p2_; - PointF p3_; - PointF p4_; -}; - -inline bool operator==(const QuadF& lhs, const QuadF& rhs) { - return - lhs.p1() == rhs.p1() && lhs.p2() == rhs.p2() && - lhs.p3() == rhs.p3() && lhs.p4() == rhs.p4(); -} - -inline bool operator!=(const QuadF& lhs, const QuadF& rhs) { - return !(lhs == rhs); -} - -// Add a vector to a quad, offseting each point in the quad by the vector. -GFX_EXPORT QuadF operator+(const QuadF& lhs, const Vector2dF& rhs); -// Subtract a vector from a quad, offseting each point in the quad by the -// inverse of the vector. -GFX_EXPORT QuadF operator-(const QuadF& lhs, const Vector2dF& rhs); - -// This is declared here for use in gtest-based unit tests but is defined in -// the gfx_test_support target. Depend on that to use this in your unit test. -// This should not be used in production code - call ToString() instead. -void PrintTo(const QuadF& quad, ::std::ostream* os); - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_QUAD_F_H_ diff --git a/ui/gfx/geometry/quad_unittest.cc b/ui/gfx/geometry/quad_unittest.cc deleted file mode 100644 index a5c200d15..000000000 --- a/ui/gfx/geometry/quad_unittest.cc +++ /dev/null @@ -1,358 +0,0 @@ -// 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/basictypes.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/gfx/geometry/quad_f.h" -#include "ui/gfx/geometry/rect_f.h" - -namespace gfx { - -TEST(QuadTest, Construction) { - // Verify constructors. - PointF a(1, 1); - PointF b(2, 1); - PointF c(2, 2); - PointF d(1, 2); - PointF e; - QuadF q1; - QuadF q2(e, e, e, e); - QuadF q3(a, b, c, d); - QuadF q4(BoundingRect(a, c)); - EXPECT_EQ(q1, q2); - EXPECT_EQ(q3, q4); - - // Verify getters. - EXPECT_EQ(q3.p1(), a); - EXPECT_EQ(q3.p2(), b); - EXPECT_EQ(q3.p3(), c); - EXPECT_EQ(q3.p4(), d); - - // Verify setters. - q3.set_p1(b); - q3.set_p2(c); - q3.set_p3(d); - q3.set_p4(a); - EXPECT_EQ(q3.p1(), b); - EXPECT_EQ(q3.p2(), c); - EXPECT_EQ(q3.p3(), d); - EXPECT_EQ(q3.p4(), a); - - // Verify operator=(Rect) - EXPECT_NE(q1, q4); - q1 = BoundingRect(a, c); - EXPECT_EQ(q1, q4); - - // Verify operator=(Quad) - EXPECT_NE(q1, q3); - q1 = q3; - EXPECT_EQ(q1, q3); -} - -TEST(QuadTest, AddingVectors) { - PointF a(1, 1); - PointF b(2, 1); - PointF c(2, 2); - PointF d(1, 2); - Vector2dF v(3.5f, -2.5f); - - QuadF q1(a, b, c, d); - QuadF added = q1 + v; - q1 += v; - QuadF expected1(PointF(4.5f, -1.5f), - PointF(5.5f, -1.5f), - PointF(5.5f, -0.5f), - PointF(4.5f, -0.5f)); - EXPECT_EQ(expected1, added); - EXPECT_EQ(expected1, q1); - - QuadF q2(a, b, c, d); - QuadF subtracted = q2 - v; - q2 -= v; - QuadF expected2(PointF(-2.5f, 3.5f), - PointF(-1.5f, 3.5f), - PointF(-1.5f, 4.5f), - PointF(-2.5f, 4.5f)); - EXPECT_EQ(expected2, subtracted); - EXPECT_EQ(expected2, q2); - - QuadF q3(a, b, c, d); - q3 += v; - q3 -= v; - EXPECT_EQ(QuadF(a, b, c, d), q3); - EXPECT_EQ(q3, (q3 + v - v)); -} - -TEST(QuadTest, IsRectilinear) { - PointF a(1, 1); - PointF b(2, 1); - PointF c(2, 2); - PointF d(1, 2); - Vector2dF v(3.5f, -2.5f); - - EXPECT_TRUE(QuadF().IsRectilinear()); - EXPECT_TRUE(QuadF(a, b, c, d).IsRectilinear()); - EXPECT_TRUE((QuadF(a, b, c, d) + v).IsRectilinear()); - - float epsilon = std::numeric_limits::epsilon(); - PointF a2(1 + epsilon / 2, 1 + epsilon / 2); - PointF b2(2 + epsilon / 2, 1 + epsilon / 2); - PointF c2(2 + epsilon / 2, 2 + epsilon / 2); - PointF d2(1 + epsilon / 2, 2 + epsilon / 2); - EXPECT_TRUE(QuadF(a2, b, c, d).IsRectilinear()); - EXPECT_TRUE((QuadF(a2, b, c, d) + v).IsRectilinear()); - EXPECT_TRUE(QuadF(a, b2, c, d).IsRectilinear()); - EXPECT_TRUE((QuadF(a, b2, c, d) + v).IsRectilinear()); - EXPECT_TRUE(QuadF(a, b, c2, d).IsRectilinear()); - EXPECT_TRUE((QuadF(a, b, c2, d) + v).IsRectilinear()); - EXPECT_TRUE(QuadF(a, b, c, d2).IsRectilinear()); - EXPECT_TRUE((QuadF(a, b, c, d2) + v).IsRectilinear()); - - struct { - PointF a_off, b_off, c_off, d_off; - } tests[] = { - { - PointF(1, 1.00001f), - PointF(2, 1.00001f), - PointF(2, 2.00001f), - PointF(1, 2.00001f) - }, - { - PointF(1.00001f, 1), - PointF(2.00001f, 1), - PointF(2.00001f, 2), - PointF(1.00001f, 2) - }, - { - PointF(1.00001f, 1.00001f), - PointF(2.00001f, 1.00001f), - PointF(2.00001f, 2.00001f), - PointF(1.00001f, 2.00001f) - }, - { - PointF(1, 0.99999f), - PointF(2, 0.99999f), - PointF(2, 1.99999f), - PointF(1, 1.99999f) - }, - { - PointF(0.99999f, 1), - PointF(1.99999f, 1), - PointF(1.99999f, 2), - PointF(0.99999f, 2) - }, - { - PointF(0.99999f, 0.99999f), - PointF(1.99999f, 0.99999f), - PointF(1.99999f, 1.99999f), - PointF(0.99999f, 1.99999f) - } - }; - - for (size_t i = 0; i < arraysize(tests); ++i) { - PointF a_off = tests[i].a_off; - PointF b_off = tests[i].b_off; - PointF c_off = tests[i].c_off; - PointF d_off = tests[i].d_off; - - EXPECT_FALSE(QuadF(a_off, b, c, d).IsRectilinear()); - EXPECT_FALSE((QuadF(a_off, b, c, d) + v).IsRectilinear()); - EXPECT_FALSE(QuadF(a, b_off, c, d).IsRectilinear()); - EXPECT_FALSE((QuadF(a, b_off, c, d) + v).IsRectilinear()); - EXPECT_FALSE(QuadF(a, b, c_off, d).IsRectilinear()); - EXPECT_FALSE((QuadF(a, b, c_off, d) + v).IsRectilinear()); - EXPECT_FALSE(QuadF(a, b, c, d_off).IsRectilinear()); - EXPECT_FALSE((QuadF(a, b, c, d_off) + v).IsRectilinear()); - EXPECT_FALSE(QuadF(a_off, b, c_off, d).IsRectilinear()); - EXPECT_FALSE((QuadF(a_off, b, c_off, d) + v).IsRectilinear()); - EXPECT_FALSE(QuadF(a, b_off, c, d_off).IsRectilinear()); - EXPECT_FALSE((QuadF(a, b_off, c, d_off) + v).IsRectilinear()); - EXPECT_FALSE(QuadF(a, b_off, c_off, d_off).IsRectilinear()); - EXPECT_FALSE((QuadF(a, b_off, c_off, d_off) + v).IsRectilinear()); - EXPECT_FALSE(QuadF(a_off, b, c_off, d_off).IsRectilinear()); - EXPECT_FALSE((QuadF(a_off, b, c_off, d_off) + v).IsRectilinear()); - EXPECT_FALSE(QuadF(a_off, b_off, c, d_off).IsRectilinear()); - EXPECT_FALSE((QuadF(a_off, b_off, c, d_off) + v).IsRectilinear()); - EXPECT_FALSE(QuadF(a_off, b_off, c_off, d).IsRectilinear()); - EXPECT_FALSE((QuadF(a_off, b_off, c_off, d) + v).IsRectilinear()); - EXPECT_TRUE(QuadF(a_off, b_off, c_off, d_off).IsRectilinear()); - EXPECT_TRUE((QuadF(a_off, b_off, c_off, d_off) + v).IsRectilinear()); - } -} - -TEST(QuadTest, IsCounterClockwise) { - PointF a1(1, 1); - PointF b1(2, 1); - PointF c1(2, 2); - PointF d1(1, 2); - EXPECT_FALSE(QuadF(a1, b1, c1, d1).IsCounterClockwise()); - EXPECT_FALSE(QuadF(b1, c1, d1, a1).IsCounterClockwise()); - EXPECT_TRUE(QuadF(a1, d1, c1, b1).IsCounterClockwise()); - EXPECT_TRUE(QuadF(c1, b1, a1, d1).IsCounterClockwise()); - - // Slightly more complicated quads should work just as easily. - PointF a2(1.3f, 1.4f); - PointF b2(-0.7f, 4.9f); - PointF c2(1.8f, 6.2f); - PointF d2(2.1f, 1.6f); - EXPECT_TRUE(QuadF(a2, b2, c2, d2).IsCounterClockwise()); - EXPECT_TRUE(QuadF(b2, c2, d2, a2).IsCounterClockwise()); - EXPECT_FALSE(QuadF(a2, d2, c2, b2).IsCounterClockwise()); - EXPECT_FALSE(QuadF(c2, b2, a2, d2).IsCounterClockwise()); - - // Quads with 3 collinear points should work correctly, too. - PointF a3(0, 0); - PointF b3(1, 0); - PointF c3(2, 0); - PointF d3(1, 1); - EXPECT_FALSE(QuadF(a3, b3, c3, d3).IsCounterClockwise()); - EXPECT_FALSE(QuadF(b3, c3, d3, a3).IsCounterClockwise()); - EXPECT_TRUE(QuadF(a3, d3, c3, b3).IsCounterClockwise()); - // The next expectation in particular would fail for an implementation - // that incorrectly uses only a cross product of the first 3 vertices. - EXPECT_TRUE(QuadF(c3, b3, a3, d3).IsCounterClockwise()); - - // Non-convex quads should work correctly, too. - PointF a4(0, 0); - PointF b4(1, 1); - PointF c4(2, 0); - PointF d4(1, 3); - EXPECT_FALSE(QuadF(a4, b4, c4, d4).IsCounterClockwise()); - EXPECT_FALSE(QuadF(b4, c4, d4, a4).IsCounterClockwise()); - EXPECT_TRUE(QuadF(a4, d4, c4, b4).IsCounterClockwise()); - EXPECT_TRUE(QuadF(c4, b4, a4, d4).IsCounterClockwise()); - - // A quad with huge coordinates should not fail this check due to - // single-precision overflow. - PointF a5(1e30f, 1e30f); - PointF b5(1e35f, 1e30f); - PointF c5(1e35f, 1e35f); - PointF d5(1e30f, 1e35f); - EXPECT_FALSE(QuadF(a5, b5, c5, d5).IsCounterClockwise()); - EXPECT_FALSE(QuadF(b5, c5, d5, a5).IsCounterClockwise()); - EXPECT_TRUE(QuadF(a5, d5, c5, b5).IsCounterClockwise()); - EXPECT_TRUE(QuadF(c5, b5, a5, d5).IsCounterClockwise()); -} - -TEST(QuadTest, BoundingBox) { - RectF r(3.2f, 5.4f, 7.007f, 12.01f); - EXPECT_EQ(r, QuadF(r).BoundingBox()); - - PointF a(1.3f, 1.4f); - PointF b(-0.7f, 4.9f); - PointF c(1.8f, 6.2f); - PointF d(2.1f, 1.6f); - float left = -0.7f; - float top = 1.4f; - float right = 2.1f; - float bottom = 6.2f; - EXPECT_EQ(RectF(left, top, right - left, bottom - top), - QuadF(a, b, c, d).BoundingBox()); -} - -TEST(QuadTest, ContainsPoint) { - PointF a(1.3f, 1.4f); - PointF b(-0.8f, 4.4f); - PointF c(1.8f, 6.1f); - PointF d(2.1f, 1.6f); - - Vector2dF epsilon_x(2 * std::numeric_limits::epsilon(), 0); - Vector2dF epsilon_y(0, 2 * std::numeric_limits::epsilon()); - - Vector2dF ac_center = c - a; - ac_center.Scale(0.5f); - Vector2dF bd_center = d - b; - bd_center.Scale(0.5f); - - EXPECT_TRUE(QuadF(a, b, c, d).Contains(a + ac_center)); - EXPECT_TRUE(QuadF(a, b, c, d).Contains(b + bd_center)); - EXPECT_TRUE(QuadF(a, b, c, d).Contains(c - ac_center)); - EXPECT_TRUE(QuadF(a, b, c, d).Contains(d - bd_center)); - EXPECT_FALSE(QuadF(a, b, c, d).Contains(a - ac_center)); - EXPECT_FALSE(QuadF(a, b, c, d).Contains(b - bd_center)); - EXPECT_FALSE(QuadF(a, b, c, d).Contains(c + ac_center)); - EXPECT_FALSE(QuadF(a, b, c, d).Contains(d + bd_center)); - - EXPECT_TRUE(QuadF(a, b, c, d).Contains(a)); - EXPECT_FALSE(QuadF(a, b, c, d).Contains(a - epsilon_x)); - EXPECT_FALSE(QuadF(a, b, c, d).Contains(a - epsilon_y)); - EXPECT_FALSE(QuadF(a, b, c, d).Contains(a + epsilon_x)); - EXPECT_TRUE(QuadF(a, b, c, d).Contains(a + epsilon_y)); - - EXPECT_TRUE(QuadF(a, b, c, d).Contains(b)); - EXPECT_FALSE(QuadF(a, b, c, d).Contains(b - epsilon_x)); - EXPECT_FALSE(QuadF(a, b, c, d).Contains(b - epsilon_y)); - EXPECT_TRUE(QuadF(a, b, c, d).Contains(b + epsilon_x)); - EXPECT_FALSE(QuadF(a, b, c, d).Contains(b + epsilon_y)); - - EXPECT_TRUE(QuadF(a, b, c, d).Contains(c)); - EXPECT_FALSE(QuadF(a, b, c, d).Contains(c - epsilon_x)); - EXPECT_TRUE(QuadF(a, b, c, d).Contains(c - epsilon_y)); - EXPECT_FALSE(QuadF(a, b, c, d).Contains(c + epsilon_x)); - EXPECT_FALSE(QuadF(a, b, c, d).Contains(c + epsilon_y)); - - EXPECT_TRUE(QuadF(a, b, c, d).Contains(d)); - EXPECT_TRUE(QuadF(a, b, c, d).Contains(d - epsilon_x)); - EXPECT_FALSE(QuadF(a, b, c, d).Contains(d - epsilon_y)); - EXPECT_FALSE(QuadF(a, b, c, d).Contains(d + epsilon_x)); - EXPECT_FALSE(QuadF(a, b, c, d).Contains(d + epsilon_y)); - - // Test a simple square. - PointF s1(-1, -1); - PointF s2(1, -1); - PointF s3(1, 1); - PointF s4(-1, 1); - // Top edge. - EXPECT_FALSE(QuadF(s1, s2, s3, s4).Contains(PointF(-1.1f, -1.0f))); - EXPECT_TRUE(QuadF(s1, s2, s3, s4).Contains(PointF(-1.0f, -1.0f))); - EXPECT_TRUE(QuadF(s1, s2, s3, s4).Contains(PointF(0.0f, -1.0f))); - EXPECT_TRUE(QuadF(s1, s2, s3, s4).Contains(PointF(1.0f, -1.0f))); - EXPECT_FALSE(QuadF(s1, s2, s3, s4).Contains(PointF(1.1f, -1.0f))); - // Bottom edge. - EXPECT_FALSE(QuadF(s1, s2, s3, s4).Contains(PointF(-1.1f, 1.0f))); - EXPECT_TRUE(QuadF(s1, s2, s3, s4).Contains(PointF(-1.0f, 1.0f))); - EXPECT_TRUE(QuadF(s1, s2, s3, s4).Contains(PointF(0.0f, 1.0f))); - EXPECT_TRUE(QuadF(s1, s2, s3, s4).Contains(PointF(1.0f, 1.0f))); - EXPECT_FALSE(QuadF(s1, s2, s3, s4).Contains(PointF(1.1f, 1.0f))); - // Left edge. - EXPECT_FALSE(QuadF(s1, s2, s3, s4).Contains(PointF(-1.0f, -1.1f))); - EXPECT_TRUE(QuadF(s1, s2, s3, s4).Contains(PointF(-1.0f, -1.0f))); - EXPECT_TRUE(QuadF(s1, s2, s3, s4).Contains(PointF(-1.0f, 0.0f))); - EXPECT_TRUE(QuadF(s1, s2, s3, s4).Contains(PointF(-1.0f, 1.0f))); - EXPECT_FALSE(QuadF(s1, s2, s3, s4).Contains(PointF(-1.0f, 1.1f))); - // Right edge. - EXPECT_FALSE(QuadF(s1, s2, s3, s4).Contains(PointF(1.0f, -1.1f))); - EXPECT_TRUE(QuadF(s1, s2, s3, s4).Contains(PointF(1.0f, -1.0f))); - EXPECT_TRUE(QuadF(s1, s2, s3, s4).Contains(PointF(1.0f, 0.0f))); - EXPECT_TRUE(QuadF(s1, s2, s3, s4).Contains(PointF(1.0f, 1.0f))); - EXPECT_FALSE(QuadF(s1, s2, s3, s4).Contains(PointF(1.0f, 1.1f))); - // Centered inside. - EXPECT_TRUE(QuadF(s1, s2, s3, s4).Contains(PointF(0, 0))); - // Centered outside. - EXPECT_FALSE(QuadF(s1, s2, s3, s4).Contains(PointF(-1.1f, 0))); - EXPECT_FALSE(QuadF(s1, s2, s3, s4).Contains(PointF(1.1f, 0))); - EXPECT_FALSE(QuadF(s1, s2, s3, s4).Contains(PointF(0, -1.1f))); - EXPECT_FALSE(QuadF(s1, s2, s3, s4).Contains(PointF(0, 1.1f))); -} - -TEST(QuadTest, Scale) { - PointF a(1.3f, 1.4f); - PointF b(-0.8f, 4.4f); - PointF c(1.8f, 6.1f); - PointF d(2.1f, 1.6f); - QuadF q1(a, b, c, d); - q1.Scale(1.5f); - - PointF a_scaled = ScalePoint(a, 1.5f); - PointF b_scaled = ScalePoint(b, 1.5f); - PointF c_scaled = ScalePoint(c, 1.5f); - PointF d_scaled = ScalePoint(d, 1.5f); - EXPECT_EQ(q1, QuadF(a_scaled, b_scaled, c_scaled, d_scaled)); - - QuadF q2; - q2.Scale(1.5f); - EXPECT_EQ(q2, q2); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/r_tree.h b/ui/gfx/geometry/r_tree.h deleted file mode 100644 index 53fd5c9f9..000000000 --- a/ui/gfx/geometry/r_tree.h +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright 2014 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. - -// Defines a hierarchical bounding rectangle data structure for Rect objects, -// associated with a generic unique key K for efficient spatial queries. The -// R*-tree algorithm is used to build the trees. Based on the papers: -// -// A Guttman 'R-trees: a dynamic index structure for spatial searching', Proc -// ACM SIGMOD Int Conf on Management of Data, 47-57, 1984 -// -// N Beckmann, H-P Kriegel, R Schneider, B Seeger 'The R*-tree: an efficient and -// robust access method for points and rectangles', Proc ACM SIGMOD Int Conf on -// Management of Data, 322-331, 1990 - -#ifndef UI_GFX_GEOMETRY_R_TREE_H_ -#define UI_GFX_GEOMETRY_R_TREE_H_ - -#include "r_tree_base.h" - -namespace gfx { - -template -class RTree : public RTreeBase { - public: - typedef base::hash_set Matches; - - // RTrees organize pairs of keys and rectangles in a hierarchical bounding - // box structure. This allows for queries of the tree within logarithmic time. - // |min_children| and |max_children| allows for adjustment of the average size - // of the nodes within RTree, which adjusts the base of the logarithm in the - // algorithm runtime. Some parts of insertion and deletion are polynomial - // in the size of the individual node, so the trade-off with larger nodes is - // potentially faster queries but slower insertions and deletions. Generally - // it is worth considering how much overlap between rectangles of different - // keys will occur in the tree, and trying to set |max_children| as a - // reasonable upper bound to the number of overlapping rectangles expected. - // Then |min_children| can bet set to a quantity slightly less than half of - // that. - RTree(size_t min_children, size_t max_children); - ~RTree(); - - // Insert a new rect into the tree, associated with provided key. Note that if - // |rect| is empty, the |key| will not actually be inserted. Duplicate keys - // overwrite old entries. - void Insert(const Rect& rect, Key key); - - // If present, remove the supplied |key| from the tree. - void Remove(Key key); - - // Fills |matches_out| with all keys having bounding rects intersecting - // |query_rect|. - void AppendIntersectingRecords(const Rect& query_rect, - Matches* matches_out) const; - - void Clear(); - - private: - friend class RTreeTest; - friend class RTreeNodeTest; - - class Record : public RecordBase { - public: - Record(const Rect& rect, const Key& key); - virtual ~Record(); - const Key& key() const { return key_; } - - private: - Key key_; - - DISALLOW_COPY_AND_ASSIGN(Record); - }; - - // A map of supplied keys to their Node representation within the RTree, for - // efficient retrieval of keys without requiring a bounding rect. - typedef base::hash_map RecordMap; - RecordMap record_map_; - - DISALLOW_COPY_AND_ASSIGN(RTree); -}; - -template -RTree::RTree(size_t min_children, size_t max_children) - : RTreeBase(min_children, max_children) { -} - -template -RTree::~RTree() { -} - -template -void RTree::Insert(const Rect& rect, Key key) { - scoped_ptr record; - // Check if this key is already present in the tree. - typename RecordMap::iterator it(record_map_.find(key)); - - if (it != record_map_.end()) { - // We will re-use this node structure, regardless of re-insert or return. - Record* existing_record = it->second; - // If the new rect and the current rect are identical we can skip the rest - // of Insert() as nothing has changed. - if (existing_record->rect() == rect) - return; - - // Remove the node from the tree in its current position. - record = RemoveNode(existing_record); - - PruneRootIfNecessary(); - - // If we are replacing this key with an empty rectangle we just remove the - // old node from the list and return, thus preventing insertion of empty - // rectangles into our spatial database. - if (rect.IsEmpty()) { - record_map_.erase(it); - return; - } - - // Reset the rectangle to the new value. - record->set_rect(rect); - } else { - if (rect.IsEmpty()) - return; - - record.reset(new Record(rect, key)); - record_map_.insert(std::make_pair(key, static_cast(record.get()))); - } - - int highest_reinsert_level = -1; - InsertNode(record.Pass(), &highest_reinsert_level); -} - -template -void RTree::Clear() { - record_map_.clear(); - ResetRoot(); -} - -template -void RTree::Remove(Key key) { - // Search the map for the leaf parent that has the provided record. - typename RecordMap::iterator it = record_map_.find(key); - if (it == record_map_.end()) - return; - - Record* record = it->second; - record_map_.erase(it); - RemoveNode(record); - - // Lastly check the root. If it has only one non-leaf child, delete it and - // replace it with its child. - PruneRootIfNecessary(); -} - -template -void RTree::AppendIntersectingRecords( - const Rect& query_rect, Matches* matches_out) const { - RTreeBase::Records matching_records; - root()->AppendIntersectingRecords(query_rect, &matching_records); - for (RTreeBase::Records::const_iterator it = matching_records.begin(); - it != matching_records.end(); - ++it) { - const Record* record = static_cast(*it); - matches_out->insert(record->key()); - } -} - - -// RTree::Record -------------------------------------------------------------- - -template -RTree::Record::Record(const Rect& rect, const Key& key) - : RecordBase(rect), - key_(key) { -} - -template -RTree::Record::~Record() { -} - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_R_TREE_H_ diff --git a/ui/gfx/geometry/r_tree_base.cc b/ui/gfx/geometry/r_tree_base.cc deleted file mode 100644 index fd5deabc3..000000000 --- a/ui/gfx/geometry/r_tree_base.cc +++ /dev/null @@ -1,658 +0,0 @@ -// Copyright 2014 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 "ui/gfx/geometry/r_tree_base.h" - -#include - -#include "base/logging.h" - - -// Helpers -------------------------------------------------------------------- - -namespace { - -// Returns a Vector2d to allow us to do arithmetic on the result such as -// computing distances between centers. -gfx::Vector2d CenterOfRect(const gfx::Rect& rect) { - return rect.OffsetFromOrigin() + - gfx::Vector2d(rect.width() / 2, rect.height() / 2); -} - -} - -namespace gfx { - - -// RTreeBase::NodeBase -------------------------------------------------------- - -RTreeBase::NodeBase::~NodeBase() { -} - -void RTreeBase::NodeBase::RecomputeBoundsUpToRoot() { - RecomputeLocalBounds(); - if (parent_) - parent_->RecomputeBoundsUpToRoot(); -} - -RTreeBase::NodeBase::NodeBase(const Rect& rect, NodeBase* parent) - : rect_(rect), - parent_(parent) { -} - -void RTreeBase::NodeBase::RecomputeLocalBounds() { -} - -// RTreeBase::RecordBase ------------------------------------------------------ - -RTreeBase::RecordBase::RecordBase(const Rect& rect) : NodeBase(rect, NULL) { -} - -RTreeBase::RecordBase::~RecordBase() { -} - -void RTreeBase::RecordBase::AppendIntersectingRecords( - const Rect& query_rect, Records* matches_out) const { - if (rect().Intersects(query_rect)) - matches_out->push_back(this); -} - -void RTreeBase::RecordBase::AppendAllRecords(Records* matches_out) const { - matches_out->push_back(this); -} - -scoped_ptr -RTreeBase::RecordBase::RemoveAndReturnLastChild() { - return scoped_ptr(); -} - -int RTreeBase::RecordBase::Level() const { - return -1; -} - - -// RTreeBase::Node ------------------------------------------------------------ - -RTreeBase::Node::Node() : NodeBase(Rect(), NULL), level_(0) { -} - -RTreeBase::Node::~Node() { -} - -scoped_ptr RTreeBase::Node::ConstructParent() { - DCHECK(!parent()); - scoped_ptr new_parent(new Node(level_ + 1)); - new_parent->AddChild(scoped_ptr(this)); - return new_parent.Pass(); -} - -void RTreeBase::Node::AppendIntersectingRecords( - const Rect& query_rect, Records* matches_out) const { - // Check own bounding box for intersection, can cull all children if no - // intersection. - if (!rect().Intersects(query_rect)) - return; - - // Conversely if we are completely contained within the query rect we can - // confidently skip all bounds checks for ourselves and all our children. - if (query_rect.Contains(rect())) { - AppendAllRecords(matches_out); - return; - } - - // We intersect the query rect but we are not are not contained within it. - // We must query each of our children in turn. - for (Nodes::const_iterator i = children_.begin(); i != children_.end(); ++i) - (*i)->AppendIntersectingRecords(query_rect, matches_out); -} - -void RTreeBase::Node::AppendAllRecords(Records* matches_out) const { - for (Nodes::const_iterator i = children_.begin(); i != children_.end(); ++i) - (*i)->AppendAllRecords(matches_out); -} - -void RTreeBase::Node::RemoveNodesForReinsert(size_t number_to_remove, - Nodes* nodes) { - DCHECK_LE(number_to_remove, children_.size()); - - std::partial_sort(children_.begin(), - children_.begin() + number_to_remove, - children_.end(), - &RTreeBase::Node::CompareCenterDistanceFromParent); - - // Move the lowest-distance nodes to the returned vector. - nodes->insert( - nodes->end(), children_.begin(), children_.begin() + number_to_remove); - children_.weak_erase(children_.begin(), children_.begin() + number_to_remove); -} - -scoped_ptr RTreeBase::Node::RemoveChild( - NodeBase* child_node, Nodes* orphans) { - DCHECK_EQ(this, child_node->parent()); - - scoped_ptr orphan(child_node->RemoveAndReturnLastChild()); - while (orphan) { - orphans->push_back(orphan.release()); - orphan = child_node->RemoveAndReturnLastChild(); - } - - Nodes::iterator i = std::find(children_.begin(), children_.end(), child_node); - DCHECK(i != children_.end()); - children_.weak_erase(i); - - return scoped_ptr(child_node); -} - -scoped_ptr RTreeBase::Node::RemoveAndReturnLastChild() { - if (children_.empty()) - return scoped_ptr(); - - scoped_ptr last_child(children_.back()); - children_.weak_erase(children_.end() - 1); - last_child->set_parent(NULL); - return last_child.Pass(); -} - -RTreeBase::Node* RTreeBase::Node::ChooseSubtree(NodeBase* node) { - DCHECK(node); - // Should never be called on a node at equal or lower level in the tree than - // the node to insert. - DCHECK_GT(level_, node->Level()); - - // If we are a parent of nodes on the provided node level, we are done. - if (level_ == node->Level() + 1) - return this; - - // Precompute a vector of expanded rects, used by both LeastOverlapIncrease - // and LeastAreaEnlargement. - Rects expanded_rects; - expanded_rects.reserve(children_.size()); - for (Nodes::iterator i = children_.begin(); i != children_.end(); ++i) - expanded_rects.push_back(UnionRects(node->rect(), (*i)->rect())); - - Node* best_candidate = NULL; - // For parents of leaf nodes, we pick the node that will cause the least - // increase in overlap by the addition of this new node. This may detect a - // tie, in which case it will return NULL. - if (level_ == 1) - best_candidate = LeastOverlapIncrease(node->rect(), expanded_rects); - - // For non-parents of leaf nodes, or for parents of leaf nodes with ties in - // overlap increase, we choose the subtree with least area enlargement caused - // by the addition of the new node. - if (!best_candidate) - best_candidate = LeastAreaEnlargement(node->rect(), expanded_rects); - - DCHECK(best_candidate); - return best_candidate->ChooseSubtree(node); -} - -size_t RTreeBase::Node::AddChild(scoped_ptr node) { - DCHECK(node); - // Sanity-check that the level of the child being added is one less than ours. - DCHECK_EQ(level_ - 1, node->Level()); - node->set_parent(this); - set_rect(UnionRects(rect(), node->rect())); - children_.push_back(node.release()); - return children_.size(); -} - -scoped_ptr RTreeBase::Node::Split(size_t min_children, - size_t max_children) { - // We should have too many children to begin with. - DCHECK_EQ(max_children + 1, children_.size()); - - // Determine if we should split along the horizontal or vertical axis. - std::vector vertical_sort(children_.get()); - std::vector horizontal_sort(children_.get()); - std::sort(vertical_sort.begin(), - vertical_sort.end(), - &RTreeBase::Node::CompareVertical); - std::sort(horizontal_sort.begin(), - horizontal_sort.end(), - &RTreeBase::Node::CompareHorizontal); - - Rects low_vertical_bounds; - Rects low_horizontal_bounds; - BuildLowBounds(vertical_sort, - horizontal_sort, - &low_vertical_bounds, - &low_horizontal_bounds); - - Rects high_vertical_bounds; - Rects high_horizontal_bounds; - BuildHighBounds(vertical_sort, - horizontal_sort, - &high_vertical_bounds, - &high_horizontal_bounds); - - // Choose |end_index| such that both Nodes after the split will have - // min_children <= children_.size() <= max_children. - size_t end_index = std::min(max_children, children_.size() - min_children); - bool is_vertical_split = - SmallestMarginSum(min_children, - end_index, - low_horizontal_bounds, - high_horizontal_bounds) < - SmallestMarginSum(min_children, - end_index, - low_vertical_bounds, - high_vertical_bounds); - - // Choose split index along chosen axis and perform the split. - const Rects& low_bounds( - is_vertical_split ? low_vertical_bounds : low_horizontal_bounds); - const Rects& high_bounds( - is_vertical_split ? high_vertical_bounds : high_horizontal_bounds); - size_t split_index = - ChooseSplitIndex(min_children, end_index, low_bounds, high_bounds); - - const std::vector& sort( - is_vertical_split ? vertical_sort : horizontal_sort); - return DivideChildren(low_bounds, high_bounds, sort, split_index); -} - -int RTreeBase::Node::Level() const { - return level_; -} - -RTreeBase::Node::Node(int level) : NodeBase(Rect(), NULL), level_(level) { -} - -// static -bool RTreeBase::Node::CompareVertical(const NodeBase* a, const NodeBase* b) { - const Rect& a_rect = a->rect(); - const Rect& b_rect = b->rect(); - return (a_rect.y() < b_rect.y()) || - ((a_rect.y() == b_rect.y()) && (a_rect.height() < b_rect.height())); -} - -// static -bool RTreeBase::Node::CompareHorizontal(const NodeBase* a, const NodeBase* b) { - const Rect& a_rect = a->rect(); - const Rect& b_rect = b->rect(); - return (a_rect.x() < b_rect.x()) || - ((a_rect.x() == b_rect.x()) && (a_rect.width() < b_rect.width())); -} - -// static -bool RTreeBase::Node::CompareCenterDistanceFromParent(const NodeBase* a, - const NodeBase* b) { - const NodeBase* p = a->parent(); - - DCHECK(p); - DCHECK_EQ(p, b->parent()); - - Vector2d p_center = CenterOfRect(p->rect()); - Vector2d a_center = CenterOfRect(a->rect()); - Vector2d b_center = CenterOfRect(b->rect()); - - // We don't bother with square roots because we are only comparing the two - // values for sorting purposes. - return (a_center - p_center).LengthSquared() < - (b_center - p_center).LengthSquared(); -} - -// static -void RTreeBase::Node::BuildLowBounds( - const std::vector& vertical_sort, - const std::vector& horizontal_sort, - Rects* vertical_bounds, - Rects* horizontal_bounds) { - Rect vertical_bounds_rect; - vertical_bounds->reserve(vertical_sort.size()); - for (std::vector::const_iterator i = vertical_sort.begin(); - i != vertical_sort.end(); - ++i) { - vertical_bounds_rect.Union((*i)->rect()); - vertical_bounds->push_back(vertical_bounds_rect); - } - - Rect horizontal_bounds_rect; - horizontal_bounds->reserve(horizontal_sort.size()); - for (std::vector::const_iterator i = horizontal_sort.begin(); - i != horizontal_sort.end(); - ++i) { - horizontal_bounds_rect.Union((*i)->rect()); - horizontal_bounds->push_back(horizontal_bounds_rect); - } -} - -// static -void RTreeBase::Node::BuildHighBounds( - const std::vector& vertical_sort, - const std::vector& horizontal_sort, - Rects* vertical_bounds, - Rects* horizontal_bounds) { - Rect vertical_bounds_rect; - vertical_bounds->reserve(vertical_sort.size()); - for (std::vector::const_reverse_iterator i = - vertical_sort.rbegin(); - i != vertical_sort.rend(); - ++i) { - vertical_bounds_rect.Union((*i)->rect()); - vertical_bounds->push_back(vertical_bounds_rect); - } - std::reverse(vertical_bounds->begin(), vertical_bounds->end()); - - Rect horizontal_bounds_rect; - horizontal_bounds->reserve(horizontal_sort.size()); - for (std::vector::const_reverse_iterator i = - horizontal_sort.rbegin(); - i != horizontal_sort.rend(); - ++i) { - horizontal_bounds_rect.Union((*i)->rect()); - horizontal_bounds->push_back(horizontal_bounds_rect); - } - std::reverse(horizontal_bounds->begin(), horizontal_bounds->end()); -} - -size_t RTreeBase::Node::ChooseSplitIndex(size_t start_index, - size_t end_index, - const Rects& low_bounds, - const Rects& high_bounds) { - DCHECK_EQ(low_bounds.size(), high_bounds.size()); - - int smallest_overlap_area = UnionRects( - low_bounds[start_index], high_bounds[start_index]).size().GetArea(); - int smallest_combined_area = low_bounds[start_index].size().GetArea() + - high_bounds[start_index].size().GetArea(); - size_t optimal_split_index = start_index; - for (size_t p = start_index + 1; p < end_index; ++p) { - const int overlap_area = - UnionRects(low_bounds[p], high_bounds[p]).size().GetArea(); - const int combined_area = - low_bounds[p].size().GetArea() + high_bounds[p].size().GetArea(); - if ((overlap_area < smallest_overlap_area) || - ((overlap_area == smallest_overlap_area) && - (combined_area < smallest_combined_area))) { - smallest_overlap_area = overlap_area; - smallest_combined_area = combined_area; - optimal_split_index = p; - } - } - - // optimal_split_index currently points at the last element in the first set, - // so advance it by 1 to point at the first element in the second set. - return optimal_split_index + 1; -} - -// static -int RTreeBase::Node::SmallestMarginSum(size_t start_index, - size_t end_index, - const Rects& low_bounds, - const Rects& high_bounds) { - DCHECK_EQ(low_bounds.size(), high_bounds.size()); - DCHECK_LT(start_index, low_bounds.size()); - DCHECK_LE(start_index, end_index); - DCHECK_LE(end_index, low_bounds.size()); - Rects::const_iterator i(low_bounds.begin() + start_index); - Rects::const_iterator j(high_bounds.begin() + start_index); - int smallest_sum = i->width() + i->height() + j->width() + j->height(); - for (; i != (low_bounds.begin() + end_index); ++i, ++j) { - smallest_sum = std::min( - smallest_sum, i->width() + i->height() + j->width() + j->height()); - } - - return smallest_sum; -} - -void RTreeBase::Node::RecomputeLocalBounds() { - Rect bounds; - for (size_t i = 0; i < children_.size(); ++i) - bounds.Union(children_[i]->rect()); - - set_rect(bounds); -} - -int RTreeBase::Node::OverlapIncreaseToAdd(const Rect& rect, - const NodeBase* candidate_node, - const Rect& expanded_rect) const { - DCHECK(candidate_node); - - // Early-out when |rect| is contained completely within |candidate|. - if (candidate_node->rect().Contains(rect)) - return 0; - - int total_original_overlap = 0; - int total_expanded_overlap = 0; - - // Now calculate overlap with all other rects in this node. - for (Nodes::const_iterator it = children_.begin(); - it != children_.end(); ++it) { - // Skip calculating overlap with the candidate rect. - if ((*it) == candidate_node) - continue; - NodeBase* overlap_node = (*it); - total_original_overlap += IntersectRects( - candidate_node->rect(), overlap_node->rect()).size().GetArea(); - Rect expanded_overlap_rect = expanded_rect; - expanded_overlap_rect.Intersect(overlap_node->rect()); - total_expanded_overlap += expanded_overlap_rect.size().GetArea(); - } - - return total_expanded_overlap - total_original_overlap; -} - -scoped_ptr RTreeBase::Node::DivideChildren( - const Rects& low_bounds, - const Rects& high_bounds, - const std::vector& sorted_children, - size_t split_index) { - DCHECK_EQ(low_bounds.size(), high_bounds.size()); - DCHECK_EQ(low_bounds.size(), sorted_children.size()); - DCHECK_LT(split_index, low_bounds.size()); - DCHECK_GT(split_index, 0U); - - scoped_ptr sibling(new Node(level_)); - sibling->set_parent(parent()); - set_rect(low_bounds[split_index - 1]); - sibling->set_rect(high_bounds[split_index]); - - // Our own children_ vector is unsorted, so we wipe it out and divide the - // sorted bounds rects between ourselves and our sibling. - children_.weak_clear(); - children_.insert(children_.end(), - sorted_children.begin(), - sorted_children.begin() + split_index); - sibling->children_.insert(sibling->children_.end(), - sorted_children.begin() + split_index, - sorted_children.end()); - - for (size_t i = 0; i < sibling->children_.size(); ++i) - sibling->children_[i]->set_parent(sibling.get()); - - return sibling.Pass(); -} - -RTreeBase::Node* RTreeBase::Node::LeastOverlapIncrease( - const Rect& node_rect, - const Rects& expanded_rects) { - NodeBase* best_node = children_.front(); - int least_overlap_increase = - OverlapIncreaseToAdd(node_rect, children_[0], expanded_rects[0]); - for (size_t i = 1; i < children_.size(); ++i) { - int overlap_increase = - OverlapIncreaseToAdd(node_rect, children_[i], expanded_rects[i]); - if (overlap_increase < least_overlap_increase) { - least_overlap_increase = overlap_increase; - best_node = children_[i]; - } else if (overlap_increase == least_overlap_increase) { - // If we are tied at zero there is no possible better overlap increase, - // so we can report a tie early. - if (overlap_increase == 0) - return NULL; - - best_node = NULL; - } - } - - // Ensure that our children are always Nodes and not Records. - DCHECK_GE(level_, 1); - return static_cast(best_node); -} - -RTreeBase::Node* RTreeBase::Node::LeastAreaEnlargement( - const Rect& node_rect, - const Rects& expanded_rects) { - DCHECK(!children_.empty()); - DCHECK_EQ(children_.size(), expanded_rects.size()); - - NodeBase* best_node = children_.front(); - int least_area_enlargement = - expanded_rects[0].size().GetArea() - best_node->rect().size().GetArea(); - for (size_t i = 1; i < children_.size(); ++i) { - NodeBase* candidate_node = children_[i]; - int area_change = expanded_rects[i].size().GetArea() - - candidate_node->rect().size().GetArea(); - DCHECK_GE(area_change, 0); - if (area_change < least_area_enlargement) { - best_node = candidate_node; - least_area_enlargement = area_change; - } else if (area_change == least_area_enlargement && - candidate_node->rect().size().GetArea() < - best_node->rect().size().GetArea()) { - // Ties are broken by choosing the entry with the least area. - best_node = candidate_node; - } - } - - // Ensure that our children are always Nodes and not Records. - DCHECK_GE(level_, 1); - return static_cast(best_node); -} - - -// RTreeBase ------------------------------------------------------------------ - -RTreeBase::RTreeBase(size_t min_children, size_t max_children) - : root_(new Node()), - min_children_(min_children), - max_children_(max_children) { - DCHECK_GE(min_children_, 2U); - DCHECK_LE(min_children_, max_children_ / 2U); -} - -RTreeBase::~RTreeBase() { -} - -void RTreeBase::InsertNode( - scoped_ptr node, int* highest_reinsert_level) { - // Find the most appropriate parent to insert node into. - Node* parent = root_->ChooseSubtree(node.get()); - DCHECK(parent); - // Verify ChooseSubtree returned a Node at the correct level. - DCHECK_EQ(parent->Level(), node->Level() + 1); - Node* insert_parent = static_cast(parent); - NodeBase* needs_bounds_recomputed = insert_parent->parent(); - Nodes reinserts; - // Attempt to insert the Node, if this overflows the Node we must handle it. - while (insert_parent && - insert_parent->AddChild(node.Pass()) > max_children_) { - // If we have yet to re-insert nodes at this level during this data insert, - // and we're not at the root, R*-Tree calls for re-insertion of some of the - // nodes, resulting in a better balance on the tree. - if (insert_parent->parent() && - insert_parent->Level() > *highest_reinsert_level) { - insert_parent->RemoveNodesForReinsert(max_children_ / 3, &reinserts); - // Adjust highest_reinsert_level to this level. - *highest_reinsert_level = insert_parent->Level(); - // RemoveNodesForReinsert() does not recompute bounds, so mark it. - needs_bounds_recomputed = insert_parent; - break; - } - - // Split() will create a sibling to insert_parent both of which will have - // valid bounds, but this invalidates their parent's bounds. - node = insert_parent->Split(min_children_, max_children_); - insert_parent = static_cast(insert_parent->parent()); - needs_bounds_recomputed = insert_parent; - } - - // If we have a Node to insert, and we hit the root of the current tree, - // we create a new root which is the parent of the current root and the - // insert_node. Note that we must release() the |root_| since - // ConstructParent() will take ownership of it. - if (!insert_parent && node) { - root_ = root_.release()->ConstructParent(); - root_->AddChild(node.Pass()); - } - - // Recompute bounds along insertion path. - if (needs_bounds_recomputed) - needs_bounds_recomputed->RecomputeBoundsUpToRoot(); - - // Complete re-inserts, if any. The algorithm only allows for one invocation - // of RemoveNodesForReinsert() per level of the tree in an overall call to - // Insert(). - while (!reinserts.empty()) { - Nodes::iterator last_element = reinserts.end() - 1; - NodeBase* temp_ptr(*last_element); - reinserts.weak_erase(last_element); - InsertNode(make_scoped_ptr(temp_ptr), highest_reinsert_level); - } -} - -scoped_ptr RTreeBase::RemoveNode(NodeBase* node) { - // We need to remove this node from its parent. - Node* parent = static_cast(node->parent()); - // Record nodes are never allowed as the root, so we should always have a - // parent. - DCHECK(parent); - // Should always be a leaf that had the record. - DCHECK_EQ(0, parent->Level()); - - Nodes orphans; - scoped_ptr removed_node(parent->RemoveChild(node, &orphans)); - - // It's possible that by removing |node| from |parent| we have made |parent| - // have less than the minimum number of children, in which case we will need - // to remove and delete |parent| while reinserting any other children that it - // had. We traverse up the tree doing this until we remove a child from a - // parent that still has greater than or equal to the minimum number of Nodes. - while (parent->count() < min_children_) { - NodeBase* child = parent; - parent = static_cast(parent->parent()); - - // If we've hit the root, stop. - if (!parent) - break; - - parent->RemoveChild(child, &orphans); - } - - // If we stopped deleting nodes up the tree before encountering the root, - // we'll need to fix up the bounds from the first parent we didn't delete - // up to the root. - if (parent) - parent->RecomputeBoundsUpToRoot(); - else - root_->RecomputeBoundsUpToRoot(); - - while (!orphans.empty()) { - Nodes::iterator last_element = orphans.end() - 1; - NodeBase* temp_ptr(*last_element); - orphans.weak_erase(last_element); - int starting_level = -1; - InsertNode(make_scoped_ptr(temp_ptr), &starting_level); - } - - return removed_node.Pass(); -} - -void RTreeBase::PruneRootIfNecessary() { - if (root()->count() == 1 && root()->Level() > 0) { - // Awkward reset(cast(release)) pattern here because there's no better way - // to downcast the scoped_ptr from RemoveAndReturnLastChild() from NodeBase - // to Node. - root_.reset( - static_cast(root_->RemoveAndReturnLastChild().release())); - } -} - -void RTreeBase::ResetRoot() { - root_.reset(new Node()); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/r_tree_base.h b/ui/gfx/geometry/r_tree_base.h deleted file mode 100644 index dbb3b6d56..000000000 --- a/ui/gfx/geometry/r_tree_base.h +++ /dev/null @@ -1,309 +0,0 @@ -// Copyright 2014 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. - -// Provides an implementation the parts of the RTree data structure that don't -// require knowledge of the generic key type. Don't use these objects directly, -// rather specialize the RTree<> object in r_tree.h. This file defines the -// internal objects of an RTree, namely Nodes (internal nodes of the tree) and -// Records, which hold (key, rectangle) pairs. - -#ifndef UI_GFX_GEOMETRY_R_TREE_BASE_H_ -#define UI_GFX_GEOMETRY_R_TREE_BASE_H_ - -#include -#include - -#include "base/containers/hash_tables.h" -#include "base/macros.h" -#include "base/memory/scoped_ptr.h" -#include "base/memory/scoped_vector.h" -#include "ui/gfx/geometry/rect.h" -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -class GFX_EXPORT RTreeBase { - protected: - class NodeBase; - class RecordBase; - - typedef std::vector Records; - typedef ScopedVector Nodes; - - RTreeBase(size_t min_children, size_t max_children); - ~RTreeBase(); - - // Protected data structure class for storing internal Nodes or leaves with - // Records. - class GFX_EXPORT NodeBase { - public: - virtual ~NodeBase(); - - // Appends to |records_out| the set of Records in this subtree with rects - // that intersect |query_rect|. Avoids clearing |records_out| so that it - // can be called recursively. - virtual void AppendIntersectingRecords(const Rect& query_rect, - Records* records_out) const = 0; - - // Returns all records stored in the subtree rooted at this node. Appends to - // |matches_out| without clearing. - virtual void AppendAllRecords(Records* records_out) const = 0; - - // Returns NULL if no children. Does not recompute bounds. - virtual scoped_ptr RemoveAndReturnLastChild() = 0; - - // Returns -1 for Records, or the height of this subtree for Nodes. The - // height of a leaf Node (a Node containing only Records) is 0, a leaf's - // parent is 1, etc. Note that in an R*-Tree, all branches from the root - // Node will be the same height. - virtual int Level() const = 0; - - // Recomputes our bounds by taking the union of all child rects, then calls - // recursively on our parent so that ultimately all nodes up to the root - // recompute their bounds. - void RecomputeBoundsUpToRoot(); - - NodeBase* parent() { return parent_; } - const NodeBase* parent() const { return parent_; } - void set_parent(NodeBase* parent) { parent_ = parent; } - const Rect& rect() const { return rect_; } - void set_rect(const Rect& rect) { rect_ = rect; } - - protected: - NodeBase(const Rect& rect, NodeBase* parent); - - // Bounds recomputation without calling parents to do the same. - virtual void RecomputeLocalBounds(); - - private: - friend class RTreeTest; - friend class RTreeNodeTest; - - // This Node's bounding rectangle. - Rect rect_; - - // A weak pointer to our parent Node in the RTree. The root node will have a - // NULL value for |parent_|. - NodeBase* parent_; - - DISALLOW_COPY_AND_ASSIGN(NodeBase); - }; - - class GFX_EXPORT RecordBase : public NodeBase { - public: - explicit RecordBase(const Rect& rect); - ~RecordBase() override; - - void AppendIntersectingRecords(const Rect& query_rect, - Records* records_out) const override; - void AppendAllRecords(Records* records_out) const override; - scoped_ptr RemoveAndReturnLastChild() override; - int Level() const override; - - private: - friend class RTreeTest; - friend class RTreeNodeTest; - - DISALLOW_COPY_AND_ASSIGN(RecordBase); - }; - - class GFX_EXPORT Node : public NodeBase { - public: - // Constructs an empty Node with |level_| of 0. - Node(); - ~Node() override; - - void AppendIntersectingRecords(const Rect& query_rect, - Records* records_out) const override; - scoped_ptr RemoveAndReturnLastChild() override; - int Level() const override; - void AppendAllRecords(Records* matches_out) const override; - - // Constructs a new Node that is the parent of this Node and already has - // this Node as its sole child. Valid to call only on root Nodes, meaning - // Nodes with |parent_| NULL. Note that ownership of this Node is - // transferred to the parent returned by this function. - scoped_ptr ConstructParent(); - - // Removes |number_to_remove| children from this Node, and appends them to - // the supplied list. Does not repair bounds upon completion. Nodes are - // selected in the manner suggested in the Beckmann et al. paper, which - // suggests that the children should be sorted by the distance from the - // center of their bounding rectangle to their parent's bounding rectangle, - // and then the n closest children should be removed for re-insertion. This - // removal occurs at most once on each level of the tree when overflowing - // nodes that have exceeded the maximum number of children during an Insert. - void RemoveNodesForReinsert(size_t number_to_remove, Nodes* nodes); - - // Given a pointer to a child node within this Node, removes it from our - // list. If that child had any children, appends them to the supplied orphan - // list. Returns the removed child. Does not recompute bounds, as the caller - // might subsequently remove this node as well, meaning the recomputation - // would be wasted work. - scoped_ptr RemoveChild(NodeBase* child_node, Nodes* orphans); - - // Returns the best parent for insertion of the provided |node| as a child. - Node* ChooseSubtree(NodeBase* node); - - // Adds |node| as a child of this Node, and recomputes the bounds of this - // node after the addition of the child. Returns the new count of children - // stored in this Node. This node becomes the owner of |node|. - size_t AddChild(scoped_ptr node); - - // Returns a sibling to this Node with at least min_children and no greater - // than max_children of this Node's children assigned to it, and having the - // same parent. Bounds will be valid on both Nodes after this call. - scoped_ptr Split(size_t min_children, size_t max_children); - - size_t count() const { return children_.size(); } - const NodeBase* child(size_t i) const { return children_[i]; } - NodeBase* child(size_t i) { return children_[i]; } - - private: - typedef std::vector Rects; - - explicit Node(int level); - - // Given two arrays of bounds rectangles as computed by BuildLowBounds() - // and BuildHighBounds(), returns the index of the element in those arrays - // along which a split of the arrays would result in a minimum amount of - // overlap (area of intersection) in the two groups. - static size_t ChooseSplitIndex(size_t start_index, - size_t end_index, - const Rects& low_bounds, - const Rects& high_bounds); - - // R*-Tree attempts to keep groups of rectangles that are roughly square - // in shape. It does this by comparing the "margins" of different bounding - // boxes, where margin is defined as the sum of the length of all four sides - // of a rectangle. For two rectangles of equal area, the one with the - // smallest margin will be the rectangle whose width and height differ the - // least. When splitting we decide to split along an axis chosen from the - // rectangles either sorted vertically or horizontally by finding the axis - // that would result in the smallest sum of margins between the two bounding - // boxes of the resulting split. Returns the smallest sum computed given the - // sorted bounding boxes and a range to look within. - static int SmallestMarginSum(size_t start_index, - size_t end_index, - const Rects& low_bounds, - const Rects& high_bounds); - - // Sorts nodes primarily by increasing y coordinates, and secondarily by - // increasing height. - static bool CompareVertical(const NodeBase* a, const NodeBase* b); - - // Sorts nodes primarily by increasing x coordinates, and secondarily by - // increasing width. - static bool CompareHorizontal(const NodeBase* a, const NodeBase* b); - - // Sorts nodes by the distance of the center of their rectangles to the - // center of their parent's rectangles. - static bool CompareCenterDistanceFromParent( - const NodeBase* a, const NodeBase* b); - - // Given two vectors of Nodes sorted by vertical or horizontal bounds, - // populates two vectors of Rectangles in which the ith element is the union - // of all bounding rectangles [0,i] in the associated sorted array of Nodes. - static void BuildLowBounds(const std::vector& vertical_sort, - const std::vector& horizontal_sort, - Rects* vertical_bounds, - Rects* horizontal_bounds); - - // Given two vectors of Nodes sorted by vertical or horizontal bounds, - // populates two vectors of Rectangles in which the ith element is the - // union of all bounding rectangles [i, count()) in the associated sorted - // array of Nodes. - static void BuildHighBounds(const std::vector& vertical_sort, - const std::vector& horizontal_sort, - Rects* vertical_bounds, - Rects* horizontal_bounds); - - void RecomputeLocalBounds() override; - - // Returns the increase in overlap value, as defined in Beckmann et al. as - // the sum of the areas of the intersection of all child rectangles - // (excepting the candidate child) with the argument rectangle. Here the - // |candidate_node| is one of our |children_|, and |expanded_rect| is the - // already-computed union of the candidate's rect and |rect|. - int OverlapIncreaseToAdd(const Rect& rect, - const NodeBase* candidate_node, - const Rect& expanded_rect) const; - - // Returns a new node containing children [split_index, count()) within - // |sorted_children|. Children before |split_index| remain with |this|. - scoped_ptr DivideChildren( - const Rects& low_bounds, - const Rects& high_bounds, - const std::vector& sorted_children, - size_t split_index); - - // Returns a pointer to the child node that will result in the least overlap - // increase with the addition of node_rect, or NULL if there's a tie found. - // Requires a precomputed vector of expanded rectangles where the ith - // rectangle in the vector is the union of |children_|[i] and node_rect. - // Overlap is defined in Beckmann et al. as the sum of the areas of - // intersection of all child rectangles with the |node_rect| argument - // rectangle. This heuristic attempts to choose the node for which adding - // the new rectangle to their bounding box will result in the least overlap - // with the other rectangles, thus trying to preserve the usefulness of the - // bounding rectangle by keeping it from covering too much redundant area. - Node* LeastOverlapIncrease(const Rect& node_rect, - const Rects& expanded_rects); - - // Returns a pointer to the child node that will result in the least area - // enlargement if the argument node rectangle were to be added to that - // node's bounding box. Requires a precomputed vector of expanded rectangles - // where the ith rectangle in the vector is the union of children_[i] and - // |node_rect|. - Node* LeastAreaEnlargement(const Rect& node_rect, - const Rects& expanded_rects); - - const int level_; - - Nodes children_; - - friend class RTreeTest; - friend class RTreeNodeTest; - - DISALLOW_COPY_AND_ASSIGN(Node); - }; - - // Inserts |node| into the tree. The |highest_reinsert_level| supports - // re-insertion as described by Beckmann et al. As Node overflows progagate - // up the tree the algorithm performs a reinsertion of the overflow Nodes - // (instead of a split) at most once per level of the tree. A starting value - // of -1 for |highest_reinsert_level| means that reinserts are permitted for - // every level of the tree. This should always be set to -1 except by - // recursive calls from within InsertNode(). - void InsertNode(scoped_ptr node, int* highest_reinsert_level); - - // Removes |node| from the tree without deleting it. - scoped_ptr RemoveNode(NodeBase* node); - - // If |root_| has only one child, deletes the |root_| Node and replaces it - // with its only descendant child. Otherwise does nothing. - void PruneRootIfNecessary(); - - // Deletes the entire current tree and replaces it with an empty Node. - void ResetRoot(); - - const Node* root() const { return root_.get(); } - - private: - friend class RTreeTest; - friend class RTreeNodeTest; - - // A pointer to the root node in the RTree. - scoped_ptr root_; - - // The parameters used to define the shape of the RTree. - const size_t min_children_; - const size_t max_children_; - - DISALLOW_COPY_AND_ASSIGN(RTreeBase); -}; - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_R_TREE_BASE_H_ diff --git a/ui/gfx/geometry/r_tree_unittest.cc b/ui/gfx/geometry/r_tree_unittest.cc deleted file mode 100644 index d4da8ef7a..000000000 --- a/ui/gfx/geometry/r_tree_unittest.cc +++ /dev/null @@ -1,1025 +0,0 @@ -// Copyright 2014 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 "testing/gtest/include/gtest/gtest.h" -#include "ui/gfx/geometry/r_tree.h" -#include "ui/gfx/geometry/r_tree_base.h" -#include "ui/gfx/geometry/rect.h" - -namespace gfx { - -class RTreeTest : public ::testing::Test { - protected: - typedef RTree RT; - - // Given a pointer to an RTree, traverse it and verify that its internal - // structure is consistent with RTree semantics. - void ValidateRTree(RTreeBase* rt) { - // If RTree is empty it should have an empty rectangle. - if (!rt->root()->count()) { - EXPECT_TRUE(rt->root()->rect().IsEmpty()); - EXPECT_EQ(0, rt->root()->Level()); - return; - } - // Root is allowed to have fewer than min_children_ but never more than - // max_children_. - EXPECT_LE(rt->root()->count(), rt->max_children_); - // The root should never be a record node. - EXPECT_GT(rt->root()->Level(), -1); - // The root should never have a parent pointer. - EXPECT_TRUE(rt->root()->parent() == NULL); - // Bounds must be consistent on the root. - CheckBoundsConsistent(rt->root()); - for (size_t i = 0; i < rt->root()->count(); ++i) { - ValidateNode( - rt->root()->child(i), rt->min_children_, rt->max_children_); - } - } - - // Recursive descent method used by ValidateRTree to check each node within - // the RTree for consistency with RTree semantics. - void ValidateNode(const RTreeBase::NodeBase* node_base, - size_t min_children, - size_t max_children) { - if (node_base->Level() >= 0) { - const RTreeBase::Node* node = - static_cast(node_base); - EXPECT_GE(node->count(), min_children); - EXPECT_LE(node->count(), max_children); - CheckBoundsConsistent(node); - for (size_t i = 0; i < node->count(); ++i) - ValidateNode(node->child(i), min_children, max_children); - } - } - - // Check bounds are consistent with children bounds, and other checks - // convenient to do while enumerating the children of node. - void CheckBoundsConsistent(const RTreeBase::Node* node) { - EXPECT_FALSE(node->rect().IsEmpty()); - Rect check_bounds; - for (size_t i = 0; i < node->count(); ++i) { - const RTreeBase::NodeBase* child_node = node->child(i); - check_bounds.Union(child_node->rect()); - EXPECT_EQ(node->Level() - 1, child_node->Level()); - EXPECT_EQ(node, child_node->parent()); - } - EXPECT_EQ(check_bounds, node->rect()); - } - - // Adds count squares stacked around the point (0,0) with key equal to width. - void AddStackedSquares(RT* rt, int count) { - for (int i = 1; i <= count; ++i) { - rt->Insert(Rect(0, 0, i, i), i); - ValidateRTree(static_cast(rt)); - } - } - - // Given an unordered list of matching keys, verifies that it contains all - // values [1..length] for the length of that list. - void VerifyAllKeys(const RT::Matches& keys) { - for (size_t i = 1; i <= keys.size(); ++i) - EXPECT_EQ(1U, keys.count(i)); - } - - // Given a node and a rectangle, builds an expanded rectangle list where the - // ith element of the vector is the union of the rectangle of the ith child of - // the node and the argument rectangle. - void BuildExpandedRects(RTreeBase::Node* node, - const Rect& rect, - std::vector* expanded_rects) { - expanded_rects->clear(); - expanded_rects->reserve(node->count()); - for (size_t i = 0; i < node->count(); ++i) { - Rect expanded_rect(rect); - expanded_rect.Union(node->child(i)->rect()); - expanded_rects->push_back(expanded_rect); - } - } -}; - -class RTreeNodeTest : public RTreeTest { - protected: - typedef RTreeBase::NodeBase RTreeNodeBase; - typedef RT::Record RTreeRecord; - typedef RTreeBase::Node RTreeNode; - typedef RTreeBase::Node::Rects RTreeRects; - typedef RTreeBase::Nodes RTreeNodes; - - // Accessors to private members of RTree::Node. - const RTreeRecord* record(RTreeNode* node, size_t i) { - return static_cast(node->child(i)); - } - - // Provides access for tests to private methods of RTree::Node. - scoped_ptr NewNodeAtLevel(size_t level) { - return make_scoped_ptr(new RTreeBase::Node(level)); - } - - void NodeRecomputeLocalBounds(RTreeNodeBase* node) { - node->RecomputeLocalBounds(); - } - - bool NodeCompareVertical(RTreeNodeBase* a, RTreeNodeBase* b) { - return RTreeBase::Node::CompareVertical(a, b); - } - - bool NodeCompareHorizontal(RTreeNodeBase* a, RTreeNodeBase* b) { - return RTreeBase::Node::CompareHorizontal(a, b); - } - - bool NodeCompareCenterDistanceFromParent( - const RTreeNodeBase* a, const RTreeNodeBase* b) { - return RTreeBase::Node::CompareCenterDistanceFromParent(a, b); - } - - int NodeOverlapIncreaseToAdd(RTreeNode* node, - const Rect& rect, - const RTreeNodeBase* candidate_node, - const Rect& expanded_rect) { - return node->OverlapIncreaseToAdd(rect, candidate_node, expanded_rect); - } - - void NodeBuildLowBounds(const std::vector& vertical_sort, - const std::vector& horizontal_sort, - RTreeRects* vertical_bounds, - RTreeRects* horizontal_bounds) { - RTreeBase::Node::BuildLowBounds( - vertical_sort, horizontal_sort, vertical_bounds, horizontal_bounds); - } - - void NodeBuildHighBounds(const std::vector& vertical_sort, - const std::vector& horizontal_sort, - RTreeRects* vertical_bounds, - RTreeRects* horizontal_bounds) { - RTreeBase::Node::BuildHighBounds( - vertical_sort, horizontal_sort, vertical_bounds, horizontal_bounds); - } - - int NodeSmallestMarginSum(size_t start_index, - size_t end_index, - const RTreeRects& low_bounds, - const RTreeRects& high_bounds) { - return RTreeBase::Node::SmallestMarginSum( - start_index, end_index, low_bounds, high_bounds); - } - - size_t NodeChooseSplitIndex(size_t min_children, - size_t max_children, - const RTreeRects& low_bounds, - const RTreeRects& high_bounds) { - return RTreeBase::Node::ChooseSplitIndex( - min_children, max_children, low_bounds, high_bounds); - } - - scoped_ptr NodeDivideChildren( - RTreeNode* node, - const RTreeRects& low_bounds, - const RTreeRects& high_bounds, - const std::vector& sorted_children, - size_t split_index) { - return node->DivideChildren( - low_bounds, high_bounds, sorted_children, split_index); - } - - RTreeNode* NodeLeastOverlapIncrease(RTreeNode* node, - const Rect& node_rect, - const RTreeRects& expanded_rects) { - return node->LeastOverlapIncrease(node_rect, expanded_rects); - } - - RTreeNode* NodeLeastAreaEnlargement(RTreeNode* node, - const Rect& node_rect, - const RTreeRects& expanded_rects) { - return node->LeastAreaEnlargement(node_rect, expanded_rects); - } -}; - -// RTreeNodeTest -------------------------------------------------------------- - -TEST_F(RTreeNodeTest, RemoveNodesForReinsert) { - // Make a leaf node for testing removal from. - scoped_ptr test_node(new RTreeNode); - // Build 20 record nodes with rectangle centers going from (1,1) to (20,20) - for (int i = 1; i <= 20; ++i) - test_node->AddChild(scoped_ptr( - new RTreeRecord(Rect(i - 1, i - 1, 2, 2), i))); - - // Quick verification of the node before removing children. - ValidateNode(test_node.get(), 1U, 20U); - // Use a scoped vector to delete all children that get removed from the Node. - RTreeNodes removals; - test_node->RemoveNodesForReinsert(1, &removals); - // Should have gotten back 1 node pointer. - EXPECT_EQ(1U, removals.size()); - // There should be 19 left in the test_node. - EXPECT_EQ(19U, test_node->count()); - // If we fix up the bounds on the test_node, it should verify. - NodeRecomputeLocalBounds(test_node.get()); - ValidateNode(test_node.get(), 2U, 20U); - // The node we removed should be node 10, as it was exactly in the center. - EXPECT_EQ(10, static_cast(removals[0])->key()); - - // Now remove the next 2. - removals.clear(); - test_node->RemoveNodesForReinsert(2, &removals); - EXPECT_EQ(2U, removals.size()); - EXPECT_EQ(17U, test_node->count()); - NodeRecomputeLocalBounds(test_node.get()); - ValidateNode(test_node.get(), 2U, 20U); - // Lastly the 2 nodes we should have gotten back are keys 9 and 11, as their - // centers were the closest to the center of the node bounding box. - base::hash_set results_hash; - results_hash.insert(static_cast(removals[0])->key()); - results_hash.insert(static_cast(removals[1])->key()); - EXPECT_EQ(1U, results_hash.count(9)); - EXPECT_EQ(1U, results_hash.count(11)); -} - -TEST_F(RTreeNodeTest, CompareVertical) { - // One rect with lower y than another should always sort lower. - RTreeRecord low(Rect(0, 1, 10, 10), 1); - RTreeRecord middle(Rect(0, 5, 10, 10), 5); - EXPECT_TRUE(NodeCompareVertical(&low, &middle)); - EXPECT_FALSE(NodeCompareVertical(&middle, &low)); - - // Try a non-overlapping higher-y rectangle. - RTreeRecord high(Rect(-10, 20, 10, 1), 10); - EXPECT_TRUE(NodeCompareVertical(&low, &high)); - EXPECT_FALSE(NodeCompareVertical(&high, &low)); - - // Ties are broken by lowest bottom y value. - RTreeRecord shorter_tie(Rect(10, 1, 100, 2), 2); - EXPECT_TRUE(NodeCompareVertical(&shorter_tie, &low)); - EXPECT_FALSE(NodeCompareVertical(&low, &shorter_tie)); -} - -TEST_F(RTreeNodeTest, CompareHorizontal) { - // One rect with lower x than another should always sort lower than higher x. - RTreeRecord low(Rect(1, 0, 10, 10), 1); - RTreeRecord middle(Rect(5, 0, 10, 10), 5); - EXPECT_TRUE(NodeCompareHorizontal(&low, &middle)); - EXPECT_FALSE(NodeCompareHorizontal(&middle, &low)); - - // Try a non-overlapping higher-x rectangle. - RTreeRecord high(Rect(20, -10, 1, 10), 10); - EXPECT_TRUE(NodeCompareHorizontal(&low, &high)); - EXPECT_FALSE(NodeCompareHorizontal(&high, &low)); - - // Ties are broken by lowest bottom x value. - RTreeRecord shorter_tie(Rect(1, 10, 2, 100), 2); - EXPECT_TRUE(NodeCompareHorizontal(&shorter_tie, &low)); - EXPECT_FALSE(NodeCompareHorizontal(&low, &shorter_tie)); -} - -TEST_F(RTreeNodeTest, CompareCenterDistanceFromParent) { - // Create a test node we can add children to, for distance comparisons. - scoped_ptr parent(new RTreeNode); - - // Add three children, one each with centers at (0, 0), (10, 10), (-9, -9), - // around which a bounding box will be centered at (0, 0) - scoped_ptr center_zero(new RTreeRecord(Rect(-1, -1, 2, 2), 1)); - parent->AddChild(center_zero.Pass()); - - scoped_ptr center_positive(new RTreeRecord(Rect(9, 9, 2, 2), 2)); - parent->AddChild(center_positive.Pass()); - - scoped_ptr center_negative( - new RTreeRecord(Rect(-10, -10, 2, 2), 3)); - parent->AddChild(center_negative.Pass()); - - ValidateNode(parent.get(), 1U, 5U); - EXPECT_EQ(Rect(-10, -10, 21, 21), parent->rect()); - - EXPECT_TRUE( - NodeCompareCenterDistanceFromParent(parent->child(0), parent->child(1))); - EXPECT_FALSE( - NodeCompareCenterDistanceFromParent(parent->child(1), parent->child(0))); - EXPECT_TRUE( - NodeCompareCenterDistanceFromParent(parent->child(0), parent->child(2))); - EXPECT_FALSE( - NodeCompareCenterDistanceFromParent(parent->child(2), parent->child(0))); - EXPECT_TRUE( - NodeCompareCenterDistanceFromParent(parent->child(2), parent->child(1))); - EXPECT_FALSE( - NodeCompareCenterDistanceFromParent(parent->child(1), parent->child(2))); -} - -TEST_F(RTreeNodeTest, OverlapIncreaseToAdd) { - // Create a test node with three children, for overlap comparisons. - scoped_ptr parent(new RTreeNode); - - // Add three children, each 4 wide and tall, at (0, 0), (3, 3), (6, 6) with - // overlapping corners. - Rect top(0, 0, 4, 4); - parent->AddChild(scoped_ptr(new RTreeRecord(top, 1))); - Rect middle(3, 3, 4, 4); - parent->AddChild(scoped_ptr(new RTreeRecord(middle, 2))); - Rect bottom(6, 6, 4, 4); - parent->AddChild(scoped_ptr(new RTreeRecord(bottom, 3))); - ValidateNode(parent.get(), 1U, 5U); - - // Test a rect in corner. - Rect corner(0, 0, 1, 1); - Rect expanded = top; - expanded.Union(corner); - // It should not add any overlap to add this to the first child at (0, 0). - EXPECT_EQ(0, NodeOverlapIncreaseToAdd( - parent.get(), corner, parent->child(0), expanded)); - - expanded = middle; - expanded.Union(corner); - // Overlap for middle rectangle should increase from 2 pixels at (3, 3) and - // (6, 6) to 17 pixels, as it will now cover 4x4 rectangle top, - // so a change of +15. - EXPECT_EQ(15, NodeOverlapIncreaseToAdd( - parent.get(), corner, parent->child(1), expanded)); - - expanded = bottom; - expanded.Union(corner); - // Overlap for bottom rectangle should increase from 1 pixel at (6, 6) to - // 32 pixels, as it will now cover both 4x4 rectangles top and middle, - // so a change of 31. - EXPECT_EQ(31, NodeOverlapIncreaseToAdd( - parent.get(), corner, parent->child(2), expanded)); - - // Test a rect that doesn't overlap with anything, in the far right corner. - Rect far_corner(9, 0, 1, 1); - expanded = top; - expanded.Union(far_corner); - // Overlap of top should go from 1 to 4, as it will now cover the entire first - // row of pixels in middle. - EXPECT_EQ(3, NodeOverlapIncreaseToAdd( - parent.get(), far_corner, parent->child(0), expanded)); - - expanded = middle; - expanded.Union(far_corner); - // Overlap of middle should go from 2 to 8, as it will cover the rightmost 4 - // pixels of top and the top 4 pixels of bottom as it expands. - EXPECT_EQ(6, NodeOverlapIncreaseToAdd( - parent.get(), far_corner, parent->child(1), expanded)); - - expanded = bottom; - expanded.Union(far_corner); - // Overlap of bottom should go from 1 to 4, as it will now cover the rightmost - // 4 pixels of middle. - EXPECT_EQ(3, NodeOverlapIncreaseToAdd( - parent.get(), far_corner, parent->child(2), expanded)); -} - -TEST_F(RTreeNodeTest, BuildLowBounds) { - RTreeNodes records; - records.reserve(10); - for (int i = 1; i <= 10; ++i) - records.push_back(new RTreeRecord(Rect(0, 0, i, i), i)); - - RTreeRects vertical_bounds; - RTreeRects horizontal_bounds; - NodeBuildLowBounds( - records.get(), records.get(), &vertical_bounds, &horizontal_bounds); - for (int i = 0; i < 10; ++i) { - EXPECT_EQ(records[i]->rect(), vertical_bounds[i]); - EXPECT_EQ(records[i]->rect(), horizontal_bounds[i]); - } -} - -TEST_F(RTreeNodeTest, BuildHighBounds) { - RTreeNodes records; - records.reserve(25); - for (int i = 0; i < 25; ++i) - records.push_back(new RTreeRecord(Rect(i, i, 25 - i, 25 - i), i)); - - RTreeRects vertical_bounds; - RTreeRects horizontal_bounds; - NodeBuildHighBounds( - records.get(), records.get(), &vertical_bounds, &horizontal_bounds); - for (int i = 0; i < 25; ++i) { - EXPECT_EQ(records[i]->rect(), vertical_bounds[i]); - EXPECT_EQ(records[i]->rect(), horizontal_bounds[i]); - } -} - -TEST_F(RTreeNodeTest, ChooseSplitAxisAndIndexVertical) { - RTreeRects low_vertical_bounds; - RTreeRects high_vertical_bounds; - RTreeRects low_horizontal_bounds; - RTreeRects high_horizontal_bounds; - // In this test scenario we describe a mirrored, stacked configuration of - // horizontal, 1 pixel high rectangles labeled a-f like this: - // - // shape: | v sort: | h sort: | - // -------+---------+---------+ - // aaaaa | 0 | 0 | - // bbb | 1 | 2 | - // c | 2 | 4 | - // d | 3 | 5 | - // eee | 4 | 3 | - // fffff | 5 | 1 | - // - // These are already sorted vertically from top to bottom. Bounding rectangles - // of these vertically sorted will be 5 wide, i tall bounding boxes. - for (int i = 0; i < 6; ++i) { - low_vertical_bounds.push_back(Rect(0, 0, 5, i + 1)); - high_vertical_bounds.push_back(Rect(0, i, 5, 6 - i)); - } - - // Low bounds of horizontal sort start with bounds of box a and then jump to - // cover everything, as box f is second in horizontal sort. - low_horizontal_bounds.push_back(Rect(0, 0, 5, 1)); - for (int i = 0; i < 5; ++i) - low_horizontal_bounds.push_back(Rect(0, 0, 5, 6)); - - // High horizontal bounds are hand-calculated. - high_horizontal_bounds.push_back(Rect(0, 0, 5, 6)); - high_horizontal_bounds.push_back(Rect(0, 1, 5, 5)); - high_horizontal_bounds.push_back(Rect(1, 1, 3, 4)); - high_horizontal_bounds.push_back(Rect(1, 2, 3, 3)); - high_horizontal_bounds.push_back(Rect(2, 2, 1, 2)); - high_horizontal_bounds.push_back(Rect(2, 3, 1, 1)); - - int smallest_vertical_margin = - NodeSmallestMarginSum(2, 3, low_vertical_bounds, high_vertical_bounds); - int smallest_horizontal_margin = NodeSmallestMarginSum( - 2, 3, low_horizontal_bounds, high_horizontal_bounds); - EXPECT_LT(smallest_vertical_margin, smallest_horizontal_margin); - - EXPECT_EQ( - 3U, - NodeChooseSplitIndex(2, 5, low_vertical_bounds, high_vertical_bounds)); -} - -TEST_F(RTreeNodeTest, ChooseSplitAxisAndIndexHorizontal) { - RTreeRects low_vertical_bounds; - RTreeRects high_vertical_bounds; - RTreeRects low_horizontal_bounds; - RTreeRects high_horizontal_bounds; - // We rotate the shape from ChooseSplitAxisAndIndexVertical to test - // horizontal split axis detection: - // - // +--------+ - // | a f | - // | ab ef | - // sort: | abcdef | - // | ab ef | - // | a f | - // |--------+ - // v sort: | 024531 | - // h sort: | 012345 | - // +--------+ - // - // Low bounds of vertical sort start with bounds of box a and then jump to - // cover everything, as box f is second in vertical sort. - low_vertical_bounds.push_back(Rect(0, 0, 1, 5)); - for (int i = 0; i < 5; ++i) - low_vertical_bounds.push_back(Rect(0, 0, 6, 5)); - - // High vertical bounds are hand-calculated. - high_vertical_bounds.push_back(Rect(0, 0, 6, 5)); - high_vertical_bounds.push_back(Rect(1, 0, 5, 5)); - high_vertical_bounds.push_back(Rect(1, 1, 4, 3)); - high_vertical_bounds.push_back(Rect(2, 1, 3, 3)); - high_vertical_bounds.push_back(Rect(2, 2, 2, 1)); - high_vertical_bounds.push_back(Rect(3, 2, 1, 1)); - - // These are already sorted horizontally from left to right. Bounding - // rectangles of these horizontally sorted will be i wide, 5 tall bounding - // boxes. - for (int i = 0; i < 6; ++i) { - low_horizontal_bounds.push_back(Rect(0, 0, i + 1, 5)); - high_horizontal_bounds.push_back(Rect(i, 0, 6 - i, 5)); - } - - int smallest_vertical_margin = - NodeSmallestMarginSum(2, 3, low_vertical_bounds, high_vertical_bounds); - int smallest_horizontal_margin = NodeSmallestMarginSum( - 2, 3, low_horizontal_bounds, high_horizontal_bounds); - - EXPECT_GT(smallest_vertical_margin, smallest_horizontal_margin); - - EXPECT_EQ(3U, - NodeChooseSplitIndex( - 2, 5, low_horizontal_bounds, high_horizontal_bounds)); -} - -TEST_F(RTreeNodeTest, DivideChildren) { - // Create a test node to split. - scoped_ptr test_node(new RTreeNode); - std::vector sorted_children; - RTreeRects low_bounds; - RTreeRects high_bounds; - // Insert 10 record nodes, also inserting them into our children array. - for (int i = 1; i <= 10; ++i) { - scoped_ptr record(new RTreeRecord(Rect(0, 0, i, i), i)); - sorted_children.push_back(record.get()); - test_node->AddChild(record.Pass()); - low_bounds.push_back(Rect(0, 0, i, i)); - high_bounds.push_back(Rect(0, 0, 10, 10)); - } - // Split the children in half. - scoped_ptr split_node_base(NodeDivideChildren( - test_node.get(), low_bounds, high_bounds, sorted_children, 5)); - RTreeNode* split_node = static_cast(split_node_base.get()); - // Both nodes should be valid. - ValidateNode(test_node.get(), 1U, 10U); - ValidateNode(split_node, 1U, 10U); - // Both nodes should have five children. - EXPECT_EQ(5U, test_node->count()); - EXPECT_EQ(5U, split_node->count()); - // Test node should have children 1-5, split node should have children 6-10. - for (int i = 0; i < 5; ++i) { - EXPECT_EQ(i + 1, record(test_node.get(), i)->key()); - EXPECT_EQ(i + 6, record(split_node, i)->key()); - } -} - -TEST_F(RTreeNodeTest, RemoveChildNoOrphans) { - scoped_ptr test_parent(new RTreeNode); - test_parent->AddChild( - scoped_ptr(new RTreeRecord(Rect(0, 0, 1, 1), 1))); - test_parent->AddChild( - scoped_ptr(new RTreeRecord(Rect(0, 0, 2, 2), 2))); - test_parent->AddChild( - scoped_ptr(new RTreeRecord(Rect(0, 0, 3, 3), 3))); - ValidateNode(test_parent.get(), 1U, 5U); - - RTreeNodes orphans; - - // Remove the middle node. - scoped_ptr middle_child( - test_parent->RemoveChild(test_parent->child(1), &orphans)); - EXPECT_EQ(0U, orphans.size()); - EXPECT_EQ(2U, test_parent->count()); - NodeRecomputeLocalBounds(test_parent.get()); - ValidateNode(test_parent.get(), 1U, 5U); - - // Remove the end node. - scoped_ptr end_child( - test_parent->RemoveChild(test_parent->child(1), &orphans)); - EXPECT_EQ(0U, orphans.size()); - EXPECT_EQ(1U, test_parent->count()); - NodeRecomputeLocalBounds(test_parent.get()); - ValidateNode(test_parent.get(), 1U, 5U); - - // Remove the first node. - scoped_ptr first_child( - test_parent->RemoveChild(test_parent->child(0), &orphans)); - EXPECT_EQ(0U, orphans.size()); - EXPECT_EQ(0U, test_parent->count()); -} - -TEST_F(RTreeNodeTest, RemoveChildOrphans) { - // Build binary tree of Nodes of height 4, keeping weak pointers to the - // Levels 0 and 1 Nodes and the Records so we can test removal of them below. - std::vector level_1_children; - std::vector level_0_children; - std::vector records; - int id = 1; - scoped_ptr root(NewNodeAtLevel(2)); - for (int i = 0; i < 2; ++i) { - scoped_ptr level_1_child(NewNodeAtLevel(1)); - for (int j = 0; j < 2; ++j) { - scoped_ptr level_0_child(new RTreeNode); - for (int k = 0; k < 2; ++k) { - scoped_ptr record( - new RTreeRecord(Rect(0, 0, id, id), id)); - ++id; - records.push_back(record.get()); - level_0_child->AddChild(record.Pass()); - } - level_0_children.push_back(level_0_child.get()); - level_1_child->AddChild(level_0_child.Pass()); - } - level_1_children.push_back(level_1_child.get()); - root->AddChild(level_1_child.Pass()); - } - - // This should now be a valid tree structure. - ValidateNode(root.get(), 2U, 2U); - EXPECT_EQ(2U, level_1_children.size()); - EXPECT_EQ(4U, level_0_children.size()); - EXPECT_EQ(8U, records.size()); - - // Now remove all of the level 0 nodes so we get the record nodes as orphans. - RTreeNodes orphans; - for (size_t i = 0; i < level_0_children.size(); ++i) - level_1_children[i / 2]->RemoveChild(level_0_children[i], &orphans); - - // Orphans should be all 8 records but no order guarantee. - EXPECT_EQ(8U, orphans.size()); - for (std::vector::iterator it = records.begin(); - it != records.end(); ++it) { - RTreeNodes::iterator orphan = - std::find(orphans.begin(), orphans.end(), *it); - EXPECT_NE(orphan, orphans.end()); - orphans.erase(orphan); - } - EXPECT_EQ(0U, orphans.size()); -} - -TEST_F(RTreeNodeTest, RemoveAndReturnLastChild) { - scoped_ptr test_parent(new RTreeNode); - test_parent->AddChild( - scoped_ptr(new RTreeRecord(Rect(0, 0, 1, 1), 1))); - test_parent->AddChild( - scoped_ptr(new RTreeRecord(Rect(0, 0, 2, 2), 2))); - test_parent->AddChild( - scoped_ptr(new RTreeRecord(Rect(0, 0, 3, 3), 3))); - ValidateNode(test_parent.get(), 1U, 5U); - - RTreeNodeBase* child = test_parent->child(2); - scoped_ptr last_child(test_parent->RemoveAndReturnLastChild()); - EXPECT_EQ(child, last_child.get()); - EXPECT_EQ(2U, test_parent->count()); - NodeRecomputeLocalBounds(test_parent.get()); - ValidateNode(test_parent.get(), 1U, 5U); - - child = test_parent->child(1); - scoped_ptr middle_child( - test_parent->RemoveAndReturnLastChild()); - EXPECT_EQ(child, middle_child.get()); - EXPECT_EQ(1U, test_parent->count()); - NodeRecomputeLocalBounds(test_parent.get()); - ValidateNode(test_parent.get(), 1U, 5U); - - child = test_parent->child(0); - scoped_ptr first_child( - test_parent->RemoveAndReturnLastChild()); - EXPECT_EQ(child, first_child.get()); - EXPECT_EQ(0U, test_parent->count()); -} - -TEST_F(RTreeNodeTest, LeastOverlapIncrease) { - scoped_ptr test_parent(NewNodeAtLevel(1)); - // Construct 4 nodes with 1x2 rects spaced horizontally 1 pixel apart, or: - // - // a b c d - // a b c d - // - for (int i = 0; i < 4; ++i) { - scoped_ptr node(new RTreeNode); - scoped_ptr record( - new RTreeRecord(Rect(i * 2, 0, 1, 2), i + 1)); - node->AddChild(record.Pass()); - test_parent->AddChild(node.Pass()); - } - - ValidateNode(test_parent.get(), 1U, 5U); - - // Test rect at (7, 0) should require minimum overlap on the part of the - // fourth rectangle to add: - // - // a b c dT - // a b c d - // - Rect test_rect_far(7, 0, 1, 1); - RTreeRects expanded_rects; - BuildExpandedRects(test_parent.get(), test_rect_far, &expanded_rects); - RTreeNode* result = NodeLeastOverlapIncrease( - test_parent.get(), test_rect_far, expanded_rects); - EXPECT_EQ(4, record(result, 0)->key()); - - // Test rect covering the bottom half of all children should be a 4-way tie, - // so LeastOverlapIncrease should return NULL: - // - // a b c d - // TTTTTTT - // - Rect test_rect_tie(0, 1, 7, 1); - BuildExpandedRects(test_parent.get(), test_rect_tie, &expanded_rects); - result = NodeLeastOverlapIncrease( - test_parent.get(), test_rect_tie, expanded_rects); - EXPECT_TRUE(result == NULL); - - // Test rect completely inside c should return the third rectangle: - // - // a b T d - // a b c d - // - Rect test_rect_inside(4, 0, 1, 1); - BuildExpandedRects(test_parent.get(), test_rect_inside, &expanded_rects); - result = NodeLeastOverlapIncrease( - test_parent.get(), test_rect_inside, expanded_rects); - EXPECT_EQ(3, record(result, 0)->key()); - - // Add a rectangle that overlaps completely with rectangle c, to test - // when there is a tie between two completely contained rectangles: - // - // a b Ted - // a b eed - // - scoped_ptr record_parent(new RTreeNode); - record_parent->AddChild( - scoped_ptr(new RTreeRecord(Rect(4, 0, 2, 2), 9))); - test_parent->AddChild(record_parent.Pass()); - BuildExpandedRects(test_parent.get(), test_rect_inside, &expanded_rects); - result = NodeLeastOverlapIncrease( - test_parent.get(), test_rect_inside, expanded_rects); - EXPECT_TRUE(result == NULL); -} - -TEST_F(RTreeNodeTest, LeastAreaEnlargement) { - scoped_ptr test_parent(NewNodeAtLevel(1)); - // Construct 4 nodes in a cross-hairs style configuration: - // - // a - // b c - // d - // - scoped_ptr node(new RTreeNode); - node->AddChild( - scoped_ptr(new RTreeRecord(Rect(1, 0, 1, 1), 1))); - test_parent->AddChild(node.Pass()); - node.reset(new RTreeNode); - node->AddChild( - scoped_ptr(new RTreeRecord(Rect(0, 1, 1, 1), 2))); - test_parent->AddChild(node.Pass()); - node.reset(new RTreeNode); - node->AddChild( - scoped_ptr(new RTreeRecord(Rect(2, 1, 1, 1), 3))); - test_parent->AddChild(node.Pass()); - node.reset(new RTreeNode); - node->AddChild( - scoped_ptr(new RTreeRecord(Rect(1, 2, 1, 1), 4))); - test_parent->AddChild(node.Pass()); - - ValidateNode(test_parent.get(), 1U, 5U); - - // Test rect at (1, 3) should require minimum area to add to Node d: - // - // a - // b c - // d - // T - // - Rect test_rect_below(1, 3, 1, 1); - RTreeRects expanded_rects; - BuildExpandedRects(test_parent.get(), test_rect_below, &expanded_rects); - RTreeNode* result = NodeLeastAreaEnlargement( - test_parent.get(), test_rect_below, expanded_rects); - EXPECT_EQ(4, record(result, 0)->key()); - - // Test rect completely inside b should require minimum area to add to Node b: - // - // a - // T c - // d - // - Rect test_rect_inside(0, 1, 1, 1); - BuildExpandedRects(test_parent.get(), test_rect_inside, &expanded_rects); - result = NodeLeastAreaEnlargement( - test_parent.get(), test_rect_inside, expanded_rects); - EXPECT_EQ(2, record(result, 0)->key()); - - // Add e at (0, 1) to overlap b and c, to test tie-breaking: - // - // a - // eee - // d - // - node.reset(new RTreeNode); - node->AddChild( - scoped_ptr(new RTreeRecord(Rect(0, 1, 3, 1), 7))); - test_parent->AddChild(node.Pass()); - - ValidateNode(test_parent.get(), 1U, 5U); - - // Test rect at (3, 1) should tie between c and e, but c has smaller area so - // the algorithm should select c: - // - // - // a - // eeeT - // d - // - Rect test_rect_tie_breaker(3, 1, 1, 1); - BuildExpandedRects(test_parent.get(), test_rect_tie_breaker, &expanded_rects); - result = NodeLeastAreaEnlargement( - test_parent.get(), test_rect_tie_breaker, expanded_rects); - EXPECT_EQ(3, record(result, 0)->key()); -} - -// RTreeTest ------------------------------------------------------------------ - -// An empty RTree should never return AppendIntersectingRecords results, and -// RTrees should be empty upon construction. -TEST_F(RTreeTest, AppendIntersectingRecordsOnEmptyTree) { - RT rt(2, 10); - ValidateRTree(&rt); - RT::Matches results; - Rect test_rect(25, 25); - rt.AppendIntersectingRecords(test_rect, &results); - EXPECT_EQ(0U, results.size()); - ValidateRTree(&rt); -} - -// Clear should empty the tree, meaning that all queries should not return -// results after. -TEST_F(RTreeTest, ClearEmptiesTreeOfSingleNode) { - RT rt(2, 5); - rt.Insert(Rect(0, 0, 100, 100), 1); - rt.Clear(); - RT::Matches results; - Rect test_rect(1, 1); - rt.AppendIntersectingRecords(test_rect, &results); - EXPECT_EQ(0U, results.size()); - ValidateRTree(&rt); -} - -// Even with a complex internal structure, clear should empty the tree, meaning -// that all queries should not return results after. -TEST_F(RTreeTest, ClearEmptiesTreeOfManyNodes) { - RT rt(2, 5); - AddStackedSquares(&rt, 100); - rt.Clear(); - RT::Matches results; - Rect test_rect(1, 1); - rt.AppendIntersectingRecords(test_rect, &results); - EXPECT_EQ(0U, results.size()); - ValidateRTree(&rt); -} - -// Duplicate inserts should overwrite previous inserts. -TEST_F(RTreeTest, DuplicateInsertsOverwrite) { - RT rt(2, 5); - // Add 100 stacked squares, but always with duplicate key of 0. - for (int i = 1; i <= 100; ++i) { - rt.Insert(Rect(0, 0, i, i), 0); - ValidateRTree(&rt); - } - RT::Matches results; - Rect test_rect(1, 1); - rt.AppendIntersectingRecords(test_rect, &results); - EXPECT_EQ(1U, results.size()); - EXPECT_EQ(1U, results.count(0)); -} - -// Call Remove() once on something that's been inserted repeatedly. -TEST_F(RTreeTest, DuplicateInsertRemove) { - RT rt(3, 9); - AddStackedSquares(&rt, 25); - for (int i = 1; i <= 100; ++i) { - rt.Insert(Rect(0, 0, i, i), 26); - ValidateRTree(&rt); - } - rt.Remove(26); - RT::Matches results; - Rect test_rect(1, 1); - rt.AppendIntersectingRecords(test_rect, &results); - EXPECT_EQ(25U, results.size()); - VerifyAllKeys(results); -} - -// Call Remove() repeatedly on something that's been inserted once. -TEST_F(RTreeTest, InsertDuplicateRemove) { - RT rt(7, 15); - AddStackedSquares(&rt, 101); - for (int i = 0; i < 100; ++i) { - rt.Remove(101); - ValidateRTree(&rt); - } - RT::Matches results; - Rect test_rect(1, 1); - rt.AppendIntersectingRecords(test_rect, &results); - EXPECT_EQ(100U, results.size()); - VerifyAllKeys(results); -} - -// Stacked rects should meet all matching queries regardless of nesting. -TEST_F(RTreeTest, AppendIntersectingRecordsStackedSquaresNestedHit) { - RT rt(2, 5); - AddStackedSquares(&rt, 100); - RT::Matches results; - Rect test_rect(1, 1); - rt.AppendIntersectingRecords(test_rect, &results); - EXPECT_EQ(100U, results.size()); - VerifyAllKeys(results); -} - -// Stacked rects should meet all matching queries when contained completely by -// the query rectangle. -TEST_F(RTreeTest, AppendIntersectingRecordsStackedSquaresContainedHit) { - RT rt(2, 10); - AddStackedSquares(&rt, 100); - RT::Matches results; - Rect test_rect(0, 0, 100, 100); - rt.AppendIntersectingRecords(test_rect, &results); - EXPECT_EQ(100U, results.size()); - VerifyAllKeys(results); -} - -// Stacked rects should miss a missing query when the query has no intersection -// with the rects. -TEST_F(RTreeTest, AppendIntersectingRecordsStackedSquaresCompleteMiss) { - RT rt(2, 7); - AddStackedSquares(&rt, 100); - RT::Matches results; - Rect test_rect(150, 150, 100, 100); - rt.AppendIntersectingRecords(test_rect, &results); - EXPECT_EQ(0U, results.size()); -} - -// Removing half the nodes after insertion should still result in a valid tree. -TEST_F(RTreeTest, RemoveHalfStackedRects) { - RT rt(2, 11); - AddStackedSquares(&rt, 200); - for (int i = 101; i <= 200; ++i) { - rt.Remove(i); - ValidateRTree(&rt); - } - RT::Matches results; - Rect test_rect(1, 1); - rt.AppendIntersectingRecords(test_rect, &results); - EXPECT_EQ(100U, results.size()); - VerifyAllKeys(results); - - // Add the nodes back in. - for (int i = 101; i <= 200; ++i) { - rt.Insert(Rect(0, 0, i, i), i); - ValidateRTree(&rt); - } - results.clear(); - rt.AppendIntersectingRecords(test_rect, &results); - EXPECT_EQ(200U, results.size()); - VerifyAllKeys(results); -} - -TEST_F(RTreeTest, InsertDupToRoot) { - RT rt(2, 5); - rt.Insert(Rect(0, 0, 1, 2), 1); - ValidateRTree(&rt); - rt.Insert(Rect(0, 0, 2, 1), 1); - ValidateRTree(&rt); -} - -TEST_F(RTreeTest, InsertNegativeCoordsRect) { - RT rt(5, 11); - for (int i = 1; i <= 100; ++i) { - rt.Insert(Rect(-i, -i, i, i), (i * 2) - 1); - ValidateRTree(&rt); - rt.Insert(Rect(0, 0, i, i), i * 2); - ValidateRTree(&rt); - } - RT::Matches results; - Rect test_rect(-1, -1, 2, 2); - rt.AppendIntersectingRecords(test_rect, &results); - EXPECT_EQ(200U, results.size()); - VerifyAllKeys(results); -} - -TEST_F(RTreeTest, RemoveNegativeCoordsRect) { - RT rt(7, 21); - - // Add 100 positive stacked squares. - AddStackedSquares(&rt, 100); - - // Now add 100 negative stacked squares. - for (int i = 101; i <= 200; ++i) { - rt.Insert(Rect(100 - i, 100 - i, i - 100, i - 100), 301 - i); - ValidateRTree(&rt); - } - - // Now remove half of the negative squares. - for (int i = 101; i <= 150; ++i) { - rt.Remove(301 - i); - ValidateRTree(&rt); - } - - // Queries should return 100 positive and 50 negative stacked squares. - RT::Matches results; - Rect test_rect(-1, -1, 2, 2); - rt.AppendIntersectingRecords(test_rect, &results); - EXPECT_EQ(150U, results.size()); - VerifyAllKeys(results); -} - -TEST_F(RTreeTest, InsertEmptyRectReplacementRemovesKey) { - RT rt(10, 31); - AddStackedSquares(&rt, 50); - ValidateRTree(&rt); - - // Replace last square with empty rect. - rt.Insert(Rect(), 50); - ValidateRTree(&rt); - - // Now query large area to get all rects in tree. - RT::Matches results; - Rect test_rect(0, 0, 100, 100); - rt.AppendIntersectingRecords(test_rect, &results); - - // Should only be 49 rects in tree. - EXPECT_EQ(49U, results.size()); - VerifyAllKeys(results); -} - -TEST_F(RTreeTest, InsertReplacementMaintainsTree) { - RT rt(2, 5); - AddStackedSquares(&rt, 100); - ValidateRTree(&rt); - - for (int i = 1; i <= 100; ++i) { - rt.Insert(Rect(0, 0, 0, 0), i); - ValidateRTree(&rt); - } -} - -} // namespace gfx diff --git a/ui/gfx/geometry/rect.cc b/ui/gfx/geometry/rect.cc deleted file mode 100644 index caebc9df2..000000000 --- a/ui/gfx/geometry/rect.cc +++ /dev/null @@ -1,251 +0,0 @@ -// 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 "ui/gfx/geometry/rect.h" - -#include - -#include "base/logging.h" -#include "base/strings/stringprintf.h" -#include "ui/gfx/geometry/insets.h" - -namespace gfx { - -void AdjustAlongAxis(int dst_origin, int dst_size, int* origin, int* size) { - *size = std::min(dst_size, *size); - if (*origin < dst_origin) - *origin = dst_origin; - else - *origin = std::min(dst_origin + dst_size, *origin + *size) - *size; -} - -} // namespace - -namespace gfx { - -void Rect::Inset(const Insets& insets) { - Inset(insets.left(), insets.top(), insets.right(), insets.bottom()); -} - -void Rect::Inset(int left, int top, int right, int bottom) { - origin_ += Vector2d(left, top); - set_width(std::max(width() - left - right, static_cast(0))); - set_height(std::max(height() - top - bottom, static_cast(0))); -} - -void Rect::Offset(int horizontal, int vertical) { - origin_ += Vector2d(horizontal, vertical); -} - -void Rect::operator+=(const Vector2d& offset) { - origin_ += offset; -} - -void Rect::operator-=(const Vector2d& offset) { - origin_ -= offset; -} - -Insets Rect::InsetsFrom(const Rect& inner) const { - return Insets(inner.y() - y(), - inner.x() - x(), - bottom() - inner.bottom(), - right() - inner.right()); -} - -bool Rect::operator<(const Rect& other) const { - if (origin_ == other.origin_) { - if (width() == other.width()) { - return height() < other.height(); - } else { - return width() < other.width(); - } - } else { - return origin_ < other.origin_; - } -} - -bool Rect::Contains(int point_x, int point_y) const { - return (point_x >= x()) && (point_x < right()) && (point_y >= y()) && - (point_y < bottom()); -} - -bool Rect::Contains(const Rect& rect) const { - return (rect.x() >= x() && rect.right() <= right() && rect.y() >= y() && - rect.bottom() <= bottom()); -} - -bool Rect::Intersects(const Rect& rect) const { - return !(IsEmpty() || rect.IsEmpty() || rect.x() >= right() || - rect.right() <= x() || rect.y() >= bottom() || rect.bottom() <= y()); -} - -void Rect::Intersect(const Rect& rect) { - if (IsEmpty() || rect.IsEmpty()) { - SetRect(0, 0, 0, 0); - return; - } - - int rx = std::max(x(), rect.x()); - int ry = std::max(y(), rect.y()); - int rr = std::min(right(), rect.right()); - int rb = std::min(bottom(), rect.bottom()); - - if (rx >= rr || ry >= rb) - rx = ry = rr = rb = 0; // non-intersecting - - SetRect(rx, ry, rr - rx, rb - ry); -} - -void Rect::Union(const Rect& rect) { - if (IsEmpty()) { - *this = rect; - return; - } - if (rect.IsEmpty()) - return; - - int rx = std::min(x(), rect.x()); - int ry = std::min(y(), rect.y()); - int rr = std::max(right(), rect.right()); - int rb = std::max(bottom(), rect.bottom()); - - SetRect(rx, ry, rr - rx, rb - ry); -} - -void Rect::Subtract(const Rect& rect) { - if (!Intersects(rect)) - return; - if (rect.Contains(*this)) { - SetRect(0, 0, 0, 0); - return; - } - - int rx = x(); - int ry = y(); - int rr = right(); - int rb = bottom(); - - if (rect.y() <= y() && rect.bottom() >= bottom()) { - // complete intersection in the y-direction - if (rect.x() <= x()) { - rx = rect.right(); - } else if (rect.right() >= right()) { - rr = rect.x(); - } - } else if (rect.x() <= x() && rect.right() >= right()) { - // complete intersection in the x-direction - if (rect.y() <= y()) { - ry = rect.bottom(); - } else if (rect.bottom() >= bottom()) { - rb = rect.y(); - } - } - SetRect(rx, ry, rr - rx, rb - ry); -} - -void Rect::AdjustToFit(const Rect& rect) { - int new_x = x(); - int new_y = y(); - int new_width = width(); - int new_height = height(); - AdjustAlongAxis(rect.x(), rect.width(), &new_x, &new_width); - AdjustAlongAxis(rect.y(), rect.height(), &new_y, &new_height); - SetRect(new_x, new_y, new_width, new_height); -} - -Point Rect::CenterPoint() const { - return Point(x() + width() / 2, y() + height() / 2); -} - -void Rect::ClampToCenteredSize(const Size& size) { - int new_width = std::min(width(), size.width()); - int new_height = std::min(height(), size.height()); - int new_x = x() + (width() - new_width) / 2; - int new_y = y() + (height() - new_height) / 2; - SetRect(new_x, new_y, new_width, new_height); -} - -void Rect::SplitVertically(Rect* left_half, Rect* right_half) const { - DCHECK(left_half); - DCHECK(right_half); - - left_half->SetRect(x(), y(), width() / 2, height()); - right_half->SetRect( - left_half->right(), y(), width() - left_half->width(), height()); -} - -bool Rect::SharesEdgeWith(const Rect& rect) const { - return (y() == rect.y() && height() == rect.height() && - (x() == rect.right() || right() == rect.x())) || - (x() == rect.x() && width() == rect.width() && - (y() == rect.bottom() || bottom() == rect.y())); -} - -int Rect::ManhattanDistanceToPoint(const Point& point) const { - int x_distance = - std::max(0, std::max(x() - point.x(), point.x() - right())); - int y_distance = - std::max(0, std::max(y() - point.y(), point.y() - bottom())); - - return x_distance + y_distance; -} - -int Rect::ManhattanInternalDistance(const Rect& rect) const { - Rect c(*this); - c.Union(rect); - - static const int kEpsilon = std::numeric_limits::is_integer - ? 1 - : std::numeric_limits::epsilon(); - - int x = std::max(0, c.width() - width() - rect.width() + kEpsilon); - int y = std::max(0, c.height() - height() - rect.height() + kEpsilon); - return x + y; -} - -std::string Rect::ToString() const { - return base::StringPrintf("%s %s", - origin().ToString().c_str(), - size().ToString().c_str()); -} - -Rect operator+(const Rect& lhs, const Vector2d& rhs) { - Rect result(lhs); - result += rhs; - return result; -} - -Rect operator-(const Rect& lhs, const Vector2d& rhs) { - Rect result(lhs); - result -= rhs; - return result; -} - -Rect IntersectRects(const Rect& a, const Rect& b) { - Rect result = a; - result.Intersect(b); - return result; -} - -Rect UnionRects(const Rect& a, const Rect& b) { - Rect result = a; - result.Union(b); - return result; -} - -Rect SubtractRects(const Rect& a, const Rect& b) { - Rect result = a; - result.Subtract(b); - return result; -} - -Rect BoundingRect(const Point& p1, const Point& p2) { - int rx = std::min(p1.x(), p2.x()); - int ry = std::min(p1.y(), p2.y()); - int rr = std::max(p1.x(), p2.x()); - int rb = std::max(p1.y(), p2.y()); - return Rect(rx, ry, rr - rx, rb - ry); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/rect.h b/ui/gfx/geometry/rect.h deleted file mode 100644 index 5a5c6ae70..000000000 --- a/ui/gfx/geometry/rect.h +++ /dev/null @@ -1,233 +0,0 @@ -// 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. - -// Defines a simple integer rectangle class. The containment semantics -// are array-like; that is, the coordinate (x, y) is considered to be -// contained by the rectangle, but the coordinate (x + width, y) is not. -// The class will happily let you create malformed rectangles (that is, -// rectangles with negative width and/or height), but there will be assertions -// in the operations (such as Contains()) to complain in this case. - -#ifndef UI_GFX_GEOMETRY_RECT_H_ -#define UI_GFX_GEOMETRY_RECT_H_ - -#include -#include -#include - -#include "ui/gfx/geometry/point.h" -#include "ui/gfx/geometry/rect_f.h" -#include "ui/gfx/geometry/size.h" -#include "ui/gfx/geometry/vector2d.h" - -namespace gfx { - -class Insets; - -class GFX_EXPORT Rect { - public: - Rect() {} - Rect(int width, int height) : size_(width, height) {} - Rect(int x, int y, int width, int height) - : origin_(x, y), size_(width, height) {} - explicit Rect(const Size& size) : size_(size) {} - Rect(const Point& origin, const Size& size) : origin_(origin), size_(size) {} - - ~Rect() {} - - operator RectF() const { - return RectF(origin().x(), origin().y(), size().width(), size().height()); - } - - int x() const { return origin_.x(); } - void set_x(int x) { origin_.set_x(x); } - - int y() const { return origin_.y(); } - void set_y(int y) { origin_.set_y(y); } - - int width() const { return size_.width(); } - void set_width(int width) { size_.set_width(width); } - - int height() const { return size_.height(); } - void set_height(int height) { size_.set_height(height); } - - const Point& origin() const { return origin_; } - void set_origin(const Point& origin) { origin_ = origin; } - - const Size& size() const { return size_; } - void set_size(const Size& size) { size_ = size; } - - int right() const { return x() + width(); } - int bottom() const { return y() + height(); } - - Point top_right() const { return Point(right(), y()); } - Point bottom_left() const { return Point(x(), bottom()); } - Point bottom_right() const { return Point(right(), bottom()); } - - Vector2d OffsetFromOrigin() const { return Vector2d(x(), y()); } - - void SetRect(int x, int y, int width, int height) { - origin_.SetPoint(x, y); - size_.SetSize(width, height); - } - - // Shrink the rectangle by a horizontal and vertical distance on all sides. - void Inset(int horizontal, int vertical) { - Inset(horizontal, vertical, horizontal, vertical); - } - - // Shrink the rectangle by the given insets. - void Inset(const Insets& insets); - - // Shrink the rectangle by the specified amount on each side. - void Inset(int left, int top, int right, int bottom); - - // Move the rectangle by a horizontal and vertical distance. - void Offset(int horizontal, int vertical); - void Offset(const Vector2d& distance) { Offset(distance.x(), distance.y()); } - void operator+=(const Vector2d& offset); - void operator-=(const Vector2d& offset); - - Insets InsetsFrom(const Rect& inner) const; - - // Returns true if the area of the rectangle is zero. - bool IsEmpty() const { return size_.IsEmpty(); } - - // A rect is less than another rect if its origin is less than - // the other rect's origin. If the origins are equal, then the - // shortest rect is less than the other. If the origin and the - // height are equal, then the narrowest rect is less than. - // This comparison is required to use Rects in sets, or sorted - // vectors. - bool operator<(const Rect& other) const; - - // Returns true if the point identified by point_x and point_y falls inside - // this rectangle. The point (x, y) is inside the rectangle, but the - // point (x + width, y + height) is not. - bool Contains(int point_x, int point_y) const; - - // Returns true if the specified point is contained by this rectangle. - bool Contains(const Point& point) const { - return Contains(point.x(), point.y()); - } - - // Returns true if this rectangle contains the specified rectangle. - bool Contains(const Rect& rect) const; - - // Returns true if this rectangle intersects the specified rectangle. - // An empty rectangle doesn't intersect any rectangle. - bool Intersects(const Rect& rect) const; - - // Computes the intersection of this rectangle with the given rectangle. - void Intersect(const Rect& rect); - - // Computes the union of this rectangle with the given rectangle. The union - // is the smallest rectangle containing both rectangles. - void Union(const Rect& rect); - - // Computes the rectangle resulting from subtracting |rect| from |*this|, - // i.e. the bounding rect of |Region(*this) - Region(rect)|. - void Subtract(const Rect& rect); - - // Fits as much of the receiving rectangle into the supplied rectangle as - // possible, becoming the result. For example, if the receiver had - // a x-location of 2 and a width of 4, and the supplied rectangle had - // an x-location of 0 with a width of 5, the returned rectangle would have - // an x-location of 1 with a width of 4. - void AdjustToFit(const Rect& rect); - - // Returns the center of this rectangle. - Point CenterPoint() const; - - // Becomes a rectangle that has the same center point but with a size capped - // at given |size|. - void ClampToCenteredSize(const Size& size); - - // Splits |this| in two halves, |left_half| and |right_half|. - void SplitVertically(Rect* left_half, Rect* right_half) const; - - // Returns true if this rectangle shares an entire edge (i.e., same width or - // same height) with the given rectangle, and the rectangles do not overlap. - bool SharesEdgeWith(const Rect& rect) const; - - // Returns the manhattan distance from the rect to the point. If the point is - // inside the rect, returns 0. - int ManhattanDistanceToPoint(const Point& point) const; - - // Returns the manhattan distance between the contents of this rect and the - // contents of the given rect. That is, if the intersection of the two rects - // is non-empty then the function returns 0. If the rects share a side, it - // returns the smallest non-zero value appropriate for int. - int ManhattanInternalDistance(const Rect& rect) const; - - std::string ToString() const; - - private: - gfx::Point origin_; - gfx::Size size_; -}; - -inline bool operator==(const Rect& lhs, const Rect& rhs) { - return lhs.origin() == rhs.origin() && lhs.size() == rhs.size(); -} - -inline bool operator!=(const Rect& lhs, const Rect& rhs) { - return !(lhs == rhs); -} - -GFX_EXPORT Rect operator+(const Rect& lhs, const Vector2d& rhs); -GFX_EXPORT Rect operator-(const Rect& lhs, const Vector2d& rhs); - -inline Rect operator+(const Vector2d& lhs, const Rect& rhs) { - return rhs + lhs; -} - -GFX_EXPORT Rect IntersectRects(const Rect& a, const Rect& b); -GFX_EXPORT Rect UnionRects(const Rect& a, const Rect& b); -GFX_EXPORT Rect SubtractRects(const Rect& a, const Rect& b); - -// Constructs a rectangle with |p1| and |p2| as opposite corners. -// -// This could also be thought of as "the smallest rect that contains both -// points", except that we consider points on the right/bottom edges of the -// rect to be outside the rect. So technically one or both points will not be -// contained within the rect, because they will appear on one of these edges. -GFX_EXPORT Rect BoundingRect(const Point& p1, const Point& p2); - -inline Rect ScaleToEnclosingRect(const Rect& rect, - float x_scale, - float y_scale) { - int x = std::floor(rect.x() * x_scale); - int y = std::floor(rect.y() * y_scale); - int r = rect.width() == 0 ? x : std::ceil(rect.right() * x_scale); - int b = rect.height() == 0 ? y : std::ceil(rect.bottom() * y_scale); - return Rect(x, y, r - x, b - y); -} - -inline Rect ScaleToEnclosingRect(const Rect& rect, float scale) { - return ScaleToEnclosingRect(rect, scale, scale); -} - -inline Rect ScaleToEnclosedRect(const Rect& rect, - float x_scale, - float y_scale) { - int x = std::ceil(rect.x() * x_scale); - int y = std::ceil(rect.y() * y_scale); - int r = rect.width() == 0 ? x : std::floor(rect.right() * x_scale); - int b = rect.height() == 0 ? y : std::floor(rect.bottom() * y_scale); - return Rect(x, y, r - x, b - y); -} - -inline Rect ScaleToEnclosedRect(const Rect& rect, float scale) { - return ScaleToEnclosedRect(rect, scale, scale); -} - -// This is declared here for use in gtest-based unit tests but is defined in -// the gfx_test_support target. Depend on that to use this in your unit test. -// This should not be used in production code - call ToString() instead. -void PrintTo(const Rect& rect, ::std::ostream* os); - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_RECT_H_ diff --git a/ui/gfx/geometry/rect_conversions.cc b/ui/gfx/geometry/rect_conversions.cc deleted file mode 100644 index cceeb83a0..000000000 --- a/ui/gfx/geometry/rect_conversions.cc +++ /dev/null @@ -1,82 +0,0 @@ -// 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 "ui/gfx/geometry/rect_conversions.h" - -#include -#include - -#include "base/logging.h" -#include "ui/gfx/geometry/safe_integer_conversions.h" - -namespace gfx { - -Rect ToEnclosingRect(const RectF& rect) { - int min_x = ToFlooredInt(rect.x()); - int min_y = ToFlooredInt(rect.y()); - float max_x = rect.right(); - float max_y = rect.bottom(); - int width = rect.width() == 0 ? 0 : std::max(ToCeiledInt(max_x) - min_x, 0); - int height = rect.height() == 0 ? 0 : std::max(ToCeiledInt(max_y) - min_y, 0); - return Rect(min_x, min_y, width, height); -} - -Rect ToEnclosedRect(const RectF& rect) { - int min_x = ToCeiledInt(rect.x()); - int min_y = ToCeiledInt(rect.y()); - float max_x = rect.right(); - float max_y = rect.bottom(); - int width = std::max(ToFlooredInt(max_x) - min_x, 0); - int height = std::max(ToFlooredInt(max_y) - min_y, 0); - return Rect(min_x, min_y, width, height); -} - -Rect ToNearestRect(const RectF& rect) { - float float_min_x = rect.x(); - float float_min_y = rect.y(); - float float_max_x = rect.right(); - float float_max_y = rect.bottom(); - - int min_x = ToRoundedInt(float_min_x); - int min_y = ToRoundedInt(float_min_y); - int max_x = ToRoundedInt(float_max_x); - int max_y = ToRoundedInt(float_max_y); - - // If these DCHECKs fail, you're using the wrong method, consider using - // ToEnclosingRect or ToEnclosedRect instead. - DCHECK(std::abs(min_x - float_min_x) < 0.01f); - DCHECK(std::abs(min_y - float_min_y) < 0.01f); - DCHECK(std::abs(max_x - float_max_x) < 0.01f); - DCHECK(std::abs(max_y - float_max_y) < 0.01f); - - return Rect(min_x, min_y, max_x - min_x, max_y - min_y); -} - -bool IsNearestRectWithinDistance(const gfx::RectF& rect, float distance) { - float float_min_x = rect.x(); - float float_min_y = rect.y(); - float float_max_x = rect.right(); - float float_max_y = rect.bottom(); - - int min_x = ToRoundedInt(float_min_x); - int min_y = ToRoundedInt(float_min_y); - int max_x = ToRoundedInt(float_max_x); - int max_y = ToRoundedInt(float_max_y); - - return - (std::abs(min_x - float_min_x) < distance) && - (std::abs(min_y - float_min_y) < distance) && - (std::abs(max_x - float_max_x) < distance) && - (std::abs(max_y - float_max_y) < distance); -} - -Rect ToFlooredRectDeprecated(const RectF& rect) { - return Rect(ToFlooredInt(rect.x()), - ToFlooredInt(rect.y()), - ToFlooredInt(rect.width()), - ToFlooredInt(rect.height())); -} - -} // namespace gfx - diff --git a/ui/gfx/geometry/rect_conversions.h b/ui/gfx/geometry/rect_conversions.h deleted file mode 100644 index 617074abe..000000000 --- a/ui/gfx/geometry/rect_conversions.h +++ /dev/null @@ -1,36 +0,0 @@ -// 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 UI_GFX_GEOMETRY_RECT_CONVERSIONS_H_ -#define UI_GFX_GEOMETRY_RECT_CONVERSIONS_H_ - -#include "ui/gfx/geometry/rect.h" -#include "ui/gfx/geometry/rect_f.h" - -namespace gfx { - -// Returns the smallest Rect that encloses the given RectF. -GFX_EXPORT Rect ToEnclosingRect(const RectF& rect); - -// Returns the largest Rect that is enclosed by the given RectF. -GFX_EXPORT Rect ToEnclosedRect(const RectF& rect); - -// Returns the Rect after snapping the corners of the RectF to an integer grid. -// This should only be used when the RectF you provide is expected to be an -// integer rect with floating point error. If it is an arbitrary RectF, then -// you should use a different method. -GFX_EXPORT Rect ToNearestRect(const RectF& rect); - -// Returns true if the Rect produced after snapping the corners of the RectF -// to an integer grid is withing |distance|. -GFX_EXPORT bool IsNearestRectWithinDistance( - const gfx::RectF& rect, float distance); - -// Returns a Rect obtained by flooring the values of the given RectF. -// Please prefer the previous two functions in new code. -GFX_EXPORT Rect ToFlooredRectDeprecated(const RectF& rect); - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_RECT_CONVERSIONS_H_ diff --git a/ui/gfx/geometry/rect_f.cc b/ui/gfx/geometry/rect_f.cc deleted file mode 100644 index c87ea3de6..000000000 --- a/ui/gfx/geometry/rect_f.cc +++ /dev/null @@ -1,246 +0,0 @@ -// 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 "ui/gfx/geometry/rect_f.h" - -#include - -#include "base/logging.h" -#include "base/strings/stringprintf.h" -#include "ui/gfx/geometry/insets_f.h" -#include "ui/gfx/geometry/safe_integer_conversions.h" - -namespace gfx { - -static void AdjustAlongAxis(float dst_origin, - float dst_size, - float* origin, - float* size) { - *size = std::min(dst_size, *size); - if (*origin < dst_origin) - *origin = dst_origin; - else - *origin = std::min(dst_origin + dst_size, *origin + *size) - *size; -} - -void RectF::Inset(const InsetsF& insets) { - Inset(insets.left(), insets.top(), insets.right(), insets.bottom()); -} - -void RectF::Inset(float left, float top, float right, float bottom) { - origin_ += Vector2dF(left, top); - set_width(std::max(width() - left - right, static_cast(0))); - set_height(std::max(height() - top - bottom, static_cast(0))); -} - -void RectF::Offset(float horizontal, float vertical) { - origin_ += Vector2dF(horizontal, vertical); -} - -void RectF::operator+=(const Vector2dF& offset) { - origin_ += offset; -} - -void RectF::operator-=(const Vector2dF& offset) { - origin_ -= offset; -} - -InsetsF RectF::InsetsFrom(const RectF& inner) const { - return InsetsF(inner.y() - y(), - inner.x() - x(), - bottom() - inner.bottom(), - right() - inner.right()); -} - -bool RectF::operator<(const RectF& other) const { - if (origin_ == other.origin_) { - if (width() == other.width()) { - return height() < other.height(); - } else { - return width() < other.width(); - } - } else { - return origin_ < other.origin_; - } -} - -bool RectF::Contains(float point_x, float point_y) const { - return (point_x >= x()) && (point_x < right()) && (point_y >= y()) && - (point_y < bottom()); -} - -bool RectF::Contains(const RectF& rect) const { - return (rect.x() >= x() && rect.right() <= right() && rect.y() >= y() && - rect.bottom() <= bottom()); -} - -bool RectF::Intersects(const RectF& rect) const { - return !(IsEmpty() || rect.IsEmpty() || rect.x() >= right() || - rect.right() <= x() || rect.y() >= bottom() || rect.bottom() <= y()); -} - -void RectF::Intersect(const RectF& rect) { - if (IsEmpty() || rect.IsEmpty()) { - SetRect(0, 0, 0, 0); - return; - } - - float rx = std::max(x(), rect.x()); - float ry = std::max(y(), rect.y()); - float rr = std::min(right(), rect.right()); - float rb = std::min(bottom(), rect.bottom()); - - if (rx >= rr || ry >= rb) - rx = ry = rr = rb = 0; // non-intersecting - - SetRect(rx, ry, rr - rx, rb - ry); -} - -void RectF::Union(const RectF& rect) { - if (IsEmpty()) { - *this = rect; - return; - } - if (rect.IsEmpty()) - return; - - float rx = std::min(x(), rect.x()); - float ry = std::min(y(), rect.y()); - float rr = std::max(right(), rect.right()); - float rb = std::max(bottom(), rect.bottom()); - - SetRect(rx, ry, rr - rx, rb - ry); -} - -void RectF::Subtract(const RectF& rect) { - if (!Intersects(rect)) - return; - if (rect.Contains(*static_cast(this))) { - SetRect(0, 0, 0, 0); - return; - } - - float rx = x(); - float ry = y(); - float rr = right(); - float rb = bottom(); - - if (rect.y() <= y() && rect.bottom() >= bottom()) { - // complete intersection in the y-direction - if (rect.x() <= x()) { - rx = rect.right(); - } else if (rect.right() >= right()) { - rr = rect.x(); - } - } else if (rect.x() <= x() && rect.right() >= right()) { - // complete intersection in the x-direction - if (rect.y() <= y()) { - ry = rect.bottom(); - } else if (rect.bottom() >= bottom()) { - rb = rect.y(); - } - } - SetRect(rx, ry, rr - rx, rb - ry); -} - -void RectF::AdjustToFit(const RectF& rect) { - float new_x = x(); - float new_y = y(); - float new_width = width(); - float new_height = height(); - AdjustAlongAxis(rect.x(), rect.width(), &new_x, &new_width); - AdjustAlongAxis(rect.y(), rect.height(), &new_y, &new_height); - SetRect(new_x, new_y, new_width, new_height); -} - -PointF RectF::CenterPoint() const { - return PointF(x() + width() / 2, y() + height() / 2); -} - -void RectF::ClampToCenteredSize(const SizeF& size) { - float new_width = std::min(width(), size.width()); - float new_height = std::min(height(), size.height()); - float new_x = x() + (width() - new_width) / 2; - float new_y = y() + (height() - new_height) / 2; - SetRect(new_x, new_y, new_width, new_height); -} - -void RectF::SplitVertically(RectF* left_half, RectF* right_half) const { - DCHECK(left_half); - DCHECK(right_half); - - left_half->SetRect(x(), y(), width() / 2, height()); - right_half->SetRect( - left_half->right(), y(), width() - left_half->width(), height()); -} - -bool RectF::SharesEdgeWith(const RectF& rect) const { - return (y() == rect.y() && height() == rect.height() && - (x() == rect.right() || right() == rect.x())) || - (x() == rect.x() && width() == rect.width() && - (y() == rect.bottom() || bottom() == rect.y())); -} - -float RectF::ManhattanDistanceToPoint(const PointF& point) const { - float x_distance = - std::max(0, std::max(x() - point.x(), point.x() - right())); - float y_distance = - std::max(0, std::max(y() - point.y(), point.y() - bottom())); - - return x_distance + y_distance; -} - -float RectF::ManhattanInternalDistance(const RectF& rect) const { - RectF c(*this); - c.Union(rect); - - static const float kEpsilon = std::numeric_limits::is_integer - ? 1 - : std::numeric_limits::epsilon(); - - float x = std::max(0, c.width() - width() - rect.width() + kEpsilon); - float y = - std::max(0, c.height() - height() - rect.height() + kEpsilon); - return x + y; -} - -bool RectF::IsExpressibleAsRect() const { - return IsExpressibleAsInt(x()) && IsExpressibleAsInt(y()) && - IsExpressibleAsInt(width()) && IsExpressibleAsInt(height()) && - IsExpressibleAsInt(right()) && IsExpressibleAsInt(bottom()); -} - -std::string RectF::ToString() const { - return base::StringPrintf("%s %s", - origin().ToString().c_str(), - size().ToString().c_str()); -} - -RectF IntersectRects(const RectF& a, const RectF& b) { - RectF result = a; - result.Intersect(b); - return result; -} - -RectF UnionRects(const RectF& a, const RectF& b) { - RectF result = a; - result.Union(b); - return result; -} - -RectF SubtractRects(const RectF& a, const RectF& b) { - RectF result = a; - result.Subtract(b); - return result; -} - -RectF BoundingRect(const PointF& p1, const PointF& p2) { - float rx = std::min(p1.x(), p2.x()); - float ry = std::min(p1.y(), p2.y()); - float rr = std::max(p1.x(), p2.x()); - float rb = std::max(p1.y(), p2.y()); - return RectF(rx, ry, rr - rx, rb - ry); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/rect_f.h b/ui/gfx/geometry/rect_f.h deleted file mode 100644 index dc233a771..000000000 --- a/ui/gfx/geometry/rect_f.h +++ /dev/null @@ -1,226 +0,0 @@ -// 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 UI_GFX_GEOMETRY_RECT_F_H_ -#define UI_GFX_GEOMETRY_RECT_F_H_ - -#include -#include - -#include "ui/gfx/geometry/point_f.h" -#include "ui/gfx/geometry/size_f.h" -#include "ui/gfx/geometry/vector2d_f.h" - -namespace gfx { - -class InsetsF; - -// A floating version of gfx::Rect. -class GFX_EXPORT RectF { - public: - RectF() {} - RectF(float width, float height) : size_(width, height) {} - RectF(float x, float y, float width, float height) - : origin_(x, y), size_(width, height) {} - explicit RectF(const SizeF& size) : size_(size) {} - RectF(const PointF& origin, const SizeF& size) - : origin_(origin), size_(size) {} - - ~RectF() {} - - float x() const { return origin_.x(); } - void set_x(float x) { origin_.set_x(x); } - - float y() const { return origin_.y(); } - void set_y(float y) { origin_.set_y(y); } - - float width() const { return size_.width(); } - void set_width(float width) { size_.set_width(width); } - - float height() const { return size_.height(); } - void set_height(float height) { size_.set_height(height); } - - const PointF& origin() const { return origin_; } - void set_origin(const PointF& origin) { origin_ = origin; } - - const SizeF& size() const { return size_; } - void set_size(const SizeF& size) { size_ = size; } - - float right() const { return x() + width(); } - float bottom() const { return y() + height(); } - - PointF top_right() const { return PointF(right(), y()); } - PointF bottom_left() const { return PointF(x(), bottom()); } - PointF bottom_right() const { return PointF(right(), bottom()); } - - Vector2dF OffsetFromOrigin() const { return Vector2dF(x(), y()); } - - void SetRect(float x, float y, float width, float height) { - origin_.SetPoint(x, y); - size_.SetSize(width, height); - } - - // Shrink the rectangle by a horizontal and vertical distance on all sides. - void Inset(float horizontal, float vertical) { - Inset(horizontal, vertical, horizontal, vertical); - } - - // Shrink the rectangle by the given insets. - void Inset(const InsetsF& insets); - - // Shrink the rectangle by the specified amount on each side. - void Inset(float left, float top, float right, float bottom); - - // Move the rectangle by a horizontal and vertical distance. - void Offset(float horizontal, float vertical); - void Offset(const Vector2dF& distance) { Offset(distance.x(), distance.y()); } - void operator+=(const Vector2dF& offset); - void operator-=(const Vector2dF& offset); - - InsetsF InsetsFrom(const RectF& inner) const; - - // Returns true if the area of the rectangle is zero. - bool IsEmpty() const { return size_.IsEmpty(); } - - // A rect is less than another rect if its origin is less than - // the other rect's origin. If the origins are equal, then the - // shortest rect is less than the other. If the origin and the - // height are equal, then the narrowest rect is less than. - // This comparison is required to use Rects in sets, or sorted - // vectors. - bool operator<(const RectF& other) const; - - // Returns true if the point identified by point_x and point_y falls inside - // this rectangle. The point (x, y) is inside the rectangle, but the - // point (x + width, y + height) is not. - bool Contains(float point_x, float point_y) const; - - // Returns true if the specified point is contained by this rectangle. - bool Contains(const PointF& point) const { - return Contains(point.x(), point.y()); - } - - // Returns true if this rectangle contains the specified rectangle. - bool Contains(const RectF& rect) const; - - // Returns true if this rectangle intersects the specified rectangle. - // An empty rectangle doesn't intersect any rectangle. - bool Intersects(const RectF& rect) const; - - // Computes the intersection of this rectangle with the given rectangle. - void Intersect(const RectF& rect); - - // Computes the union of this rectangle with the given rectangle. The union - // is the smallest rectangle containing both rectangles. - void Union(const RectF& rect); - - // Computes the rectangle resulting from subtracting |rect| from |*this|, - // i.e. the bounding rect of |Region(*this) - Region(rect)|. - void Subtract(const RectF& rect); - - // Fits as much of the receiving rectangle into the supplied rectangle as - // possible, becoming the result. For example, if the receiver had - // a x-location of 2 and a width of 4, and the supplied rectangle had - // an x-location of 0 with a width of 5, the returned rectangle would have - // an x-location of 1 with a width of 4. - void AdjustToFit(const RectF& rect); - - // Returns the center of this rectangle. - PointF CenterPoint() const; - - // Becomes a rectangle that has the same center point but with a size capped - // at given |size|. - void ClampToCenteredSize(const SizeF& size); - - // Splits |this| in two halves, |left_half| and |right_half|. - void SplitVertically(RectF* left_half, RectF* right_half) const; - - // Returns true if this rectangle shares an entire edge (i.e., same width or - // same height) with the given rectangle, and the rectangles do not overlap. - bool SharesEdgeWith(const RectF& rect) const; - - // Returns the manhattan distance from the rect to the point. If the point is - // inside the rect, returns 0. - float ManhattanDistanceToPoint(const PointF& point) const; - - // Returns the manhattan distance between the contents of this rect and the - // contents of the given rect. That is, if the intersection of the two rects - // is non-empty then the function returns 0. If the rects share a side, it - // returns the smallest non-zero value appropriate for float. - float ManhattanInternalDistance(const RectF& rect) const; - - // Scales the rectangle by |scale|. - void Scale(float scale) { - Scale(scale, scale); - } - - void Scale(float x_scale, float y_scale) { - set_origin(ScalePoint(origin(), x_scale, y_scale)); - set_size(ScaleSize(size(), x_scale, y_scale)); - } - - // This method reports if the RectF can be safely converted to an integer - // Rect. When it is false, some dimension of the RectF is outside the bounds - // of what an integer can represent, and converting it to a Rect will require - // clamping. - bool IsExpressibleAsRect() const; - - std::string ToString() const; - - private: - PointF origin_; - SizeF size_; -}; - -inline bool operator==(const RectF& lhs, const RectF& rhs) { - return lhs.origin() == rhs.origin() && lhs.size() == rhs.size(); -} - -inline bool operator!=(const RectF& lhs, const RectF& rhs) { - return !(lhs == rhs); -} - -inline RectF operator+(const RectF& lhs, const Vector2dF& rhs) { - return RectF(lhs.x() + rhs.x(), lhs.y() + rhs.y(), - lhs.width(), lhs.height()); -} - -inline RectF operator-(const RectF& lhs, const Vector2dF& rhs) { - return RectF(lhs.x() - rhs.x(), lhs.y() - rhs.y(), - lhs.width(), lhs.height()); -} - -inline RectF operator+(const Vector2dF& lhs, const RectF& rhs) { - return rhs + lhs; -} - -GFX_EXPORT RectF IntersectRects(const RectF& a, const RectF& b); -GFX_EXPORT RectF UnionRects(const RectF& a, const RectF& b); -GFX_EXPORT RectF SubtractRects(const RectF& a, const RectF& b); - -inline RectF ScaleRect(const RectF& r, float x_scale, float y_scale) { - return RectF(r.x() * x_scale, r.y() * y_scale, - r.width() * x_scale, r.height() * y_scale); -} - -inline RectF ScaleRect(const RectF& r, float scale) { - return ScaleRect(r, scale, scale); -} - -// Constructs a rectangle with |p1| and |p2| as opposite corners. -// -// This could also be thought of as "the smallest rect that contains both -// points", except that we consider points on the right/bottom edges of the -// rect to be outside the rect. So technically one or both points will not be -// contained within the rect, because they will appear on one of these edges. -GFX_EXPORT RectF BoundingRect(const PointF& p1, const PointF& p2); - -// This is declared here for use in gtest-based unit tests but is defined in -// the gfx_test_support target. Depend on that to use this in your unit test. -// This should not be used in production code - call ToString() instead. -void PrintTo(const RectF& rect, ::std::ostream* os); - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_RECT_F_H_ diff --git a/ui/gfx/geometry/rect_unittest.cc b/ui/gfx/geometry/rect_unittest.cc deleted file mode 100644 index 83890cc8f..000000000 --- a/ui/gfx/geometry/rect_unittest.cc +++ /dev/null @@ -1,910 +0,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 - -#include "base/basictypes.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/gfx/geometry/rect.h" -#include "ui/gfx/geometry/rect_conversions.h" -#include "ui/gfx/test/gfx_util.h" - -namespace gfx { - -TEST(RectTest, Contains) { - static const struct ContainsCase { - int rect_x; - int rect_y; - int rect_width; - int rect_height; - int point_x; - int point_y; - bool contained; - } contains_cases[] = { - {0, 0, 10, 10, 0, 0, true}, - {0, 0, 10, 10, 5, 5, true}, - {0, 0, 10, 10, 9, 9, true}, - {0, 0, 10, 10, 5, 10, false}, - {0, 0, 10, 10, 10, 5, false}, - {0, 0, 10, 10, -1, -1, false}, - {0, 0, 10, 10, 50, 50, false}, - #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) - {0, 0, -10, -10, 0, 0, false}, - #endif - }; - for (size_t i = 0; i < arraysize(contains_cases); ++i) { - const ContainsCase& value = contains_cases[i]; - Rect rect(value.rect_x, value.rect_y, value.rect_width, value.rect_height); - EXPECT_EQ(value.contained, rect.Contains(value.point_x, value.point_y)); - } -} - -TEST(RectTest, Intersects) { - static const struct { - int x1; // rect 1 - int y1; - int w1; - int h1; - int x2; // rect 2 - int y2; - int w2; - int h2; - bool intersects; - } tests[] = { - { 0, 0, 0, 0, 0, 0, 0, 0, false }, - { 0, 0, 0, 0, -10, -10, 20, 20, false }, - { -10, 0, 0, 20, 0, -10, 20, 0, false }, - { 0, 0, 10, 10, 0, 0, 10, 10, true }, - { 0, 0, 10, 10, 10, 10, 10, 10, false }, - { 10, 10, 10, 10, 0, 0, 10, 10, false }, - { 10, 10, 10, 10, 5, 5, 10, 10, true }, - { 10, 10, 10, 10, 15, 15, 10, 10, true }, - { 10, 10, 10, 10, 20, 15, 10, 10, false }, - { 10, 10, 10, 10, 21, 15, 10, 10, false } - }; - for (size_t i = 0; i < arraysize(tests); ++i) { - Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); - Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); - EXPECT_EQ(tests[i].intersects, r1.Intersects(r2)); - EXPECT_EQ(tests[i].intersects, r2.Intersects(r1)); - } -} - -TEST(RectTest, Intersect) { - static const struct { - int x1; // rect 1 - int y1; - int w1; - int h1; - int x2; // rect 2 - int y2; - int w2; - int h2; - int x3; // rect 3: the union of rects 1 and 2 - int y3; - int w3; - int h3; - } tests[] = { - { 0, 0, 0, 0, // zeros - 0, 0, 0, 0, - 0, 0, 0, 0 }, - { 0, 0, 4, 4, // equal - 0, 0, 4, 4, - 0, 0, 4, 4 }, - { 0, 0, 4, 4, // neighboring - 4, 4, 4, 4, - 0, 0, 0, 0 }, - { 0, 0, 4, 4, // overlapping corners - 2, 2, 4, 4, - 2, 2, 2, 2 }, - { 0, 0, 4, 4, // T junction - 3, 1, 4, 2, - 3, 1, 1, 2 }, - { 3, 0, 2, 2, // gap - 0, 0, 2, 2, - 0, 0, 0, 0 } - }; - for (size_t i = 0; i < arraysize(tests); ++i) { - Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); - Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); - Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3); - Rect ir = IntersectRects(r1, r2); - EXPECT_EQ(r3.x(), ir.x()); - EXPECT_EQ(r3.y(), ir.y()); - EXPECT_EQ(r3.width(), ir.width()); - EXPECT_EQ(r3.height(), ir.height()); - } -} - -TEST(RectTest, Union) { - static const struct Test { - int x1; // rect 1 - int y1; - int w1; - int h1; - int x2; // rect 2 - int y2; - int w2; - int h2; - int x3; // rect 3: the union of rects 1 and 2 - int y3; - int w3; - int h3; - } tests[] = { - { 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0 }, - { 0, 0, 4, 4, - 0, 0, 4, 4, - 0, 0, 4, 4 }, - { 0, 0, 4, 4, - 4, 4, 4, 4, - 0, 0, 8, 8 }, - { 0, 0, 4, 4, - 0, 5, 4, 4, - 0, 0, 4, 9 }, - { 0, 0, 2, 2, - 3, 3, 2, 2, - 0, 0, 5, 5 }, - { 3, 3, 2, 2, // reverse r1 and r2 from previous test - 0, 0, 2, 2, - 0, 0, 5, 5 }, - { 0, 0, 0, 0, // union with empty rect - 2, 2, 2, 2, - 2, 2, 2, 2 } - }; - for (size_t i = 0; i < arraysize(tests); ++i) { - Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); - Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); - Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3); - Rect u = UnionRects(r1, r2); - EXPECT_EQ(r3.x(), u.x()); - EXPECT_EQ(r3.y(), u.y()); - EXPECT_EQ(r3.width(), u.width()); - EXPECT_EQ(r3.height(), u.height()); - } -} - -TEST(RectTest, Equals) { - ASSERT_TRUE(Rect(0, 0, 0, 0) == Rect(0, 0, 0, 0)); - ASSERT_TRUE(Rect(1, 2, 3, 4) == Rect(1, 2, 3, 4)); - ASSERT_FALSE(Rect(0, 0, 0, 0) == Rect(0, 0, 0, 1)); - ASSERT_FALSE(Rect(0, 0, 0, 0) == Rect(0, 0, 1, 0)); - ASSERT_FALSE(Rect(0, 0, 0, 0) == Rect(0, 1, 0, 0)); - ASSERT_FALSE(Rect(0, 0, 0, 0) == Rect(1, 0, 0, 0)); -} - -TEST(RectTest, AdjustToFit) { - static const struct Test { - int x1; // source - int y1; - int w1; - int h1; - int x2; // target - int y2; - int w2; - int h2; - int x3; // rect 3: results of invoking AdjustToFit - int y3; - int w3; - int h3; - } tests[] = { - { 0, 0, 2, 2, - 0, 0, 2, 2, - 0, 0, 2, 2 }, - { 2, 2, 3, 3, - 0, 0, 4, 4, - 1, 1, 3, 3 }, - { -1, -1, 5, 5, - 0, 0, 4, 4, - 0, 0, 4, 4 }, - { 2, 2, 4, 4, - 0, 0, 3, 3, - 0, 0, 3, 3 }, - { 2, 2, 1, 1, - 0, 0, 3, 3, - 2, 2, 1, 1 } - }; - for (size_t i = 0; i < arraysize(tests); ++i) { - Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); - Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); - Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3); - Rect u = r1; - u.AdjustToFit(r2); - EXPECT_EQ(r3.x(), u.x()); - EXPECT_EQ(r3.y(), u.y()); - EXPECT_EQ(r3.width(), u.width()); - EXPECT_EQ(r3.height(), u.height()); - } -} - -TEST(RectTest, Subtract) { - Rect result; - - // Matching - result = Rect(10, 10, 20, 20); - result.Subtract(Rect(10, 10, 20, 20)); - EXPECT_EQ(Rect(0, 0, 0, 0), result); - - // Contains - result = Rect(10, 10, 20, 20); - result.Subtract(Rect(5, 5, 30, 30)); - EXPECT_EQ(Rect(0, 0, 0, 0), result); - - // No intersection - result = Rect(10, 10, 20, 20); - result.Subtract(Rect(30, 30, 30, 30)); - EXPECT_EQ(Rect(10, 10, 20, 20), result); - - // Not a complete intersection in either direction - result = Rect(10, 10, 20, 20); - result.Subtract(Rect(15, 15, 20, 20)); - EXPECT_EQ(Rect(10, 10, 20, 20), result); - - // Complete intersection in the x-direction, top edge is fully covered. - result = Rect(10, 10, 20, 20); - result.Subtract(Rect(10, 15, 20, 20)); - EXPECT_EQ(Rect(10, 10, 20, 5), result); - - // Complete intersection in the x-direction, top edge is fully covered. - result = Rect(10, 10, 20, 20); - result.Subtract(Rect(5, 15, 30, 20)); - EXPECT_EQ(Rect(10, 10, 20, 5), result); - - // Complete intersection in the x-direction, bottom edge is fully covered. - result = Rect(10, 10, 20, 20); - result.Subtract(Rect(5, 5, 30, 20)); - EXPECT_EQ(Rect(10, 25, 20, 5), result); - - // Complete intersection in the x-direction, none of the edges is fully - // covered. - result = Rect(10, 10, 20, 20); - result.Subtract(Rect(5, 15, 30, 1)); - EXPECT_EQ(Rect(10, 10, 20, 20), result); - - // Complete intersection in the y-direction, left edge is fully covered. - result = Rect(10, 10, 20, 20); - result.Subtract(Rect(10, 10, 10, 30)); - EXPECT_EQ(Rect(20, 10, 10, 20), result); - - // Complete intersection in the y-direction, left edge is fully covered. - result = Rect(10, 10, 20, 20); - result.Subtract(Rect(5, 5, 20, 30)); - EXPECT_EQ(Rect(25, 10, 5, 20), result); - - // Complete intersection in the y-direction, right edge is fully covered. - result = Rect(10, 10, 20, 20); - result.Subtract(Rect(20, 5, 20, 30)); - EXPECT_EQ(Rect(10, 10, 10, 20), result); - - // Complete intersection in the y-direction, none of the edges is fully - // covered. - result = Rect(10, 10, 20, 20); - result.Subtract(Rect(15, 5, 1, 30)); - EXPECT_EQ(Rect(10, 10, 20, 20), result); -} - -TEST(RectTest, IsEmpty) { - EXPECT_TRUE(Rect(0, 0, 0, 0).IsEmpty()); - EXPECT_TRUE(Rect(0, 0, 0, 0).size().IsEmpty()); - EXPECT_TRUE(Rect(0, 0, 10, 0).IsEmpty()); - EXPECT_TRUE(Rect(0, 0, 10, 0).size().IsEmpty()); - EXPECT_TRUE(Rect(0, 0, 0, 10).IsEmpty()); - EXPECT_TRUE(Rect(0, 0, 0, 10).size().IsEmpty()); - EXPECT_FALSE(Rect(0, 0, 10, 10).IsEmpty()); - EXPECT_FALSE(Rect(0, 0, 10, 10).size().IsEmpty()); -} - -TEST(RectTest, SplitVertically) { - Rect left_half, right_half; - - // Splitting when origin is (0, 0). - Rect(0, 0, 20, 20).SplitVertically(&left_half, &right_half); - EXPECT_TRUE(left_half == Rect(0, 0, 10, 20)); - EXPECT_TRUE(right_half == Rect(10, 0, 10, 20)); - - // Splitting when origin is arbitrary. - Rect(10, 10, 20, 10).SplitVertically(&left_half, &right_half); - EXPECT_TRUE(left_half == Rect(10, 10, 10, 10)); - EXPECT_TRUE(right_half == Rect(20, 10, 10, 10)); - - // Splitting a rectangle of zero width. - Rect(10, 10, 0, 10).SplitVertically(&left_half, &right_half); - EXPECT_TRUE(left_half == Rect(10, 10, 0, 10)); - EXPECT_TRUE(right_half == Rect(10, 10, 0, 10)); - - // Splitting a rectangle of odd width. - Rect(10, 10, 5, 10).SplitVertically(&left_half, &right_half); - EXPECT_TRUE(left_half == Rect(10, 10, 2, 10)); - EXPECT_TRUE(right_half == Rect(12, 10, 3, 10)); -} - -TEST(RectTest, CenterPoint) { - Point center; - - // When origin is (0, 0). - center = Rect(0, 0, 20, 20).CenterPoint(); - EXPECT_TRUE(center == Point(10, 10)); - - // When origin is even. - center = Rect(10, 10, 20, 20).CenterPoint(); - EXPECT_TRUE(center == Point(20, 20)); - - // When origin is odd. - center = Rect(11, 11, 20, 20).CenterPoint(); - EXPECT_TRUE(center == Point(21, 21)); - - // When 0 width or height. - center = Rect(10, 10, 0, 20).CenterPoint(); - EXPECT_TRUE(center == Point(10, 20)); - center = Rect(10, 10, 20, 0).CenterPoint(); - EXPECT_TRUE(center == Point(20, 10)); - - // When an odd size. - center = Rect(10, 10, 21, 21).CenterPoint(); - EXPECT_TRUE(center == Point(20, 20)); - - // When an odd size and position. - center = Rect(11, 11, 21, 21).CenterPoint(); - EXPECT_TRUE(center == Point(21, 21)); -} - -TEST(RectTest, CenterPointF) { - PointF center; - - // When origin is (0, 0). - center = RectF(0, 0, 20, 20).CenterPoint(); - EXPECT_TRUE(center == PointF(10, 10)); - - // When origin is even. - center = RectF(10, 10, 20, 20).CenterPoint(); - EXPECT_TRUE(center == PointF(20, 20)); - - // When origin is odd. - center = RectF(11, 11, 20, 20).CenterPoint(); - EXPECT_TRUE(center == PointF(21, 21)); - - // When 0 width or height. - center = RectF(10, 10, 0, 20).CenterPoint(); - EXPECT_TRUE(center == PointF(10, 20)); - center = RectF(10, 10, 20, 0).CenterPoint(); - EXPECT_TRUE(center == PointF(20, 10)); - - // When an odd size. - center = RectF(10, 10, 21, 21).CenterPoint(); - EXPECT_TRUE(center == PointF(20.5f, 20.5f)); - - // When an odd size and position. - center = RectF(11, 11, 21, 21).CenterPoint(); - EXPECT_TRUE(center == PointF(21.5f, 21.5f)); -} - -TEST(RectTest, SharesEdgeWith) { - Rect r(2, 3, 4, 5); - - // Must be non-overlapping - EXPECT_FALSE(r.SharesEdgeWith(r)); - - Rect just_above(2, 1, 4, 2); - Rect just_below(2, 8, 4, 2); - Rect just_left(0, 3, 2, 5); - Rect just_right(6, 3, 2, 5); - - EXPECT_TRUE(r.SharesEdgeWith(just_above)); - EXPECT_TRUE(r.SharesEdgeWith(just_below)); - EXPECT_TRUE(r.SharesEdgeWith(just_left)); - EXPECT_TRUE(r.SharesEdgeWith(just_right)); - - // Wrong placement - Rect same_height_no_edge(0, 0, 1, 5); - Rect same_width_no_edge(0, 0, 4, 1); - - EXPECT_FALSE(r.SharesEdgeWith(same_height_no_edge)); - EXPECT_FALSE(r.SharesEdgeWith(same_width_no_edge)); - - Rect just_above_no_edge(2, 1, 5, 2); // too wide - Rect just_below_no_edge(2, 8, 3, 2); // too narrow - Rect just_left_no_edge(0, 3, 2, 6); // too tall - Rect just_right_no_edge(6, 3, 2, 4); // too short - - EXPECT_FALSE(r.SharesEdgeWith(just_above_no_edge)); - EXPECT_FALSE(r.SharesEdgeWith(just_below_no_edge)); - EXPECT_FALSE(r.SharesEdgeWith(just_left_no_edge)); - EXPECT_FALSE(r.SharesEdgeWith(just_right_no_edge)); -} - -// Similar to EXPECT_FLOAT_EQ, but lets NaN equal NaN -#define EXPECT_FLOAT_AND_NAN_EQ(a, b) \ - { if (a == a || b == b) { EXPECT_FLOAT_EQ(a, b); } } - -TEST(RectTest, ScaleRect) { - static const struct Test { - int x1; // source - int y1; - int w1; - int h1; - float scale; - float x2; // target - float y2; - float w2; - float h2; - } tests[] = { - { 3, 3, 3, 3, - 1.5f, - 4.5f, 4.5f, 4.5f, 4.5f }, - { 3, 3, 3, 3, - 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f }, - { 3, 3, 3, 3, - std::numeric_limits::quiet_NaN(), - std::numeric_limits::quiet_NaN(), - std::numeric_limits::quiet_NaN(), - std::numeric_limits::quiet_NaN(), - std::numeric_limits::quiet_NaN() }, - { 3, 3, 3, 3, - std::numeric_limits::max(), - std::numeric_limits::max(), - std::numeric_limits::max(), - std::numeric_limits::max(), - std::numeric_limits::max() } - }; - - for (size_t i = 0; i < arraysize(tests); ++i) { - Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); - RectF r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); - - RectF scaled = ScaleRect(r1, tests[i].scale); - EXPECT_FLOAT_AND_NAN_EQ(r2.x(), scaled.x()); - EXPECT_FLOAT_AND_NAN_EQ(r2.y(), scaled.y()); - EXPECT_FLOAT_AND_NAN_EQ(r2.width(), scaled.width()); - EXPECT_FLOAT_AND_NAN_EQ(r2.height(), scaled.height()); - } -} - -TEST(RectTest, ToEnclosedRect) { - static const struct Test { - float x1; // source - float y1; - float w1; - float h1; - int x2; // target - int y2; - int w2; - int h2; - } tests [] = { - { 0.0f, 0.0f, 0.0f, 0.0f, - 0, 0, 0, 0 }, - { -1.5f, -1.5f, 3.0f, 3.0f, - -1, -1, 2, 2 }, - { -1.5f, -1.5f, 3.5f, 3.5f, - -1, -1, 3, 3 }, - { std::numeric_limits::max(), - std::numeric_limits::max(), - 2.0f, 2.0f, - std::numeric_limits::max(), - std::numeric_limits::max(), - 0, 0 }, - { 0.0f, 0.0f, - std::numeric_limits::max(), - std::numeric_limits::max(), - 0, 0, - std::numeric_limits::max(), - std::numeric_limits::max() }, - { 20000.5f, 20000.5f, 0.5f, 0.5f, - 20001, 20001, 0, 0 }, - { std::numeric_limits::quiet_NaN(), - std::numeric_limits::quiet_NaN(), - std::numeric_limits::quiet_NaN(), - std::numeric_limits::quiet_NaN(), - 0, 0, 0, 0 } - }; - - for (size_t i = 0; i < arraysize(tests); ++i) { - RectF r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); - Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); - - Rect enclosed = ToEnclosedRect(r1); - EXPECT_FLOAT_AND_NAN_EQ(r2.x(), enclosed.x()); - EXPECT_FLOAT_AND_NAN_EQ(r2.y(), enclosed.y()); - EXPECT_FLOAT_AND_NAN_EQ(r2.width(), enclosed.width()); - EXPECT_FLOAT_AND_NAN_EQ(r2.height(), enclosed.height()); - } -} - -TEST(RectTest, ToEnclosingRect) { - static const struct Test { - float x1; // source - float y1; - float w1; - float h1; - int x2; // target - int y2; - int w2; - int h2; - } tests [] = { - { 0.0f, 0.0f, 0.0f, 0.0f, - 0, 0, 0, 0 }, - { 5.5f, 5.5f, 0.0f, 0.0f, - 5, 5, 0, 0 }, - { -1.5f, -1.5f, 3.0f, 3.0f, - -2, -2, 4, 4 }, - { -1.5f, -1.5f, 3.5f, 3.5f, - -2, -2, 4, 4 }, - { std::numeric_limits::max(), - std::numeric_limits::max(), - 2.0f, 2.0f, - std::numeric_limits::max(), - std::numeric_limits::max(), - 0, 0 }, - { 0.0f, 0.0f, - std::numeric_limits::max(), - std::numeric_limits::max(), - 0, 0, - std::numeric_limits::max(), - std::numeric_limits::max() }, - { 20000.5f, 20000.5f, 0.5f, 0.5f, - 20000, 20000, 1, 1 }, - { std::numeric_limits::quiet_NaN(), - std::numeric_limits::quiet_NaN(), - std::numeric_limits::quiet_NaN(), - std::numeric_limits::quiet_NaN(), - 0, 0, 0, 0 } - }; - - for (size_t i = 0; i < arraysize(tests); ++i) { - RectF r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); - Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); - - Rect enclosed = ToEnclosingRect(r1); - EXPECT_FLOAT_AND_NAN_EQ(r2.x(), enclosed.x()); - EXPECT_FLOAT_AND_NAN_EQ(r2.y(), enclosed.y()); - EXPECT_FLOAT_AND_NAN_EQ(r2.width(), enclosed.width()); - EXPECT_FLOAT_AND_NAN_EQ(r2.height(), enclosed.height()); - } -} - -TEST(RectTest, ToNearestRect) { - Rect rect; - EXPECT_EQ(rect, ToNearestRect(RectF(rect))); - - rect = Rect(-1, -1, 3, 3); - EXPECT_EQ(rect, ToNearestRect(RectF(rect))); - - RectF rectf(-1.00001f, -0.999999f, 3.0000001f, 2.999999f); - EXPECT_EQ(rect, ToNearestRect(rectf)); -} - -TEST(RectTest, ToFlooredRect) { - static const struct Test { - float x1; // source - float y1; - float w1; - float h1; - int x2; // target - int y2; - int w2; - int h2; - } tests [] = { - { 0.0f, 0.0f, 0.0f, 0.0f, - 0, 0, 0, 0 }, - { -1.5f, -1.5f, 3.0f, 3.0f, - -2, -2, 3, 3 }, - { -1.5f, -1.5f, 3.5f, 3.5f, - -2, -2, 3, 3 }, - { 20000.5f, 20000.5f, 0.5f, 0.5f, - 20000, 20000, 0, 0 }, - }; - - for (size_t i = 0; i < arraysize(tests); ++i) { - RectF r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); - Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); - - Rect floored = ToFlooredRectDeprecated(r1); - EXPECT_FLOAT_EQ(r2.x(), floored.x()); - EXPECT_FLOAT_EQ(r2.y(), floored.y()); - EXPECT_FLOAT_EQ(r2.width(), floored.width()); - EXPECT_FLOAT_EQ(r2.height(), floored.height()); - } -} - -TEST(RectTest, ScaleToEnclosedRect) { - static const struct Test { - Rect input_rect; - float input_scale; - Rect expected_rect; - } tests[] = { - { - Rect(), - 5.f, - Rect(), - }, { - Rect(1, 1, 1, 1), - 5.f, - Rect(5, 5, 5, 5), - }, { - Rect(-1, -1, 0, 0), - 5.f, - Rect(-5, -5, 0, 0), - }, { - Rect(1, -1, 0, 1), - 5.f, - Rect(5, -5, 0, 5), - }, { - Rect(-1, 1, 1, 0), - 5.f, - Rect(-5, 5, 5, 0), - }, { - Rect(1, 2, 3, 4), - 1.5f, - Rect(2, 3, 4, 6), - }, { - Rect(-1, -2, 0, 0), - 1.5f, - Rect(-1, -3, 0, 0), - } - }; - - for (size_t i = 0; i < arraysize(tests); ++i) { - Rect result = ScaleToEnclosedRect(tests[i].input_rect, - tests[i].input_scale); - EXPECT_EQ(tests[i].expected_rect, result); - } -} - -TEST(RectTest, ScaleToEnclosingRect) { - static const struct Test { - Rect input_rect; - float input_scale; - Rect expected_rect; - } tests[] = { - { - Rect(), - 5.f, - Rect(), - }, { - Rect(1, 1, 1, 1), - 5.f, - Rect(5, 5, 5, 5), - }, { - Rect(-1, -1, 0, 0), - 5.f, - Rect(-5, -5, 0, 0), - }, { - Rect(1, -1, 0, 1), - 5.f, - Rect(5, -5, 0, 5), - }, { - Rect(-1, 1, 1, 0), - 5.f, - Rect(-5, 5, 5, 0), - }, { - Rect(1, 2, 3, 4), - 1.5f, - Rect(1, 3, 5, 6), - }, { - Rect(-1, -2, 0, 0), - 1.5f, - Rect(-2, -3, 0, 0), - } - }; - - for (size_t i = 0; i < arraysize(tests); ++i) { - Rect result = ScaleToEnclosingRect(tests[i].input_rect, - tests[i].input_scale); - EXPECT_EQ(tests[i].expected_rect, result); - } -} - -TEST(RectTest, ToRectF) { - // Check that implicit conversion from integer to float compiles. - Rect a(10, 20, 30, 40); - RectF b(10, 20, 30, 40); - - RectF intersect = IntersectRects(a, b); - EXPECT_EQ(b, intersect); - - EXPECT_EQ(a, b); - EXPECT_EQ(b, a); -} - -TEST(RectTest, BoundingRect) { - struct { - Point a; - Point b; - Rect expected; - } int_tests[] = { - // If point B dominates A, then A should be the origin. - { Point(4, 6), Point(4, 6), Rect(4, 6, 0, 0) }, - { Point(4, 6), Point(8, 6), Rect(4, 6, 4, 0) }, - { Point(4, 6), Point(4, 9), Rect(4, 6, 0, 3) }, - { Point(4, 6), Point(8, 9), Rect(4, 6, 4, 3) }, - // If point A dominates B, then B should be the origin. - { Point(4, 6), Point(4, 6), Rect(4, 6, 0, 0) }, - { Point(8, 6), Point(4, 6), Rect(4, 6, 4, 0) }, - { Point(4, 9), Point(4, 6), Rect(4, 6, 0, 3) }, - { Point(8, 9), Point(4, 6), Rect(4, 6, 4, 3) }, - // If neither point dominates, then the origin is a combination of the two. - { Point(4, 6), Point(6, 4), Rect(4, 4, 2, 2) }, - { Point(-4, -6), Point(-6, -4), Rect(-6, -6, 2, 2) }, - { Point(-4, 6), Point(6, -4), Rect(-4, -4, 10, 10) }, - }; - - for (size_t i = 0; i < arraysize(int_tests); ++i) { - Rect actual = BoundingRect(int_tests[i].a, int_tests[i].b); - EXPECT_EQ(int_tests[i].expected, actual); - } - - struct { - PointF a; - PointF b; - RectF expected; - } float_tests[] = { - // If point B dominates A, then A should be the origin. - { PointF(4.2f, 6.8f), PointF(4.2f, 6.8f), - RectF(4.2f, 6.8f, 0, 0) }, - { PointF(4.2f, 6.8f), PointF(8.5f, 6.8f), - RectF(4.2f, 6.8f, 4.3f, 0) }, - { PointF(4.2f, 6.8f), PointF(4.2f, 9.3f), - RectF(4.2f, 6.8f, 0, 2.5f) }, - { PointF(4.2f, 6.8f), PointF(8.5f, 9.3f), - RectF(4.2f, 6.8f, 4.3f, 2.5f) }, - // If point A dominates B, then B should be the origin. - { PointF(4.2f, 6.8f), PointF(4.2f, 6.8f), - RectF(4.2f, 6.8f, 0, 0) }, - { PointF(8.5f, 6.8f), PointF(4.2f, 6.8f), - RectF(4.2f, 6.8f, 4.3f, 0) }, - { PointF(4.2f, 9.3f), PointF(4.2f, 6.8f), - RectF(4.2f, 6.8f, 0, 2.5f) }, - { PointF(8.5f, 9.3f), PointF(4.2f, 6.8f), - RectF(4.2f, 6.8f, 4.3f, 2.5f) }, - // If neither point dominates, then the origin is a combination of the two. - { PointF(4.2f, 6.8f), PointF(6.8f, 4.2f), - RectF(4.2f, 4.2f, 2.6f, 2.6f) }, - { PointF(-4.2f, -6.8f), PointF(-6.8f, -4.2f), - RectF(-6.8f, -6.8f, 2.6f, 2.6f) }, - { PointF(-4.2f, 6.8f), PointF(6.8f, -4.2f), - RectF(-4.2f, -4.2f, 11.0f, 11.0f) } - }; - - for (size_t i = 0; i < arraysize(float_tests); ++i) { - RectF actual = BoundingRect(float_tests[i].a, float_tests[i].b); - EXPECT_RECTF_EQ(float_tests[i].expected, actual); - } -} - -TEST(RectTest, IsExpressibleAsRect) { - EXPECT_TRUE(RectF().IsExpressibleAsRect()); - - float min = std::numeric_limits::min(); - float max = std::numeric_limits::max(); - float infinity = std::numeric_limits::infinity(); - - EXPECT_TRUE(RectF( - min + 200, min + 200, max - 200, max - 200).IsExpressibleAsRect()); - EXPECT_FALSE(RectF( - min - 200, min + 200, max + 200, max + 200).IsExpressibleAsRect()); - EXPECT_FALSE(RectF( - min + 200 , min - 200, max + 200, max + 200).IsExpressibleAsRect()); - EXPECT_FALSE(RectF( - min + 200, min + 200, max + 200, max - 200).IsExpressibleAsRect()); - EXPECT_FALSE(RectF( - min + 200, min + 200, max - 200, max + 200).IsExpressibleAsRect()); - - EXPECT_TRUE(RectF(0, 0, max - 200, max - 200).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(200, 0, max + 200, max - 200).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(0, 200, max - 200, max + 200).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(0, 0, max + 200, max - 200).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(0, 0, max - 200, max + 200).IsExpressibleAsRect()); - - EXPECT_FALSE(RectF(infinity, 0, 1, 1).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(0, infinity, 1, 1).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(0, 0, infinity, 1).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(0, 0, 1, infinity).IsExpressibleAsRect()); -} - -TEST(RectTest, Offset) { - Rect i(1, 2, 3, 4); - - EXPECT_EQ(Rect(2, 1, 3, 4), (i + Vector2d(1, -1))); - EXPECT_EQ(Rect(2, 1, 3, 4), (Vector2d(1, -1) + i)); - i += Vector2d(1, -1); - EXPECT_EQ(Rect(2, 1, 3, 4), i); - EXPECT_EQ(Rect(1, 2, 3, 4), (i - Vector2d(1, -1))); - i -= Vector2d(1, -1); - EXPECT_EQ(Rect(1, 2, 3, 4), i); - - RectF f(1.1f, 2.2f, 3.3f, 4.4f); - EXPECT_EQ(RectF(2.2f, 1.1f, 3.3f, 4.4f), (f + Vector2dF(1.1f, -1.1f))); - EXPECT_EQ(RectF(2.2f, 1.1f, 3.3f, 4.4f), (Vector2dF(1.1f, -1.1f) + f)); - f += Vector2dF(1.1f, -1.1f); - EXPECT_EQ(RectF(2.2f, 1.1f, 3.3f, 4.4f), f); - EXPECT_EQ(RectF(1.1f, 2.2f, 3.3f, 4.4f), (f - Vector2dF(1.1f, -1.1f))); - f -= Vector2dF(1.1f, -1.1f); - EXPECT_EQ(RectF(1.1f, 2.2f, 3.3f, 4.4f), f); -} - -TEST(RectTest, Corners) { - Rect i(1, 2, 3, 4); - RectF f(1.1f, 2.1f, 3.1f, 4.1f); - - EXPECT_EQ(Point(1, 2), i.origin()); - EXPECT_EQ(Point(4, 2), i.top_right()); - EXPECT_EQ(Point(1, 6), i.bottom_left()); - EXPECT_EQ(Point(4, 6), i.bottom_right()); - - EXPECT_EQ(PointF(1.1f, 2.1f), f.origin()); - EXPECT_EQ(PointF(4.2f, 2.1f), f.top_right()); - EXPECT_EQ(PointF(1.1f, 6.2f), f.bottom_left()); - EXPECT_EQ(PointF(4.2f, 6.2f), f.bottom_right()); -} - -TEST(RectTest, ManhattanDistanceToPoint) { - Rect i(1, 2, 3, 4); - EXPECT_EQ(0, i.ManhattanDistanceToPoint(Point(1, 2))); - EXPECT_EQ(0, i.ManhattanDistanceToPoint(Point(4, 6))); - EXPECT_EQ(0, i.ManhattanDistanceToPoint(Point(2, 4))); - EXPECT_EQ(3, i.ManhattanDistanceToPoint(Point(0, 0))); - EXPECT_EQ(2, i.ManhattanDistanceToPoint(Point(2, 0))); - EXPECT_EQ(3, i.ManhattanDistanceToPoint(Point(5, 0))); - EXPECT_EQ(1, i.ManhattanDistanceToPoint(Point(5, 4))); - EXPECT_EQ(3, i.ManhattanDistanceToPoint(Point(5, 8))); - EXPECT_EQ(2, i.ManhattanDistanceToPoint(Point(3, 8))); - EXPECT_EQ(2, i.ManhattanDistanceToPoint(Point(0, 7))); - EXPECT_EQ(1, i.ManhattanDistanceToPoint(Point(0, 3))); - - RectF f(1.1f, 2.1f, 3.1f, 4.1f); - EXPECT_FLOAT_EQ(0.f, f.ManhattanDistanceToPoint(PointF(1.1f, 2.1f))); - EXPECT_FLOAT_EQ(0.f, f.ManhattanDistanceToPoint(PointF(4.2f, 6.f))); - EXPECT_FLOAT_EQ(0.f, f.ManhattanDistanceToPoint(PointF(2.f, 4.f))); - EXPECT_FLOAT_EQ(3.2f, f.ManhattanDistanceToPoint(PointF(0.f, 0.f))); - EXPECT_FLOAT_EQ(2.1f, f.ManhattanDistanceToPoint(PointF(2.f, 0.f))); - EXPECT_FLOAT_EQ(2.9f, f.ManhattanDistanceToPoint(PointF(5.f, 0.f))); - EXPECT_FLOAT_EQ(.8f, f.ManhattanDistanceToPoint(PointF(5.f, 4.f))); - EXPECT_FLOAT_EQ(2.6f, f.ManhattanDistanceToPoint(PointF(5.f, 8.f))); - EXPECT_FLOAT_EQ(1.8f, f.ManhattanDistanceToPoint(PointF(3.f, 8.f))); - EXPECT_FLOAT_EQ(1.9f, f.ManhattanDistanceToPoint(PointF(0.f, 7.f))); - EXPECT_FLOAT_EQ(1.1f, f.ManhattanDistanceToPoint(PointF(0.f, 3.f))); -} - -TEST(RectTest, ManhattanInternalDistance) { - Rect i(0, 0, 400, 400); - EXPECT_EQ(0, i.ManhattanInternalDistance(gfx::Rect(-1, 0, 2, 1))); - EXPECT_EQ(1, i.ManhattanInternalDistance(gfx::Rect(400, 0, 1, 400))); - EXPECT_EQ(2, i.ManhattanInternalDistance(gfx::Rect(-100, -100, 100, 100))); - EXPECT_EQ(2, i.ManhattanInternalDistance(gfx::Rect(-101, 100, 100, 100))); - EXPECT_EQ(4, i.ManhattanInternalDistance(gfx::Rect(-101, -101, 100, 100))); - EXPECT_EQ(435, i.ManhattanInternalDistance(gfx::Rect(630, 603, 100, 100))); - - RectF f(0.0f, 0.0f, 400.0f, 400.0f); - static const float kEpsilon = std::numeric_limits::epsilon(); - - EXPECT_FLOAT_EQ( - 0.0f, f.ManhattanInternalDistance(gfx::RectF(-1.0f, 0.0f, 2.0f, 1.0f))); - EXPECT_FLOAT_EQ( - kEpsilon, - f.ManhattanInternalDistance(gfx::RectF(400.0f, 0.0f, 1.0f, 400.0f))); - EXPECT_FLOAT_EQ(2.0f * kEpsilon, - f.ManhattanInternalDistance( - gfx::RectF(-100.0f, -100.0f, 100.0f, 100.0f))); - EXPECT_FLOAT_EQ( - 1.0f + kEpsilon, - f.ManhattanInternalDistance(gfx::RectF(-101.0f, 100.0f, 100.0f, 100.0f))); - EXPECT_FLOAT_EQ(2.0f + 2.0f * kEpsilon, - f.ManhattanInternalDistance( - gfx::RectF(-101.0f, -101.0f, 100.0f, 100.0f))); - EXPECT_FLOAT_EQ( - 433.0f + 2.0f * kEpsilon, - f.ManhattanInternalDistance(gfx::RectF(630.0f, 603.0f, 100.0f, 100.0f))); - - EXPECT_FLOAT_EQ( - 0.0f, f.ManhattanInternalDistance(gfx::RectF(-1.0f, 0.0f, 1.1f, 1.0f))); - EXPECT_FLOAT_EQ( - 0.1f + kEpsilon, - f.ManhattanInternalDistance(gfx::RectF(-1.5f, 0.0f, 1.4f, 1.0f))); - EXPECT_FLOAT_EQ( - kEpsilon, - f.ManhattanInternalDistance(gfx::RectF(-1.5f, 0.0f, 1.5f, 1.0f))); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/safe_integer_conversions.h b/ui/gfx/geometry/safe_integer_conversions.h deleted file mode 100644 index 58ed2a933..000000000 --- a/ui/gfx/geometry/safe_integer_conversions.h +++ /dev/null @@ -1,62 +0,0 @@ -// 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 UI_GFX_GEOMETRY_SAFE_INTEGER_CONVERSIONS_H_ -#define UI_GFX_GEOMETRY_SAFE_INTEGER_CONVERSIONS_H_ - -#include -#include - -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -inline int ClampToInt(float value) { - if (value != value) - return 0; // no int NaN. - if (value >= std::numeric_limits::max()) - return std::numeric_limits::max(); - if (value <= std::numeric_limits::min()) - return std::numeric_limits::min(); - return static_cast(value); -} - -inline int ToFlooredInt(float value) { - return ClampToInt(std::floor(value)); -} - -inline int ToCeiledInt(float value) { - return ClampToInt(std::ceil(value)); -} - -inline int ToFlooredInt(double value) { - return ClampToInt(std::floor(value)); -} - -inline int ToCeiledInt(double value) { - return ClampToInt(std::ceil(value)); -} - -inline int ToRoundedInt(float value) { - float rounded; - if (value >= 0.0f) - rounded = std::floor(value + 0.5f); - else - rounded = std::ceil(value - 0.5f); - return ClampToInt(rounded); -} - -inline bool IsExpressibleAsInt(float value) { - if (value != value) - return false; // no int NaN. - if (value > std::numeric_limits::max()) - return false; - if (value < std::numeric_limits::min()) - return false; - return true; -} - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_SAFE_INTEGER_CONVERSIONS_H_ diff --git a/ui/gfx/geometry/safe_integer_conversions_unittest.cc b/ui/gfx/geometry/safe_integer_conversions_unittest.cc deleted file mode 100644 index 20e05b49e..000000000 --- a/ui/gfx/geometry/safe_integer_conversions_unittest.cc +++ /dev/null @@ -1,109 +0,0 @@ -// 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 "ui/gfx/geometry/safe_integer_conversions.h" - -#include - -#include "testing/gtest/include/gtest/gtest.h" - -namespace gfx { - -TEST(SafeIntegerConversions, ClampToInt) { - EXPECT_EQ(0, ClampToInt(std::numeric_limits::quiet_NaN())); - - float max = std::numeric_limits::max(); - float min = std::numeric_limits::min(); - float infinity = std::numeric_limits::infinity(); - - int int_max = std::numeric_limits::max(); - int int_min = std::numeric_limits::min(); - - EXPECT_EQ(int_max, ClampToInt(infinity)); - EXPECT_EQ(int_max, ClampToInt(max)); - EXPECT_EQ(int_max, ClampToInt(max + 100)); - - EXPECT_EQ(-100, ClampToInt(-100.5f)); - EXPECT_EQ(0, ClampToInt(0)); - EXPECT_EQ(100, ClampToInt(100.5f)); - - EXPECT_EQ(int_min, ClampToInt(-infinity)); - EXPECT_EQ(int_min, ClampToInt(min)); - EXPECT_EQ(int_min, ClampToInt(min - 100)); -} - -TEST(SafeIntegerConversions, ToFlooredInt) { - EXPECT_EQ(0, ToFlooredInt(std::numeric_limits::quiet_NaN())); - - float max = std::numeric_limits::max(); - float min = std::numeric_limits::min(); - float infinity = std::numeric_limits::infinity(); - - int int_max = std::numeric_limits::max(); - int int_min = std::numeric_limits::min(); - - EXPECT_EQ(int_max, ToFlooredInt(infinity)); - EXPECT_EQ(int_max, ToFlooredInt(max)); - EXPECT_EQ(int_max, ToFlooredInt(max + 100)); - - EXPECT_EQ(-101, ToFlooredInt(-100.5f)); - EXPECT_EQ(0, ToFlooredInt(0.f)); - EXPECT_EQ(100, ToFlooredInt(100.5f)); - - EXPECT_EQ(int_min, ToFlooredInt(-infinity)); - EXPECT_EQ(int_min, ToFlooredInt(min)); - EXPECT_EQ(int_min, ToFlooredInt(min - 100)); -} - -TEST(SafeIntegerConversions, ToCeiledInt) { - EXPECT_EQ(0, ToCeiledInt(std::numeric_limits::quiet_NaN())); - - float max = std::numeric_limits::max(); - float min = std::numeric_limits::min(); - float infinity = std::numeric_limits::infinity(); - - int int_max = std::numeric_limits::max(); - int int_min = std::numeric_limits::min(); - - EXPECT_EQ(int_max, ToCeiledInt(infinity)); - EXPECT_EQ(int_max, ToCeiledInt(max)); - EXPECT_EQ(int_max, ToCeiledInt(max + 100)); - - EXPECT_EQ(-100, ToCeiledInt(-100.5f)); - EXPECT_EQ(0, ToCeiledInt(0.f)); - EXPECT_EQ(101, ToCeiledInt(100.5f)); - - EXPECT_EQ(int_min, ToCeiledInt(-infinity)); - EXPECT_EQ(int_min, ToCeiledInt(min)); - EXPECT_EQ(int_min, ToCeiledInt(min - 100)); -} - -TEST(SafeIntegerConversions, ToRoundedInt) { - EXPECT_EQ(0, ToRoundedInt(std::numeric_limits::quiet_NaN())); - - float max = std::numeric_limits::max(); - float min = std::numeric_limits::min(); - float infinity = std::numeric_limits::infinity(); - - int int_max = std::numeric_limits::max(); - int int_min = std::numeric_limits::min(); - - EXPECT_EQ(int_max, ToRoundedInt(infinity)); - EXPECT_EQ(int_max, ToRoundedInt(max)); - EXPECT_EQ(int_max, ToRoundedInt(max + 100)); - - EXPECT_EQ(-100, ToRoundedInt(-100.1f)); - EXPECT_EQ(-101, ToRoundedInt(-100.5f)); - EXPECT_EQ(-101, ToRoundedInt(-100.9f)); - EXPECT_EQ(0, ToRoundedInt(0)); - EXPECT_EQ(100, ToRoundedInt(100.1f)); - EXPECT_EQ(101, ToRoundedInt(100.5f)); - EXPECT_EQ(101, ToRoundedInt(100.9f)); - - EXPECT_EQ(int_min, ToRoundedInt(-infinity)); - EXPECT_EQ(int_min, ToRoundedInt(min)); - EXPECT_EQ(int_min, ToRoundedInt(min - 100)); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/scroll_offset.cc b/ui/gfx/geometry/scroll_offset.cc deleted file mode 100644 index 37356d83a..000000000 --- a/ui/gfx/geometry/scroll_offset.cc +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 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 "ui/gfx/geometry/scroll_offset.h" - -#include "base/strings/stringprintf.h" - -namespace gfx { - -std::string ScrollOffset::ToString() const { - return base::StringPrintf("[%lf %lf]", x_, y_); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/scroll_offset.h b/ui/gfx/geometry/scroll_offset.h deleted file mode 100644 index 496b5f429..000000000 --- a/ui/gfx/geometry/scroll_offset.h +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2014 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 UI_GFX_GEOMETRY_SCROLL_OFFSET_H_ -#define UI_GFX_GEOMETRY_SCROLL_OFFSET_H_ - -#include -#include - -#include "ui/gfx/geometry/safe_integer_conversions.h" -#include "ui/gfx/geometry/vector2d.h" -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -class GFX_EXPORT ScrollOffset { - public: - ScrollOffset() : x_(0), y_(0) {} - ScrollOffset(double x, double y) : x_(x), y_(y) {} - explicit ScrollOffset(const Vector2dF& v) : x_(v.x()), y_(v.y()) {} - explicit ScrollOffset(const Vector2d& v) : x_(v.x()), y_(v.y()) {} - - double x() const { return x_; } - void set_x(double x) { x_ = x; } - - double y() const { return y_; } - void set_y(double y) { y_ = y; } - - // True if both components are 0. - bool IsZero() const { - return x_ == 0 && y_ == 0; - } - - // Add the components of the |other| ScrollOffset to the current ScrollOffset. - void Add(const ScrollOffset& other) { - x_ += other.x_; - y_ += other.y_; - } - - // Subtract the components of the |other| ScrollOffset from the current - // ScrollOffset. - void Subtract(const ScrollOffset& other) { - x_ -= other.x_; - y_ -= other.y_; - } - - Vector2dF DeltaFrom(const ScrollOffset& v) const { - return Vector2dF(x_ - v.x(), y_ - v.y()); - } - - void operator+=(const ScrollOffset& other) { Add(other); } - void operator-=(const ScrollOffset& other) { Subtract(other); } - - void SetToMin(const ScrollOffset& other) { - x_ = x_ <= other.x_ ? x_ : other.x_; - y_ = y_ <= other.y_ ? y_ : other.y_; - } - - void SetToMax(const ScrollOffset& other) { - x_ = x_ >= other.x_ ? x_ : other.x_; - y_ = y_ >= other.y_ ? y_ : other.y_; - } - - void Scale(double scale) { Scale(scale, scale); } - void Scale(double x_scale, double y_scale) { - x_ *= x_scale; - y_ *= y_scale; - } - - std::string ToString() const; - - private: - double x_; - double y_; -}; - -inline bool operator==(const ScrollOffset& lhs, const ScrollOffset& rhs) { - return lhs.x() == rhs.x() && lhs.y() == rhs.y(); -} - -inline bool operator!=(const ScrollOffset& lhs, const ScrollOffset& rhs) { - return lhs.x() != rhs.x() || lhs.y() != rhs.y(); -} - -inline ScrollOffset operator-(const ScrollOffset& v) { - return ScrollOffset(-v.x(), -v.y()); -} - -inline ScrollOffset operator+(const ScrollOffset& lhs, - const ScrollOffset& rhs) { - ScrollOffset result = lhs; - result.Add(rhs); - return result; -} - -inline ScrollOffset operator-(const ScrollOffset& lhs, - const ScrollOffset& rhs) { - ScrollOffset result = lhs; - result.Add(-rhs); - return result; -} - -inline Vector2d ScrollOffsetToFlooredVector2d(const ScrollOffset& v) { - return Vector2d(ToFlooredInt(v.x()), ToFlooredInt(v.y())); -} - -inline Vector2dF ScrollOffsetToVector2dF(const ScrollOffset& v) { - return Vector2dF(v.x(), v.y()); -} - -inline ScrollOffset ScrollOffsetWithDelta(const ScrollOffset& offset, - const Vector2dF& delta) { - return ScrollOffset(offset.x() + delta.x(), - offset.y() + delta.y()); -} - -// This is declared here for use in gtest-based unit tests but is defined in -// the gfx_test_support target. Depend on that to use this in your unit test. -// This should not be used in production code - call ToString() instead. -void PrintTo(const ScrollOffset& scroll_offset, ::std::ostream* os); - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_SCROLL_OFFSET_H_ diff --git a/ui/gfx/geometry/scroll_offset_unittest.cc b/ui/gfx/geometry/scroll_offset_unittest.cc deleted file mode 100644 index 72073c143..000000000 --- a/ui/gfx/geometry/scroll_offset_unittest.cc +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2014 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 -#include - -#include "base/basictypes.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/gfx/geometry/scroll_offset.h" - -namespace gfx { - -TEST(ScrollOffsetTest, IsZero) { - ScrollOffset zero(0, 0); - ScrollOffset nonzero(0.1, -0.1); - - EXPECT_TRUE(zero.IsZero()); - EXPECT_FALSE(nonzero.IsZero()); -} - -TEST(ScrollOffsetTest, Add) { - ScrollOffset f1(3.1, 5.1); - ScrollOffset f2(4.3, -1.3); - - const struct { - ScrollOffset expected; - ScrollOffset actual; - } scroll_offset_tests[] = { - { ScrollOffset(3.1, 5.1), f1 + ScrollOffset() }, - { ScrollOffset(3.1 + 4.3, 5.1f - 1.3), f1 + f2 }, - { ScrollOffset(3.1 - 4.3, 5.1f + 1.3), f1 - f2 } - }; - - for (size_t i = 0; i < arraysize(scroll_offset_tests); ++i) - EXPECT_EQ(scroll_offset_tests[i].expected.ToString(), - scroll_offset_tests[i].actual.ToString()); -} - -TEST(ScrollOffsetTest, Negative) { - const struct { - ScrollOffset expected; - ScrollOffset actual; - } scroll_offset_tests[] = { - { ScrollOffset(-0.3, -0.3), -ScrollOffset(0.3, 0.3) }, - { ScrollOffset(0.3, 0.3), -ScrollOffset(-0.3, -0.3) }, - { ScrollOffset(-0.3, 0.3), -ScrollOffset(0.3, -0.3) }, - { ScrollOffset(0.3, -0.3), -ScrollOffset(-0.3, 0.3) } - }; - - for (size_t i = 0; i < arraysize(scroll_offset_tests); ++i) - EXPECT_EQ(scroll_offset_tests[i].expected.ToString(), - scroll_offset_tests[i].actual.ToString()); -} - -TEST(ScrollOffsetTest, Scale) { - double double_values[][4] = { - { 4.5, 1.2, 3.3, 5.6 }, - { 4.5, -1.2, 3.3, 5.6 }, - { 4.5, 1.2, 3.3, -5.6 }, - { 4.5, 1.2, -3.3, -5.6 }, - { -4.5, 1.2, 3.3, 5.6 }, - { -4.5, 1.2, 0, 5.6 }, - { -4.5, 1.2, 3.3, 0 }, - { 4.5, 0, 3.3, 5.6 }, - { 0, 1.2, 3.3, 5.6 } - }; - - for (size_t i = 0; i < arraysize(double_values); ++i) { - ScrollOffset v(double_values[i][0], double_values[i][1]); - v.Scale(double_values[i][2], double_values[i][3]); - EXPECT_EQ(v.x(), double_values[i][0] * double_values[i][2]); - EXPECT_EQ(v.y(), double_values[i][1] * double_values[i][3]); - } - - double single_values[][3] = { - { 4.5, 1.2, 3.3 }, - { 4.5, -1.2, 3.3 }, - { 4.5, 1.2, 3.3 }, - { 4.5, 1.2, -3.3 }, - { -4.5, 1.2, 3.3 }, - { -4.5, 1.2, 0 }, - { -4.5, 1.2, 3.3 }, - { 4.5, 0, 3.3 }, - { 0, 1.2, 3.3 } - }; - - for (size_t i = 0; i < arraysize(single_values); ++i) { - ScrollOffset v(single_values[i][0], single_values[i][1]); - v.Scale(single_values[i][2]); - EXPECT_EQ(v.x(), single_values[i][0] * single_values[i][2]); - EXPECT_EQ(v.y(), single_values[i][1] * single_values[i][2]); - } -} - -TEST(ScrollOffsetTest, ClampScrollOffset) { - ScrollOffset a; - - a = ScrollOffset(3.5, 5.5); - EXPECT_EQ(ScrollOffset(3.5, 5.5).ToString(), a.ToString()); - a.SetToMax(ScrollOffset(2.5, 4.5)); - EXPECT_EQ(ScrollOffset(3.5, 5.5).ToString(), a.ToString()); - a.SetToMax(ScrollOffset(3.5, 5.5)); - EXPECT_EQ(ScrollOffset(3.5, 5.5).ToString(), a.ToString()); - a.SetToMax(ScrollOffset(4.5, 2.5)); - EXPECT_EQ(ScrollOffset(4.5, 5.5).ToString(), a.ToString()); - a.SetToMax(ScrollOffset(8.5, 10.5)); - EXPECT_EQ(ScrollOffset(8.5, 10.5).ToString(), a.ToString()); - - a.SetToMin(ScrollOffset(9.5, 11.5)); - EXPECT_EQ(ScrollOffset(8.5, 10.5).ToString(), a.ToString()); - a.SetToMin(ScrollOffset(8.5, 10.5)); - EXPECT_EQ(ScrollOffset(8.5, 10.5).ToString(), a.ToString()); - a.SetToMin(ScrollOffset(11.5, 9.5)); - EXPECT_EQ(ScrollOffset(8.5, 9.5).ToString(), a.ToString()); - a.SetToMin(ScrollOffset(7.5, 11.5)); - EXPECT_EQ(ScrollOffset(7.5, 9.5).ToString(), a.ToString()); - a.SetToMin(ScrollOffset(3.5, 5.5)); - EXPECT_EQ(ScrollOffset(3.5, 5.5).ToString(), a.ToString()); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/size.cc b/ui/gfx/geometry/size.cc deleted file mode 100644 index fc49a56cf..000000000 --- a/ui/gfx/geometry/size.cc +++ /dev/null @@ -1,33 +0,0 @@ -// 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 "ui/gfx/geometry/size.h" - -#include "base/strings/stringprintf.h" - -namespace gfx { - -int Size::GetArea() const { - return width() * height(); -} - -void Size::Enlarge(int grow_width, int grow_height) { - SetSize(width() + grow_width, height() + grow_height); -} - -void Size::SetToMin(const Size& other) { - width_ = width() <= other.width() ? width() : other.width(); - height_ = height() <= other.height() ? height() : other.height(); -} - -void Size::SetToMax(const Size& other) { - width_ = width() >= other.width() ? width() : other.width(); - height_ = height() >= other.height() ? height() : other.height(); -} - -std::string Size::ToString() const { - return base::StringPrintf("%dx%d", width(), height()); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/size.h b/ui/gfx/geometry/size.h deleted file mode 100644 index cc5d6aa45..000000000 --- a/ui/gfx/geometry/size.h +++ /dev/null @@ -1,71 +0,0 @@ -// 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 UI_GFX_GEOMETRY_SIZE_H_ -#define UI_GFX_GEOMETRY_SIZE_H_ - -#include -#include - -#include "base/compiler_specific.h" -#include "ui/gfx/geometry/size_f.h" -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -// A size has width and height values. -class GFX_EXPORT Size { - public: - Size() : width_(0), height_(0) {} - Size(int width, int height) - : width_(width < 0 ? 0 : width), height_(height < 0 ? 0 : height) {} - ~Size() {} - - int width() const { return width_; } - int height() const { return height_; } - - void set_width(int width) { width_ = width < 0 ? 0 : width; } - void set_height(int height) { height_ = height < 0 ? 0 : height; } - - int GetArea() const; - - void SetSize(int width, int height) { - set_width(width); - set_height(height); - } - - void Enlarge(int grow_width, int grow_height); - - void SetToMin(const Size& other); - void SetToMax(const Size& other); - - bool IsEmpty() const { return !width() || !height(); } - - operator SizeF() const { - return SizeF(width(), height()); - } - - std::string ToString() const; - - private: - int width_; - int height_; -}; - -inline bool operator==(const Size& lhs, const Size& rhs) { - return lhs.width() == rhs.width() && lhs.height() == rhs.height(); -} - -inline bool operator!=(const Size& lhs, const Size& rhs) { - return !(lhs == rhs); -} - -// This is declared here for use in gtest-based unit tests but is defined in -// the gfx_test_support target. Depend on that to use this in your unit test. -// This should not be used in production code - call ToString() instead. -void PrintTo(const Size& size, ::std::ostream* os); - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_SIZE_H_ diff --git a/ui/gfx/geometry/size_conversions.cc b/ui/gfx/geometry/size_conversions.cc deleted file mode 100644 index c924e86c9..000000000 --- a/ui/gfx/geometry/size_conversions.cc +++ /dev/null @@ -1,30 +0,0 @@ -// 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 "ui/gfx/geometry/size_conversions.h" - -#include "ui/gfx/geometry/safe_integer_conversions.h" - -namespace gfx { - -Size ToFlooredSize(const SizeF& size) { - int w = ToFlooredInt(size.width()); - int h = ToFlooredInt(size.height()); - return Size(w, h); -} - -Size ToCeiledSize(const SizeF& size) { - int w = ToCeiledInt(size.width()); - int h = ToCeiledInt(size.height()); - return Size(w, h); -} - -Size ToRoundedSize(const SizeF& size) { - int w = ToRoundedInt(size.width()); - int h = ToRoundedInt(size.height()); - return Size(w, h); -} - -} // namespace gfx - diff --git a/ui/gfx/geometry/size_conversions.h b/ui/gfx/geometry/size_conversions.h deleted file mode 100644 index 96fb79f93..000000000 --- a/ui/gfx/geometry/size_conversions.h +++ /dev/null @@ -1,24 +0,0 @@ -// 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 UI_GFX_GEOMETRY_SIZE_CONVERSIONS_H_ -#define UI_GFX_GEOMETRY_SIZE_CONVERSIONS_H_ - -#include "ui/gfx/geometry/size.h" -#include "ui/gfx/geometry/size_f.h" - -namespace gfx { - -// Returns a Size with each component from the input SizeF floored. -GFX_EXPORT Size ToFlooredSize(const SizeF& size); - -// Returns a Size with each component from the input SizeF ceiled. -GFX_EXPORT Size ToCeiledSize(const SizeF& size); - -// Returns a Size with each component from the input SizeF rounded. -GFX_EXPORT Size ToRoundedSize(const SizeF& size); - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_SIZE_CONVERSIONS_H_ diff --git a/ui/gfx/geometry/size_f.cc b/ui/gfx/geometry/size_f.cc deleted file mode 100644 index 6d08e18c6..000000000 --- a/ui/gfx/geometry/size_f.cc +++ /dev/null @@ -1,39 +0,0 @@ -// 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 "ui/gfx/geometry/size_f.h" - -#include "base/strings/stringprintf.h" - -namespace gfx { - -float SizeF::GetArea() const { - return width() * height(); -} - -void SizeF::Enlarge(float grow_width, float grow_height) { - SetSize(width() + grow_width, height() + grow_height); -} - -void SizeF::SetToMin(const SizeF& other) { - width_ = width() <= other.width() ? width() : other.width(); - height_ = height() <= other.height() ? height() : other.height(); -} - -void SizeF::SetToMax(const SizeF& other) { - width_ = width() >= other.width() ? width() : other.width(); - height_ = height() >= other.height() ? height() : other.height(); -} - -std::string SizeF::ToString() const { - return base::StringPrintf("%fx%f", width(), height()); -} - -SizeF ScaleSize(const SizeF& s, float x_scale, float y_scale) { - SizeF scaled_s(s); - scaled_s.Scale(x_scale, y_scale); - return scaled_s; -} - -} // namespace gfx diff --git a/ui/gfx/geometry/size_f.h b/ui/gfx/geometry/size_f.h deleted file mode 100644 index 66080f09c..000000000 --- a/ui/gfx/geometry/size_f.h +++ /dev/null @@ -1,81 +0,0 @@ -// 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 UI_GFX_GEOMETRY_SIZE_F_H_ -#define UI_GFX_GEOMETRY_SIZE_F_H_ - -#include -#include -#include - -#include "base/compiler_specific.h" -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -// A floating version of gfx::Size. -class GFX_EXPORT SizeF { - public: - SizeF() : width_(0.f), height_(0.f) {} - SizeF(float width, float height) - : width_(fmaxf(0, width)), height_(fmaxf(0, height)) {} - ~SizeF() {} - - float width() const { return width_; } - float height() const { return height_; } - - void set_width(float width) { width_ = fmaxf(0, width); } - void set_height(float height) { height_ = fmaxf(0, height); } - - float GetArea() const; - - void SetSize(float width, float height) { - set_width(width); - set_height(height); - } - - void Enlarge(float grow_width, float grow_height); - - void SetToMin(const SizeF& other); - void SetToMax(const SizeF& other); - - bool IsEmpty() const { return !width() || !height(); } - - void Scale(float scale) { - Scale(scale, scale); - } - - void Scale(float x_scale, float y_scale) { - SetSize(width() * x_scale, height() * y_scale); - } - - std::string ToString() const; - - private: - float width_; - float height_; -}; - -inline bool operator==(const SizeF& lhs, const SizeF& rhs) { - return lhs.width() == rhs.width() && lhs.height() == rhs.height(); -} - -inline bool operator!=(const SizeF& lhs, const SizeF& rhs) { - return !(lhs == rhs); -} - -GFX_EXPORT SizeF ScaleSize(const SizeF& p, float x_scale, float y_scale); - -inline SizeF ScaleSize(const SizeF& p, float scale) { - return ScaleSize(p, scale, scale); -} - -// This is declared here for use in gtest-based unit tests but is defined in -// the gfx_test_support target. Depend on that to use this in your unit test. -// This should not be used in production code - call ToString() instead. -void PrintTo(const SizeF& size, ::std::ostream* os); - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_SIZE_F_H_ diff --git a/ui/gfx/geometry/size_unittest.cc b/ui/gfx/geometry/size_unittest.cc deleted file mode 100644 index 87a487c7a..000000000 --- a/ui/gfx/geometry/size_unittest.cc +++ /dev/null @@ -1,126 +0,0 @@ -// 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 "testing/gtest/include/gtest/gtest.h" -#include "ui/gfx/geometry/size.h" -#include "ui/gfx/geometry/size_conversions.h" -#include "ui/gfx/geometry/size_f.h" - -namespace gfx { - -namespace { - -int TestSizeF(const SizeF& s) { - return s.width(); -} - -} // namespace - -TEST(SizeTest, ToSizeF) { - // Check that implicit conversion from integer to float compiles. - Size a(10, 20); - float width = TestSizeF(a); - EXPECT_EQ(width, a.width()); - - SizeF b(10, 20); - - EXPECT_EQ(a, b); - EXPECT_EQ(b, a); -} - -TEST(SizeTest, ToFlooredSize) { - EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0, 0))); - EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0.0001f, 0.0001f))); - EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0.4999f, 0.4999f))); - EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0.5f, 0.5f))); - EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0.9999f, 0.9999f))); - - EXPECT_EQ(Size(10, 10), ToFlooredSize(SizeF(10, 10))); - EXPECT_EQ(Size(10, 10), ToFlooredSize(SizeF(10.0001f, 10.0001f))); - EXPECT_EQ(Size(10, 10), ToFlooredSize(SizeF(10.4999f, 10.4999f))); - EXPECT_EQ(Size(10, 10), ToFlooredSize(SizeF(10.5f, 10.5f))); - EXPECT_EQ(Size(10, 10), ToFlooredSize(SizeF(10.9999f, 10.9999f))); -} - -TEST(SizeTest, ToCeiledSize) { - EXPECT_EQ(Size(0, 0), ToCeiledSize(SizeF(0, 0))); - EXPECT_EQ(Size(1, 1), ToCeiledSize(SizeF(0.0001f, 0.0001f))); - EXPECT_EQ(Size(1, 1), ToCeiledSize(SizeF(0.4999f, 0.4999f))); - EXPECT_EQ(Size(1, 1), ToCeiledSize(SizeF(0.5f, 0.5f))); - EXPECT_EQ(Size(1, 1), ToCeiledSize(SizeF(0.9999f, 0.9999f))); - - EXPECT_EQ(Size(10, 10), ToCeiledSize(SizeF(10, 10))); - EXPECT_EQ(Size(11, 11), ToCeiledSize(SizeF(10.0001f, 10.0001f))); - EXPECT_EQ(Size(11, 11), ToCeiledSize(SizeF(10.4999f, 10.4999f))); - EXPECT_EQ(Size(11, 11), ToCeiledSize(SizeF(10.5f, 10.5f))); - EXPECT_EQ(Size(11, 11), ToCeiledSize(SizeF(10.9999f, 10.9999f))); -} - -TEST(SizeTest, ToRoundedSize) { - EXPECT_EQ(Size(0, 0), ToRoundedSize(SizeF(0, 0))); - EXPECT_EQ(Size(0, 0), ToRoundedSize(SizeF(0.0001f, 0.0001f))); - EXPECT_EQ(Size(0, 0), ToRoundedSize(SizeF(0.4999f, 0.4999f))); - EXPECT_EQ(Size(1, 1), ToRoundedSize(SizeF(0.5f, 0.5f))); - EXPECT_EQ(Size(1, 1), ToRoundedSize(SizeF(0.9999f, 0.9999f))); - - EXPECT_EQ(Size(10, 10), ToRoundedSize(SizeF(10, 10))); - EXPECT_EQ(Size(10, 10), ToRoundedSize(SizeF(10.0001f, 10.0001f))); - EXPECT_EQ(Size(10, 10), ToRoundedSize(SizeF(10.4999f, 10.4999f))); - EXPECT_EQ(Size(11, 11), ToRoundedSize(SizeF(10.5f, 10.5f))); - EXPECT_EQ(Size(11, 11), ToRoundedSize(SizeF(10.9999f, 10.9999f))); -} - -TEST(SizeTest, ClampSize) { - Size a; - - a = Size(3, 5); - EXPECT_EQ(Size(3, 5).ToString(), a.ToString()); - a.SetToMax(Size(2, 4)); - EXPECT_EQ(Size(3, 5).ToString(), a.ToString()); - a.SetToMax(Size(3, 5)); - EXPECT_EQ(Size(3, 5).ToString(), a.ToString()); - a.SetToMax(Size(4, 2)); - EXPECT_EQ(Size(4, 5).ToString(), a.ToString()); - a.SetToMax(Size(8, 10)); - EXPECT_EQ(Size(8, 10).ToString(), a.ToString()); - - a.SetToMin(Size(9, 11)); - EXPECT_EQ(Size(8, 10).ToString(), a.ToString()); - a.SetToMin(Size(8, 10)); - EXPECT_EQ(Size(8, 10).ToString(), a.ToString()); - a.SetToMin(Size(11, 9)); - EXPECT_EQ(Size(8, 9).ToString(), a.ToString()); - a.SetToMin(Size(7, 11)); - EXPECT_EQ(Size(7, 9).ToString(), a.ToString()); - a.SetToMin(Size(3, 5)); - EXPECT_EQ(Size(3, 5).ToString(), a.ToString()); -} - -TEST(SizeTest, ClampSizeF) { - SizeF a; - - a = SizeF(3.5f, 5.5f); - EXPECT_EQ(SizeF(3.5f, 5.5f).ToString(), a.ToString()); - a.SetToMax(SizeF(2.5f, 4.5f)); - EXPECT_EQ(SizeF(3.5f, 5.5f).ToString(), a.ToString()); - a.SetToMax(SizeF(3.5f, 5.5f)); - EXPECT_EQ(SizeF(3.5f, 5.5f).ToString(), a.ToString()); - a.SetToMax(SizeF(4.5f, 2.5f)); - EXPECT_EQ(SizeF(4.5f, 5.5f).ToString(), a.ToString()); - a.SetToMax(SizeF(8.5f, 10.5f)); - EXPECT_EQ(SizeF(8.5f, 10.5f).ToString(), a.ToString()); - - a.SetToMin(SizeF(9.5f, 11.5f)); - EXPECT_EQ(SizeF(8.5f, 10.5f).ToString(), a.ToString()); - a.SetToMin(SizeF(8.5f, 10.5f)); - EXPECT_EQ(SizeF(8.5f, 10.5f).ToString(), a.ToString()); - a.SetToMin(SizeF(11.5f, 9.5f)); - EXPECT_EQ(SizeF(8.5f, 9.5f).ToString(), a.ToString()); - a.SetToMin(SizeF(7.5f, 11.5f)); - EXPECT_EQ(SizeF(7.5f, 9.5f).ToString(), a.ToString()); - a.SetToMin(SizeF(3.5f, 5.5f)); - EXPECT_EQ(SizeF(3.5f, 5.5f).ToString(), a.ToString()); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/vector2d.cc b/ui/gfx/geometry/vector2d.cc deleted file mode 100644 index d9f57fd3b..000000000 --- a/ui/gfx/geometry/vector2d.cc +++ /dev/null @@ -1,39 +0,0 @@ -// 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 "ui/gfx/geometry/vector2d.h" - -#include - -#include "base/strings/stringprintf.h" - -namespace gfx { - -bool Vector2d::IsZero() const { - return x_ == 0 && y_ == 0; -} - -void Vector2d::Add(const Vector2d& other) { - x_ += other.x_; - y_ += other.y_; -} - -void Vector2d::Subtract(const Vector2d& other) { - x_ -= other.x_; - y_ -= other.y_; -} - -int64 Vector2d::LengthSquared() const { - return static_cast(x_) * x_ + static_cast(y_) * y_; -} - -float Vector2d::Length() const { - return static_cast(std::sqrt(static_cast(LengthSquared()))); -} - -std::string Vector2d::ToString() const { - return base::StringPrintf("[%d %d]", x_, y_); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/vector2d.h b/ui/gfx/geometry/vector2d.h deleted file mode 100644 index 4e404be1a..000000000 --- a/ui/gfx/geometry/vector2d.h +++ /dev/null @@ -1,97 +0,0 @@ -// 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. - -// Defines a simple integer vector class. This class is used to indicate a -// distance in two dimensions between two points. Subtracting two points should -// produce a vector, and adding a vector to a point produces the point at the -// vector's distance from the original point. - -#ifndef UI_GFX_GEOMETRY_VECTOR2D_H_ -#define UI_GFX_GEOMETRY_VECTOR2D_H_ - -#include -#include - -#include "base/basictypes.h" -#include "ui/gfx/geometry/vector2d_f.h" -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -class GFX_EXPORT Vector2d { - public: - Vector2d() : x_(0), y_(0) {} - Vector2d(int x, int y) : x_(x), y_(y) {} - - int x() const { return x_; } - void set_x(int x) { x_ = x; } - - int y() const { return y_; } - void set_y(int y) { y_ = y; } - - // True if both components of the vector are 0. - bool IsZero() const; - - // Add the components of the |other| vector to the current vector. - void Add(const Vector2d& other); - // Subtract the components of the |other| vector from the current vector. - void Subtract(const Vector2d& other); - - void operator+=(const Vector2d& other) { Add(other); } - void operator-=(const Vector2d& other) { Subtract(other); } - - void SetToMin(const Vector2d& other) { - x_ = x_ <= other.x_ ? x_ : other.x_; - y_ = y_ <= other.y_ ? y_ : other.y_; - } - - void SetToMax(const Vector2d& other) { - x_ = x_ >= other.x_ ? x_ : other.x_; - y_ = y_ >= other.y_ ? y_ : other.y_; - } - - // Gives the square of the diagonal length of the vector. Since this is - // cheaper to compute than Length(), it is useful when you want to compare - // relative lengths of different vectors without needing the actual lengths. - int64 LengthSquared() const; - // Gives the diagonal length of the vector. - float Length() const; - - std::string ToString() const; - - operator Vector2dF() const { return Vector2dF(x_, y_); } - - private: - int x_; - int y_; -}; - -inline bool operator==(const Vector2d& lhs, const Vector2d& rhs) { - return lhs.x() == rhs.x() && lhs.y() == rhs.y(); -} - -inline Vector2d operator-(const Vector2d& v) { - return Vector2d(-v.x(), -v.y()); -} - -inline Vector2d operator+(const Vector2d& lhs, const Vector2d& rhs) { - Vector2d result = lhs; - result.Add(rhs); - return result; -} - -inline Vector2d operator-(const Vector2d& lhs, const Vector2d& rhs) { - Vector2d result = lhs; - result.Add(-rhs); - return result; -} - -// This is declared here for use in gtest-based unit tests but is defined in -// the gfx_test_support target. Depend on that to use this in your unit test. -// This should not be used in production code - call ToString() instead. -void PrintTo(const Vector2d& vector, ::std::ostream* os); - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_VECTOR2D_H_ diff --git a/ui/gfx/geometry/vector2d_conversions.cc b/ui/gfx/geometry/vector2d_conversions.cc deleted file mode 100644 index dceb69e2f..000000000 --- a/ui/gfx/geometry/vector2d_conversions.cc +++ /dev/null @@ -1,30 +0,0 @@ -// 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 "ui/gfx/geometry/vector2d_conversions.h" - -#include "ui/gfx/geometry/safe_integer_conversions.h" - -namespace gfx { - -Vector2d ToFlooredVector2d(const Vector2dF& vector2d) { - int x = ToFlooredInt(vector2d.x()); - int y = ToFlooredInt(vector2d.y()); - return Vector2d(x, y); -} - -Vector2d ToCeiledVector2d(const Vector2dF& vector2d) { - int x = ToCeiledInt(vector2d.x()); - int y = ToCeiledInt(vector2d.y()); - return Vector2d(x, y); -} - -Vector2d ToRoundedVector2d(const Vector2dF& vector2d) { - int x = ToRoundedInt(vector2d.x()); - int y = ToRoundedInt(vector2d.y()); - return Vector2d(x, y); -} - -} // namespace gfx - diff --git a/ui/gfx/geometry/vector2d_conversions.h b/ui/gfx/geometry/vector2d_conversions.h deleted file mode 100644 index f4e16ae4b..000000000 --- a/ui/gfx/geometry/vector2d_conversions.h +++ /dev/null @@ -1,24 +0,0 @@ -// 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 UI_GFX_GEOMETRY_VECTOR2D_CONVERSIONS_H_ -#define UI_GFX_GEOMETRY_VECTOR2D_CONVERSIONS_H_ - -#include "ui/gfx/geometry/vector2d.h" -#include "ui/gfx/geometry/vector2d_f.h" - -namespace gfx { - -// Returns a Vector2d with each component from the input Vector2dF floored. -GFX_EXPORT Vector2d ToFlooredVector2d(const Vector2dF& vector2d); - -// Returns a Vector2d with each component from the input Vector2dF ceiled. -GFX_EXPORT Vector2d ToCeiledVector2d(const Vector2dF& vector2d); - -// Returns a Vector2d with each component from the input Vector2dF rounded. -GFX_EXPORT Vector2d ToRoundedVector2d(const Vector2dF& vector2d); - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_VECTOR2D_CONVERSIONS_H_ diff --git a/ui/gfx/geometry/vector2d_f.cc b/ui/gfx/geometry/vector2d_f.cc deleted file mode 100644 index ccb15ae0c..000000000 --- a/ui/gfx/geometry/vector2d_f.cc +++ /dev/null @@ -1,60 +0,0 @@ -// 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 "ui/gfx/geometry/vector2d_f.h" - -#include - -#include "base/strings/stringprintf.h" - -namespace gfx { - -std::string Vector2dF::ToString() const { - return base::StringPrintf("[%f %f]", x_, y_); -} - -bool Vector2dF::IsZero() const { - return x_ == 0 && y_ == 0; -} - -void Vector2dF::Add(const Vector2dF& other) { - x_ += other.x_; - y_ += other.y_; -} - -void Vector2dF::Subtract(const Vector2dF& other) { - x_ -= other.x_; - y_ -= other.y_; -} - -double Vector2dF::LengthSquared() const { - return static_cast(x_) * x_ + static_cast(y_) * y_; -} - -float Vector2dF::Length() const { - return static_cast(std::sqrt(LengthSquared())); -} - -void Vector2dF::Scale(float x_scale, float y_scale) { - x_ *= x_scale; - y_ *= y_scale; -} - -double CrossProduct(const Vector2dF& lhs, const Vector2dF& rhs) { - return static_cast(lhs.x()) * rhs.y() - - static_cast(lhs.y()) * rhs.x(); -} - -double DotProduct(const Vector2dF& lhs, const Vector2dF& rhs) { - return static_cast(lhs.x()) * rhs.x() + - static_cast(lhs.y()) * rhs.y(); -} - -Vector2dF ScaleVector2d(const Vector2dF& v, float x_scale, float y_scale) { - Vector2dF scaled_v(v); - scaled_v.Scale(x_scale, y_scale); - return scaled_v; -} - -} // namespace gfx diff --git a/ui/gfx/geometry/vector2d_f.h b/ui/gfx/geometry/vector2d_f.h deleted file mode 100644 index 593e7b82b..000000000 --- a/ui/gfx/geometry/vector2d_f.h +++ /dev/null @@ -1,118 +0,0 @@ -// 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. - -// Defines a simple float vector class. This class is used to indicate a -// distance in two dimensions between two points. Subtracting two points should -// produce a vector, and adding a vector to a point produces the point at the -// vector's distance from the original point. - -#ifndef UI_GFX_GEOMETRY_VECTOR2D_F_H_ -#define UI_GFX_GEOMETRY_VECTOR2D_F_H_ - -#include -#include - -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -class GFX_EXPORT Vector2dF { - public: - Vector2dF() : x_(0), y_(0) {} - Vector2dF(float x, float y) : x_(x), y_(y) {} - - float x() const { return x_; } - void set_x(float x) { x_ = x; } - - float y() const { return y_; } - void set_y(float y) { y_ = y; } - - // True if both components of the vector are 0. - bool IsZero() const; - - // Add the components of the |other| vector to the current vector. - void Add(const Vector2dF& other); - // Subtract the components of the |other| vector from the current vector. - void Subtract(const Vector2dF& other); - - void operator+=(const Vector2dF& other) { Add(other); } - void operator-=(const Vector2dF& other) { Subtract(other); } - - void SetToMin(const Vector2dF& other) { - x_ = x_ <= other.x_ ? x_ : other.x_; - y_ = y_ <= other.y_ ? y_ : other.y_; - } - - void SetToMax(const Vector2dF& other) { - x_ = x_ >= other.x_ ? x_ : other.x_; - y_ = y_ >= other.y_ ? y_ : other.y_; - } - - // Gives the square of the diagonal length of the vector. - double LengthSquared() const; - // Gives the diagonal length of the vector. - float Length() const; - - // Scale the x and y components of the vector by |scale|. - void Scale(float scale) { Scale(scale, scale); } - // Scale the x and y components of the vector by |x_scale| and |y_scale| - // respectively. - void Scale(float x_scale, float y_scale); - - std::string ToString() const; - - private: - float x_; - float y_; -}; - -inline bool operator==(const Vector2dF& lhs, const Vector2dF& rhs) { - return lhs.x() == rhs.x() && lhs.y() == rhs.y(); -} - -inline bool operator!=(const Vector2dF& lhs, const Vector2dF& rhs) { - return !(lhs == rhs); -} - -inline Vector2dF operator-(const Vector2dF& v) { - return Vector2dF(-v.x(), -v.y()); -} - -inline Vector2dF operator+(const Vector2dF& lhs, const Vector2dF& rhs) { - Vector2dF result = lhs; - result.Add(rhs); - return result; -} - -inline Vector2dF operator-(const Vector2dF& lhs, const Vector2dF& rhs) { - Vector2dF result = lhs; - result.Add(-rhs); - return result; -} - -// Return the cross product of two vectors. -GFX_EXPORT double CrossProduct(const Vector2dF& lhs, const Vector2dF& rhs); - -// Return the dot product of two vectors. -GFX_EXPORT double DotProduct(const Vector2dF& lhs, const Vector2dF& rhs); - -// Return a vector that is |v| scaled by the given scale factors along each -// axis. -GFX_EXPORT Vector2dF ScaleVector2d(const Vector2dF& v, - float x_scale, - float y_scale); - -// Return a vector that is |v| scaled by the given scale factor. -inline Vector2dF ScaleVector2d(const Vector2dF& v, float scale) { - return ScaleVector2d(v, scale, scale); -} - -// This is declared here for use in gtest-based unit tests but is defined in -// the gfx_test_support target. Depend on that to use this in your unit test. -// This should not be used in production code - call ToString() instead. -void PrintTo(const Vector2dF& vector, ::std::ostream* os); - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_VECTOR2D_F_H_ diff --git a/ui/gfx/geometry/vector2d_unittest.cc b/ui/gfx/geometry/vector2d_unittest.cc deleted file mode 100644 index b87609fe2..000000000 --- a/ui/gfx/geometry/vector2d_unittest.cc +++ /dev/null @@ -1,250 +0,0 @@ -// 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 -#include - -#include "base/basictypes.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/gfx/geometry/vector2d.h" -#include "ui/gfx/geometry/vector2d_f.h" - -namespace gfx { - -TEST(Vector2dTest, ConversionToFloat) { - Vector2d i(3, 4); - Vector2dF f = i; - EXPECT_EQ(i, f); -} - -TEST(Vector2dTest, IsZero) { - Vector2d int_zero(0, 0); - Vector2d int_nonzero(2, -2); - Vector2dF float_zero(0, 0); - Vector2dF float_nonzero(0.1f, -0.1f); - - EXPECT_TRUE(int_zero.IsZero()); - EXPECT_FALSE(int_nonzero.IsZero()); - EXPECT_TRUE(float_zero.IsZero()); - EXPECT_FALSE(float_nonzero.IsZero()); -} - -TEST(Vector2dTest, Add) { - Vector2d i1(3, 5); - Vector2d i2(4, -1); - - const struct { - Vector2d expected; - Vector2d actual; - } int_tests[] = { - { Vector2d(3, 5), i1 + Vector2d() }, - { Vector2d(3 + 4, 5 - 1), i1 + i2 }, - { Vector2d(3 - 4, 5 + 1), i1 - i2 } - }; - - for (size_t i = 0; i < arraysize(int_tests); ++i) - EXPECT_EQ(int_tests[i].expected.ToString(), - int_tests[i].actual.ToString()); - - Vector2dF f1(3.1f, 5.1f); - Vector2dF f2(4.3f, -1.3f); - - const struct { - Vector2dF expected; - Vector2dF actual; - } float_tests[] = { - { Vector2dF(3.1F, 5.1F), f1 + Vector2d() }, - { Vector2dF(3.1F, 5.1F), f1 + Vector2dF() }, - { Vector2dF(3.1f + 4.3f, 5.1f - 1.3f), f1 + f2 }, - { Vector2dF(3.1f - 4.3f, 5.1f + 1.3f), f1 - f2 } - }; - - for (size_t i = 0; i < arraysize(float_tests); ++i) - EXPECT_EQ(float_tests[i].expected.ToString(), - float_tests[i].actual.ToString()); -} - -TEST(Vector2dTest, Negative) { - const struct { - Vector2d expected; - Vector2d actual; - } int_tests[] = { - { Vector2d(0, 0), -Vector2d(0, 0) }, - { Vector2d(-3, -3), -Vector2d(3, 3) }, - { Vector2d(3, 3), -Vector2d(-3, -3) }, - { Vector2d(-3, 3), -Vector2d(3, -3) }, - { Vector2d(3, -3), -Vector2d(-3, 3) } - }; - - for (size_t i = 0; i < arraysize(int_tests); ++i) - EXPECT_EQ(int_tests[i].expected.ToString(), - int_tests[i].actual.ToString()); - - const struct { - Vector2dF expected; - Vector2dF actual; - } float_tests[] = { - { Vector2dF(0, 0), -Vector2d(0, 0) }, - { Vector2dF(-0.3f, -0.3f), -Vector2dF(0.3f, 0.3f) }, - { Vector2dF(0.3f, 0.3f), -Vector2dF(-0.3f, -0.3f) }, - { Vector2dF(-0.3f, 0.3f), -Vector2dF(0.3f, -0.3f) }, - { Vector2dF(0.3f, -0.3f), -Vector2dF(-0.3f, 0.3f) } - }; - - for (size_t i = 0; i < arraysize(float_tests); ++i) - EXPECT_EQ(float_tests[i].expected.ToString(), - float_tests[i].actual.ToString()); -} - -TEST(Vector2dTest, Scale) { - float double_values[][4] = { - { 4.5f, 1.2f, 3.3f, 5.6f }, - { 4.5f, -1.2f, 3.3f, 5.6f }, - { 4.5f, 1.2f, 3.3f, -5.6f }, - { 4.5f, 1.2f, -3.3f, -5.6f }, - { -4.5f, 1.2f, 3.3f, 5.6f }, - { -4.5f, 1.2f, 0, 5.6f }, - { -4.5f, 1.2f, 3.3f, 0 }, - { 4.5f, 0, 3.3f, 5.6f }, - { 0, 1.2f, 3.3f, 5.6f } - }; - - for (size_t i = 0; i < arraysize(double_values); ++i) { - Vector2dF v(double_values[i][0], double_values[i][1]); - v.Scale(double_values[i][2], double_values[i][3]); - EXPECT_EQ(v.x(), double_values[i][0] * double_values[i][2]); - EXPECT_EQ(v.y(), double_values[i][1] * double_values[i][3]); - - Vector2dF v2 = ScaleVector2d( - gfx::Vector2dF(double_values[i][0], double_values[i][1]), - double_values[i][2], double_values[i][3]); - EXPECT_EQ(double_values[i][0] * double_values[i][2], v2.x()); - EXPECT_EQ(double_values[i][1] * double_values[i][3], v2.y()); - } - - float single_values[][3] = { - { 4.5f, 1.2f, 3.3f }, - { 4.5f, -1.2f, 3.3f }, - { 4.5f, 1.2f, 3.3f }, - { 4.5f, 1.2f, -3.3f }, - { -4.5f, 1.2f, 3.3f }, - { -4.5f, 1.2f, 0 }, - { -4.5f, 1.2f, 3.3f }, - { 4.5f, 0, 3.3f }, - { 0, 1.2f, 3.3f } - }; - - for (size_t i = 0; i < arraysize(single_values); ++i) { - Vector2dF v(single_values[i][0], single_values[i][1]); - v.Scale(single_values[i][2]); - EXPECT_EQ(v.x(), single_values[i][0] * single_values[i][2]); - EXPECT_EQ(v.y(), single_values[i][1] * single_values[i][2]); - - Vector2dF v2 = ScaleVector2d( - gfx::Vector2dF(double_values[i][0], double_values[i][1]), - double_values[i][2]); - EXPECT_EQ(single_values[i][0] * single_values[i][2], v2.x()); - EXPECT_EQ(single_values[i][1] * single_values[i][2], v2.y()); - } -} - -TEST(Vector2dTest, Length) { - int int_values[][2] = { - { 0, 0 }, - { 10, 20 }, - { 20, 10 }, - { -10, -20 }, - { -20, 10 }, - { 10, -20 }, - }; - - for (size_t i = 0; i < arraysize(int_values); ++i) { - int v0 = int_values[i][0]; - int v1 = int_values[i][1]; - double length_squared = - static_cast(v0) * v0 + static_cast(v1) * v1; - double length = std::sqrt(length_squared); - Vector2d vector(v0, v1); - EXPECT_EQ(static_cast(length_squared), vector.LengthSquared()); - EXPECT_EQ(static_cast(length), vector.Length()); - } - - float float_values[][2] = { - { 0, 0 }, - { 10.5f, 20.5f }, - { 20.5f, 10.5f }, - { -10.5f, -20.5f }, - { -20.5f, 10.5f }, - { 10.5f, -20.5f }, - // A large vector that fails if the Length function doesn't use - // double precision internally. - { 1236278317862780234892374893213178027.12122348904204230f, - 335890352589839028212313231225425134332.38123f }, - }; - - for (size_t i = 0; i < arraysize(float_values); ++i) { - double v0 = float_values[i][0]; - double v1 = float_values[i][1]; - double length_squared = - static_cast(v0) * v0 + static_cast(v1) * v1; - double length = std::sqrt(length_squared); - Vector2dF vector(v0, v1); - EXPECT_DOUBLE_EQ(length_squared, vector.LengthSquared()); - EXPECT_FLOAT_EQ(static_cast(length), vector.Length()); - } -} - -TEST(Vector2dTest, ClampVector2d) { - Vector2d a; - - a = Vector2d(3, 5); - EXPECT_EQ(Vector2d(3, 5).ToString(), a.ToString()); - a.SetToMax(Vector2d(2, 4)); - EXPECT_EQ(Vector2d(3, 5).ToString(), a.ToString()); - a.SetToMax(Vector2d(3, 5)); - EXPECT_EQ(Vector2d(3, 5).ToString(), a.ToString()); - a.SetToMax(Vector2d(4, 2)); - EXPECT_EQ(Vector2d(4, 5).ToString(), a.ToString()); - a.SetToMax(Vector2d(8, 10)); - EXPECT_EQ(Vector2d(8, 10).ToString(), a.ToString()); - - a.SetToMin(Vector2d(9, 11)); - EXPECT_EQ(Vector2d(8, 10).ToString(), a.ToString()); - a.SetToMin(Vector2d(8, 10)); - EXPECT_EQ(Vector2d(8, 10).ToString(), a.ToString()); - a.SetToMin(Vector2d(11, 9)); - EXPECT_EQ(Vector2d(8, 9).ToString(), a.ToString()); - a.SetToMin(Vector2d(7, 11)); - EXPECT_EQ(Vector2d(7, 9).ToString(), a.ToString()); - a.SetToMin(Vector2d(3, 5)); - EXPECT_EQ(Vector2d(3, 5).ToString(), a.ToString()); -} - -TEST(Vector2dTest, ClampVector2dF) { - Vector2dF a; - - a = Vector2dF(3.5f, 5.5f); - EXPECT_EQ(Vector2dF(3.5f, 5.5f).ToString(), a.ToString()); - a.SetToMax(Vector2dF(2.5f, 4.5f)); - EXPECT_EQ(Vector2dF(3.5f, 5.5f).ToString(), a.ToString()); - a.SetToMax(Vector2dF(3.5f, 5.5f)); - EXPECT_EQ(Vector2dF(3.5f, 5.5f).ToString(), a.ToString()); - a.SetToMax(Vector2dF(4.5f, 2.5f)); - EXPECT_EQ(Vector2dF(4.5f, 5.5f).ToString(), a.ToString()); - a.SetToMax(Vector2dF(8.5f, 10.5f)); - EXPECT_EQ(Vector2dF(8.5f, 10.5f).ToString(), a.ToString()); - - a.SetToMin(Vector2dF(9.5f, 11.5f)); - EXPECT_EQ(Vector2dF(8.5f, 10.5f).ToString(), a.ToString()); - a.SetToMin(Vector2dF(8.5f, 10.5f)); - EXPECT_EQ(Vector2dF(8.5f, 10.5f).ToString(), a.ToString()); - a.SetToMin(Vector2dF(11.5f, 9.5f)); - EXPECT_EQ(Vector2dF(8.5f, 9.5f).ToString(), a.ToString()); - a.SetToMin(Vector2dF(7.5f, 11.5f)); - EXPECT_EQ(Vector2dF(7.5f, 9.5f).ToString(), a.ToString()); - a.SetToMin(Vector2dF(3.5f, 5.5f)); - EXPECT_EQ(Vector2dF(3.5f, 5.5f).ToString(), a.ToString()); -} - -} // namespace gfx diff --git a/ui/gfx/geometry/vector3d_f.cc b/ui/gfx/geometry/vector3d_f.cc deleted file mode 100644 index a30f9db5c..000000000 --- a/ui/gfx/geometry/vector3d_f.cc +++ /dev/null @@ -1,88 +0,0 @@ -// 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 "ui/gfx/geometry/vector3d_f.h" - -#include - -#include "base/strings/stringprintf.h" - -namespace gfx { - -Vector3dF::Vector3dF() - : x_(0), - y_(0), - z_(0) { -} - -Vector3dF::Vector3dF(float x, float y, float z) - : x_(x), - y_(y), - z_(z) { -} - -Vector3dF::Vector3dF(const Vector2dF& other) - : x_(other.x()), - y_(other.y()), - z_(0) { -} - -std::string Vector3dF::ToString() const { - return base::StringPrintf("[%f %f %f]", x_, y_, z_); -} - -bool Vector3dF::IsZero() const { - return x_ == 0 && y_ == 0 && z_ == 0; -} - -void Vector3dF::Add(const Vector3dF& other) { - x_ += other.x_; - y_ += other.y_; - z_ += other.z_; -} - -void Vector3dF::Subtract(const Vector3dF& other) { - x_ -= other.x_; - y_ -= other.y_; - z_ -= other.z_; -} - -double Vector3dF::LengthSquared() const { - return static_cast(x_) * x_ + static_cast(y_) * y_ + - static_cast(z_) * z_; -} - -float Vector3dF::Length() const { - return static_cast(std::sqrt(LengthSquared())); -} - -void Vector3dF::Scale(float x_scale, float y_scale, float z_scale) { - x_ *= x_scale; - y_ *= y_scale; - z_ *= z_scale; -} - -void Vector3dF::Cross(const Vector3dF& other) { - float x = y_ * other.z() - z_ * other.y(); - float y = z_ * other.x() - x_ * other.z(); - float z = x_ * other.y() - y_ * other.x(); - x_ = x; - y_ = y; - z_ = z; -} - -float DotProduct(const Vector3dF& lhs, const Vector3dF& rhs) { - return lhs.x() * rhs.x() + lhs.y() * rhs.y() + lhs.z() * rhs.z(); -} - -Vector3dF ScaleVector3d(const Vector3dF& v, - float x_scale, - float y_scale, - float z_scale) { - Vector3dF scaled_v(v); - scaled_v.Scale(x_scale, y_scale, z_scale); - return scaled_v; -} - -} // namespace gfx diff --git a/ui/gfx/geometry/vector3d_f.h b/ui/gfx/geometry/vector3d_f.h deleted file mode 100644 index 637b6d918..000000000 --- a/ui/gfx/geometry/vector3d_f.h +++ /dev/null @@ -1,130 +0,0 @@ -// 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. - -// Defines a simple float vector class. This class is used to indicate a -// distance in two dimensions between two points. Subtracting two points should -// produce a vector, and adding a vector to a point produces the point at the -// vector's distance from the original point. - -#ifndef UI_GFX_GEOMETRY_VECTOR3D_F_H_ -#define UI_GFX_GEOMETRY_VECTOR3D_F_H_ - -#include -#include - -#include "ui/gfx/geometry/vector2d_f.h" -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -class GFX_EXPORT Vector3dF { - public: - Vector3dF(); - Vector3dF(float x, float y, float z); - - explicit Vector3dF(const Vector2dF& other); - - float x() const { return x_; } - void set_x(float x) { x_ = x; } - - float y() const { return y_; } - void set_y(float y) { y_ = y; } - - float z() const { return z_; } - void set_z(float z) { z_ = z; } - - // True if all components of the vector are 0. - bool IsZero() const; - - // Add the components of the |other| vector to the current vector. - void Add(const Vector3dF& other); - // Subtract the components of the |other| vector from the current vector. - void Subtract(const Vector3dF& other); - - void operator+=(const Vector3dF& other) { Add(other); } - void operator-=(const Vector3dF& other) { Subtract(other); } - - void SetToMin(const Vector3dF& other) { - x_ = x_ <= other.x_ ? x_ : other.x_; - y_ = y_ <= other.y_ ? y_ : other.y_; - z_ = z_ <= other.z_ ? z_ : other.z_; - } - - void SetToMax(const Vector3dF& other) { - x_ = x_ >= other.x_ ? x_ : other.x_; - y_ = y_ >= other.y_ ? y_ : other.y_; - z_ = z_ >= other.z_ ? z_ : other.z_; - } - - // Gives the square of the diagonal length of the vector. - double LengthSquared() const; - // Gives the diagonal length of the vector. - float Length() const; - - // Scale all components of the vector by |scale|. - void Scale(float scale) { Scale(scale, scale, scale); } - // Scale the each component of the vector by the given scale factors. - void Scale(float x_scale, float y_scale, float z_scale); - - // Take the cross product of this vector with |other| and become the result. - void Cross(const Vector3dF& other); - - std::string ToString() const; - - private: - float x_; - float y_; - float z_; -}; - -inline bool operator==(const Vector3dF& lhs, const Vector3dF& rhs) { - return lhs.x() == rhs.x() && lhs.y() == rhs.y() && lhs.z() == rhs.z(); -} - -inline Vector3dF operator-(const Vector3dF& v) { - return Vector3dF(-v.x(), -v.y(), -v.z()); -} - -inline Vector3dF operator+(const Vector3dF& lhs, const Vector3dF& rhs) { - Vector3dF result = lhs; - result.Add(rhs); - return result; -} - -inline Vector3dF operator-(const Vector3dF& lhs, const Vector3dF& rhs) { - Vector3dF result = lhs; - result.Add(-rhs); - return result; -} - -// Return the cross product of two vectors. -inline Vector3dF CrossProduct(const Vector3dF& lhs, const Vector3dF& rhs) { - Vector3dF result = lhs; - result.Cross(rhs); - return result; -} - -// Return the dot product of two vectors. -GFX_EXPORT float DotProduct(const Vector3dF& lhs, const Vector3dF& rhs); - -// Return a vector that is |v| scaled by the given scale factors along each -// axis. -GFX_EXPORT Vector3dF ScaleVector3d(const Vector3dF& v, - float x_scale, - float y_scale, - float z_scale); - -// Return a vector that is |v| scaled by the given scale factor. -inline Vector3dF ScaleVector3d(const Vector3dF& v, float scale) { - return ScaleVector3d(v, scale, scale, scale); -} - -// This is declared here for use in gtest-based unit tests but is defined in -// the gfx_test_support target. Depend on that to use this in your unit test. -// This should not be used in production code - call ToString() instead. -void PrintTo(const Vector3dF& vector, ::std::ostream* os); - -} // namespace gfx - -#endif // UI_GFX_GEOMETRY_VECTOR3D_F_H_ diff --git a/ui/gfx/geometry/vector3d_unittest.cc b/ui/gfx/geometry/vector3d_unittest.cc deleted file mode 100644 index d058ad122..000000000 --- a/ui/gfx/geometry/vector3d_unittest.cc +++ /dev/null @@ -1,264 +0,0 @@ -// 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 -#include - -#include "base/basictypes.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/gfx/geometry/vector3d_f.h" - -namespace gfx { - -TEST(Vector3dTest, IsZero) { - gfx::Vector3dF float_zero(0, 0, 0); - gfx::Vector3dF float_nonzero(0.1f, -0.1f, 0.1f); - - EXPECT_TRUE(float_zero.IsZero()); - EXPECT_FALSE(float_nonzero.IsZero()); -} - -TEST(Vector3dTest, Add) { - gfx::Vector3dF f1(3.1f, 5.1f, 2.7f); - gfx::Vector3dF f2(4.3f, -1.3f, 8.1f); - - const struct { - gfx::Vector3dF expected; - gfx::Vector3dF actual; - } float_tests[] = { - { gfx::Vector3dF(3.1F, 5.1F, 2.7f), f1 + gfx::Vector3dF() }, - { gfx::Vector3dF(3.1f + 4.3f, 5.1f - 1.3f, 2.7f + 8.1f), f1 + f2 }, - { gfx::Vector3dF(3.1f - 4.3f, 5.1f + 1.3f, 2.7f - 8.1f), f1 - f2 } - }; - - for (size_t i = 0; i < arraysize(float_tests); ++i) - EXPECT_EQ(float_tests[i].expected.ToString(), - float_tests[i].actual.ToString()); -} - -TEST(Vector3dTest, Negative) { - const struct { - gfx::Vector3dF expected; - gfx::Vector3dF actual; - } float_tests[] = { - { gfx::Vector3dF(-0.0f, -0.0f, -0.0f), -gfx::Vector3dF(0, 0, 0) }, - { gfx::Vector3dF(-0.3f, -0.3f, -0.3f), -gfx::Vector3dF(0.3f, 0.3f, 0.3f) }, - { gfx::Vector3dF(0.3f, 0.3f, 0.3f), -gfx::Vector3dF(-0.3f, -0.3f, -0.3f) }, - { gfx::Vector3dF(-0.3f, 0.3f, -0.3f), -gfx::Vector3dF(0.3f, -0.3f, 0.3f) }, - { gfx::Vector3dF(0.3f, -0.3f, -0.3f), -gfx::Vector3dF(-0.3f, 0.3f, 0.3f) }, - { gfx::Vector3dF(-0.3f, -0.3f, 0.3f), -gfx::Vector3dF(0.3f, 0.3f, -0.3f) } - }; - - for (size_t i = 0; i < arraysize(float_tests); ++i) - EXPECT_EQ(float_tests[i].expected.ToString(), - float_tests[i].actual.ToString()); -} - -TEST(Vector3dTest, Scale) { - float triple_values[][6] = { - { 4.5f, 1.2f, 1.8f, 3.3f, 5.6f, 4.2f }, - { 4.5f, -1.2f, -1.8f, 3.3f, 5.6f, 4.2f }, - { 4.5f, 1.2f, -1.8f, 3.3f, 5.6f, 4.2f }, - { 4.5f, -1.2f -1.8f, 3.3f, 5.6f, 4.2f }, - - { 4.5f, 1.2f, 1.8f, 3.3f, -5.6f, -4.2f }, - { 4.5f, 1.2f, 1.8f, -3.3f, -5.6f, -4.2f }, - { 4.5f, 1.2f, -1.8f, 3.3f, -5.6f, -4.2f }, - { 4.5f, 1.2f, -1.8f, -3.3f, -5.6f, -4.2f }, - - { -4.5f, 1.2f, 1.8f, 3.3f, 5.6f, 4.2f }, - { -4.5f, 1.2f, 1.8f, 0, 5.6f, 4.2f }, - { -4.5f, 1.2f, -1.8f, 3.3f, 5.6f, 4.2f }, - { -4.5f, 1.2f, -1.8f, 0, 5.6f, 4.2f }, - - { -4.5f, 1.2f, 1.8f, 3.3f, 0, 4.2f }, - { 4.5f, 0, 1.8f, 3.3f, 5.6f, 4.2f }, - { -4.5f, 1.2f, -1.8f, 3.3f, 0, 4.2f }, - { 4.5f, 0, -1.8f, 3.3f, 5.6f, 4.2f }, - { -4.5f, 1.2f, 1.8f, 3.3f, 5.6f, 0 }, - { -4.5f, 1.2f, -1.8f, 3.3f, 5.6f, 0 }, - - { 0, 1.2f, 0, 3.3f, 5.6f, 4.2f }, - { 0, 1.2f, 1.8f, 3.3f, 5.6f, 4.2f } - }; - - for (size_t i = 0; i < arraysize(triple_values); ++i) { - gfx::Vector3dF v(triple_values[i][0], - triple_values[i][1], - triple_values[i][2]); - v.Scale(triple_values[i][3], triple_values[i][4], triple_values[i][5]); - EXPECT_EQ(triple_values[i][0] * triple_values[i][3], v.x()); - EXPECT_EQ(triple_values[i][1] * triple_values[i][4], v.y()); - EXPECT_EQ(triple_values[i][2] * triple_values[i][5], v.z()); - - Vector3dF v2 = ScaleVector3d( - gfx::Vector3dF(triple_values[i][0], - triple_values[i][1], - triple_values[i][2]), - triple_values[i][3], triple_values[i][4], triple_values[i][5]); - EXPECT_EQ(triple_values[i][0] * triple_values[i][3], v2.x()); - EXPECT_EQ(triple_values[i][1] * triple_values[i][4], v2.y()); - EXPECT_EQ(triple_values[i][2] * triple_values[i][5], v2.z()); - } - - float single_values[][4] = { - { 4.5f, 1.2f, 1.8f, 3.3f }, - { 4.5f, -1.2f, 1.8f, 3.3f }, - { 4.5f, 1.2f, -1.8f, 3.3f }, - { 4.5f, -1.2f, -1.8f, 3.3f }, - { -4.5f, 1.2f, 3.3f }, - { -4.5f, 1.2f, 0 }, - { -4.5f, 1.2f, 1.8f, 3.3f }, - { -4.5f, 1.2f, 1.8f, 0 }, - { 4.5f, 0, 1.8f, 3.3f }, - { 0, 1.2f, 1.8f, 3.3f }, - { 4.5f, 0, 1.8f, 3.3f }, - { 0, 1.2f, 1.8f, 3.3f }, - { 4.5f, 1.2f, 0, 3.3f }, - { 4.5f, 1.2f, 0, 3.3f } - }; - - for (size_t i = 0; i < arraysize(single_values); ++i) { - gfx::Vector3dF v(single_values[i][0], - single_values[i][1], - single_values[i][2]); - v.Scale(single_values[i][3]); - EXPECT_EQ(single_values[i][0] * single_values[i][3], v.x()); - EXPECT_EQ(single_values[i][1] * single_values[i][3], v.y()); - EXPECT_EQ(single_values[i][2] * single_values[i][3], v.z()); - - Vector3dF v2 = ScaleVector3d( - gfx::Vector3dF(single_values[i][0], - single_values[i][1], - single_values[i][2]), - single_values[i][3]); - EXPECT_EQ(single_values[i][0] * single_values[i][3], v2.x()); - EXPECT_EQ(single_values[i][1] * single_values[i][3], v2.y()); - EXPECT_EQ(single_values[i][2] * single_values[i][3], v2.z()); - } -} - -TEST(Vector3dTest, Length) { - float float_values[][3] = { - { 0, 0, 0 }, - { 10.5f, 20.5f, 8.5f }, - { 20.5f, 10.5f, 8.5f }, - { 8.5f, 20.5f, 10.5f }, - { 10.5f, 8.5f, 20.5f }, - { -10.5f, -20.5f, -8.5f }, - { -20.5f, 10.5f, -8.5f }, - { -8.5f, -20.5f, -10.5f }, - { -10.5f, -8.5f, -20.5f }, - { 10.5f, -20.5f, 8.5f }, - { -10.5f, 20.5f, 8.5f }, - { 10.5f, -20.5f, -8.5f }, - { -10.5f, 20.5f, -8.5f }, - // A large vector that fails if the Length function doesn't use - // double precision internally. - { 1236278317862780234892374893213178027.12122348904204230f, - 335890352589839028212313231225425134332.38123f, - 27861786423846742743236423478236784678.236713617231f } - }; - - for (size_t i = 0; i < arraysize(float_values); ++i) { - double v0 = float_values[i][0]; - double v1 = float_values[i][1]; - double v2 = float_values[i][2]; - double length_squared = - static_cast(v0) * v0 + - static_cast(v1) * v1 + - static_cast(v2) * v2; - double length = std::sqrt(length_squared); - gfx::Vector3dF vector(v0, v1, v2); - EXPECT_DOUBLE_EQ(length_squared, vector.LengthSquared()); - EXPECT_FLOAT_EQ(static_cast(length), vector.Length()); - } -} - -TEST(Vector3dTest, DotProduct) { - const struct { - float expected; - gfx::Vector3dF input1; - gfx::Vector3dF input2; - } tests[] = { - { 0, gfx::Vector3dF(1, 0, 0), gfx::Vector3dF(0, 1, 1) }, - { 0, gfx::Vector3dF(0, 1, 0), gfx::Vector3dF(1, 0, 1) }, - { 0, gfx::Vector3dF(0, 0, 1), gfx::Vector3dF(1, 1, 0) }, - - { 3, gfx::Vector3dF(1, 1, 1), gfx::Vector3dF(1, 1, 1) }, - - { 1.2f, gfx::Vector3dF(1.2f, -1.2f, 1.2f), gfx::Vector3dF(1, 1, 1) }, - { 1.2f, gfx::Vector3dF(1, 1, 1), gfx::Vector3dF(1.2f, -1.2f, 1.2f) }, - - { 38.72f, - gfx::Vector3dF(1.1f, 2.2f, 3.3f), gfx::Vector3dF(4.4f, 5.5f, 6.6f) } - }; - - for (size_t i = 0; i < arraysize(tests); ++i) { - float actual = gfx::DotProduct(tests[i].input1, tests[i].input2); - EXPECT_EQ(tests[i].expected, actual); - } -} - -TEST(Vector3dTest, CrossProduct) { - const struct { - gfx::Vector3dF expected; - gfx::Vector3dF input1; - gfx::Vector3dF input2; - } tests[] = { - { Vector3dF(), Vector3dF(), Vector3dF(1, 1, 1) }, - { Vector3dF(), Vector3dF(1, 1, 1), Vector3dF() }, - { Vector3dF(), Vector3dF(1, 1, 1), Vector3dF(1, 1, 1) }, - { Vector3dF(), - Vector3dF(1.6f, 10.6f, -10.6f), - Vector3dF(1.6f, 10.6f, -10.6f) }, - - { Vector3dF(1, -1, 0), Vector3dF(1, 1, 1), Vector3dF(0, 0, 1) }, - { Vector3dF(-1, 0, 1), Vector3dF(1, 1, 1), Vector3dF(0, 1, 0) }, - { Vector3dF(0, 1, -1), Vector3dF(1, 1, 1), Vector3dF(1, 0, 0) }, - - { Vector3dF(-1, 1, 0), Vector3dF(0, 0, 1), Vector3dF(1, 1, 1) }, - { Vector3dF(1, 0, -1), Vector3dF(0, 1, 0), Vector3dF(1, 1, 1) }, - { Vector3dF(0, -1, 1), Vector3dF(1, 0, 0), Vector3dF(1, 1, 1) } - }; - - for (size_t i = 0; i < arraysize(tests); ++i) { - Vector3dF actual = gfx::CrossProduct(tests[i].input1, tests[i].input2); - EXPECT_EQ(tests[i].expected.ToString(), actual.ToString()); - } -} - -TEST(Vector3dFTest, ClampVector3dF) { - Vector3dF a; - - a = Vector3dF(3.5f, 5.5f, 7.5f); - EXPECT_EQ(Vector3dF(3.5f, 5.5f, 7.5f).ToString(), a.ToString()); - a.SetToMax(Vector3dF(2, 4.5f, 6.5f)); - EXPECT_EQ(Vector3dF(3.5f, 5.5f, 7.5f).ToString(), a.ToString()); - a.SetToMax(Vector3dF(3.5f, 5.5f, 7.5f)); - EXPECT_EQ(Vector3dF(3.5f, 5.5f, 7.5f).ToString(), a.ToString()); - a.SetToMax(Vector3dF(4.5f, 2, 6.5f)); - EXPECT_EQ(Vector3dF(4.5f, 5.5f, 7.5f).ToString(), a.ToString()); - a.SetToMax(Vector3dF(3.5f, 6.5f, 6.5f)); - EXPECT_EQ(Vector3dF(4.5f, 6.5f, 7.5f).ToString(), a.ToString()); - a.SetToMax(Vector3dF(3.5f, 5.5f, 8.5f)); - EXPECT_EQ(Vector3dF(4.5f, 6.5f, 8.5f).ToString(), a.ToString()); - a.SetToMax(Vector3dF(8.5f, 10.5f, 12.5f)); - EXPECT_EQ(Vector3dF(8.5f, 10.5f, 12.5f).ToString(), a.ToString()); - - a.SetToMin(Vector3dF(9.5f, 11.5f, 13.5f)); - EXPECT_EQ(Vector3dF(8.5f, 10.5f, 12.5f).ToString(), a.ToString()); - a.SetToMin(Vector3dF(8.5f, 10.5f, 12.5f)); - EXPECT_EQ(Vector3dF(8.5f, 10.5f, 12.5f).ToString(), a.ToString()); - a.SetToMin(Vector3dF(7.5f, 11.5f, 13.5f)); - EXPECT_EQ(Vector3dF(7.5f, 10.5f, 12.5f).ToString(), a.ToString()); - a.SetToMin(Vector3dF(9.5f, 9.5f, 13.5f)); - EXPECT_EQ(Vector3dF(7.5f, 9.5f, 12.5f).ToString(), a.ToString()); - a.SetToMin(Vector3dF(9.5f, 11.5f, 11.5f)); - EXPECT_EQ(Vector3dF(7.5f, 9.5f, 11.5f).ToString(), a.ToString()); - a.SetToMin(Vector3dF(3.5f, 5.5f, 7.5f)); - EXPECT_EQ(Vector3dF(3.5f, 5.5f, 7.5f).ToString(), a.ToString()); -} - -} // namespace gfx diff --git a/ui/gfx/gfx_export.h b/ui/gfx/gfx_export.h deleted file mode 100644 index 20c8bb168..000000000 --- a/ui/gfx/gfx_export.h +++ /dev/null @@ -1,29 +0,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. - -#ifndef UI_GFX_GFX_EXPORT_H_ -#define UI_GFX_GFX_EXPORT_H_ - -#if defined(COMPONENT_BUILD) -#if defined(WIN32) - -#if defined(GFX_IMPLEMENTATION) -#define GFX_EXPORT __declspec(dllexport) -#else -#define GFX_EXPORT __declspec(dllimport) -#endif // defined(GFX_IMPLEMENTATION) - -#else // defined(WIN32) -#if defined(GFX_IMPLEMENTATION) -#define GFX_EXPORT __attribute__((visibility("default"))) -#else -#define GFX_EXPORT -#endif -#endif - -#else // defined(COMPONENT_BUILD) -#define GFX_EXPORT -#endif - -#endif // UI_GFX_GFX_EXPORT_H_ diff --git a/ui/gfx/native_widget_types.h b/ui/gfx/native_widget_types.h deleted file mode 100644 index 265d6e9a0..000000000 --- a/ui/gfx/native_widget_types.h +++ /dev/null @@ -1,179 +0,0 @@ -// 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 UI_GFX_NATIVE_WIDGET_TYPES_H_ -#define UI_GFX_NATIVE_WIDGET_TYPES_H_ - -#include "build/build_config.h" - -#if defined(OS_ANDROID) -#include -#endif - -#include "base/basictypes.h" -#include "base/logging.h" -#include "ui/gfx/gfx_export.h" - -// This file provides cross platform typedefs for native widget types. -// NativeWindow: this is a handle to a native, top-level window -// NativeView: this is a handle to a native UI element. It may be the -// same type as a NativeWindow on some platforms. -// NativeViewId: Often, in our cross process model, we need to pass around a -// reference to a "window". This reference will, say, be echoed back from a -// renderer to the browser when it wishes to query its size. On Windows we -// use an HWND for this. -// -// As a rule of thumb - if you're in the renderer, you should be dealing -// with NativeViewIds. This should remind you that you shouldn't be doing -// direct operations on platform widgets from the renderer process. -// -// If you're in the browser, you're probably dealing with NativeViews, -// unless you're in the IPC layer, which will be translating between -// NativeViewIds from the renderer and NativeViews. -// -// NativeEditView: a handle to a native edit-box. The Mac folks wanted this -// specific typedef. -// -// NativeImage: The platform-specific image type used for drawing UI elements -// in the browser. -// -// The name 'View' here meshes with OS X where the UI elements are called -// 'views' and with our Chrome UI code where the elements are also called -// 'views'. - -class SkRegion; -namespace ui { -class Event; -} - -#if defined(OS_POSIX) -typedef struct _PangoFontDescription PangoFontDescription; -typedef struct _cairo cairo_t; -#endif - -#if defined(OS_ANDROID) -struct ANativeWindow; -namespace ui { -class WindowAndroid; -class ViewAndroid; -} -#endif -class SkBitmap; - -#if defined(USE_GLFW) -struct GLFWwindow; -#endif - -namespace gfx { - -#if defined(OS_LINUX) -typedef SkRegion* NativeRegion; -typedef ui::Event* NativeEvent; -#elif defined(OS_ANDROID) -typedef void* NativeRegion; -typedef jobject NativeEvent; -#endif - -#if defined(USE_CAIRO) -typedef PangoFontDescription* NativeFont; -typedef void* NativeEditView; -typedef cairo_t* NativeDrawingContext; -typedef void* NativeViewAccessible; -#else -typedef void* NativeFont; -typedef void* NativeEditView; -typedef void* NativeDrawingContext; -typedef void* NativeViewAccessible; -#endif - -// A constant value to indicate that gfx::NativeCursor refers to no cursor. -#if defined(OS_LINUX) -const int kNullCursor = 0; -#endif - -typedef SkBitmap NativeImageType; -typedef NativeImageType* NativeImage; - -// Note: for test_shell we're packing a pointer into the NativeViewId. So, if -// you make it a type which is smaller than a pointer, you have to fix -// test_shell. -// -// See comment at the top of the file for usage. -typedef intptr_t NativeViewId; - -// PluginWindowHandle is an abstraction wrapping "the types of windows -// used by NPAPI plugins". On Windows it's an HWND, on X it's an X -// window id. -#if defined(USE_X11) - typedef unsigned long PluginWindowHandle; - const PluginWindowHandle kNullPluginWindow = 0; -#elif defined(OS_ANDROID) - typedef uint64 PluginWindowHandle; - const PluginWindowHandle kNullPluginWindow = 0; -#elif defined(USE_OZONE) - typedef intptr_t PluginWindowHandle; - const PluginWindowHandle kNullPluginWindow = 0; -#else - // On Mac we don't have windowed plugins. We use a NULL/0 PluginWindowHandle - // in shared code to indicate there is no window present. - typedef bool PluginWindowHandle; - const PluginWindowHandle kNullPluginWindow = 0; -#endif - -enum SurfaceType { - EMPTY, - NATIVE_DIRECT, - NULL_TRANSPORT, - SURFACE_TYPE_LAST = NULL_TRANSPORT -}; - -struct GLSurfaceHandle { - GLSurfaceHandle() - : handle(kNullPluginWindow), - transport_type(EMPTY), - parent_client_id(0) { - } - GLSurfaceHandle(PluginWindowHandle handle_, SurfaceType transport_) - : handle(handle_), - transport_type(transport_), - parent_client_id(0) { - DCHECK(!is_null() || handle == kNullPluginWindow); - DCHECK(transport_type != NULL_TRANSPORT || - handle == kNullPluginWindow); - } - bool is_null() const { return transport_type == EMPTY; } - bool is_transport() const { - return transport_type == NULL_TRANSPORT; - } - PluginWindowHandle handle; - SurfaceType transport_type; - uint32 parent_client_id; -}; - -// AcceleratedWidget provides a surface to compositors to paint pixels. -#if defined(USE_GLFW) -typedef GLFWwindow* AcceleratedWidget; -const AcceleratedWidget kNullAcceleratedWidget = 0; -#elif defined(USE_X11) -typedef unsigned long AcceleratedWidget; -const AcceleratedWidget kNullAcceleratedWidget = 0; -#elif defined(OS_ANDROID) -typedef ANativeWindow* AcceleratedWidget; -const AcceleratedWidget kNullAcceleratedWidget = 0; -#elif defined(USE_OZONE) -typedef intptr_t AcceleratedWidget; -const AcceleratedWidget kNullAcceleratedWidget = 0; -#elif defined(OS_IOS) -typedef uintptr_t AcceleratedWidget; -const AcceleratedWidget kNullAcceleratedWidget = 0; -#elif defined(OS_MACOSX) -typedef uintptr_t AcceleratedWidget; -const AcceleratedWidget kNullAcceleratedWidget = 0; -#else -#error unknown platform -#endif - -} // namespace gfx - -#endif // UI_GFX_NATIVE_WIDGET_TYPES_H_ diff --git a/ui/gfx/overlay_transform.h b/ui/gfx/overlay_transform.h deleted file mode 100644 index 1e2701093..000000000 --- a/ui/gfx/overlay_transform.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 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 UI_GFX_OVERLAY_TRANSFORM_H_ -#define UI_GFX_OVERLAY_TRANSFORM_H_ - -namespace gfx { - -// Describes transformation to be applied to the buffer before presenting -// to screen. -enum OverlayTransform { - OVERLAY_TRANSFORM_INVALID, - OVERLAY_TRANSFORM_NONE, - OVERLAY_TRANSFORM_FLIP_HORIZONTAL, - OVERLAY_TRANSFORM_FLIP_VERTICAL, - OVERLAY_TRANSFORM_ROTATE_90, - OVERLAY_TRANSFORM_ROTATE_180, - OVERLAY_TRANSFORM_ROTATE_270, -}; - -} // namespace gfx - -#endif // UI_GFX_OVERLAY_TRANSFORM_H_ diff --git a/ui/gfx/skia_util.cc b/ui/gfx/skia_util.cc deleted file mode 100644 index b6fb04a86..000000000 --- a/ui/gfx/skia_util.cc +++ /dev/null @@ -1,136 +0,0 @@ -// 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 "ui/gfx/skia_util.h" - -#include "third_party/skia/include/core/SkBitmap.h" -#include "third_party/skia/include/core/SkBlurTypes.h" -#include "third_party/skia/include/core/SkColorFilter.h" -#include "third_party/skia/include/core/SkColorPriv.h" -#include "third_party/skia/include/core/SkUnPreMultiply.h" -#include "third_party/skia/include/effects/SkBlurMaskFilter.h" -#include "third_party/skia/include/effects/SkGradientShader.h" -#include "third_party/skia/include/effects/SkLayerDrawLooper.h" -#include "ui/gfx/geometry/quad_f.h" -#include "ui/gfx/geometry/rect.h" -#include "ui/gfx/geometry/rect_f.h" -#include "ui/gfx/transform.h" - -namespace gfx { - -SkRect RectToSkRect(const Rect& rect) { - SkRect r; - r.iset(rect.x(), rect.y(), rect.right(), rect.bottom()); - return r; -} - -SkIRect RectToSkIRect(const Rect& rect) { - return SkIRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()); -} - -Rect SkIRectToRect(const SkIRect& rect) { - return Rect(rect.x(), rect.y(), rect.width(), rect.height()); -} - -SkRect RectFToSkRect(const RectF& rect) { - return SkRect::MakeXYWH(SkFloatToScalar(rect.x()), - SkFloatToScalar(rect.y()), - SkFloatToScalar(rect.width()), - SkFloatToScalar(rect.height())); -} - -RectF SkRectToRectF(const SkRect& rect) { - return RectF(SkScalarToFloat(rect.x()), - SkScalarToFloat(rect.y()), - SkScalarToFloat(rect.width()), - SkScalarToFloat(rect.height())); -} - -SkSize SizeFToSkSize(const SizeF& size) { - return SkSize::Make(SkFloatToScalar(size.width()), - SkFloatToScalar(size.height())); -} - -SizeF SkSizeToSizeF(const SkSize& size) { - return SizeF(SkScalarToFloat(size.width()), SkScalarToFloat(size.height())); -} - -void TransformToFlattenedSkMatrix(const gfx::Transform& transform, - SkMatrix* flattened) { - // Convert from 4x4 to 3x3 by dropping the third row and column. - flattened->set(0, SkMScalarToScalar(transform.matrix().get(0, 0))); - flattened->set(1, SkMScalarToScalar(transform.matrix().get(0, 1))); - flattened->set(2, SkMScalarToScalar(transform.matrix().get(0, 3))); - flattened->set(3, SkMScalarToScalar(transform.matrix().get(1, 0))); - flattened->set(4, SkMScalarToScalar(transform.matrix().get(1, 1))); - flattened->set(5, SkMScalarToScalar(transform.matrix().get(1, 3))); - flattened->set(6, SkMScalarToScalar(transform.matrix().get(3, 0))); - flattened->set(7, SkMScalarToScalar(transform.matrix().get(3, 1))); - flattened->set(8, SkMScalarToScalar(transform.matrix().get(3, 3))); -} - -skia::RefPtr CreateGradientShader(int start_point, - int end_point, - SkColor start_color, - SkColor end_color) { - SkColor grad_colors[2] = { start_color, end_color}; - SkPoint grad_points[2]; - grad_points[0].iset(0, start_point); - grad_points[1].iset(0, end_point); - - return skia::AdoptRef(SkGradientShader::MakeLinear( - grad_points, grad_colors, NULL, 2, SkShader::kRepeat_TileMode)); -} - -bool BitmapsAreEqual(const SkBitmap& bitmap1, const SkBitmap& bitmap2) { - void* addr1 = NULL; - void* addr2 = NULL; - size_t size1 = 0; - size_t size2 = 0; - - bitmap1.lockPixels(); - addr1 = bitmap1.getAddr32(0, 0); - size1 = bitmap1.getSize(); - bitmap1.unlockPixels(); - - bitmap2.lockPixels(); - addr2 = bitmap2.getAddr32(0, 0); - size2 = bitmap2.getSize(); - bitmap2.unlockPixels(); - - return (size1 == size2) && (0 == memcmp(addr1, addr2, bitmap1.getSize())); -} - -void ConvertSkiaToRGBA(const unsigned char* skia, - int pixel_width, - unsigned char* rgba) { - int total_length = pixel_width * 4; - for (int i = 0; i < total_length; i += 4) { - const uint32_t pixel_in = *reinterpret_cast(&skia[i]); - - // Pack the components here. - SkAlpha alpha = SkGetPackedA32(pixel_in); - if (alpha != 0 && alpha != 255) { - SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel_in); - rgba[i + 0] = SkColorGetR(unmultiplied); - rgba[i + 1] = SkColorGetG(unmultiplied); - rgba[i + 2] = SkColorGetB(unmultiplied); - rgba[i + 3] = alpha; - } else { - rgba[i + 0] = SkGetPackedR32(pixel_in); - rgba[i + 1] = SkGetPackedG32(pixel_in); - rgba[i + 2] = SkGetPackedB32(pixel_in); - rgba[i + 3] = alpha; - } - } -} - -void QuadFToSkPoints(const gfx::QuadF& quad, SkPoint points[4]) { - points[0] = SkPoint::Make(quad.p1().x(), quad.p1().y()); - points[1] = SkPoint::Make(quad.p2().x(), quad.p2().y()); - points[2] = SkPoint::Make(quad.p3().x(), quad.p3().y()); - points[3] = SkPoint::Make(quad.p4().x(), quad.p4().y()); -} - -} // namespace gfx diff --git a/ui/gfx/skia_util.h b/ui/gfx/skia_util.h deleted file mode 100644 index 79ca0b9a8..000000000 --- a/ui/gfx/skia_util.h +++ /dev/null @@ -1,80 +0,0 @@ -// 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 UI_GFX_SKIA_UTIL_H_ -#define UI_GFX_SKIA_UTIL_H_ - -#include -#include - -#include "skia/ext/refptr.h" -#include "third_party/skia/include/core/SkColor.h" -#include "third_party/skia/include/core/SkRect.h" -#include "third_party/skia/include/core/SkShader.h" -#include "ui/gfx/geometry/quad_f.h" -#include "ui/gfx/geometry/size.h" -#include "ui/gfx/gfx_export.h" - -class SkBitmap; -class SkDrawLooper; - -namespace gfx { - -class ImageSkiaRep; -class Rect; -class RectF; -class Transform; - -// Convert between Skia and gfx rect types. -GFX_EXPORT SkRect RectToSkRect(const Rect& rect); -GFX_EXPORT SkIRect RectToSkIRect(const Rect& rect); -GFX_EXPORT Rect SkIRectToRect(const SkIRect& rect); -GFX_EXPORT SkRect RectFToSkRect(const RectF& rect); -GFX_EXPORT RectF SkRectToRectF(const SkRect& rect); -GFX_EXPORT SkSize SizeFToSkSize(const SizeF& size); -GFX_EXPORT SizeF SkSizeToSizeF(const SkSize& size); - -GFX_EXPORT void QuadFToSkPoints(const gfx::QuadF& quad, SkPoint points[4]); - -GFX_EXPORT void TransformToFlattenedSkMatrix(const gfx::Transform& transform, - SkMatrix* flattened); - -// Creates a bitmap shader for the image rep with the image rep's scale factor. -// Sets the created shader's local matrix such that it displays the image rep at -// the correct scale factor. -// The shader's local matrix should not be changed after the shader is created. -// TODO(pkotwicz): Allow shader's local matrix to be changed after the shader -// is created. -// -GFX_EXPORT skia::RefPtr CreateImageRepShader( - const gfx::ImageSkiaRep& image_rep, - SkShader::TileMode tile_mode, - const SkMatrix& local_matrix); - -// Creates a bitmap shader for the image rep with the passed in scale factor. -GFX_EXPORT skia::RefPtr CreateImageRepShaderForScale( - const gfx::ImageSkiaRep& image_rep, - SkShader::TileMode tile_mode, - const SkMatrix& local_matrix, - SkScalar scale); - -// Creates a vertical gradient shader. The caller owns the shader. -// Example usage to avoid leaks: -GFX_EXPORT skia::RefPtr CreateGradientShader(int start_point, - int end_point, - SkColor start_color, - SkColor end_color); - -// Returns true if the two bitmaps contain the same pixels. -GFX_EXPORT bool BitmapsAreEqual(const SkBitmap& bitmap1, - const SkBitmap& bitmap2); - -// Converts Skia ARGB format pixels in |skia| to RGBA. -GFX_EXPORT void ConvertSkiaToRGBA(const unsigned char* skia, - int pixel_width, - unsigned char* rgba); - -} // namespace gfx - -#endif // UI_GFX_SKIA_UTIL_H_ diff --git a/ui/gfx/skrect_conversion_unittest.cc b/ui/gfx/skrect_conversion_unittest.cc deleted file mode 100644 index ef116c2a4..000000000 --- a/ui/gfx/skrect_conversion_unittest.cc +++ /dev/null @@ -1,26 +0,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 "base/basictypes.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/gfx/geometry/rect.h" -#include "ui/gfx/skia_util.h" - -namespace gfx { - -TEST(RectTest, SkiaRectConversions) { - Rect isrc(10, 20, 30, 40); - RectF fsrc(10.5f, 20.5f, 30.5f, 40.5f); - - SkIRect skirect = RectToSkIRect(isrc); - EXPECT_EQ(isrc.ToString(), SkIRectToRect(skirect).ToString()); - - SkRect skrect = RectToSkRect(isrc); - EXPECT_EQ(gfx::RectF(isrc).ToString(), SkRectToRectF(skrect).ToString()); - - skrect = RectFToSkRect(fsrc); - EXPECT_EQ(fsrc.ToString(), SkRectToRectF(skrect).ToString()); -} - -} // namespace gfx diff --git a/ui/gfx/test/data/compositor/ModifyHierarchy1.png b/ui/gfx/test/data/compositor/ModifyHierarchy1.png deleted file mode 100644 index 465c24e54..000000000 Binary files a/ui/gfx/test/data/compositor/ModifyHierarchy1.png and /dev/null differ diff --git a/ui/gfx/test/data/compositor/ModifyHierarchy2.png b/ui/gfx/test/data/compositor/ModifyHierarchy2.png deleted file mode 100644 index f4ac5dbd2..000000000 Binary files a/ui/gfx/test/data/compositor/ModifyHierarchy2.png and /dev/null differ diff --git a/ui/gfx/test/data/compositor/Opacity.png b/ui/gfx/test/data/compositor/Opacity.png deleted file mode 100644 index 83e119985..000000000 Binary files a/ui/gfx/test/data/compositor/Opacity.png and /dev/null differ diff --git a/ui/gfx/test/data/icon_util/128_X_128_icon.ico b/ui/gfx/test/data/icon_util/128_X_128_icon.ico deleted file mode 100644 index a5d72fe2f..000000000 Binary files a/ui/gfx/test/data/icon_util/128_X_128_icon.ico and /dev/null differ diff --git a/ui/gfx/test/data/icon_util/16_X_16_icon.ico b/ui/gfx/test/data/icon_util/16_X_16_icon.ico deleted file mode 100644 index 0e524f16e..000000000 Binary files a/ui/gfx/test/data/icon_util/16_X_16_icon.ico and /dev/null differ diff --git a/ui/gfx/test/fontconfig_util_linux.cc b/ui/gfx/test/fontconfig_util_linux.cc deleted file mode 100644 index d0b7aefa3..000000000 --- a/ui/gfx/test/fontconfig_util_linux.cc +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright 2014 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 "ui/gfx/test/fontconfig_util_linux.h" - -#include - -#include "base/files/file_util.h" -#include "base/logging.h" -#include "base/strings/stringprintf.h" - -namespace gfx { - -const char* const kSystemFontsForFontconfig[] = { - "/usr/share/fonts/truetype/kochi/kochi-gothic.ttf", - "/usr/share/fonts/truetype/kochi/kochi-mincho.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS_Bold.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Courier_New_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Georgia.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Georgia_Bold.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Georgia_Bold_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Georgia_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Impact.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS_Bold.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS_Bold_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Verdana.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Verdana_Bold.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Verdana_Bold_Italic.ttf", - "/usr/share/fonts/truetype/msttcorefonts/Verdana_Italic.ttf", - // The DejaVuSans font is used by the css2.1 tests. - "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf", - "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_hi.ttf", - "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_ta.ttf", - "/usr/share/fonts/truetype/ttf-indic-fonts-core/MuktiNarrow.ttf", -}; - -const size_t kNumSystemFontsForFontconfig = - arraysize(kSystemFontsForFontconfig); - -const char kFontconfigFileHeader[] = - "\n" - "\n" - "\n"; -const char kFontconfigFileFooter[] = ""; -const char kFontconfigMatchHeader[] = " \n"; -const char kFontconfigMatchFooter[] = " \n"; - -void SetUpFontconfig() { - FcInit(); - - // A primer on undocumented FcConfig reference-counting: - // - // - FcConfigCreate() creates a config with a refcount of 1. - // - FcConfigReference() increments a config's refcount. - // - FcConfigDestroy() decrements a config's refcount, deallocating the - // config when the count reaches 0. - // - FcConfigSetCurrent() calls FcConfigDestroy() on the old config, but - // interestingly does not call FcConfigReference() on the new config. - CHECK(FcConfigSetCurrent(FcConfigCreate())); -} - -void TearDownFontconfig() { - FcFini(); -} - -bool LoadFontIntoFontconfig(const base::FilePath& path) { - if (!base::PathExists(path)) { - LOG(ERROR) << "You are missing " << path.value() << ". Try re-running " - << "build/install-build-deps.sh. Also see " - << "http://code.google.com/p/chromium/wiki/LayoutTestsLinux"; - return false; - } - - if (!FcConfigAppFontAddFile( - NULL, reinterpret_cast(path.value().c_str()))) { - LOG(ERROR) << "Failed to load font " << path.value(); - return false; - } - - return true; -} - -bool LoadConfigFileIntoFontconfig(const base::FilePath& path) { - // Unlike other FcConfig functions, FcConfigParseAndLoad() doesn't default to - // the current config when passed NULL. So that's cool. - if (!FcConfigParseAndLoad(FcConfigGetCurrent(), - reinterpret_cast(path.value().c_str()), FcTrue)) { - LOG(ERROR) << "Fontconfig failed to load " << path.value(); - return false; - } - return true; -} - -bool LoadConfigDataIntoFontconfig(const base::FilePath& temp_dir, - const std::string& data) { - base::FilePath path; - if (!CreateTemporaryFileInDir(temp_dir, &path)) { - PLOG(ERROR) << "Unable to create temporary file in " << temp_dir.value(); - return false; - } - if (base::WriteFile(path, data.data(), data.size()) != - static_cast(data.size())) { - PLOG(ERROR) << "Unable to write config data to " << path.value(); - return false; - } - return LoadConfigFileIntoFontconfig(path); -} - -std::string CreateFontconfigEditStanza(const std::string& name, - const std::string& type, - const std::string& value) { - return base::StringPrintf( - " \n" - " <%s>%s\n" - " \n", - name.c_str(), type.c_str(), value.c_str(), type.c_str()); -} - -std::string CreateFontconfigTestStanza(const std::string& name, - const std::string& op, - const std::string& type, - const std::string& value) { - return base::StringPrintf( - " \n" - " <%s>%s\n" - " \n", - name.c_str(), op.c_str(), type.c_str(), value.c_str(), type.c_str()); -} - -std::string CreateFontconfigAliasStanza(const std::string& original_family, - const std::string& preferred_family) { - return base::StringPrintf( - " \n" - " %s\n" - " %s\n" - " \n", - original_family.c_str(), preferred_family.c_str()); -} - -} // namespace gfx diff --git a/ui/gfx/test/fontconfig_util_linux.h b/ui/gfx/test/fontconfig_util_linux.h deleted file mode 100644 index 9fa66b282..000000000 --- a/ui/gfx/test/fontconfig_util_linux.h +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2014 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 UI_GFX_TEST_FONTCONFIG_UTIL_LINUX_H_ -#define UI_GFX_TEST_FONTCONFIG_UTIL_LINUX_H_ - -#include - -#include "base/files/file_path.h" - -namespace gfx { - -// Array of paths to font files that are expected to exist on machines where -// tests are run. -extern const char* const kSystemFontsForFontconfig[]; -extern const size_t kNumSystemFontsForFontconfig; - -// Strings appearing at the beginning and end of Fontconfig XML files. -extern const char kFontconfigFileHeader[]; -extern const char kFontconfigFileFooter[]; - -// Strings appearing at the beginning and end of Fontconfig stanzas. -extern const char kFontconfigMatchHeader[]; -extern const char kFontconfigMatchFooter[]; - -// Initializes Fontconfig and creates and swaps in a new, empty config. -void SetUpFontconfig(); - -// Deinitializes Fontconfig. -void TearDownFontconfig(); - -// Loads the font file at |path| into the current config, returning true on -// success. -bool LoadFontIntoFontconfig(const base::FilePath& path); - -// Instructs Fontconfig to load |path|, an XML configuration file, into the -// current config, returning true on success. -bool LoadConfigFileIntoFontconfig(const base::FilePath& path); - -// Writes |data| to a file in |temp_dir| and passes it to -// LoadConfigFileIntoFontconfig(). -bool LoadConfigDataIntoFontconfig(const base::FilePath& temp_dir, - const std::string& data); - -// Returns a Fontconfig stanza. -std::string CreateFontconfigEditStanza(const std::string& name, - const std::string& type, - const std::string& value); - -// Returns a Fontconfig stanza. -std::string CreateFontconfigTestStanza(const std::string& name, - const std::string& op, - const std::string& type, - const std::string& value); - -// Returns a Fontconfig stanza. -std::string CreateFontconfigAliasStanza(const std::string& original_family, - const std::string& preferred_family); - -} // namespace gfx - -#endif // UI_GFX_TEST_FONTCONFIG_UTIL_LINUX_H_ diff --git a/ui/gfx/test/gfx_util.cc b/ui/gfx/test/gfx_util.cc deleted file mode 100644 index d8bf5f2af..000000000 --- a/ui/gfx/test/gfx_util.cc +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2014 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 "ui/gfx/test/gfx_util.h" - -#include -#include -#include - -#include "ui/gfx/geometry/box_f.h" -#include "ui/gfx/geometry/point.h" -#include "ui/gfx/geometry/point3_f.h" -#include "ui/gfx/geometry/point_f.h" -#include "ui/gfx/geometry/quad_f.h" -#include "ui/gfx/geometry/rect.h" -#include "ui/gfx/geometry/rect_f.h" -#include "ui/gfx/geometry/scroll_offset.h" -#include "ui/gfx/geometry/size.h" -#include "ui/gfx/geometry/size_f.h" -#include "ui/gfx/geometry/vector2d.h" -#include "ui/gfx/geometry/vector2d_f.h" -#include "ui/gfx/geometry/vector3d_f.h" -#include "ui/gfx/transform.h" - -namespace gfx { - -namespace { - -std::string ColorAsString(SkColor color) { - std::ostringstream stream; - stream << std::hex << std::uppercase << "#" << std::setfill('0') - << std::setw(2) << SkColorGetA(color) - << std::setw(2) << SkColorGetR(color) - << std::setw(2) << SkColorGetG(color) - << std::setw(2) << SkColorGetB(color); - return stream.str(); -} - -bool FloatAlmostEqual(float a, float b) { - // FloatLE is the gtest predicate for less than or almost equal to. - return ::testing::FloatLE("a", "b", a, b) && - ::testing::FloatLE("b", "a", b, a); -} - -} // namespace - -::testing::AssertionResult AssertBoxFloatEqual(const char* lhs_expr, - const char* rhs_expr, - const BoxF& lhs, - const BoxF& rhs) { - if (FloatAlmostEqual(lhs.x(), rhs.x()) && - FloatAlmostEqual(lhs.y(), rhs.y()) && - FloatAlmostEqual(lhs.z(), rhs.z()) && - FloatAlmostEqual(lhs.width(), rhs.width()) && - FloatAlmostEqual(lhs.height(), rhs.height()) && - FloatAlmostEqual(lhs.depth(), rhs.depth())) { - return ::testing::AssertionSuccess(); - } - return ::testing::AssertionFailure() << "Value of: " << rhs_expr - << "\n Actual: " << rhs.ToString() - << "\nExpected: " << lhs_expr - << "\nWhich is: " << lhs.ToString(); -} - -::testing::AssertionResult AssertRectFloatEqual(const char* lhs_expr, - const char* rhs_expr, - const RectF& lhs, - const RectF& rhs) { - if (FloatAlmostEqual(lhs.x(), rhs.x()) && - FloatAlmostEqual(lhs.y(), rhs.y()) && - FloatAlmostEqual(lhs.width(), rhs.width()) && - FloatAlmostEqual(lhs.height(), rhs.height())) { - return ::testing::AssertionSuccess(); - } - return ::testing::AssertionFailure() - << "Value of: " << rhs_expr << "\n Actual: " << rhs.ToString() - << "\nExpected: " << lhs_expr << "\nWhich is: " << lhs.ToString(); -} - -::testing::AssertionResult AssertSkColorsEqual(const char* lhs_expr, - const char* rhs_expr, - SkColor lhs, - SkColor rhs) { - if (lhs == rhs) { - return ::testing::AssertionSuccess(); - } - return ::testing::AssertionFailure() << "Value of: " << rhs_expr - << "\n Actual: " << ColorAsString(rhs) - << "\nExpected: " << lhs_expr - << "\nWhich is: " << ColorAsString(lhs); -} - -void PrintTo(const BoxF& box, ::std::ostream* os) { - *os << box.ToString(); -} - -void PrintTo(const Point& point, ::std::ostream* os) { - *os << point.ToString(); -} - -void PrintTo(const Point3F& point, ::std::ostream* os) { - *os << point.ToString(); -} - -void PrintTo(const PointF& point, ::std::ostream* os) { - *os << point.ToString(); -} - -void PrintTo(const QuadF& quad, ::std::ostream* os) { - *os << quad.ToString(); -} - -void PrintTo(const Rect& rect, ::std::ostream* os) { - *os << rect.ToString(); -} - -void PrintTo(const RectF& rect, ::std::ostream* os) { - *os << rect.ToString(); -} - -void PrintTo(const ScrollOffset& offset, ::std::ostream* os) { - *os << offset.ToString(); -} - -void PrintTo(const Size& size, ::std::ostream* os) { - *os << size.ToString(); -} - -void PrintTo(const SizeF& size, ::std::ostream* os) { - *os << size.ToString(); -} - -void PrintTo(const Transform& transform, ::std::ostream* os) { - *os << transform.ToString(); -} - -void PrintTo(const Vector2d& vector, ::std::ostream* os) { - *os << vector.ToString(); -} - -void PrintTo(const Vector2dF& vector, ::std::ostream* os) { - *os << vector.ToString(); -} - -void PrintTo(const Vector3dF& vector, ::std::ostream* os) { - *os << vector.ToString(); -} - -} // namespace gfx diff --git a/ui/gfx/test/gfx_util.h b/ui/gfx/test/gfx_util.h deleted file mode 100644 index f5e9d9d0f..000000000 --- a/ui/gfx/test/gfx_util.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2014 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 UI_GFX_TEST_GFX_UTIL_H_ -#define UI_GFX_TEST_GFX_UTIL_H_ - -#include -#include - -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/skia/include/core/SkColor.h" -#include "ui/gfx/box_f.h" -#include "ui/gfx/geometry/rect_f.h" - -namespace gfx { - -// Checks that the box coordinates are each almost equal floats. -#define EXPECT_BOXF_EQ(a, b) \ - EXPECT_PRED_FORMAT2(::gfx::AssertBoxFloatEqual, a, b) - -::testing::AssertionResult AssertBoxFloatEqual(const char* lhs_expr, - const char* rhs_expr, - const BoxF& lhs, - const BoxF& rhs); - -#define EXPECT_RECTF_EQ(a, b) \ - EXPECT_PRED_FORMAT2(::gfx::AssertRectFloatEqual, a, b) - -::testing::AssertionResult AssertRectFloatEqual(const char* lhs_expr, - const char* rhs_expr, - const RectF& lhs, - const RectF& rhs); - -#define EXPECT_SKCOLOR_EQ(a, b) \ - EXPECT_PRED_FORMAT2(::gfx::AssertSkColorsEqual, a, b) - -::testing::AssertionResult AssertSkColorsEqual(const char* lhs_expr, - const char* rhs_expr, - SkColor lhs, - SkColor rhs); - -} // namespace gfx - -#endif // UI_GFX_TEST_GFX_UTIL_H_ diff --git a/ui/gfx/test/run_all_unittests.cc b/ui/gfx/test/run_all_unittests.cc deleted file mode 100644 index 65c97d76e..000000000 --- a/ui/gfx/test/run_all_unittests.cc +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2014 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/bind.h" -#include "base/compiler_specific.h" -#include "base/macros.h" -#include "base/path_service.h" -#include "base/test/launcher/unit_test_launcher.h" -#include "base/test/test_suite.h" -#include "testing/gtest/include/gtest/gtest.h" - -#if defined(OS_ANDROID) -#include "base/android/jni_android.h" -#include "ui/gfx/android/gfx_jni_registrar.h" -#endif - -namespace { - -class GfxTestSuite : public base::TestSuite { - public: - GfxTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} - - protected: - void Initialize() override { - base::TestSuite::Initialize(); - -#if defined(OS_ANDROID) - gfx::android::RegisterJni(base::android::AttachCurrentThread()); -#endif - } - - void Shutdown() override { - base::TestSuite::Shutdown(); - } - - private: - DISALLOW_COPY_AND_ASSIGN(GfxTestSuite); -}; - -} // namespace - -int main(int argc, char** argv) { - GfxTestSuite test_suite(argc, argv); - - return base::LaunchUnitTests( - argc, - argv, - base::Bind(&GfxTestSuite::Run, base::Unretained(&test_suite))); -} diff --git a/ui/gfx/transform.cc b/ui/gfx/transform.cc deleted file mode 100644 index e26630873..000000000 --- a/ui/gfx/transform.cc +++ /dev/null @@ -1,570 +0,0 @@ -// 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. - -// MSVC++ requires this to be set before any other includes to get M_PI. -#define _USE_MATH_DEFINES - -#include "ui/gfx/transform.h" - -#include - -#include "base/logging.h" -#include "base/strings/stringprintf.h" -#include "ui/gfx/geometry/box_f.h" -#include "ui/gfx/geometry/point.h" -#include "ui/gfx/geometry/point3_f.h" -#include "ui/gfx/geometry/rect.h" -#include "ui/gfx/geometry/safe_integer_conversions.h" -#include "ui/gfx/geometry/vector3d_f.h" -#include "ui/gfx/skia_util.h" -#include "ui/gfx/transform_util.h" - -namespace gfx { - -namespace { - -// Taken from SkMatrix44. -const SkMScalar kEpsilon = 1e-8f; - -SkMScalar TanDegrees(double degrees) { - double radians = degrees * M_PI / 180; - return SkDoubleToMScalar(std::tan(radians)); -} - -inline bool ApproximatelyZero(SkMScalar x, SkMScalar tolerance) { - return std::abs(x) <= tolerance; -} - -inline bool ApproximatelyOne(SkMScalar x, SkMScalar tolerance) { - return std::abs(x - SkDoubleToMScalar(1.0)) <= tolerance; -} - -static float Round(float f) { - if (f == 0.f) - return f; - return (f > 0.f) ? std::floor(f + 0.5f) : std::ceil(f - 0.5f); -} - -} // namespace - -Transform::Transform(SkMScalar col1row1, - SkMScalar col2row1, - SkMScalar col3row1, - SkMScalar col4row1, - SkMScalar col1row2, - SkMScalar col2row2, - SkMScalar col3row2, - SkMScalar col4row2, - SkMScalar col1row3, - SkMScalar col2row3, - SkMScalar col3row3, - SkMScalar col4row3, - SkMScalar col1row4, - SkMScalar col2row4, - SkMScalar col3row4, - SkMScalar col4row4) - : matrix_(SkMatrix44::kUninitialized_Constructor) { - matrix_.set(0, 0, col1row1); - matrix_.set(1, 0, col1row2); - matrix_.set(2, 0, col1row3); - matrix_.set(3, 0, col1row4); - - matrix_.set(0, 1, col2row1); - matrix_.set(1, 1, col2row2); - matrix_.set(2, 1, col2row3); - matrix_.set(3, 1, col2row4); - - matrix_.set(0, 2, col3row1); - matrix_.set(1, 2, col3row2); - matrix_.set(2, 2, col3row3); - matrix_.set(3, 2, col3row4); - - matrix_.set(0, 3, col4row1); - matrix_.set(1, 3, col4row2); - matrix_.set(2, 3, col4row3); - matrix_.set(3, 3, col4row4); -} - -Transform::Transform(SkMScalar col1row1, - SkMScalar col2row1, - SkMScalar col1row2, - SkMScalar col2row2, - SkMScalar x_translation, - SkMScalar y_translation) - : matrix_(SkMatrix44::kIdentity_Constructor) { - matrix_.set(0, 0, col1row1); - matrix_.set(1, 0, col1row2); - matrix_.set(0, 1, col2row1); - matrix_.set(1, 1, col2row2); - matrix_.set(0, 3, x_translation); - matrix_.set(1, 3, y_translation); -} - -void Transform::RotateAboutXAxis(double degrees) { - double radians = degrees * M_PI / 180; - SkMScalar cosTheta = SkDoubleToMScalar(std::cos(radians)); - SkMScalar sinTheta = SkDoubleToMScalar(std::sin(radians)); - if (matrix_.isIdentity()) { - matrix_.set3x3(1, 0, 0, - 0, cosTheta, sinTheta, - 0, -sinTheta, cosTheta); - } else { - SkMatrix44 rot(SkMatrix44::kUninitialized_Constructor); - rot.set3x3(1, 0, 0, - 0, cosTheta, sinTheta, - 0, -sinTheta, cosTheta); - matrix_.preConcat(rot); - } -} - -void Transform::RotateAboutYAxis(double degrees) { - double radians = degrees * M_PI / 180; - SkMScalar cosTheta = SkDoubleToMScalar(std::cos(radians)); - SkMScalar sinTheta = SkDoubleToMScalar(std::sin(radians)); - if (matrix_.isIdentity()) { - // Note carefully the placement of the -sinTheta for rotation about - // y-axis is different than rotation about x-axis or z-axis. - matrix_.set3x3(cosTheta, 0, -sinTheta, - 0, 1, 0, - sinTheta, 0, cosTheta); - } else { - SkMatrix44 rot(SkMatrix44::kUninitialized_Constructor); - rot.set3x3(cosTheta, 0, -sinTheta, - 0, 1, 0, - sinTheta, 0, cosTheta); - matrix_.preConcat(rot); - } -} - -void Transform::RotateAboutZAxis(double degrees) { - double radians = degrees * M_PI / 180; - SkMScalar cosTheta = SkDoubleToMScalar(std::cos(radians)); - SkMScalar sinTheta = SkDoubleToMScalar(std::sin(radians)); - if (matrix_.isIdentity()) { - matrix_.set3x3(cosTheta, sinTheta, 0, - -sinTheta, cosTheta, 0, - 0, 0, 1); - } else { - SkMatrix44 rot(SkMatrix44::kUninitialized_Constructor); - rot.set3x3(cosTheta, sinTheta, 0, - -sinTheta, cosTheta, 0, - 0, 0, 1); - matrix_.preConcat(rot); - } -} - -void Transform::RotateAbout(const Vector3dF& axis, double degrees) { - if (matrix_.isIdentity()) { - matrix_.setRotateDegreesAbout(SkFloatToMScalar(axis.x()), - SkFloatToMScalar(axis.y()), - SkFloatToMScalar(axis.z()), - degrees); - } else { - SkMatrix44 rot(SkMatrix44::kUninitialized_Constructor); - rot.setRotateDegreesAbout(SkFloatToMScalar(axis.x()), - SkFloatToMScalar(axis.y()), - SkFloatToMScalar(axis.z()), - degrees); - matrix_.preConcat(rot); - } -} - -void Transform::Scale(SkMScalar x, SkMScalar y) { matrix_.preScale(x, y, 1); } - -void Transform::Scale3d(SkMScalar x, SkMScalar y, SkMScalar z) { - matrix_.preScale(x, y, z); -} - -void Transform::Translate(SkMScalar x, SkMScalar y) { - matrix_.preTranslate(x, y, 0); -} - -void Transform::Translate3d(SkMScalar x, SkMScalar y, SkMScalar z) { - matrix_.preTranslate(x, y, z); -} - -void Transform::SkewX(double angle_x) { - if (matrix_.isIdentity()) - matrix_.set(0, 1, TanDegrees(angle_x)); - else { - SkMatrix44 skew(SkMatrix44::kIdentity_Constructor); - skew.set(0, 1, TanDegrees(angle_x)); - matrix_.preConcat(skew); - } -} - -void Transform::SkewY(double angle_y) { - if (matrix_.isIdentity()) - matrix_.set(1, 0, TanDegrees(angle_y)); - else { - SkMatrix44 skew(SkMatrix44::kIdentity_Constructor); - skew.set(1, 0, TanDegrees(angle_y)); - matrix_.preConcat(skew); - } -} - -void Transform::ApplyPerspectiveDepth(SkMScalar depth) { - if (depth == 0) - return; - if (matrix_.isIdentity()) - matrix_.set(3, 2, -1.0 / depth); - else { - SkMatrix44 m(SkMatrix44::kIdentity_Constructor); - m.set(3, 2, -1.0 / depth); - matrix_.preConcat(m); - } -} - -void Transform::PreconcatTransform(const Transform& transform) { - matrix_.preConcat(transform.matrix_); -} - -void Transform::ConcatTransform(const Transform& transform) { - matrix_.postConcat(transform.matrix_); -} - -bool Transform::IsApproximatelyIdentityOrTranslation( - SkMScalar tolerance) const { - DCHECK_GE(tolerance, 0); - return - ApproximatelyOne(matrix_.get(0, 0), tolerance) && - ApproximatelyZero(matrix_.get(1, 0), tolerance) && - ApproximatelyZero(matrix_.get(2, 0), tolerance) && - matrix_.get(3, 0) == 0 && - ApproximatelyZero(matrix_.get(0, 1), tolerance) && - ApproximatelyOne(matrix_.get(1, 1), tolerance) && - ApproximatelyZero(matrix_.get(2, 1), tolerance) && - matrix_.get(3, 1) == 0 && - ApproximatelyZero(matrix_.get(0, 2), tolerance) && - ApproximatelyZero(matrix_.get(1, 2), tolerance) && - ApproximatelyOne(matrix_.get(2, 2), tolerance) && - matrix_.get(3, 2) == 0 && - matrix_.get(3, 3) == 1; -} - -bool Transform::IsIdentityOrIntegerTranslation() const { - if (!IsIdentityOrTranslation()) - return false; - - bool no_fractional_translation = - static_cast(matrix_.get(0, 3)) == matrix_.get(0, 3) && - static_cast(matrix_.get(1, 3)) == matrix_.get(1, 3) && - static_cast(matrix_.get(2, 3)) == matrix_.get(2, 3); - - return no_fractional_translation; -} - -bool Transform::IsBackFaceVisible() const { - // Compute whether a layer with a forward-facing normal of (0, 0, 1, 0) - // would have its back face visible after applying the transform. - if (matrix_.isIdentity()) - return false; - - // This is done by transforming the normal and seeing if the resulting z - // value is positive or negative. However, note that transforming a normal - // actually requires using the inverse-transpose of the original transform. - // - // We can avoid inverting and transposing the matrix since we know we want - // to transform only the specific normal vector (0, 0, 1, 0). In this case, - // we only need the 3rd row, 3rd column of the inverse-transpose. We can - // calculate only the 3rd row 3rd column element of the inverse, skipping - // everything else. - // - // For more information, refer to: - // http://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution - // - - double determinant = matrix_.determinant(); - - // If matrix was not invertible, then just assume back face is not visible. - if (std::abs(determinant) <= kEpsilon) - return false; - - // Compute the cofactor of the 3rd row, 3rd column. - double cofactor_part_1 = - matrix_.get(0, 0) * matrix_.get(1, 1) * matrix_.get(3, 3); - - double cofactor_part_2 = - matrix_.get(0, 1) * matrix_.get(1, 3) * matrix_.get(3, 0); - - double cofactor_part_3 = - matrix_.get(0, 3) * matrix_.get(1, 0) * matrix_.get(3, 1); - - double cofactor_part_4 = - matrix_.get(0, 0) * matrix_.get(1, 3) * matrix_.get(3, 1); - - double cofactor_part_5 = - matrix_.get(0, 1) * matrix_.get(1, 0) * matrix_.get(3, 3); - - double cofactor_part_6 = - matrix_.get(0, 3) * matrix_.get(1, 1) * matrix_.get(3, 0); - - double cofactor33 = - cofactor_part_1 + - cofactor_part_2 + - cofactor_part_3 - - cofactor_part_4 - - cofactor_part_5 - - cofactor_part_6; - - // Technically the transformed z component is cofactor33 / determinant. But - // we can avoid the costly division because we only care about the resulting - // +/- sign; we can check this equivalently by multiplication. - return cofactor33 * determinant < 0; -} - -bool Transform::GetInverse(Transform* transform) const { - if (!matrix_.invert(&transform->matrix_)) { - // Initialize the return value to identity if this matrix turned - // out to be un-invertible. - transform->MakeIdentity(); - return false; - } - - return true; -} - -bool Transform::Preserves2dAxisAlignment() const { - // Check whether an axis aligned 2-dimensional rect would remain axis-aligned - // after being transformed by this matrix (and implicitly projected by - // dropping any non-zero z-values). - // - // The 4th column can be ignored because translations don't affect axis - // alignment. The 3rd column can be ignored because we are assuming 2d - // inputs, where z-values will be zero. The 3rd row can also be ignored - // because we are assuming 2d outputs, and any resulting z-value is dropped - // anyway. For the inner 2x2 portion, the only effects that keep a rect axis - // aligned are (1) swapping axes and (2) scaling axes. This can be checked by - // verifying only 1 element of every column and row is non-zero. Degenerate - // cases that project the x or y dimension to zero are considered to preserve - // axis alignment. - // - // If the matrix does have perspective component that is affected by x or y - // values: The current implementation conservatively assumes that axis - // alignment is not preserved. - - bool has_x_or_y_perspective = - matrix_.get(3, 0) != 0 || matrix_.get(3, 1) != 0; - - int num_non_zero_in_row_0 = 0; - int num_non_zero_in_row_1 = 0; - int num_non_zero_in_col_0 = 0; - int num_non_zero_in_col_1 = 0; - - if (std::abs(matrix_.get(0, 0)) > kEpsilon) { - num_non_zero_in_row_0++; - num_non_zero_in_col_0++; - } - - if (std::abs(matrix_.get(0, 1)) > kEpsilon) { - num_non_zero_in_row_0++; - num_non_zero_in_col_1++; - } - - if (std::abs(matrix_.get(1, 0)) > kEpsilon) { - num_non_zero_in_row_1++; - num_non_zero_in_col_0++; - } - - if (std::abs(matrix_.get(1, 1)) > kEpsilon) { - num_non_zero_in_row_1++; - num_non_zero_in_col_1++; - } - - return - num_non_zero_in_row_0 <= 1 && - num_non_zero_in_row_1 <= 1 && - num_non_zero_in_col_0 <= 1 && - num_non_zero_in_col_1 <= 1 && - !has_x_or_y_perspective; -} - -void Transform::Transpose() { - matrix_.transpose(); -} - -void Transform::FlattenTo2d() { - matrix_.set(2, 0, 0.0); - matrix_.set(2, 1, 0.0); - matrix_.set(0, 2, 0.0); - matrix_.set(1, 2, 0.0); - matrix_.set(2, 2, 1.0); - matrix_.set(3, 2, 0.0); - matrix_.set(2, 3, 0.0); -} - -bool Transform::IsFlat() const { - return matrix_.get(2, 0) == 0.0 && matrix_.get(2, 1) == 0.0 && - matrix_.get(0, 2) == 0.0 && matrix_.get(1, 2) == 0.0 && - matrix_.get(2, 2) == 1.0 && matrix_.get(3, 2) == 0.0 && - matrix_.get(2, 3) == 0.0; -} - -Vector2dF Transform::To2dTranslation() const { - return gfx::Vector2dF(SkMScalarToFloat(matrix_.get(0, 3)), - SkMScalarToFloat(matrix_.get(1, 3))); -} - -void Transform::TransformPoint(Point* point) const { - DCHECK(point); - TransformPointInternal(matrix_, point); -} - -void Transform::TransformPoint(Point3F* point) const { - DCHECK(point); - TransformPointInternal(matrix_, point); -} - -bool Transform::TransformPointReverse(Point* point) const { - DCHECK(point); - - // TODO(sad): Try to avoid trying to invert the matrix. - SkMatrix44 inverse(SkMatrix44::kUninitialized_Constructor); - if (!matrix_.invert(&inverse)) - return false; - - TransformPointInternal(inverse, point); - return true; -} - -bool Transform::TransformPointReverse(Point3F* point) const { - DCHECK(point); - - // TODO(sad): Try to avoid trying to invert the matrix. - SkMatrix44 inverse(SkMatrix44::kUninitialized_Constructor); - if (!matrix_.invert(&inverse)) - return false; - - TransformPointInternal(inverse, point); - return true; -} - -void Transform::TransformRect(RectF* rect) const { - if (matrix_.isIdentity()) - return; - - SkRect src = RectFToSkRect(*rect); - const SkMatrix& matrix = matrix_; - matrix.mapRect(&src); - *rect = SkRectToRectF(src); -} - -bool Transform::TransformRectReverse(RectF* rect) const { - if (matrix_.isIdentity()) - return true; - - SkMatrix44 inverse(SkMatrix44::kUninitialized_Constructor); - if (!matrix_.invert(&inverse)) - return false; - - const SkMatrix& matrix = inverse; - SkRect src = RectFToSkRect(*rect); - matrix.mapRect(&src); - *rect = SkRectToRectF(src); - return true; -} - -void Transform::TransformBox(BoxF* box) const { - BoxF bounds; - bool first_point = true; - for (int corner = 0; corner < 8; ++corner) { - gfx::Point3F point = box->origin(); - point += gfx::Vector3dF(corner & 1 ? box->width() : 0.f, - corner & 2 ? box->height() : 0.f, - corner & 4 ? box->depth() : 0.f); - TransformPoint(&point); - if (first_point) { - bounds.set_origin(point); - first_point = false; - } else { - bounds.ExpandTo(point); - } - } - *box = bounds; -} - -bool Transform::TransformBoxReverse(BoxF* box) const { - gfx::Transform inverse = *this; - if (!GetInverse(&inverse)) - return false; - inverse.TransformBox(box); - return true; -} - -bool Transform::Blend(const Transform& from, double progress) { - DecomposedTransform to_decomp; - DecomposedTransform from_decomp; - if (!DecomposeTransform(&to_decomp, *this) || - !DecomposeTransform(&from_decomp, from)) - return false; - - if (!BlendDecomposedTransforms(&to_decomp, to_decomp, from_decomp, progress)) - return false; - - matrix_ = ComposeTransform(to_decomp).matrix(); - return true; -} - -void Transform::RoundTranslationComponents() { - matrix_.set(0, 3, Round(matrix_.get(0, 3))); - matrix_.set(1, 3, Round(matrix_.get(1, 3))); -} - - -void Transform::TransformPointInternal(const SkMatrix44& xform, - Point3F* point) const { - if (xform.isIdentity()) - return; - - SkMScalar p[4] = {SkFloatToMScalar(point->x()), SkFloatToMScalar(point->y()), - SkFloatToMScalar(point->z()), 1}; - - xform.mapMScalars(p); - - if (p[3] != SK_MScalar1 && p[3] != 0.f) { - float w_inverse = SK_MScalar1 / p[3]; - point->SetPoint(p[0] * w_inverse, p[1] * w_inverse, p[2] * w_inverse); - } else { - point->SetPoint(p[0], p[1], p[2]); - } -} - -void Transform::TransformPointInternal(const SkMatrix44& xform, - Point* point) const { - if (xform.isIdentity()) - return; - - SkMScalar p[4] = {SkFloatToMScalar(point->x()), SkFloatToMScalar(point->y()), - 0, 1}; - - xform.mapMScalars(p); - - point->SetPoint(ToRoundedInt(p[0]), ToRoundedInt(p[1])); -} - -std::string Transform::ToString() const { - return base::StringPrintf( - "[ %+0.4f %+0.4f %+0.4f %+0.4f \n" - " %+0.4f %+0.4f %+0.4f %+0.4f \n" - " %+0.4f %+0.4f %+0.4f %+0.4f \n" - " %+0.4f %+0.4f %+0.4f %+0.4f ]\n", - matrix_.get(0, 0), - matrix_.get(0, 1), - matrix_.get(0, 2), - matrix_.get(0, 3), - matrix_.get(1, 0), - matrix_.get(1, 1), - matrix_.get(1, 2), - matrix_.get(1, 3), - matrix_.get(2, 0), - matrix_.get(2, 1), - matrix_.get(2, 2), - matrix_.get(2, 3), - matrix_.get(3, 0), - matrix_.get(3, 1), - matrix_.get(3, 2), - matrix_.get(3, 3)); -} - -} // namespace gfx diff --git a/ui/gfx/transform.h b/ui/gfx/transform.h deleted file mode 100644 index 76c6b3a9b..000000000 --- a/ui/gfx/transform.h +++ /dev/null @@ -1,282 +0,0 @@ -// 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 UI_GFX_TRANSFORM_H_ -#define UI_GFX_TRANSFORM_H_ - -#include -#include - -#include "base/compiler_specific.h" -#include "third_party/skia/include/core/SkMatrix44.h" -#include "ui/gfx/gfx_export.h" -#include "ui/gfx/geometry/vector2d_f.h" - -namespace gfx { - -class BoxF; -class RectF; -class Point; -class Point3F; -class Vector3dF; - -// 4x4 transformation matrix. Transform is cheap and explicitly allows -// copy/assign. -class GFX_EXPORT Transform { - public: - - enum SkipInitialization { - kSkipInitialization - }; - - Transform() : matrix_(SkMatrix44::kIdentity_Constructor) {} - - // Skips initializing this matrix to avoid overhead, when we know it will be - // initialized before use. - Transform(SkipInitialization) - : matrix_(SkMatrix44::kUninitialized_Constructor) {} - Transform(const Transform& rhs) : matrix_(rhs.matrix_) {} - // Initialize with the concatenation of lhs * rhs. - Transform(const Transform& lhs, const Transform& rhs) - : matrix_(lhs.matrix_, rhs.matrix_) {} - // Constructs a transform from explicit 16 matrix elements. Elements - // should be given in row-major order. - Transform(SkMScalar col1row1, - SkMScalar col2row1, - SkMScalar col3row1, - SkMScalar col4row1, - SkMScalar col1row2, - SkMScalar col2row2, - SkMScalar col3row2, - SkMScalar col4row2, - SkMScalar col1row3, - SkMScalar col2row3, - SkMScalar col3row3, - SkMScalar col4row3, - SkMScalar col1row4, - SkMScalar col2row4, - SkMScalar col3row4, - SkMScalar col4row4); - // Constructs a transform from explicit 2d elements. All other matrix - // elements remain the same as the corresponding elements of an identity - // matrix. - Transform(SkMScalar col1row1, - SkMScalar col2row1, - SkMScalar col1row2, - SkMScalar col2row2, - SkMScalar x_translation, - SkMScalar y_translation); - ~Transform() {} - - bool operator==(const Transform& rhs) const { return matrix_ == rhs.matrix_; } - bool operator!=(const Transform& rhs) const { return matrix_ != rhs.matrix_; } - - // Resets this transform to the identity transform. - void MakeIdentity() { matrix_.setIdentity(); } - - // Applies the current transformation on a 2d rotation and assigns the result - // to |this|. - void Rotate(double degrees) { RotateAboutZAxis(degrees); } - - // Applies the current transformation on an axis-angle rotation and assigns - // the result to |this|. - void RotateAboutXAxis(double degrees); - void RotateAboutYAxis(double degrees); - void RotateAboutZAxis(double degrees); - void RotateAbout(const Vector3dF& axis, double degrees); - - // Applies the current transformation on a scaling and assigns the result - // to |this|. - void Scale(SkMScalar x, SkMScalar y); - void Scale3d(SkMScalar x, SkMScalar y, SkMScalar z); - gfx::Vector2dF Scale2d() const { - return gfx::Vector2dF(matrix_.get(0, 0), matrix_.get(1, 1)); - } - - // Applies the current transformation on a translation and assigns the result - // to |this|. - void Translate(SkMScalar x, SkMScalar y); - void Translate3d(SkMScalar x, SkMScalar y, SkMScalar z); - - // Applies the current transformation on a skew and assigns the result - // to |this|. - void SkewX(double angle_x); - void SkewY(double angle_y); - - // Applies the current transformation on a perspective transform and assigns - // the result to |this|. - void ApplyPerspectiveDepth(SkMScalar depth); - - // Applies a transformation on the current transformation - // (i.e. 'this = this * transform;'). - void PreconcatTransform(const Transform& transform); - - // Applies a transformation on the current transformation - // (i.e. 'this = transform * this;'). - void ConcatTransform(const Transform& transform); - - // Returns true if this is the identity matrix. - bool IsIdentity() const { return matrix_.isIdentity(); } - - // Returns true if the matrix is either identity or pure translation. - bool IsIdentityOrTranslation() const { return matrix_.isTranslate(); } - - // Returns true if the matrix is either the identity or a 2d translation. - bool IsIdentityOr2DTranslation() const { - return matrix_.isTranslate() && matrix_.get(2, 3) == 0; - } - - // Returns true if the matrix is either identity or pure translation, - // allowing for an amount of inaccuracy as specified by the parameter. - bool IsApproximatelyIdentityOrTranslation(SkMScalar tolerance) const; - - // Returns true if the matrix is either a positive scale and/or a translation. - bool IsPositiveScaleOrTranslation() const { - if (!IsScaleOrTranslation()) - return false; - return matrix_.get(0, 0) > 0.0 && matrix_.get(1, 1) > 0.0 && - matrix_.get(2, 2) > 0.0; - } - - // Returns true if the matrix is either identity or pure, non-fractional - // translation. - bool IsIdentityOrIntegerTranslation() const; - - // Returns true if the matrix had only scaling components. - bool IsScale2d() const { - return !(matrix_.getType() & ~SkMatrix44::kScale_Mask); - } - - // Returns true if the matrix is has only scaling and translation components. - bool IsScaleOrTranslation() const { return matrix_.isScaleTranslate(); } - - // Returns true if axis-aligned 2d rects will remain axis-aligned after being - // transformed by this matrix. - bool Preserves2dAxisAlignment() const; - - // Returns true if the matrix has any perspective component that would - // change the w-component of a homogeneous point. - bool HasPerspective() const { return matrix_.hasPerspective(); } - - // Returns true if this transform is non-singular. - bool IsInvertible() const { return matrix_.invert(NULL); } - - // Returns true if a layer with a forward-facing normal of (0, 0, 1) would - // have its back side facing frontwards after applying the transform. - bool IsBackFaceVisible() const; - - // Inverts the transform which is passed in. Returns true if successful. - bool GetInverse(Transform* transform) const WARN_UNUSED_RESULT; - - // Transposes this transform in place. - void Transpose(); - - // Set 3rd row and 3rd colum to (0, 0, 1, 0). Note that this flattening - // operation is not quite the same as an orthographic projection and is - // technically not a linear operation. - // - // One useful interpretation of doing this operation: - // - For x and y values, the new transform behaves effectively like an - // orthographic projection was added to the matrix sequence. - // - For z values, the new transform overrides any effect that the transform - // had on z, and instead it preserves the z value for any points that are - // transformed. - // - Because of linearity of transforms, this flattened transform also - // preserves the effect that any subsequent (multiplied from the right) - // transforms would have on z values. - // - void FlattenTo2d(); - - // Returns true if the 3rd row and 3rd column are both (0, 0, 1, 0). - bool IsFlat() const; - - // Returns the x and y translation components of the matrix. - Vector2dF To2dTranslation() const; - - // Applies the transformation to the point. - void TransformPoint(Point3F* point) const; - - // Applies the transformation to the point. - void TransformPoint(Point* point) const; - - // Applies the reverse transformation on the point. Returns true if the - // transformation can be inverted. - bool TransformPointReverse(Point3F* point) const; - - // Applies the reverse transformation on the point. Returns true if the - // transformation can be inverted. Rounds the result to the nearest point. - bool TransformPointReverse(Point* point) const; - - // Applies transformation on the given rect. After the function completes, - // |rect| will be the smallest axis aligned bounding rect containing the - // transformed rect. - void TransformRect(RectF* rect) const; - - // Applies the reverse transformation on the given rect. After the function - // completes, |rect| will be the smallest axis aligned bounding rect - // containing the transformed rect. Returns false if the matrix cannot be - // inverted. - bool TransformRectReverse(RectF* rect) const; - - // Applies transformation on the given box. After the function completes, - // |box| will be the smallest axis aligned bounding box containing the - // transformed box. - void TransformBox(BoxF* box) const; - - // Applies the reverse transformation on the given box. After the function - // completes, |box| will be the smallest axis aligned bounding box - // containing the transformed box. Returns false if the matrix cannot be - // inverted. - bool TransformBoxReverse(BoxF* box) const; - - // Decomposes |this| and |from|, interpolates the decomposed values, and - // sets |this| to the reconstituted result. Returns false if either matrix - // can't be decomposed. Uses routines described in this spec: - // http://www.w3.org/TR/css3-3d-transforms/. - // - // Note: this call is expensive since we need to decompose the transform. If - // you're going to be calling this rapidly (e.g., in an animation) you should - // decompose once using gfx::DecomposeTransforms and reuse your - // DecomposedTransform. - bool Blend(const Transform& from, double progress); - - void RoundTranslationComponents(); - - // Returns |this| * |other|. - Transform operator*(const Transform& other) const { - return Transform(*this, other); - } - - // Sets |this| = |this| * |other| - Transform& operator*=(const Transform& other) { - PreconcatTransform(other); - return *this; - } - - // Returns the underlying matrix. - const SkMatrix44& matrix() const { return matrix_; } - SkMatrix44& matrix() { return matrix_; } - - std::string ToString() const; - - private: - void TransformPointInternal(const SkMatrix44& xform, - Point* point) const; - - void TransformPointInternal(const SkMatrix44& xform, - Point3F* point) const; - - SkMatrix44 matrix_; - - // copy/assign are allowed. -}; - -// This is declared here for use in gtest-based unit tests but is defined in -// the gfx_test_support target. Depend on that to use this in your unit test. -// This should not be used in production code - call ToString() instead. -void PrintTo(const Transform& transform, ::std::ostream* os); - -} // namespace gfx - -#endif // UI_GFX_TRANSFORM_H_ diff --git a/ui/gfx/transform_unittest.cc b/ui/gfx/transform_unittest.cc deleted file mode 100644 index aee6d8c6e..000000000 --- a/ui/gfx/transform_unittest.cc +++ /dev/null @@ -1,2717 +0,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. - -// MSVC++ requires this to be set before any other includes to get M_PI. -#define _USE_MATH_DEFINES - -#include "ui/gfx/transform.h" - -#include -#include -#include - -#include "base/basictypes.h" -#include "base/logging.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/gfx/box_f.h" -#include "ui/gfx/point.h" -#include "ui/gfx/point3_f.h" -#include "ui/gfx/quad_f.h" -#include "ui/gfx/transform_util.h" -#include "ui/gfx/vector3d_f.h" - -namespace gfx { - -namespace { - -#define EXPECT_ROW1_EQ(a, b, c, d, transform) \ - EXPECT_FLOAT_EQ((a), (transform).matrix().get(0, 0)); \ - EXPECT_FLOAT_EQ((b), (transform).matrix().get(0, 1)); \ - EXPECT_FLOAT_EQ((c), (transform).matrix().get(0, 2)); \ - EXPECT_FLOAT_EQ((d), (transform).matrix().get(0, 3)); - -#define EXPECT_ROW2_EQ(a, b, c, d, transform) \ - EXPECT_FLOAT_EQ((a), (transform).matrix().get(1, 0)); \ - EXPECT_FLOAT_EQ((b), (transform).matrix().get(1, 1)); \ - EXPECT_FLOAT_EQ((c), (transform).matrix().get(1, 2)); \ - EXPECT_FLOAT_EQ((d), (transform).matrix().get(1, 3)); - -#define EXPECT_ROW3_EQ(a, b, c, d, transform) \ - EXPECT_FLOAT_EQ((a), (transform).matrix().get(2, 0)); \ - EXPECT_FLOAT_EQ((b), (transform).matrix().get(2, 1)); \ - EXPECT_FLOAT_EQ((c), (transform).matrix().get(2, 2)); \ - EXPECT_FLOAT_EQ((d), (transform).matrix().get(2, 3)); - -#define EXPECT_ROW4_EQ(a, b, c, d, transform) \ - EXPECT_FLOAT_EQ((a), (transform).matrix().get(3, 0)); \ - EXPECT_FLOAT_EQ((b), (transform).matrix().get(3, 1)); \ - EXPECT_FLOAT_EQ((c), (transform).matrix().get(3, 2)); \ - EXPECT_FLOAT_EQ((d), (transform).matrix().get(3, 3)); \ - -// Checking float values for equality close to zero is not robust using -// EXPECT_FLOAT_EQ (see gtest documentation). So, to verify rotation matrices, -// we must use a looser absolute error threshold in some places. -#define EXPECT_ROW1_NEAR(a, b, c, d, transform, errorThreshold) \ - EXPECT_NEAR((a), (transform).matrix().get(0, 0), (errorThreshold)); \ - EXPECT_NEAR((b), (transform).matrix().get(0, 1), (errorThreshold)); \ - EXPECT_NEAR((c), (transform).matrix().get(0, 2), (errorThreshold)); \ - EXPECT_NEAR((d), (transform).matrix().get(0, 3), (errorThreshold)); - -#define EXPECT_ROW2_NEAR(a, b, c, d, transform, errorThreshold) \ - EXPECT_NEAR((a), (transform).matrix().get(1, 0), (errorThreshold)); \ - EXPECT_NEAR((b), (transform).matrix().get(1, 1), (errorThreshold)); \ - EXPECT_NEAR((c), (transform).matrix().get(1, 2), (errorThreshold)); \ - EXPECT_NEAR((d), (transform).matrix().get(1, 3), (errorThreshold)); - -#define EXPECT_ROW3_NEAR(a, b, c, d, transform, errorThreshold) \ - EXPECT_NEAR((a), (transform).matrix().get(2, 0), (errorThreshold)); \ - EXPECT_NEAR((b), (transform).matrix().get(2, 1), (errorThreshold)); \ - EXPECT_NEAR((c), (transform).matrix().get(2, 2), (errorThreshold)); \ - EXPECT_NEAR((d), (transform).matrix().get(2, 3), (errorThreshold)); - -bool PointsAreNearlyEqual(const Point3F& lhs, - const Point3F& rhs) { - float epsilon = 0.0001f; - return lhs.SquaredDistanceTo(rhs) < epsilon; -} - -bool MatricesAreNearlyEqual(const Transform& lhs, - const Transform& rhs) { - float epsilon = 0.0001f; - for (int row = 0; row < 4; ++row) { - for (int col = 0; col < 4; ++col) { - if (std::abs(lhs.matrix().get(row, col) - - rhs.matrix().get(row, col)) > epsilon) - return false; - } - } - return true; -} - -void InitializeTestMatrix(Transform* transform) { - SkMatrix44& matrix = transform->matrix(); - matrix.set(0, 0, 10.f); - matrix.set(1, 0, 11.f); - matrix.set(2, 0, 12.f); - matrix.set(3, 0, 13.f); - matrix.set(0, 1, 14.f); - matrix.set(1, 1, 15.f); - matrix.set(2, 1, 16.f); - matrix.set(3, 1, 17.f); - matrix.set(0, 2, 18.f); - matrix.set(1, 2, 19.f); - matrix.set(2, 2, 20.f); - matrix.set(3, 2, 21.f); - matrix.set(0, 3, 22.f); - matrix.set(1, 3, 23.f); - matrix.set(2, 3, 24.f); - matrix.set(3, 3, 25.f); - - // Sanity check - EXPECT_ROW1_EQ(10.0f, 14.0f, 18.0f, 22.0f, (*transform)); - EXPECT_ROW2_EQ(11.0f, 15.0f, 19.0f, 23.0f, (*transform)); - EXPECT_ROW3_EQ(12.0f, 16.0f, 20.0f, 24.0f, (*transform)); - EXPECT_ROW4_EQ(13.0f, 17.0f, 21.0f, 25.0f, (*transform)); -} - -void InitializeTestMatrix2(Transform* transform) { - SkMatrix44& matrix = transform->matrix(); - matrix.set(0, 0, 30.f); - matrix.set(1, 0, 31.f); - matrix.set(2, 0, 32.f); - matrix.set(3, 0, 33.f); - matrix.set(0, 1, 34.f); - matrix.set(1, 1, 35.f); - matrix.set(2, 1, 36.f); - matrix.set(3, 1, 37.f); - matrix.set(0, 2, 38.f); - matrix.set(1, 2, 39.f); - matrix.set(2, 2, 40.f); - matrix.set(3, 2, 41.f); - matrix.set(0, 3, 42.f); - matrix.set(1, 3, 43.f); - matrix.set(2, 3, 44.f); - matrix.set(3, 3, 45.f); - - // Sanity check - EXPECT_ROW1_EQ(30.0f, 34.0f, 38.0f, 42.0f, (*transform)); - EXPECT_ROW2_EQ(31.0f, 35.0f, 39.0f, 43.0f, (*transform)); - EXPECT_ROW3_EQ(32.0f, 36.0f, 40.0f, 44.0f, (*transform)); - EXPECT_ROW4_EQ(33.0f, 37.0f, 41.0f, 45.0f, (*transform)); -} - -const SkMScalar kApproxZero = - SkFloatToMScalar(std::numeric_limits::epsilon()); -const SkMScalar kApproxOne = 1 - kApproxZero; - -void InitializeApproxIdentityMatrix(Transform* transform) { - SkMatrix44& matrix = transform->matrix(); - matrix.set(0, 0, kApproxOne); - matrix.set(0, 1, kApproxZero); - matrix.set(0, 2, kApproxZero); - matrix.set(0, 3, kApproxZero); - - matrix.set(1, 0, kApproxZero); - matrix.set(1, 1, kApproxOne); - matrix.set(1, 2, kApproxZero); - matrix.set(1, 3, kApproxZero); - - matrix.set(2, 0, kApproxZero); - matrix.set(2, 1, kApproxZero); - matrix.set(2, 2, kApproxOne); - matrix.set(2, 3, kApproxZero); - - matrix.set(3, 0, kApproxZero); - matrix.set(3, 1, kApproxZero); - matrix.set(3, 2, kApproxZero); - matrix.set(3, 3, kApproxOne); -} - -#ifdef SK_MSCALAR_IS_DOUBLE -#define ERROR_THRESHOLD 1e-14 -#else -#define ERROR_THRESHOLD 1e-7 -#endif -#define LOOSE_ERROR_THRESHOLD 1e-7 - -TEST(XFormTest, Equality) { - Transform lhs, rhs, interpolated; - rhs.matrix().set3x3(1, 2, 3, - 4, 5, 6, - 7, 8, 9); - interpolated = lhs; - for (int i = 0; i <= 100; ++i) { - for (int row = 0; row < 4; ++row) { - for (int col = 0; col < 4; ++col) { - float a = lhs.matrix().get(row, col); - float b = rhs.matrix().get(row, col); - float t = i / 100.0f; - interpolated.matrix().set(row, col, a + (b - a) * t); - } - } - if (i == 100) { - EXPECT_TRUE(rhs == interpolated); - } else { - EXPECT_TRUE(rhs != interpolated); - } - } - lhs = Transform(); - rhs = Transform(); - for (int i = 1; i < 100; ++i) { - lhs.MakeIdentity(); - rhs.MakeIdentity(); - lhs.Translate(i, i); - rhs.Translate(-i, -i); - EXPECT_TRUE(lhs != rhs); - rhs.Translate(2*i, 2*i); - EXPECT_TRUE(lhs == rhs); - } -} - -TEST(XFormTest, ConcatTranslate) { - static const struct TestCase { - int x1; - int y1; - float tx; - float ty; - int x2; - int y2; - } test_cases[] = { - { 0, 0, 10.0f, 20.0f, 10, 20 }, - { 0, 0, -10.0f, -20.0f, 0, 0 }, - { 0, 0, -10.0f, -20.0f, -10, -20 }, - { 0, 0, - std::numeric_limits::quiet_NaN(), - std::numeric_limits::quiet_NaN(), - 10, 20 }, - }; - - Transform xform; - for (size_t i = 0; i < arraysize(test_cases); ++i) { - const TestCase& value = test_cases[i]; - Transform translation; - translation.Translate(value.tx, value.ty); - xform = translation * xform; - Point3F p1(value.x1, value.y1, 0); - Point3F p2(value.x2, value.y2, 0); - xform.TransformPoint(&p1); - if (value.tx == value.tx && - value.ty == value.ty) { - EXPECT_TRUE(PointsAreNearlyEqual(p1, p2)); - } - } -} - -TEST(XFormTest, ConcatScale) { - static const struct TestCase { - int before; - float scale; - int after; - } test_cases[] = { - { 1, 10.0f, 10 }, - { 1, .1f, 1 }, - { 1, 100.0f, 100 }, - { 1, -1.0f, -100 }, - { 1, std::numeric_limits::quiet_NaN(), 1 } - }; - - Transform xform; - for (size_t i = 0; i < arraysize(test_cases); ++i) { - const TestCase& value = test_cases[i]; - Transform scale; - scale.Scale(value.scale, value.scale); - xform = scale * xform; - Point3F p1(value.before, value.before, 0); - Point3F p2(value.after, value.after, 0); - xform.TransformPoint(&p1); - if (value.scale == value.scale) { - EXPECT_TRUE(PointsAreNearlyEqual(p1, p2)); - } - } -} - -TEST(XFormTest, ConcatRotate) { - static const struct TestCase { - int x1; - int y1; - float degrees; - int x2; - int y2; - } test_cases[] = { - { 1, 0, 90.0f, 0, 1 }, - { 1, 0, -90.0f, 1, 0 }, - { 1, 0, 90.0f, 0, 1 }, - { 1, 0, 360.0f, 0, 1 }, - { 1, 0, 0.0f, 0, 1 }, - { 1, 0, std::numeric_limits::quiet_NaN(), 1, 0 } - }; - - Transform xform; - for (size_t i = 0; i < arraysize(test_cases); ++i) { - const TestCase& value = test_cases[i]; - Transform rotation; - rotation.Rotate(value.degrees); - xform = rotation * xform; - Point3F p1(value.x1, value.y1, 0); - Point3F p2(value.x2, value.y2, 0); - xform.TransformPoint(&p1); - if (value.degrees == value.degrees) { - EXPECT_TRUE(PointsAreNearlyEqual(p1, p2)); - } - } -} - -TEST(XFormTest, SetTranslate) { - static const struct TestCase { - int x1; int y1; - float tx; float ty; - int x2; int y2; - } test_cases[] = { - { 0, 0, 10.0f, 20.0f, 10, 20 }, - { 10, 20, 10.0f, 20.0f, 20, 40 }, - { 10, 20, 0.0f, 0.0f, 10, 20 }, - { 0, 0, - std::numeric_limits::quiet_NaN(), - std::numeric_limits::quiet_NaN(), - 0, 0 } - }; - - for (size_t i = 0; i < arraysize(test_cases); ++i) { - const TestCase& value = test_cases[i]; - for (int k = 0; k < 3; ++k) { - Point3F p0, p1, p2; - Transform xform; - switch (k) { - case 0: - p1.SetPoint(value.x1, 0, 0); - p2.SetPoint(value.x2, 0, 0); - xform.Translate(value.tx, 0.0); - break; - case 1: - p1.SetPoint(0, value.y1, 0); - p2.SetPoint(0, value.y2, 0); - xform.Translate(0.0, value.ty); - break; - case 2: - p1.SetPoint(value.x1, value.y1, 0); - p2.SetPoint(value.x2, value.y2, 0); - xform.Translate(value.tx, value.ty); - break; - } - p0 = p1; - xform.TransformPoint(&p1); - if (value.tx == value.tx && - value.ty == value.ty) { - EXPECT_TRUE(PointsAreNearlyEqual(p1, p2)); - xform.TransformPointReverse(&p1); - EXPECT_TRUE(PointsAreNearlyEqual(p1, p0)); - } - } - } -} - -TEST(XFormTest, SetScale) { - static const struct TestCase { - int before; - float s; - int after; - } test_cases[] = { - { 1, 10.0f, 10 }, - { 1, 1.0f, 1 }, - { 1, 0.0f, 0 }, - { 0, 10.0f, 0 }, - { 1, std::numeric_limits::quiet_NaN(), 0 }, - }; - - for (size_t i = 0; i < arraysize(test_cases); ++i) { - const TestCase& value = test_cases[i]; - for (int k = 0; k < 3; ++k) { - Point3F p0, p1, p2; - Transform xform; - switch (k) { - case 0: - p1.SetPoint(value.before, 0, 0); - p2.SetPoint(value.after, 0, 0); - xform.Scale(value.s, 1.0); - break; - case 1: - p1.SetPoint(0, value.before, 0); - p2.SetPoint(0, value.after, 0); - xform.Scale(1.0, value.s); - break; - case 2: - p1.SetPoint(value.before, value.before, 0); - p2.SetPoint(value.after, value.after, 0); - xform.Scale(value.s, value.s); - break; - } - p0 = p1; - xform.TransformPoint(&p1); - if (value.s == value.s) { - EXPECT_TRUE(PointsAreNearlyEqual(p1, p2)); - if (value.s != 0.0f) { - xform.TransformPointReverse(&p1); - EXPECT_TRUE(PointsAreNearlyEqual(p1, p0)); - } - } - } - } -} - -TEST(XFormTest, SetRotate) { - static const struct SetRotateCase { - int x; - int y; - float degree; - int xprime; - int yprime; - } set_rotate_cases[] = { - { 100, 0, 90.0f, 0, 100 }, - { 0, 0, 90.0f, 0, 0 }, - { 0, 100, 90.0f, -100, 0 }, - { 0, 1, -90.0f, 1, 0 }, - { 100, 0, 0.0f, 100, 0 }, - { 0, 0, 0.0f, 0, 0 }, - { 0, 0, std::numeric_limits::quiet_NaN(), 0, 0 }, - { 100, 0, 360.0f, 100, 0 } - }; - - for (size_t i = 0; i < arraysize(set_rotate_cases); ++i) { - const SetRotateCase& value = set_rotate_cases[i]; - Point3F p0; - Point3F p1(value.x, value.y, 0); - Point3F p2(value.xprime, value.yprime, 0); - p0 = p1; - Transform xform; - xform.Rotate(value.degree); - // just want to make sure that we don't crash in the case of NaN. - if (value.degree == value.degree) { - xform.TransformPoint(&p1); - EXPECT_TRUE(PointsAreNearlyEqual(p1, p2)); - xform.TransformPointReverse(&p1); - EXPECT_TRUE(PointsAreNearlyEqual(p1, p0)); - } - } -} - -// 2D tests -TEST(XFormTest, ConcatTranslate2D) { - static const struct TestCase { - int x1; - int y1; - float tx; - float ty; - int x2; - int y2; - } test_cases[] = { - { 0, 0, 10.0f, 20.0f, 10, 20}, - { 0, 0, -10.0f, -20.0f, 0, 0}, - { 0, 0, -10.0f, -20.0f, -10, -20}, - { 0, 0, - std::numeric_limits::quiet_NaN(), - std::numeric_limits::quiet_NaN(), - 10, 20}, - }; - - Transform xform; - for (size_t i = 0; i < arraysize(test_cases); ++i) { - const TestCase& value = test_cases[i]; - Transform translation; - translation.Translate(value.tx, value.ty); - xform = translation * xform; - Point p1(value.x1, value.y1); - Point p2(value.x2, value.y2); - xform.TransformPoint(&p1); - if (value.tx == value.tx && - value.ty == value.ty) { - EXPECT_EQ(p1.x(), p2.x()); - EXPECT_EQ(p1.y(), p2.y()); - } - } -} - -TEST(XFormTest, ConcatScale2D) { - static const struct TestCase { - int before; - float scale; - int after; - } test_cases[] = { - { 1, 10.0f, 10}, - { 1, .1f, 1}, - { 1, 100.0f, 100}, - { 1, -1.0f, -100}, - { 1, std::numeric_limits::quiet_NaN(), 1} - }; - - Transform xform; - for (size_t i = 0; i < arraysize(test_cases); ++i) { - const TestCase& value = test_cases[i]; - Transform scale; - scale.Scale(value.scale, value.scale); - xform = scale * xform; - Point p1(value.before, value.before); - Point p2(value.after, value.after); - xform.TransformPoint(&p1); - if (value.scale == value.scale) { - EXPECT_EQ(p1.x(), p2.x()); - EXPECT_EQ(p1.y(), p2.y()); - } - } -} - -TEST(XFormTest, ConcatRotate2D) { - static const struct TestCase { - int x1; - int y1; - float degrees; - int x2; - int y2; - } test_cases[] = { - { 1, 0, 90.0f, 0, 1}, - { 1, 0, -90.0f, 1, 0}, - { 1, 0, 90.0f, 0, 1}, - { 1, 0, 360.0f, 0, 1}, - { 1, 0, 0.0f, 0, 1}, - { 1, 0, std::numeric_limits::quiet_NaN(), 1, 0} - }; - - Transform xform; - for (size_t i = 0; i < arraysize(test_cases); ++i) { - const TestCase& value = test_cases[i]; - Transform rotation; - rotation.Rotate(value.degrees); - xform = rotation * xform; - Point p1(value.x1, value.y1); - Point p2(value.x2, value.y2); - xform.TransformPoint(&p1); - if (value.degrees == value.degrees) { - EXPECT_EQ(p1.x(), p2.x()); - EXPECT_EQ(p1.y(), p2.y()); - } - } -} - -TEST(XFormTest, SetTranslate2D) { - static const struct TestCase { - int x1; int y1; - float tx; float ty; - int x2; int y2; - } test_cases[] = { - { 0, 0, 10.0f, 20.0f, 10, 20}, - { 10, 20, 10.0f, 20.0f, 20, 40}, - { 10, 20, 0.0f, 0.0f, 10, 20}, - { 0, 0, - std::numeric_limits::quiet_NaN(), - std::numeric_limits::quiet_NaN(), - 0, 0} - }; - - for (size_t i = 0; i < arraysize(test_cases); ++i) { - const TestCase& value = test_cases[i]; - for (int j = -1; j < 2; ++j) { - for (int k = 0; k < 3; ++k) { - float epsilon = 0.0001f; - Point p0, p1, p2; - Transform xform; - switch (k) { - case 0: - p1.SetPoint(value.x1, 0); - p2.SetPoint(value.x2, 0); - xform.Translate(value.tx + j * epsilon, 0.0); - break; - case 1: - p1.SetPoint(0, value.y1); - p2.SetPoint(0, value.y2); - xform.Translate(0.0, value.ty + j * epsilon); - break; - case 2: - p1.SetPoint(value.x1, value.y1); - p2.SetPoint(value.x2, value.y2); - xform.Translate(value.tx + j * epsilon, - value.ty + j * epsilon); - break; - } - p0 = p1; - xform.TransformPoint(&p1); - if (value.tx == value.tx && - value.ty == value.ty) { - EXPECT_EQ(p1.x(), p2.x()); - EXPECT_EQ(p1.y(), p2.y()); - xform.TransformPointReverse(&p1); - EXPECT_EQ(p1.x(), p0.x()); - EXPECT_EQ(p1.y(), p0.y()); - } - } - } - } -} - -TEST(XFormTest, SetScale2D) { - static const struct TestCase { - int before; - float s; - int after; - } test_cases[] = { - { 1, 10.0f, 10}, - { 1, 1.0f, 1}, - { 1, 0.0f, 0}, - { 0, 10.0f, 0}, - { 1, std::numeric_limits::quiet_NaN(), 0}, - }; - - for (size_t i = 0; i < arraysize(test_cases); ++i) { - const TestCase& value = test_cases[i]; - for (int j = -1; j < 2; ++j) { - for (int k = 0; k < 3; ++k) { - float epsilon = 0.0001f; - Point p0, p1, p2; - Transform xform; - switch (k) { - case 0: - p1.SetPoint(value.before, 0); - p2.SetPoint(value.after, 0); - xform.Scale(value.s + j * epsilon, 1.0); - break; - case 1: - p1.SetPoint(0, value.before); - p2.SetPoint(0, value.after); - xform.Scale(1.0, value.s + j * epsilon); - break; - case 2: - p1.SetPoint(value.before, - value.before); - p2.SetPoint(value.after, - value.after); - xform.Scale(value.s + j * epsilon, - value.s + j * epsilon); - break; - } - p0 = p1; - xform.TransformPoint(&p1); - if (value.s == value.s) { - EXPECT_EQ(p1.x(), p2.x()); - EXPECT_EQ(p1.y(), p2.y()); - if (value.s != 0.0f) { - xform.TransformPointReverse(&p1); - EXPECT_EQ(p1.x(), p0.x()); - EXPECT_EQ(p1.y(), p0.y()); - } - } - } - } - } -} - -TEST(XFormTest, SetRotate2D) { - static const struct SetRotateCase { - int x; - int y; - float degree; - int xprime; - int yprime; - } set_rotate_cases[] = { - { 100, 0, 90.0f, 0, 100}, - { 0, 0, 90.0f, 0, 0}, - { 0, 100, 90.0f, -100, 0}, - { 0, 1, -90.0f, 1, 0}, - { 100, 0, 0.0f, 100, 0}, - { 0, 0, 0.0f, 0, 0}, - { 0, 0, std::numeric_limits::quiet_NaN(), 0, 0}, - { 100, 0, 360.0f, 100, 0} - }; - - for (size_t i = 0; i < arraysize(set_rotate_cases); ++i) { - const SetRotateCase& value = set_rotate_cases[i]; - for (int j = 1; j >= -1; --j) { - float epsilon = 0.1f; - Point pt(value.x, value.y); - Transform xform; - // should be invariant to small floating point errors. - xform.Rotate(value.degree + j * epsilon); - // just want to make sure that we don't crash in the case of NaN. - if (value.degree == value.degree) { - xform.TransformPoint(&pt); - EXPECT_EQ(value.xprime, pt.x()); - EXPECT_EQ(value.yprime, pt.y()); - xform.TransformPointReverse(&pt); - EXPECT_EQ(pt.x(), value.x); - EXPECT_EQ(pt.y(), value.y); - } - } - } -} - -TEST(XFormTest, TransformPointWithExtremePerspective) { - Point3F point(1.f, 1.f, 1.f); - Transform perspective; - perspective.ApplyPerspectiveDepth(1.f); - Point3F transformed = point; - perspective.TransformPoint(&transformed); - EXPECT_EQ(point.ToString(), transformed.ToString()); - - transformed = point; - perspective.MakeIdentity(); - perspective.ApplyPerspectiveDepth(1.1f); - perspective.TransformPoint(&transformed); - EXPECT_FLOAT_EQ(11.f, transformed.x()); - EXPECT_FLOAT_EQ(11.f, transformed.y()); - EXPECT_FLOAT_EQ(11.f, transformed.z()); -} - -TEST(XFormTest, BlendTranslate) { - Transform from; - for (int i = -5; i < 15; ++i) { - Transform to; - to.Translate3d(1, 1, 1); - double t = i / 9.0; - EXPECT_TRUE(to.Blend(from, t)); - EXPECT_FLOAT_EQ(t, to.matrix().get(0, 3)); - EXPECT_FLOAT_EQ(t, to.matrix().get(1, 3)); - EXPECT_FLOAT_EQ(t, to.matrix().get(2, 3)); - } -} - -TEST(XFormTest, BlendRotate) { - Vector3dF axes[] = { - Vector3dF(1, 0, 0), - Vector3dF(0, 1, 0), - Vector3dF(0, 0, 1), - Vector3dF(1, 1, 1) - }; - Transform from; - for (size_t index = 0; index < arraysize(axes); ++index) { - for (int i = -5; i < 15; ++i) { - Transform to; - to.RotateAbout(axes[index], 90); - double t = i / 9.0; - EXPECT_TRUE(to.Blend(from, t)); - - Transform expected; - expected.RotateAbout(axes[index], 90 * t); - - EXPECT_TRUE(MatricesAreNearlyEqual(expected, to)); - } - } -} - -#if defined(_WIN64) -// http://crbug.com/406574 -#define MAYBE_BlendRotateFollowsShortestPath DISABLED_BlendRotateFollowsShortestPath -#else -#define MAYBE_BlendRotateFollowsShortestPath BlendRotateFollowsShortestPath -#endif -TEST(XFormTest, MAYBE_BlendRotateFollowsShortestPath) { - // Verify that we interpolate along the shortest path regardless of whether - // this path crosses the 180-degree point. - Vector3dF axes[] = { - Vector3dF(1, 0, 0), - Vector3dF(0, 1, 0), - Vector3dF(0, 0, 1), - Vector3dF(1, 1, 1) - }; - for (size_t index = 0; index < arraysize(axes); ++index) { - for (int i = -5; i < 15; ++i) { - Transform from1; - from1.RotateAbout(axes[index], 130.0); - Transform to1; - to1.RotateAbout(axes[index], 175.0); - - Transform from2; - from2.RotateAbout(axes[index], 140.0); - Transform to2; - to2.RotateAbout(axes[index], 185.0); - - double t = i / 9.0; - EXPECT_TRUE(to1.Blend(from1, t)); - EXPECT_TRUE(to2.Blend(from2, t)); - - Transform expected1; - expected1.RotateAbout(axes[index], 130.0 + 45.0 * t); - - Transform expected2; - expected2.RotateAbout(axes[index], 140.0 + 45.0 * t); - - EXPECT_TRUE(MatricesAreNearlyEqual(expected1, to1)); - EXPECT_TRUE(MatricesAreNearlyEqual(expected2, to2)); - } - } -} - -TEST(XFormTest, CanBlend180DegreeRotation) { - Vector3dF axes[] = { - Vector3dF(1, 0, 0), - Vector3dF(0, 1, 0), - Vector3dF(0, 0, 1), - Vector3dF(1, 1, 1) - }; - Transform from; - for (size_t index = 0; index < arraysize(axes); ++index) { - for (int i = -5; i < 15; ++i) { - Transform to; - to.RotateAbout(axes[index], 180.0); - double t = i / 9.0; - EXPECT_TRUE(to.Blend(from, t)); - - // A 180 degree rotation is exactly opposite on the sphere, therefore - // either great circle arc to it is equivalent (and numerical precision - // will determine which is closer). Test both directions. - Transform expected1; - expected1.RotateAbout(axes[index], 180.0 * t); - Transform expected2; - expected2.RotateAbout(axes[index], -180.0 * t); - - EXPECT_TRUE(MatricesAreNearlyEqual(expected1, to) || - MatricesAreNearlyEqual(expected2, to)) - << "axis: " << index << ", i: " << i; - } - } -} - -#if defined(_WIN64) -// http://crbug.com/406574 -#define MAYBE_BlendScale DISABLED_BlendScale -#else -#define MAYBE_BlendScale BlendScale -#endif -TEST(XFormTest, MAYBE_BlendScale) { - Transform from; - for (int i = -5; i < 15; ++i) { - Transform to; - to.Scale3d(5, 4, 3); - double t = i / 9.0; - EXPECT_TRUE(to.Blend(from, t)); - EXPECT_FLOAT_EQ(t * 4 + 1, to.matrix().get(0, 0)) << "i: " << i; - EXPECT_FLOAT_EQ(t * 3 + 1, to.matrix().get(1, 1)) << "i: " << i; - EXPECT_FLOAT_EQ(t * 2 + 1, to.matrix().get(2, 2)) << "i: " << i; - } -} - -TEST(XFormTest, BlendSkew) { - Transform from; - for (int i = 0; i < 2; ++i) { - Transform to; - to.SkewX(10); - to.SkewY(5); - double t = i; - Transform expected; - expected.SkewX(t * 10); - expected.SkewY(t * 5); - EXPECT_TRUE(to.Blend(from, t)); - EXPECT_TRUE(MatricesAreNearlyEqual(expected, to)); - } -} - -TEST(XFormTest, ExtrapolateSkew) { - Transform from; - for (int i = -1; i < 2; ++i) { - Transform to; - to.SkewX(20); - double t = i; - Transform expected; - expected.SkewX(t * 20); - EXPECT_TRUE(to.Blend(from, t)); - EXPECT_TRUE(MatricesAreNearlyEqual(expected, to)); - } -} - -#if defined(_WIN64) -// http://crbug.com/406574 -#define MAYBE_BlendPerspective DISABLED_BlendPerspective -#else -#define MAYBE_BlendPerspective BlendPerspective -#endif -TEST(XFormTest, MAYBE_BlendPerspective) { - Transform from; - from.ApplyPerspectiveDepth(200); - for (int i = -1; i < 3; ++i) { - Transform to; - to.ApplyPerspectiveDepth(800); - double t = i; - double depth = 1.0 / ((1.0 / 200) * (1.0 - t) + (1.0 / 800) * t); - Transform expected; - expected.ApplyPerspectiveDepth(depth); - EXPECT_TRUE(to.Blend(from, t)); - EXPECT_TRUE(MatricesAreNearlyEqual(expected, to)); - } -} - -TEST(XFormTest, BlendIdentity) { - Transform from; - Transform to; - EXPECT_TRUE(to.Blend(from, 0.5)); - EXPECT_EQ(to, from); -} - -TEST(XFormTest, CannotBlendSingularMatrix) { - Transform from; - Transform to; - to.matrix().set(1, 1, SkDoubleToMScalar(0)); - EXPECT_FALSE(to.Blend(from, 0.5)); -} - -TEST(XFormTest, VerifyBlendForTranslation) { - Transform from; - from.Translate3d(100.0, 200.0, 100.0); - - Transform to; - - to.Translate3d(200.0, 100.0, 300.0); - to.Blend(from, 0.0); - EXPECT_EQ(from, to); - - to = Transform(); - to.Translate3d(200.0, 100.0, 300.0); - to.Blend(from, 0.25); - EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 125.0f, to); - EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 175.0f, to); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 150.0f, to); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); - - to = Transform(); - to.Translate3d(200.0, 100.0, 300.0); - to.Blend(from, 0.5); - EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 150.0f, to); - EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 150.0f, to); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 200.0f, to); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); - - to = Transform(); - to.Translate3d(200.0, 100.0, 300.0); - to.Blend(from, 1.0); - EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 200.0f, to); - EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 100.0f, to); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 300.0f, to); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); -} - -TEST(XFormTest, VerifyBlendForScale) { - Transform from; - from.Scale3d(100.0, 200.0, 100.0); - - Transform to; - - to.Scale3d(200.0, 100.0, 300.0); - to.Blend(from, 0.0); - EXPECT_EQ(from, to); - - to = Transform(); - to.Scale3d(200.0, 100.0, 300.0); - to.Blend(from, 0.25); - EXPECT_ROW1_EQ(125.0f, 0.0f, 0.0f, 0.0f, to); - EXPECT_ROW2_EQ(0.0f, 175.0f, 0.0f, 0.0f, to); - EXPECT_ROW3_EQ(0.0f, 0.0f, 150.0f, 0.0f, to); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); - - to = Transform(); - to.Scale3d(200.0, 100.0, 300.0); - to.Blend(from, 0.5); - EXPECT_ROW1_EQ(150.0f, 0.0f, 0.0f, 0.0f, to); - EXPECT_ROW2_EQ(0.0f, 150.0f, 0.0f, 0.0f, to); - EXPECT_ROW3_EQ(0.0f, 0.0f, 200.0f, 0.0f, to); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); - - to = Transform(); - to.Scale3d(200.0, 100.0, 300.0); - to.Blend(from, 1.0); - EXPECT_ROW1_EQ(200.0f, 0.0f, 0.0f, 0.0f, to); - EXPECT_ROW2_EQ(0.0f, 100.0f, 0.0f, 0.0f, to); - EXPECT_ROW3_EQ(0.0f, 0.0f, 300.0f, 0.0f, to); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); -} - -TEST(XFormTest, VerifyBlendForSkewX) { - Transform from; - from.SkewX(0.0); - - Transform to; - - to.SkewX(45.0); - to.Blend(from, 0.0); - EXPECT_EQ(from, to); - - to = Transform(); - to.SkewX(45.0); - to.Blend(from, 0.5); - EXPECT_ROW1_EQ(1.0f, 0.5f, 0.0f, 0.0f, to); - EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); - - to = Transform(); - to.SkewX(45.0); - to.Blend(from, 0.25); - EXPECT_ROW1_EQ(1.0f, 0.25f, 0.0f, 0.0f, to); - EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); - - to = Transform(); - to.SkewX(45.0); - to.Blend(from, 1.0); - EXPECT_ROW1_EQ(1.0f, 1.0f, 0.0f, 0.0f, to); - EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); -} - -TEST(XFormTest, VerifyBlendForSkewY) { - // NOTE CAREFULLY: Decomposition of skew and rotation terms of the matrix - // is inherently underconstrained, and so it does not always compute the - // originally intended skew parameters. The current implementation uses QR - // decomposition, which decomposes the shear into a rotation + non-uniform - // scale. - // - // It is unlikely that the decomposition implementation will need to change - // very often, so to get any test coverage, the compromise is to verify the - // exact matrix that the.Blend() operation produces. - // - // This problem also potentially exists for skewX, but the current QR - // decomposition implementation just happens to decompose those test - // matrices intuitively. - // - // Unfortunately, this case suffers from uncomfortably large precision - // error. - - Transform from; - from.SkewY(0.0); - - Transform to; - - to.SkewY(45.0); - to.Blend(from, 0.0); - EXPECT_EQ(from, to); - - to = Transform(); - to.SkewY(45.0); - to.Blend(from, 0.25); - EXPECT_ROW1_NEAR(1.0823489449280947471976333, - 0.0464370719145053845178239, - 0.0, - 0.0, - to, - LOOSE_ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(0.2152925909665224513123150, - 0.9541702441750861130032035, - 0.0, - 0.0, - to, - LOOSE_ERROR_THRESHOLD); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); - - to = Transform(); - to.SkewY(45.0); - to.Blend(from, 0.5); - EXPECT_ROW1_NEAR(1.1152212925809066312865525, - 0.0676495144007326631996335, - 0.0, - 0.0, - to, - LOOSE_ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(0.4619397844342648662419037, - 0.9519009045724774464858342, - 0.0, - 0.0, - to, - LOOSE_ERROR_THRESHOLD); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); - - to = Transform(); - to.SkewY(45.0); - to.Blend(from, 1.0); - EXPECT_ROW1_NEAR(1.0, 0.0, 0.0, 0.0, to, LOOSE_ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(1.0, 1.0, 0.0, 0.0, to, LOOSE_ERROR_THRESHOLD); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); -} - -#if defined(_WIN64) -// http://crbug.com/406574 -#define MAYBE_VerifyBlendForRotationAboutX DISABLED_VerifyBlendForRotationAboutX -#else -#define MAYBE_VerifyBlendForRotationAboutX VerifyBlendForRotationAboutX -#endif -TEST(XFormTest, MAYBE_VerifyBlendForRotationAboutX) { - // Even though.Blending uses quaternions, axis-aligned rotations should. - // Blend the same with quaternions or Euler angles. So we can test - // rotation.Blending by comparing against manually specified matrices from - // Euler angles. - - Transform from; - from.RotateAbout(Vector3dF(1.0, 0.0, 0.0), 0.0); - - Transform to; - - to.RotateAbout(Vector3dF(1.0, 0.0, 0.0), 90.0); - to.Blend(from, 0.0); - EXPECT_EQ(from, to); - - double expectedRotationAngle = 22.5 * M_PI / 180.0; - to = Transform(); - to.RotateAbout(Vector3dF(1.0, 0.0, 0.0), 90.0); - to.Blend(from, 0.25); - EXPECT_ROW1_NEAR(1.0, 0.0, 0.0, 0.0, to, ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(0.0, - std::cos(expectedRotationAngle), - -std::sin(expectedRotationAngle), - 0.0, - to, - ERROR_THRESHOLD); - EXPECT_ROW3_NEAR(0.0, - std::sin(expectedRotationAngle), - std::cos(expectedRotationAngle), - 0.0, - to, - ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); - - expectedRotationAngle = 45.0 * M_PI / 180.0; - to = Transform(); - to.RotateAbout(Vector3dF(1.0, 0.0, 0.0), 90.0); - to.Blend(from, 0.5); - EXPECT_ROW1_NEAR(1.0, 0.0, 0.0, 0.0, to, ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(0.0, - std::cos(expectedRotationAngle), - -std::sin(expectedRotationAngle), - 0.0, - to, - ERROR_THRESHOLD); - EXPECT_ROW3_NEAR(0.0, - std::sin(expectedRotationAngle), - std::cos(expectedRotationAngle), - 0.0, - to, - ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); - - to = Transform(); - to.RotateAbout(Vector3dF(1.0, 0.0, 0.0), 90.0); - to.Blend(from, 1.0); - EXPECT_ROW1_NEAR(1.0, 0.0, 0.0, 0.0, to, ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(0.0, 0.0, -1.0, 0.0, to, ERROR_THRESHOLD); - EXPECT_ROW3_NEAR(0.0, 1.0, 0.0, 0.0, to, ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); -} - -#if defined(_WIN64) -// http://crbug.com/406574 -#define MAYBE_VerifyBlendForRotationAboutY DISABLED_VerifyBlendForRotationAboutY -#else -#define MAYBE_VerifyBlendForRotationAboutY VerifyBlendForRotationAboutY -#endif -TEST(XFormTest, MAYBE_VerifyBlendForRotationAboutY) { - Transform from; - from.RotateAbout(Vector3dF(0.0, 1.0, 0.0), 0.0); - - Transform to; - - to.RotateAbout(Vector3dF(0.0, 1.0, 0.0), 90.0); - to.Blend(from, 0.0); - EXPECT_EQ(from, to); - - double expectedRotationAngle = 22.5 * M_PI / 180.0; - to = Transform(); - to.RotateAbout(Vector3dF(0.0, 1.0, 0.0), 90.0); - to.Blend(from, 0.25); - EXPECT_ROW1_NEAR(std::cos(expectedRotationAngle), - 0.0, - std::sin(expectedRotationAngle), - 0.0, - to, - ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(0.0, 1.0, 0.0, 0.0, to, ERROR_THRESHOLD); - EXPECT_ROW3_NEAR(-std::sin(expectedRotationAngle), - 0.0, - std::cos(expectedRotationAngle), - 0.0, - to, - ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); - - expectedRotationAngle = 45.0 * M_PI / 180.0; - to = Transform(); - to.RotateAbout(Vector3dF(0.0, 1.0, 0.0), 90.0); - to.Blend(from, 0.5); - EXPECT_ROW1_NEAR(std::cos(expectedRotationAngle), - 0.0, - std::sin(expectedRotationAngle), - 0.0, - to, - ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(0.0, 1.0, 0.0, 0.0, to, ERROR_THRESHOLD); - EXPECT_ROW3_NEAR(-std::sin(expectedRotationAngle), - 0.0, - std::cos(expectedRotationAngle), - 0.0, - to, - ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); - - to = Transform(); - to.RotateAbout(Vector3dF(0.0, 1.0, 0.0), 90.0); - to.Blend(from, 1.0); - EXPECT_ROW1_NEAR(0.0, 0.0, 1.0, 0.0, to, ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(0.0, 1.0, 0.0, 0.0, to, ERROR_THRESHOLD); - EXPECT_ROW3_NEAR(-1.0, 0.0, 0.0, 0.0, to, ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); -} - -#if defined(_WIN64) -// http://crbug.com/406574 -#define MAYBE_VerifyBlendForRotationAboutZ DISABLED_VerifyBlendForRotationAboutZ -#else -#define MAYBE_VerifyBlendForRotationAboutZ VerifyBlendForRotationAboutZ -#endif -TEST(XFormTest, MAYBE_VerifyBlendForRotationAboutZ) { - Transform from; - from.RotateAbout(Vector3dF(0.0, 0.0, 1.0), 0.0); - - Transform to; - - to.RotateAbout(Vector3dF(0.0, 0.0, 1.0), 90.0); - to.Blend(from, 0.0); - EXPECT_EQ(from, to); - - double expectedRotationAngle = 22.5 * M_PI / 180.0; - to = Transform(); - to.RotateAbout(Vector3dF(0.0, 0.0, 1.0), 90.0); - to.Blend(from, 0.25); - EXPECT_ROW1_NEAR(std::cos(expectedRotationAngle), - -std::sin(expectedRotationAngle), - 0.0, - 0.0, - to, - ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(std::sin(expectedRotationAngle), - std::cos(expectedRotationAngle), - 0.0, - 0.0, - to, - ERROR_THRESHOLD); - EXPECT_ROW3_NEAR(0.0, 0.0, 1.0, 0.0, to, ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); - - expectedRotationAngle = 45.0 * M_PI / 180.0; - to = Transform(); - to.RotateAbout(Vector3dF(0.0, 0.0, 1.0), 90.0); - to.Blend(from, 0.5); - EXPECT_ROW1_NEAR(std::cos(expectedRotationAngle), - -std::sin(expectedRotationAngle), - 0.0, - 0.0, - to, - ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(std::sin(expectedRotationAngle), - std::cos(expectedRotationAngle), - 0.0, - 0.0, - to, - ERROR_THRESHOLD); - EXPECT_ROW3_NEAR(0.0, 0.0, 1.0, 0.0, to, ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); - - to = Transform(); - to.RotateAbout(Vector3dF(0.0, 0.0, 1.0), 90.0); - to.Blend(from, 1.0); - EXPECT_ROW1_NEAR(0.0, -1.0, 0.0, 0.0, to, ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(1.0, 0.0, 0.0, 0.0, to, ERROR_THRESHOLD); - EXPECT_ROW3_NEAR(0.0, 0.0, 1.0, 0.0, to, ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); -} - -TEST(XFormTest, VerifyBlendForCompositeTransform) { - // Verify that the.Blending was done with a decomposition in correct order - // by blending a composite transform. Using matrix x vector notation - // (Ax = b, where x is column vector), the ordering should be: - // perspective * translation * rotation * skew * scale - // - // It is not as important (or meaningful) to check intermediate - // interpolations; order of operations will be tested well enough by the - // end cases that are easier to specify. - - Transform from; - Transform to; - - Transform expectedEndOfAnimation; - expectedEndOfAnimation.ApplyPerspectiveDepth(1.0); - expectedEndOfAnimation.Translate3d(10.0, 20.0, 30.0); - expectedEndOfAnimation.RotateAbout(Vector3dF(0.0, 0.0, 1.0), 25.0); - expectedEndOfAnimation.SkewY(45.0); - expectedEndOfAnimation.Scale3d(6.0, 7.0, 8.0); - - to = expectedEndOfAnimation; - to.Blend(from, 0.0); - EXPECT_EQ(from, to); - - to = expectedEndOfAnimation; - // We short circuit if blend is >= 1, so to check the numerics, we will - // check that we get close to what we expect when we're nearly done - // interpolating. - to.Blend(from, .99999f); - - // Recomposing the matrix results in a normalized matrix, so to verify we - // need to normalize the expectedEndOfAnimation before comparing elements. - // Normalizing means dividing everything by expectedEndOfAnimation.m44(). - Transform normalizedExpectedEndOfAnimation = expectedEndOfAnimation; - Transform normalizationMatrix; - normalizationMatrix.matrix().set( - 0.0, - 0.0, - SkDoubleToMScalar(1 / expectedEndOfAnimation.matrix().get(3.0, 3.0))); - normalizationMatrix.matrix().set( - 1.0, - 1.0, - SkDoubleToMScalar(1 / expectedEndOfAnimation.matrix().get(3.0, 3.0))); - normalizationMatrix.matrix().set( - 2.0, - 2.0, - SkDoubleToMScalar(1 / expectedEndOfAnimation.matrix().get(3.0, 3.0))); - normalizationMatrix.matrix().set( - 3.0, - 3.0, - SkDoubleToMScalar(1 / expectedEndOfAnimation.matrix().get(3.0, 3.0))); - normalizedExpectedEndOfAnimation.PreconcatTransform(normalizationMatrix); - - EXPECT_TRUE(MatricesAreNearlyEqual(normalizedExpectedEndOfAnimation, to)); -} - -TEST(XFormTest, DecomposedTransformCtor) { - DecomposedTransform decomp; - for (int i = 0; i < 3; ++i) { - EXPECT_EQ(0.0, decomp.translate[i]); - EXPECT_EQ(1.0, decomp.scale[i]); - EXPECT_EQ(0.0, decomp.skew[i]); - EXPECT_EQ(0.0, decomp.quaternion[i]); - EXPECT_EQ(0.0, decomp.perspective[i]); - } - EXPECT_EQ(1.0, decomp.quaternion[3]); - EXPECT_EQ(1.0, decomp.perspective[3]); - Transform identity; - Transform composed = ComposeTransform(decomp); - EXPECT_TRUE(MatricesAreNearlyEqual(identity, composed)); -} - -TEST(XFormTest, FactorTRS) { - for (int degrees = 0; degrees < 180; ++degrees) { - // build a transformation matrix. - gfx::Transform transform; - transform.Translate(degrees * 2, -degrees * 3); - transform.Rotate(degrees); - transform.Scale(degrees + 1, 2 * degrees + 1); - - // factor the matrix - DecomposedTransform decomp; - bool success = DecomposeTransform(&decomp, transform); - EXPECT_TRUE(success); - EXPECT_FLOAT_EQ(decomp.translate[0], degrees * 2); - EXPECT_FLOAT_EQ(decomp.translate[1], -degrees * 3); - double rotation = - std::acos(SkMScalarToDouble(decomp.quaternion[3])) * 360.0 / M_PI; - while (rotation < 0.0) - rotation += 360.0; - while (rotation > 360.0) - rotation -= 360.0; - - const float epsilon = 0.00015f; - EXPECT_NEAR(rotation, degrees, epsilon); - EXPECT_NEAR(decomp.scale[0], degrees + 1, epsilon); - EXPECT_NEAR(decomp.scale[1], 2 * degrees + 1, epsilon); - } -} - -TEST(XFormTest, IntegerTranslation) { - gfx::Transform transform; - EXPECT_TRUE(transform.IsIdentityOrIntegerTranslation()); - - transform.Translate3d(1, 2, 3); - EXPECT_TRUE(transform.IsIdentityOrIntegerTranslation()); - - transform.MakeIdentity(); - transform.Translate3d(-1, -2, -3); - EXPECT_TRUE(transform.IsIdentityOrIntegerTranslation()); - - transform.MakeIdentity(); - transform.Translate3d(4.5f, 0, 0); - EXPECT_FALSE(transform.IsIdentityOrIntegerTranslation()); - - transform.MakeIdentity(); - transform.Translate3d(0, -6.7f, 0); - EXPECT_FALSE(transform.IsIdentityOrIntegerTranslation()); - - transform.MakeIdentity(); - transform.Translate3d(0, 0, 8.9f); - EXPECT_FALSE(transform.IsIdentityOrIntegerTranslation()); -} - -TEST(XFormTest, verifyMatrixInversion) { - { - // Invert a translation - gfx::Transform translation; - translation.Translate3d(2.0, 3.0, 4.0); - EXPECT_TRUE(translation.IsInvertible()); - - gfx::Transform inverse_translation; - bool is_invertible = translation.GetInverse(&inverse_translation); - EXPECT_TRUE(is_invertible); - EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, -2.0f, inverse_translation); - EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, -3.0f, inverse_translation); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, -4.0f, inverse_translation); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, inverse_translation); - } - - { - // Invert a non-uniform scale - gfx::Transform scale; - scale.Scale3d(4.0, 10.0, 100.0); - EXPECT_TRUE(scale.IsInvertible()); - - gfx::Transform inverse_scale; - bool is_invertible = scale.GetInverse(&inverse_scale); - EXPECT_TRUE(is_invertible); - EXPECT_ROW1_EQ(0.25f, 0.0f, 0.0f, 0.0f, inverse_scale); - EXPECT_ROW2_EQ(0.0f, 0.1f, 0.0f, 0.0f, inverse_scale); - EXPECT_ROW3_EQ(0.0f, 0.0f, 0.01f, 0.0f, inverse_scale); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, inverse_scale); - } - - { - // Try to invert a matrix that is not invertible. - // The inverse() function should reset the output matrix to identity. - gfx::Transform uninvertible; - uninvertible.matrix().set(0, 0, 0.f); - uninvertible.matrix().set(1, 1, 0.f); - uninvertible.matrix().set(2, 2, 0.f); - uninvertible.matrix().set(3, 3, 0.f); - EXPECT_FALSE(uninvertible.IsInvertible()); - - gfx::Transform inverse_of_uninvertible; - - // Add a scale just to more easily ensure that inverse_of_uninvertible is - // reset to identity. - inverse_of_uninvertible.Scale3d(4.0, 10.0, 100.0); - - bool is_invertible = uninvertible.GetInverse(&inverse_of_uninvertible); - EXPECT_FALSE(is_invertible); - EXPECT_TRUE(inverse_of_uninvertible.IsIdentity()); - EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 0.0f, inverse_of_uninvertible); - EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, inverse_of_uninvertible); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, inverse_of_uninvertible); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, inverse_of_uninvertible); - } -} - -TEST(XFormTest, verifyBackfaceVisibilityBasicCases) { - Transform transform; - - transform.MakeIdentity(); - EXPECT_FALSE(transform.IsBackFaceVisible()); - - transform.MakeIdentity(); - transform.RotateAboutYAxis(80.0); - EXPECT_FALSE(transform.IsBackFaceVisible()); - - transform.MakeIdentity(); - transform.RotateAboutYAxis(100.0); - EXPECT_TRUE(transform.IsBackFaceVisible()); - - // Edge case, 90 degree rotation should return false. - transform.MakeIdentity(); - transform.RotateAboutYAxis(90.0); - EXPECT_FALSE(transform.IsBackFaceVisible()); -} - -TEST(XFormTest, verifyBackfaceVisibilityForPerspective) { - Transform layer_space_to_projection_plane; - - // This tests if IsBackFaceVisible works properly under perspective - // transforms. Specifically, layers that may have their back face visible in - // orthographic projection, may not actually have back face visible under - // perspective projection. - - // Case 1: Layer is rotated by slightly more than 90 degrees, at the center - // of the prespective projection. In this case, the layer's back-side - // is visible to the camera. - layer_space_to_projection_plane.MakeIdentity(); - layer_space_to_projection_plane.ApplyPerspectiveDepth(1.0); - layer_space_to_projection_plane.Translate3d(0.0, 0.0, 0.0); - layer_space_to_projection_plane.RotateAboutYAxis(100.0); - EXPECT_TRUE(layer_space_to_projection_plane.IsBackFaceVisible()); - - // Case 2: Layer is rotated by slightly more than 90 degrees, but shifted off - // to the side of the camera. Because of the wide field-of-view, the - // layer's front side is still visible. - // - // |<-- front side of layer is visible to camera - // \ | / - // \ | / - // \| / - // | / - // |\ /<-- camera field of view - // | \ / - // back side of layer -->| \ / - // \./ <-- camera origin - // - layer_space_to_projection_plane.MakeIdentity(); - layer_space_to_projection_plane.ApplyPerspectiveDepth(1.0); - layer_space_to_projection_plane.Translate3d(-10.0, 0.0, 0.0); - layer_space_to_projection_plane.RotateAboutYAxis(100.0); - EXPECT_FALSE(layer_space_to_projection_plane.IsBackFaceVisible()); - - // Case 3: Additionally rotating the layer by 180 degrees should of course - // show the opposite result of case 2. - layer_space_to_projection_plane.RotateAboutYAxis(180.0); - EXPECT_TRUE(layer_space_to_projection_plane.IsBackFaceVisible()); -} - -TEST(XFormTest, verifyDefaultConstructorCreatesIdentityMatrix) { - Transform A; - EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 0.0f, A); - EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, A); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - EXPECT_TRUE(A.IsIdentity()); -} - -TEST(XFormTest, verifyCopyConstructor) { - Transform A; - InitializeTestMatrix(&A); - - // Copy constructor should produce exact same elements as matrix A. - Transform B(A); - EXPECT_ROW1_EQ(10.0f, 14.0f, 18.0f, 22.0f, B); - EXPECT_ROW2_EQ(11.0f, 15.0f, 19.0f, 23.0f, B); - EXPECT_ROW3_EQ(12.0f, 16.0f, 20.0f, 24.0f, B); - EXPECT_ROW4_EQ(13.0f, 17.0f, 21.0f, 25.0f, B); -} - -TEST(XFormTest, verifyConstructorFor16Elements) { - Transform transform(1.0, 2.0, 3.0, 4.0, - 5.0, 6.0, 7.0, 8.0, - 9.0, 10.0, 11.0, 12.0, - 13.0, 14.0, 15.0, 16.0); - - EXPECT_ROW1_EQ(1.0f, 2.0f, 3.0f, 4.0f, transform); - EXPECT_ROW2_EQ(5.0f, 6.0f, 7.0f, 8.0f, transform); - EXPECT_ROW3_EQ(9.0f, 10.0f, 11.0f, 12.0f, transform); - EXPECT_ROW4_EQ(13.0f, 14.0f, 15.0f, 16.0f, transform); -} - -TEST(XFormTest, verifyConstructorFor2dElements) { - Transform transform(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); - - EXPECT_ROW1_EQ(1.0f, 2.0f, 0.0f, 5.0f, transform); - EXPECT_ROW2_EQ(3.0f, 4.0f, 0.0f, 6.0f, transform); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, transform); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, transform); -} - - -TEST(XFormTest, verifyAssignmentOperator) { - Transform A; - InitializeTestMatrix(&A); - Transform B; - InitializeTestMatrix2(&B); - Transform C; - InitializeTestMatrix2(&C); - C = B = A; - - // Both B and C should now have been re-assigned to the value of A. - EXPECT_ROW1_EQ(10.0f, 14.0f, 18.0f, 22.0f, B); - EXPECT_ROW2_EQ(11.0f, 15.0f, 19.0f, 23.0f, B); - EXPECT_ROW3_EQ(12.0f, 16.0f, 20.0f, 24.0f, B); - EXPECT_ROW4_EQ(13.0f, 17.0f, 21.0f, 25.0f, B); - - EXPECT_ROW1_EQ(10.0f, 14.0f, 18.0f, 22.0f, C); - EXPECT_ROW2_EQ(11.0f, 15.0f, 19.0f, 23.0f, C); - EXPECT_ROW3_EQ(12.0f, 16.0f, 20.0f, 24.0f, C); - EXPECT_ROW4_EQ(13.0f, 17.0f, 21.0f, 25.0f, C); -} - -TEST(XFormTest, verifyEqualsBooleanOperator) { - Transform A; - InitializeTestMatrix(&A); - - Transform B; - InitializeTestMatrix(&B); - EXPECT_TRUE(A == B); - - // Modifying multiple elements should cause equals operator to return false. - Transform C; - InitializeTestMatrix2(&C); - EXPECT_FALSE(A == C); - - // Modifying any one individual element should cause equals operator to - // return false. - Transform D; - D = A; - D.matrix().set(0, 0, 0.f); - EXPECT_FALSE(A == D); - - D = A; - D.matrix().set(1, 0, 0.f); - EXPECT_FALSE(A == D); - - D = A; - D.matrix().set(2, 0, 0.f); - EXPECT_FALSE(A == D); - - D = A; - D.matrix().set(3, 0, 0.f); - EXPECT_FALSE(A == D); - - D = A; - D.matrix().set(0, 1, 0.f); - EXPECT_FALSE(A == D); - - D = A; - D.matrix().set(1, 1, 0.f); - EXPECT_FALSE(A == D); - - D = A; - D.matrix().set(2, 1, 0.f); - EXPECT_FALSE(A == D); - - D = A; - D.matrix().set(3, 1, 0.f); - EXPECT_FALSE(A == D); - - D = A; - D.matrix().set(0, 2, 0.f); - EXPECT_FALSE(A == D); - - D = A; - D.matrix().set(1, 2, 0.f); - EXPECT_FALSE(A == D); - - D = A; - D.matrix().set(2, 2, 0.f); - EXPECT_FALSE(A == D); - - D = A; - D.matrix().set(3, 2, 0.f); - EXPECT_FALSE(A == D); - - D = A; - D.matrix().set(0, 3, 0.f); - EXPECT_FALSE(A == D); - - D = A; - D.matrix().set(1, 3, 0.f); - EXPECT_FALSE(A == D); - - D = A; - D.matrix().set(2, 3, 0.f); - EXPECT_FALSE(A == D); - - D = A; - D.matrix().set(3, 3, 0.f); - EXPECT_FALSE(A == D); -} - -TEST(XFormTest, verifyMultiplyOperator) { - Transform A; - InitializeTestMatrix(&A); - - Transform B; - InitializeTestMatrix2(&B); - - Transform C = A * B; - EXPECT_ROW1_EQ(2036.0f, 2292.0f, 2548.0f, 2804.0f, C); - EXPECT_ROW2_EQ(2162.0f, 2434.0f, 2706.0f, 2978.0f, C); - EXPECT_ROW3_EQ(2288.0f, 2576.0f, 2864.0f, 3152.0f, C); - EXPECT_ROW4_EQ(2414.0f, 2718.0f, 3022.0f, 3326.0f, C); - - // Just an additional sanity check; matrix multiplication is not commutative. - EXPECT_FALSE(A * B == B * A); -} - -TEST(XFormTest, verifyMultiplyAndAssignOperator) { - Transform A; - InitializeTestMatrix(&A); - - Transform B; - InitializeTestMatrix2(&B); - - A *= B; - EXPECT_ROW1_EQ(2036.0f, 2292.0f, 2548.0f, 2804.0f, A); - EXPECT_ROW2_EQ(2162.0f, 2434.0f, 2706.0f, 2978.0f, A); - EXPECT_ROW3_EQ(2288.0f, 2576.0f, 2864.0f, 3152.0f, A); - EXPECT_ROW4_EQ(2414.0f, 2718.0f, 3022.0f, 3326.0f, A); - - // Just an additional sanity check; matrix multiplication is not commutative. - Transform C = A; - C *= B; - Transform D = B; - D *= A; - EXPECT_FALSE(C == D); -} - -TEST(XFormTest, verifyMatrixMultiplication) { - Transform A; - InitializeTestMatrix(&A); - - Transform B; - InitializeTestMatrix2(&B); - - A.PreconcatTransform(B); - EXPECT_ROW1_EQ(2036.0f, 2292.0f, 2548.0f, 2804.0f, A); - EXPECT_ROW2_EQ(2162.0f, 2434.0f, 2706.0f, 2978.0f, A); - EXPECT_ROW3_EQ(2288.0f, 2576.0f, 2864.0f, 3152.0f, A); - EXPECT_ROW4_EQ(2414.0f, 2718.0f, 3022.0f, 3326.0f, A); -} - -TEST(XFormTest, verifyMakeIdentiy) { - Transform A; - InitializeTestMatrix(&A); - A.MakeIdentity(); - EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 0.0f, A); - EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, A); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - EXPECT_TRUE(A.IsIdentity()); -} - -TEST(XFormTest, verifyTranslate) { - Transform A; - A.Translate(2.0, 3.0); - EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 2.0f, A); - EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 3.0f, A); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - - // Verify that Translate() post-multiplies the existing matrix. - A.MakeIdentity(); - A.Scale(5.0, 5.0); - A.Translate(2.0, 3.0); - EXPECT_ROW1_EQ(5.0f, 0.0f, 0.0f, 10.0f, A); - EXPECT_ROW2_EQ(0.0f, 5.0f, 0.0f, 15.0f, A); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); -} - -TEST(XFormTest, verifyTranslate3d) { - Transform A; - A.Translate3d(2.0, 3.0, 4.0); - EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 2.0f, A); - EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 3.0f, A); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 4.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - - // Verify that Translate3d() post-multiplies the existing matrix. - A.MakeIdentity(); - A.Scale3d(6.0, 7.0, 8.0); - A.Translate3d(2.0, 3.0, 4.0); - EXPECT_ROW1_EQ(6.0f, 0.0f, 0.0f, 12.0f, A); - EXPECT_ROW2_EQ(0.0f, 7.0f, 0.0f, 21.0f, A); - EXPECT_ROW3_EQ(0.0f, 0.0f, 8.0f, 32.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); -} - -TEST(XFormTest, verifyScale) { - Transform A; - A.Scale(6.0, 7.0); - EXPECT_ROW1_EQ(6.0f, 0.0f, 0.0f, 0.0f, A); - EXPECT_ROW2_EQ(0.0f, 7.0f, 0.0f, 0.0f, A); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - - // Verify that Scale() post-multiplies the existing matrix. - A.MakeIdentity(); - A.Translate3d(2.0, 3.0, 4.0); - A.Scale(6.0, 7.0); - EXPECT_ROW1_EQ(6.0f, 0.0f, 0.0f, 2.0f, A); - EXPECT_ROW2_EQ(0.0f, 7.0f, 0.0f, 3.0f, A); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 4.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); -} - -TEST(XFormTest, verifyScale3d) { - Transform A; - A.Scale3d(6.0, 7.0, 8.0); - EXPECT_ROW1_EQ(6.0f, 0.0f, 0.0f, 0.0f, A); - EXPECT_ROW2_EQ(0.0f, 7.0f, 0.0f, 0.0f, A); - EXPECT_ROW3_EQ(0.0f, 0.0f, 8.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - - // Verify that scale3d() post-multiplies the existing matrix. - A.MakeIdentity(); - A.Translate3d(2.0, 3.0, 4.0); - A.Scale3d(6.0, 7.0, 8.0); - EXPECT_ROW1_EQ(6.0f, 0.0f, 0.0f, 2.0f, A); - EXPECT_ROW2_EQ(0.0f, 7.0f, 0.0f, 3.0f, A); - EXPECT_ROW3_EQ(0.0f, 0.0f, 8.0f, 4.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); -} - -TEST(XFormTest, verifyRotate) { - Transform A; - A.Rotate(90.0); - EXPECT_ROW1_NEAR(0.0, -1.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(1.0, 0.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - - // Verify that Rotate() post-multiplies the existing matrix. - A.MakeIdentity(); - A.Scale3d(6.0, 7.0, 8.0); - A.Rotate(90.0); - EXPECT_ROW1_NEAR(0.0, -6.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(7.0, 0.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW3_EQ(0.0f, 0.0f, 8.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); -} - -TEST(XFormTest, verifyRotateAboutXAxis) { - Transform A; - double sin45 = 0.5 * sqrt(2.0); - double cos45 = sin45; - - A.MakeIdentity(); - A.RotateAboutXAxis(90.0); - EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 0.0f, A); - EXPECT_ROW2_NEAR(0.0, 0.0, -1.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW3_NEAR(0.0, 1.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - - A.MakeIdentity(); - A.RotateAboutXAxis(45.0); - EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 0.0f, A); - EXPECT_ROW2_NEAR(0.0, cos45, -sin45, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW3_NEAR(0.0, sin45, cos45, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - - // Verify that RotateAboutXAxis(angle) post-multiplies the existing matrix. - A.MakeIdentity(); - A.Scale3d(6.0, 7.0, 8.0); - A.RotateAboutXAxis(90.0); - EXPECT_ROW1_NEAR(6.0, 0.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(0.0, 0.0, -7.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW3_NEAR(0.0, 8.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); -} - -TEST(XFormTest, verifyRotateAboutYAxis) { - Transform A; - double sin45 = 0.5 * sqrt(2.0); - double cos45 = sin45; - - // Note carefully, the expected pattern is inverted compared to rotating - // about x axis or z axis. - A.MakeIdentity(); - A.RotateAboutYAxis(90.0); - EXPECT_ROW1_NEAR(0.0, 0.0, 1.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, A); - EXPECT_ROW3_NEAR(-1.0, 0.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - - A.MakeIdentity(); - A.RotateAboutYAxis(45.0); - EXPECT_ROW1_NEAR(cos45, 0.0, sin45, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, A); - EXPECT_ROW3_NEAR(-sin45, 0.0, cos45, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - - // Verify that RotateAboutYAxis(angle) post-multiplies the existing matrix. - A.MakeIdentity(); - A.Scale3d(6.0, 7.0, 8.0); - A.RotateAboutYAxis(90.0); - EXPECT_ROW1_NEAR(0.0, 0.0, 6.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(0.0, 7.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW3_NEAR(-8.0, 0.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); -} - -TEST(XFormTest, verifyRotateAboutZAxis) { - Transform A; - double sin45 = 0.5 * sqrt(2.0); - double cos45 = sin45; - - A.MakeIdentity(); - A.RotateAboutZAxis(90.0); - EXPECT_ROW1_NEAR(0.0, -1.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(1.0, 0.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - - A.MakeIdentity(); - A.RotateAboutZAxis(45.0); - EXPECT_ROW1_NEAR(cos45, -sin45, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(sin45, cos45, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - - // Verify that RotateAboutZAxis(angle) post-multiplies the existing matrix. - A.MakeIdentity(); - A.Scale3d(6.0, 7.0, 8.0); - A.RotateAboutZAxis(90.0); - EXPECT_ROW1_NEAR(0.0, -6.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(7.0, 0.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW3_EQ(0.0f, 0.0f, 8.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); -} - -TEST(XFormTest, verifyRotateAboutForAlignedAxes) { - Transform A; - - // Check rotation about z-axis - A.MakeIdentity(); - A.RotateAbout(Vector3dF(0.0, 0.0, 1.0), 90.0); - EXPECT_ROW1_NEAR(0.0, -1.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(1.0, 0.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - - // Check rotation about x-axis - A.MakeIdentity(); - A.RotateAbout(Vector3dF(1.0, 0.0, 0.0), 90.0); - EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 0.0f, A); - EXPECT_ROW2_NEAR(0.0, 0.0, -1.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW3_NEAR(0.0, 1.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - - // Check rotation about y-axis. Note carefully, the expected pattern is - // inverted compared to rotating about x axis or z axis. - A.MakeIdentity(); - A.RotateAbout(Vector3dF(0.0, 1.0, 0.0), 90.0); - EXPECT_ROW1_NEAR(0.0, 0.0, 1.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, A); - EXPECT_ROW3_NEAR(-1.0, 0.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - - // Verify that rotate3d(axis, angle) post-multiplies the existing matrix. - A.MakeIdentity(); - A.Scale3d(6.0, 7.0, 8.0); - A.RotateAboutZAxis(90.0); - EXPECT_ROW1_NEAR(0.0, -6.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(7.0, 0.0, 0.0, 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW3_EQ(0.0f, 0.0f, 8.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); -} - -TEST(XFormTest, verifyRotateAboutForArbitraryAxis) { - // Check rotation about an arbitrary non-axis-aligned vector. - Transform A; - A.RotateAbout(Vector3dF(1.0, 1.0, 1.0), 90.0); - EXPECT_ROW1_NEAR(0.3333333333333334258519187, - -0.2440169358562924717404030, - 0.9106836025229592124219380, - 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW2_NEAR(0.9106836025229592124219380, - 0.3333333333333334258519187, - -0.2440169358562924717404030, - 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW3_NEAR(-0.2440169358562924717404030, - 0.9106836025229592124219380, - 0.3333333333333334258519187, - 0.0, A, ERROR_THRESHOLD); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); -} - -TEST(XFormTest, verifyRotateAboutForDegenerateAxis) { - // Check rotation about a degenerate zero vector. - // It is expected to skip applying the rotation. - Transform A; - - A.RotateAbout(Vector3dF(0.0, 0.0, 0.0), 45.0); - // Verify that A remains unchanged. - EXPECT_TRUE(A.IsIdentity()); - - InitializeTestMatrix(&A); - A.RotateAbout(Vector3dF(0.0, 0.0, 0.0), 35.0); - - // Verify that A remains unchanged. - EXPECT_ROW1_EQ(10.0f, 14.0f, 18.0f, 22.0f, A); - EXPECT_ROW2_EQ(11.0f, 15.0f, 19.0f, 23.0f, A); - EXPECT_ROW3_EQ(12.0f, 16.0f, 20.0f, 24.0f, A); - EXPECT_ROW4_EQ(13.0f, 17.0f, 21.0f, 25.0f, A); -} - -TEST(XFormTest, verifySkewX) { - Transform A; - A.SkewX(45.0); - EXPECT_ROW1_EQ(1.0f, 1.0f, 0.0f, 0.0f, A); - EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, A); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - - // Verify that skewX() post-multiplies the existing matrix. Row 1, column 2, - // would incorrectly have value "7" if the matrix is pre-multiplied instead - // of post-multiplied. - A.MakeIdentity(); - A.Scale3d(6.0, 7.0, 8.0); - A.SkewX(45.0); - EXPECT_ROW1_EQ(6.0f, 6.0f, 0.0f, 0.0f, A); - EXPECT_ROW2_EQ(0.0f, 7.0f, 0.0f, 0.0f, A); - EXPECT_ROW3_EQ(0.0f, 0.0f, 8.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); -} - -TEST(XFormTest, verifySkewY) { - Transform A; - A.SkewY(45.0); - EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 0.0f, A); - EXPECT_ROW2_EQ(1.0f, 1.0f, 0.0f, 0.0f, A); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); - - // Verify that skewY() post-multiplies the existing matrix. Row 2, column 1 , - // would incorrectly have value "6" if the matrix is pre-multiplied instead - // of post-multiplied. - A.MakeIdentity(); - A.Scale3d(6.0, 7.0, 8.0); - A.SkewY(45.0); - EXPECT_ROW1_EQ(6.0f, 0.0f, 0.0f, 0.0f, A); - EXPECT_ROW2_EQ(7.0f, 7.0f, 0.0f, 0.0f, A); - EXPECT_ROW3_EQ(0.0f, 0.0f, 8.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); -} - -TEST(XFormTest, verifyPerspectiveDepth) { - Transform A; - A.ApplyPerspectiveDepth(1.0); - EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 0.0f, A); - EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, A); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, -1.0f, 1.0f, A); - - // Verify that PerspectiveDepth() post-multiplies the existing matrix. - A.MakeIdentity(); - A.Translate3d(2.0, 3.0, 4.0); - A.ApplyPerspectiveDepth(1.0); - EXPECT_ROW1_EQ(1.0f, 0.0f, -2.0f, 2.0f, A); - EXPECT_ROW2_EQ(0.0f, 1.0f, -3.0f, 3.0f, A); - EXPECT_ROW3_EQ(0.0f, 0.0f, -3.0f, 4.0f, A); - EXPECT_ROW4_EQ(0.0f, 0.0f, -1.0f, 1.0f, A); -} - -TEST(XFormTest, verifyHasPerspective) { - Transform A; - A.ApplyPerspectiveDepth(1.0); - EXPECT_TRUE(A.HasPerspective()); - - A.MakeIdentity(); - A.ApplyPerspectiveDepth(0.0); - EXPECT_FALSE(A.HasPerspective()); - - A.MakeIdentity(); - A.matrix().set(3, 0, -1.f); - EXPECT_TRUE(A.HasPerspective()); - - A.MakeIdentity(); - A.matrix().set(3, 1, -1.f); - EXPECT_TRUE(A.HasPerspective()); - - A.MakeIdentity(); - A.matrix().set(3, 2, -0.3f); - EXPECT_TRUE(A.HasPerspective()); - - A.MakeIdentity(); - A.matrix().set(3, 3, 0.5f); - EXPECT_TRUE(A.HasPerspective()); - - A.MakeIdentity(); - A.matrix().set(3, 3, 0.f); - EXPECT_TRUE(A.HasPerspective()); -} - -TEST(XFormTest, verifyIsInvertible) { - Transform A; - - // Translations, rotations, scales, skews and arbitrary combinations of them - // are invertible. - A.MakeIdentity(); - EXPECT_TRUE(A.IsInvertible()); - - A.MakeIdentity(); - A.Translate3d(2.0, 3.0, 4.0); - EXPECT_TRUE(A.IsInvertible()); - - A.MakeIdentity(); - A.Scale3d(6.0, 7.0, 8.0); - EXPECT_TRUE(A.IsInvertible()); - - A.MakeIdentity(); - A.RotateAboutXAxis(10.0); - A.RotateAboutYAxis(20.0); - A.RotateAboutZAxis(30.0); - EXPECT_TRUE(A.IsInvertible()); - - A.MakeIdentity(); - A.SkewX(45.0); - EXPECT_TRUE(A.IsInvertible()); - - // A perspective matrix (projection plane at z=0) is invertible. The - // intuitive explanation is that perspective is eqivalent to a skew of the - // w-axis; skews are invertible. - A.MakeIdentity(); - A.ApplyPerspectiveDepth(1.0); - EXPECT_TRUE(A.IsInvertible()); - - // A "pure" perspective matrix derived by similar triangles, with m44() set - // to zero (i.e. camera positioned at the origin), is not invertible. - A.MakeIdentity(); - A.ApplyPerspectiveDepth(1.0); - A.matrix().set(3, 3, 0.f); - EXPECT_FALSE(A.IsInvertible()); - - // Adding more to a non-invertible matrix will not make it invertible in the - // general case. - A.MakeIdentity(); - A.ApplyPerspectiveDepth(1.0); - A.matrix().set(3, 3, 0.f); - A.Scale3d(6.0, 7.0, 8.0); - A.RotateAboutXAxis(10.0); - A.RotateAboutYAxis(20.0); - A.RotateAboutZAxis(30.0); - A.Translate3d(6.0, 7.0, 8.0); - EXPECT_FALSE(A.IsInvertible()); - - // A degenerate matrix of all zeros is not invertible. - A.MakeIdentity(); - A.matrix().set(0, 0, 0.f); - A.matrix().set(1, 1, 0.f); - A.matrix().set(2, 2, 0.f); - A.matrix().set(3, 3, 0.f); - EXPECT_FALSE(A.IsInvertible()); -} - -TEST(XFormTest, verifyIsIdentity) { - Transform A; - - InitializeTestMatrix(&A); - EXPECT_FALSE(A.IsIdentity()); - - A.MakeIdentity(); - EXPECT_TRUE(A.IsIdentity()); - - // Modifying any one individual element should cause the matrix to no longer - // be identity. - A.MakeIdentity(); - A.matrix().set(0, 0, 2.f); - EXPECT_FALSE(A.IsIdentity()); - - A.MakeIdentity(); - A.matrix().set(1, 0, 2.f); - EXPECT_FALSE(A.IsIdentity()); - - A.MakeIdentity(); - A.matrix().set(2, 0, 2.f); - EXPECT_FALSE(A.IsIdentity()); - - A.MakeIdentity(); - A.matrix().set(3, 0, 2.f); - EXPECT_FALSE(A.IsIdentity()); - - A.MakeIdentity(); - A.matrix().set(0, 1, 2.f); - EXPECT_FALSE(A.IsIdentity()); - - A.MakeIdentity(); - A.matrix().set(1, 1, 2.f); - EXPECT_FALSE(A.IsIdentity()); - - A.MakeIdentity(); - A.matrix().set(2, 1, 2.f); - EXPECT_FALSE(A.IsIdentity()); - - A.MakeIdentity(); - A.matrix().set(3, 1, 2.f); - EXPECT_FALSE(A.IsIdentity()); - - A.MakeIdentity(); - A.matrix().set(0, 2, 2.f); - EXPECT_FALSE(A.IsIdentity()); - - A.MakeIdentity(); - A.matrix().set(1, 2, 2.f); - EXPECT_FALSE(A.IsIdentity()); - - A.MakeIdentity(); - A.matrix().set(2, 2, 2.f); - EXPECT_FALSE(A.IsIdentity()); - - A.MakeIdentity(); - A.matrix().set(3, 2, 2.f); - EXPECT_FALSE(A.IsIdentity()); - - A.MakeIdentity(); - A.matrix().set(0, 3, 2.f); - EXPECT_FALSE(A.IsIdentity()); - - A.MakeIdentity(); - A.matrix().set(1, 3, 2.f); - EXPECT_FALSE(A.IsIdentity()); - - A.MakeIdentity(); - A.matrix().set(2, 3, 2.f); - EXPECT_FALSE(A.IsIdentity()); - - A.MakeIdentity(); - A.matrix().set(3, 3, 2.f); - EXPECT_FALSE(A.IsIdentity()); -} - -TEST(XFormTest, verifyIsIdentityOrTranslation) { - Transform A; - - InitializeTestMatrix(&A); - EXPECT_FALSE(A.IsIdentityOrTranslation()); - - A.MakeIdentity(); - EXPECT_TRUE(A.IsIdentityOrTranslation()); - - // Modifying any non-translation components should cause - // IsIdentityOrTranslation() to return false. NOTE: (0, 3), (1, 3), and - // (2, 3) are the translation components, so modifying them should still - // return true. - A.MakeIdentity(); - A.matrix().set(0, 0, 2.f); - EXPECT_FALSE(A.IsIdentityOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(1, 0, 2.f); - EXPECT_FALSE(A.IsIdentityOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(2, 0, 2.f); - EXPECT_FALSE(A.IsIdentityOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(3, 0, 2.f); - EXPECT_FALSE(A.IsIdentityOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(0, 1, 2.f); - EXPECT_FALSE(A.IsIdentityOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(1, 1, 2.f); - EXPECT_FALSE(A.IsIdentityOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(2, 1, 2.f); - EXPECT_FALSE(A.IsIdentityOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(3, 1, 2.f); - EXPECT_FALSE(A.IsIdentityOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(0, 2, 2.f); - EXPECT_FALSE(A.IsIdentityOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(1, 2, 2.f); - EXPECT_FALSE(A.IsIdentityOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(2, 2, 2.f); - EXPECT_FALSE(A.IsIdentityOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(3, 2, 2.f); - EXPECT_FALSE(A.IsIdentityOrTranslation()); - - // Note carefully - expecting true here. - A.MakeIdentity(); - A.matrix().set(0, 3, 2.f); - EXPECT_TRUE(A.IsIdentityOrTranslation()); - - // Note carefully - expecting true here. - A.MakeIdentity(); - A.matrix().set(1, 3, 2.f); - EXPECT_TRUE(A.IsIdentityOrTranslation()); - - // Note carefully - expecting true here. - A.MakeIdentity(); - A.matrix().set(2, 3, 2.f); - EXPECT_TRUE(A.IsIdentityOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(3, 3, 2.f); - EXPECT_FALSE(A.IsIdentityOrTranslation()); -} - -TEST(XFormTest, verifyIsApproximatelyIdentityOrTranslation) { - Transform A; - SkMatrix44& matrix = A.matrix(); - - // Exact pure translation. - A.MakeIdentity(); - - // Set translate values to values other than 0 or 1. - matrix.set(0, 3, 3.4f); - matrix.set(1, 3, 4.4f); - matrix.set(2, 3, 5.6f); - - EXPECT_TRUE(A.IsApproximatelyIdentityOrTranslation(0)); - EXPECT_TRUE(A.IsApproximatelyIdentityOrTranslation(kApproxZero)); - - // Approximately pure translation. - InitializeApproxIdentityMatrix(&A); - - // Some values must be exact. - matrix.set(3, 0, 0); - matrix.set(3, 1, 0); - matrix.set(3, 2, 0); - matrix.set(3, 3, 1); - - // Set translate values to values other than 0 or 1. - matrix.set(0, 3, 3.4f); - matrix.set(1, 3, 4.4f); - matrix.set(2, 3, 5.6f); - - EXPECT_FALSE(A.IsApproximatelyIdentityOrTranslation(0)); - EXPECT_TRUE(A.IsApproximatelyIdentityOrTranslation(kApproxZero)); - - // Not approximately pure translation. - InitializeApproxIdentityMatrix(&A); - - // Some values must be exact. - matrix.set(3, 0, 0); - matrix.set(3, 1, 0); - matrix.set(3, 2, 0); - matrix.set(3, 3, 1); - - // Set some values (not translate values) to values other than 0 or 1. - matrix.set(0, 1, 3.4f); - matrix.set(3, 2, 4.4f); - matrix.set(2, 0, 5.6f); - - EXPECT_FALSE(A.IsApproximatelyIdentityOrTranslation(0)); - EXPECT_FALSE(A.IsApproximatelyIdentityOrTranslation(kApproxZero)); -} - -TEST(XFormTest, verifyIsScaleOrTranslation) { - Transform A; - - InitializeTestMatrix(&A); - EXPECT_FALSE(A.IsScaleOrTranslation()); - - A.MakeIdentity(); - EXPECT_TRUE(A.IsScaleOrTranslation()); - - // Modifying any non-scale or non-translation components should cause - // IsScaleOrTranslation() to return false. (0, 0), (1, 1), (2, 2), (0, 3), - // (1, 3), and (2, 3) are the scale and translation components, so - // modifying them should still return true. - - // Note carefully - expecting true here. - A.MakeIdentity(); - A.matrix().set(0, 0, 2.f); - EXPECT_TRUE(A.IsScaleOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(1, 0, 2.f); - EXPECT_FALSE(A.IsScaleOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(2, 0, 2.f); - EXPECT_FALSE(A.IsScaleOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(3, 0, 2.f); - EXPECT_FALSE(A.IsScaleOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(0, 1, 2.f); - EXPECT_FALSE(A.IsScaleOrTranslation()); - - // Note carefully - expecting true here. - A.MakeIdentity(); - A.matrix().set(1, 1, 2.f); - EXPECT_TRUE(A.IsScaleOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(2, 1, 2.f); - EXPECT_FALSE(A.IsScaleOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(3, 1, 2.f); - EXPECT_FALSE(A.IsScaleOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(0, 2, 2.f); - EXPECT_FALSE(A.IsScaleOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(1, 2, 2.f); - EXPECT_FALSE(A.IsScaleOrTranslation()); - - // Note carefully - expecting true here. - A.MakeIdentity(); - A.matrix().set(2, 2, 2.f); - EXPECT_TRUE(A.IsScaleOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(3, 2, 2.f); - EXPECT_FALSE(A.IsScaleOrTranslation()); - - // Note carefully - expecting true here. - A.MakeIdentity(); - A.matrix().set(0, 3, 2.f); - EXPECT_TRUE(A.IsScaleOrTranslation()); - - // Note carefully - expecting true here. - A.MakeIdentity(); - A.matrix().set(1, 3, 2.f); - EXPECT_TRUE(A.IsScaleOrTranslation()); - - // Note carefully - expecting true here. - A.MakeIdentity(); - A.matrix().set(2, 3, 2.f); - EXPECT_TRUE(A.IsScaleOrTranslation()); - - A.MakeIdentity(); - A.matrix().set(3, 3, 2.f); - EXPECT_FALSE(A.IsScaleOrTranslation()); -} - -TEST(XFormTest, verifyFlattenTo2d) { - Transform A; - InitializeTestMatrix(&A); - - A.FlattenTo2d(); - EXPECT_ROW1_EQ(10.0f, 14.0f, 0.0f, 22.0f, A); - EXPECT_ROW2_EQ(11.0f, 15.0f, 0.0f, 23.0f, A); - EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); - EXPECT_ROW4_EQ(13.0f, 17.0f, 0.0f, 25.0f, A); -} - -TEST(XFormTest, IsFlat) { - Transform transform; - InitializeTestMatrix(&transform); - - // A transform with all entries non-zero isn't flat. - EXPECT_FALSE(transform.IsFlat()); - - transform.matrix().set(0, 2, 0.f); - transform.matrix().set(1, 2, 0.f); - transform.matrix().set(2, 2, 1.f); - transform.matrix().set(3, 2, 0.f); - - EXPECT_FALSE(transform.IsFlat()); - - transform.matrix().set(2, 0, 0.f); - transform.matrix().set(2, 1, 0.f); - transform.matrix().set(2, 3, 0.f); - - // Since the third column and row are both (0, 0, 1, 0), the transform is - // flat. - EXPECT_TRUE(transform.IsFlat()); -} - -// Another implementation of Preserves2dAxisAlignment that isn't as fast, -// good for testing the faster implementation. -static bool EmpiricallyPreserves2dAxisAlignment(const Transform& transform) { - Point3F p1(5.0f, 5.0f, 0.0f); - Point3F p2(10.0f, 5.0f, 0.0f); - Point3F p3(10.0f, 20.0f, 0.0f); - Point3F p4(5.0f, 20.0f, 0.0f); - - QuadF test_quad(PointF(p1.x(), p1.y()), - PointF(p2.x(), p2.y()), - PointF(p3.x(), p3.y()), - PointF(p4.x(), p4.y())); - EXPECT_TRUE(test_quad.IsRectilinear()); - - transform.TransformPoint(&p1); - transform.TransformPoint(&p2); - transform.TransformPoint(&p3); - transform.TransformPoint(&p4); - - QuadF transformedQuad(PointF(p1.x(), p1.y()), - PointF(p2.x(), p2.y()), - PointF(p3.x(), p3.y()), - PointF(p4.x(), p4.y())); - return transformedQuad.IsRectilinear(); -} - -TEST(XFormTest, Preserves2dAxisAlignment) { - static const struct TestCase { - SkMScalar a; // row 1, column 1 - SkMScalar b; // row 1, column 2 - SkMScalar c; // row 2, column 1 - SkMScalar d; // row 2, column 2 - bool expected; - } test_cases[] = { - { 3.f, 0.f, - 0.f, 4.f, true }, // basic case - { 0.f, 4.f, - 3.f, 0.f, true }, // rotate by 90 - { 0.f, 0.f, - 0.f, 4.f, true }, // degenerate x - { 3.f, 0.f, - 0.f, 0.f, true }, // degenerate y - { 0.f, 0.f, - 3.f, 0.f, true }, // degenerate x + rotate by 90 - { 0.f, 4.f, - 0.f, 0.f, true }, // degenerate y + rotate by 90 - { 3.f, 4.f, - 0.f, 0.f, false }, - { 0.f, 0.f, - 3.f, 4.f, false }, - { 0.f, 3.f, - 0.f, 4.f, false }, - { 3.f, 0.f, - 4.f, 0.f, false }, - { 3.f, 4.f, - 5.f, 0.f, false }, - { 3.f, 4.f, - 0.f, 5.f, false }, - { 3.f, 0.f, - 4.f, 5.f, false }, - { 0.f, 3.f, - 4.f, 5.f, false }, - { 2.f, 3.f, - 4.f, 5.f, false }, - }; - - Transform transform; - for (size_t i = 0; i < arraysize(test_cases); ++i) { - const TestCase& value = test_cases[i]; - transform.MakeIdentity(); - transform.matrix().set(0, 0, value.a); - transform.matrix().set(0, 1, value.b); - transform.matrix().set(1, 0, value.c); - transform.matrix().set(1, 1, value.d); - - if (value.expected) { - EXPECT_TRUE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_TRUE(transform.Preserves2dAxisAlignment()); - } else { - EXPECT_FALSE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_FALSE(transform.Preserves2dAxisAlignment()); - } - } - - // Try the same test cases again, but this time make sure that other matrix - // elements (except perspective) have entries, to test that they are ignored. - for (size_t i = 0; i < arraysize(test_cases); ++i) { - const TestCase& value = test_cases[i]; - transform.MakeIdentity(); - transform.matrix().set(0, 0, value.a); - transform.matrix().set(0, 1, value.b); - transform.matrix().set(1, 0, value.c); - transform.matrix().set(1, 1, value.d); - - transform.matrix().set(0, 2, 1.f); - transform.matrix().set(0, 3, 2.f); - transform.matrix().set(1, 2, 3.f); - transform.matrix().set(1, 3, 4.f); - transform.matrix().set(2, 0, 5.f); - transform.matrix().set(2, 1, 6.f); - transform.matrix().set(2, 2, 7.f); - transform.matrix().set(2, 3, 8.f); - - if (value.expected) { - EXPECT_TRUE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_TRUE(transform.Preserves2dAxisAlignment()); - } else { - EXPECT_FALSE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_FALSE(transform.Preserves2dAxisAlignment()); - } - } - - // Try the same test cases again, but this time add perspective which is - // always assumed to not-preserve axis alignment. - for (size_t i = 0; i < arraysize(test_cases); ++i) { - const TestCase& value = test_cases[i]; - transform.MakeIdentity(); - transform.matrix().set(0, 0, value.a); - transform.matrix().set(0, 1, value.b); - transform.matrix().set(1, 0, value.c); - transform.matrix().set(1, 1, value.d); - - transform.matrix().set(0, 2, 1.f); - transform.matrix().set(0, 3, 2.f); - transform.matrix().set(1, 2, 3.f); - transform.matrix().set(1, 3, 4.f); - transform.matrix().set(2, 0, 5.f); - transform.matrix().set(2, 1, 6.f); - transform.matrix().set(2, 2, 7.f); - transform.matrix().set(2, 3, 8.f); - transform.matrix().set(3, 0, 9.f); - transform.matrix().set(3, 1, 10.f); - transform.matrix().set(3, 2, 11.f); - transform.matrix().set(3, 3, 12.f); - - EXPECT_FALSE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_FALSE(transform.Preserves2dAxisAlignment()); - } - - // Try a few more practical situations to check precision - transform.MakeIdentity(); - transform.RotateAboutZAxis(90.0); - EXPECT_TRUE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_TRUE(transform.Preserves2dAxisAlignment()); - - transform.MakeIdentity(); - transform.RotateAboutZAxis(180.0); - EXPECT_TRUE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_TRUE(transform.Preserves2dAxisAlignment()); - - transform.MakeIdentity(); - transform.RotateAboutZAxis(270.0); - EXPECT_TRUE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_TRUE(transform.Preserves2dAxisAlignment()); - - transform.MakeIdentity(); - transform.RotateAboutYAxis(90.0); - EXPECT_TRUE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_TRUE(transform.Preserves2dAxisAlignment()); - - transform.MakeIdentity(); - transform.RotateAboutXAxis(90.0); - EXPECT_TRUE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_TRUE(transform.Preserves2dAxisAlignment()); - - transform.MakeIdentity(); - transform.RotateAboutZAxis(90.0); - transform.RotateAboutYAxis(90.0); - EXPECT_TRUE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_TRUE(transform.Preserves2dAxisAlignment()); - - transform.MakeIdentity(); - transform.RotateAboutZAxis(90.0); - transform.RotateAboutXAxis(90.0); - EXPECT_TRUE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_TRUE(transform.Preserves2dAxisAlignment()); - - transform.MakeIdentity(); - transform.RotateAboutYAxis(90.0); - transform.RotateAboutZAxis(90.0); - EXPECT_TRUE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_TRUE(transform.Preserves2dAxisAlignment()); - - transform.MakeIdentity(); - transform.RotateAboutZAxis(45.0); - EXPECT_FALSE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_FALSE(transform.Preserves2dAxisAlignment()); - - // 3-d case; In 2d after an orthographic projection, this case does - // preserve 2d axis alignment. But in 3d, it does not preserve axis - // alignment. - transform.MakeIdentity(); - transform.RotateAboutYAxis(45.0); - EXPECT_TRUE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_TRUE(transform.Preserves2dAxisAlignment()); - - transform.MakeIdentity(); - transform.RotateAboutXAxis(45.0); - EXPECT_TRUE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_TRUE(transform.Preserves2dAxisAlignment()); - - // Perspective cases. - transform.MakeIdentity(); - transform.ApplyPerspectiveDepth(10.0); - transform.RotateAboutYAxis(45.0); - EXPECT_FALSE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_FALSE(transform.Preserves2dAxisAlignment()); - - transform.MakeIdentity(); - transform.ApplyPerspectiveDepth(10.0); - transform.RotateAboutZAxis(90.0); - EXPECT_TRUE(EmpiricallyPreserves2dAxisAlignment(transform)); - EXPECT_TRUE(transform.Preserves2dAxisAlignment()); -} - -TEST(XFormTest, To2dTranslation) { - Vector2dF translation(3.f, 7.f); - Transform transform; - transform.Translate(translation.x(), translation.y() + 1); - EXPECT_NE(translation.ToString(), transform.To2dTranslation().ToString()); - transform.MakeIdentity(); - transform.Translate(translation.x(), translation.y()); - EXPECT_EQ(translation.ToString(), transform.To2dTranslation().ToString()); -} - -TEST(XFormTest, TransformRect) { - Transform translation; - translation.Translate(3.f, 7.f); - RectF rect(1.f, 2.f, 3.f, 4.f); - RectF expected(4.f, 9.f, 3.f, 4.f); - translation.TransformRect(&rect); - EXPECT_EQ(expected.ToString(), rect.ToString()); -} - -TEST(XFormTest, TransformRectReverse) { - Transform translation; - translation.Translate(3.f, 7.f); - RectF rect(1.f, 2.f, 3.f, 4.f); - RectF expected(-2.f, -5.f, 3.f, 4.f); - EXPECT_TRUE(translation.TransformRectReverse(&rect)); - EXPECT_EQ(expected.ToString(), rect.ToString()); - - Transform singular; - singular.Scale3d(0.f, 0.f, 0.f); - EXPECT_FALSE(singular.TransformRectReverse(&rect)); -} - -TEST(XFormTest, TransformBox) { - Transform translation; - translation.Translate3d(3.f, 7.f, 6.f); - BoxF box(1.f, 2.f, 3.f, 4.f, 5.f, 6.f); - BoxF expected(4.f, 9.f, 9.f, 4.f, 5.f, 6.f); - translation.TransformBox(&box); - EXPECT_EQ(expected.ToString(), box.ToString()); -} - -TEST(XFormTest, TransformBoxReverse) { - Transform translation; - translation.Translate3d(3.f, 7.f, 6.f); - BoxF box(1.f, 2.f, 3.f, 4.f, 5.f, 6.f); - BoxF expected(-2.f, -5.f, -3.f, 4.f, 5.f, 6.f); - EXPECT_TRUE(translation.TransformBoxReverse(&box)); - EXPECT_EQ(expected.ToString(), box.ToString()); - - Transform singular; - singular.Scale3d(0.f, 0.f, 0.f); - EXPECT_FALSE(singular.TransformBoxReverse(&box)); -} - -} // namespace - -} // namespace gfx diff --git a/ui/gfx/transform_util.cc b/ui/gfx/transform_util.cc deleted file mode 100644 index 44b034a45..000000000 --- a/ui/gfx/transform_util.cc +++ /dev/null @@ -1,518 +0,0 @@ -// 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 "ui/gfx/transform_util.h" - -#include -#include - -#include "base/logging.h" -#include "base/strings/stringprintf.h" -#include "ui/gfx/geometry/point.h" -#include "ui/gfx/geometry/point3_f.h" -#include "ui/gfx/geometry/rect.h" - -namespace gfx { - -namespace { - -SkMScalar Length3(SkMScalar v[3]) { - double vd[3] = {SkMScalarToDouble(v[0]), SkMScalarToDouble(v[1]), - SkMScalarToDouble(v[2])}; - return SkDoubleToMScalar( - std::sqrt(vd[0] * vd[0] + vd[1] * vd[1] + vd[2] * vd[2])); -} - -void Scale3(SkMScalar v[3], SkMScalar scale) { - for (int i = 0; i < 3; ++i) - v[i] *= scale; -} - -template -SkMScalar Dot(const SkMScalar* a, const SkMScalar* b) { - double total = 0.0; - for (int i = 0; i < n; ++i) - total += a[i] * b[i]; - return SkDoubleToMScalar(total); -} - -template -void Combine(SkMScalar* out, - const SkMScalar* a, - const SkMScalar* b, - double scale_a, - double scale_b) { - for (int i = 0; i < n; ++i) - out[i] = SkDoubleToMScalar(a[i] * scale_a + b[i] * scale_b); -} - -void Cross3(SkMScalar out[3], SkMScalar a[3], SkMScalar b[3]) { - SkMScalar x = a[1] * b[2] - a[2] * b[1]; - SkMScalar y = a[2] * b[0] - a[0] * b[2]; - SkMScalar z = a[0] * b[1] - a[1] * b[0]; - out[0] = x; - out[1] = y; - out[2] = z; -} - -SkMScalar Round(SkMScalar n) { - return SkDoubleToMScalar(std::floor(SkMScalarToDouble(n) + 0.5)); -} - -// Taken from http://www.w3.org/TR/css3-transforms/. -bool Slerp(SkMScalar out[4], - const SkMScalar q1[4], - const SkMScalar q2[4], - double progress) { - double product = Dot<4>(q1, q2); - - // Clamp product to -1.0 <= product <= 1.0. - product = std::min(std::max(product, -1.0), 1.0); - - // Interpolate angles along the shortest path. For example, to interpolate - // between a 175 degree angle and a 185 degree angle, interpolate along the - // 10 degree path from 175 to 185, rather than along the 350 degree path in - // the opposite direction. This matches WebKit's implementation but not - // the current W3C spec. Fixing the spec to match this approach is discussed - // at: - // http://lists.w3.org/Archives/Public/www-style/2013May/0131.html - double scale1 = 1.0; - if (product < 0) { - product = -product; - scale1 = -1.0; - } - - const double epsilon = 1e-5; - if (std::abs(product - 1.0) < epsilon) { - for (int i = 0; i < 4; ++i) - out[i] = q1[i]; - return true; - } - - double denom = std::sqrt(1.0 - product * product); - double theta = std::acos(product); - double w = std::sin(progress * theta) * (1.0 / denom); - - scale1 *= std::cos(progress * theta) - product * w; - double scale2 = w; - Combine<4>(out, q1, q2, scale1, scale2); - - return true; -} - -// Returns false if the matrix cannot be normalized. -bool Normalize(SkMatrix44& m) { - if (m.get(3, 3) == 0.0) - // Cannot normalize. - return false; - - SkMScalar scale = 1.0 / m.get(3, 3); - for (int i = 0; i < 4; i++) - for (int j = 0; j < 4; j++) - m.set(i, j, m.get(i, j) * scale); - - return true; -} - -SkMatrix44 BuildPerspectiveMatrix(const DecomposedTransform& decomp) { - SkMatrix44 matrix(SkMatrix44::kIdentity_Constructor); - - for (int i = 0; i < 4; i++) - matrix.setDouble(3, i, decomp.perspective[i]); - return matrix; -} - -SkMatrix44 BuildTranslationMatrix(const DecomposedTransform& decomp) { - SkMatrix44 matrix(SkMatrix44::kUninitialized_Constructor); - // Implicitly calls matrix.setIdentity() - matrix.setTranslate(SkDoubleToMScalar(decomp.translate[0]), - SkDoubleToMScalar(decomp.translate[1]), - SkDoubleToMScalar(decomp.translate[2])); - return matrix; -} - -SkMatrix44 BuildSnappedTranslationMatrix(DecomposedTransform decomp) { - decomp.translate[0] = Round(decomp.translate[0]); - decomp.translate[1] = Round(decomp.translate[1]); - decomp.translate[2] = Round(decomp.translate[2]); - return BuildTranslationMatrix(decomp); -} - -SkMatrix44 BuildRotationMatrix(const DecomposedTransform& decomp) { - double x = decomp.quaternion[0]; - double y = decomp.quaternion[1]; - double z = decomp.quaternion[2]; - double w = decomp.quaternion[3]; - - SkMatrix44 matrix(SkMatrix44::kUninitialized_Constructor); - - // Implicitly calls matrix.setIdentity() - matrix.set3x3(1.0 - 2.0 * (y * y + z * z), - 2.0 * (x * y + z * w), - 2.0 * (x * z - y * w), - 2.0 * (x * y - z * w), - 1.0 - 2.0 * (x * x + z * z), - 2.0 * (y * z + x * w), - 2.0 * (x * z + y * w), - 2.0 * (y * z - x * w), - 1.0 - 2.0 * (x * x + y * y)); - return matrix; -} - -SkMatrix44 BuildSnappedRotationMatrix(const DecomposedTransform& decomp) { - // Create snapped rotation. - SkMatrix44 rotation_matrix = BuildRotationMatrix(decomp); - for (int i = 0; i < 3; ++i) { - for (int j = 0; j < 3; ++j) { - SkMScalar value = rotation_matrix.get(i, j); - // Snap values to -1, 0 or 1. - if (value < -0.5f) { - value = -1.0f; - } else if (value > 0.5f) { - value = 1.0f; - } else { - value = 0.0f; - } - rotation_matrix.set(i, j, value); - } - } - return rotation_matrix; -} - -SkMatrix44 BuildSkewMatrix(const DecomposedTransform& decomp) { - SkMatrix44 matrix(SkMatrix44::kIdentity_Constructor); - - SkMatrix44 temp(SkMatrix44::kIdentity_Constructor); - if (decomp.skew[2]) { - temp.setDouble(1, 2, decomp.skew[2]); - matrix.preConcat(temp); - } - - if (decomp.skew[1]) { - temp.setDouble(1, 2, 0); - temp.setDouble(0, 2, decomp.skew[1]); - matrix.preConcat(temp); - } - - if (decomp.skew[0]) { - temp.setDouble(0, 2, 0); - temp.setDouble(0, 1, decomp.skew[0]); - matrix.preConcat(temp); - } - return matrix; -} - -SkMatrix44 BuildScaleMatrix(const DecomposedTransform& decomp) { - SkMatrix44 matrix(SkMatrix44::kUninitialized_Constructor); - matrix.setScale(SkDoubleToMScalar(decomp.scale[0]), - SkDoubleToMScalar(decomp.scale[1]), - SkDoubleToMScalar(decomp.scale[2])); - return matrix; -} - -SkMatrix44 BuildSnappedScaleMatrix(DecomposedTransform decomp) { - decomp.scale[0] = Round(decomp.scale[0]); - decomp.scale[1] = Round(decomp.scale[1]); - decomp.scale[2] = Round(decomp.scale[2]); - return BuildScaleMatrix(decomp); -} - -Transform ComposeTransform(const SkMatrix44& perspective, - const SkMatrix44& translation, - const SkMatrix44& rotation, - const SkMatrix44& skew, - const SkMatrix44& scale) { - SkMatrix44 matrix(SkMatrix44::kIdentity_Constructor); - - matrix.preConcat(perspective); - matrix.preConcat(translation); - matrix.preConcat(rotation); - matrix.preConcat(skew); - matrix.preConcat(scale); - - Transform to_return; - to_return.matrix() = matrix; - return to_return; -} - -bool CheckViewportPointMapsWithinOnePixel(const Point& point, - const Transform& transform) { - Point3F point_original(point); - Point3F point_transformed(point); - - // Can't use TransformRect here since it would give us the axis-aligned - // bounding rect of the 4 points in the initial rectable which is not what we - // want. - transform.TransformPoint(&point_transformed); - - if ((point_transformed - point_original).Length() > 1.f) { - // The changed distance should not be more than 1 pixel. - return false; - } - return true; -} - -bool CheckTransformsMapsIntViewportWithinOnePixel(const Rect& viewport, - const Transform& original, - const Transform& snapped) { - - Transform original_inv(Transform::kSkipInitialization); - bool invertible = true; - invertible &= original.GetInverse(&original_inv); - DCHECK(invertible) << "Non-invertible transform, cannot snap."; - - Transform combined = snapped * original_inv; - - return CheckViewportPointMapsWithinOnePixel(viewport.origin(), combined) && - CheckViewportPointMapsWithinOnePixel(viewport.top_right(), combined) && - CheckViewportPointMapsWithinOnePixel(viewport.bottom_left(), - combined) && - CheckViewportPointMapsWithinOnePixel(viewport.bottom_right(), - combined); -} - -} // namespace - -Transform GetScaleTransform(const Point& anchor, float scale) { - Transform transform; - transform.Translate(anchor.x() * (1 - scale), - anchor.y() * (1 - scale)); - transform.Scale(scale, scale); - return transform; -} - -DecomposedTransform::DecomposedTransform() { - translate[0] = translate[1] = translate[2] = 0.0; - scale[0] = scale[1] = scale[2] = 1.0; - skew[0] = skew[1] = skew[2] = 0.0; - perspective[0] = perspective[1] = perspective[2] = 0.0; - quaternion[0] = quaternion[1] = quaternion[2] = 0.0; - perspective[3] = quaternion[3] = 1.0; -} - -bool BlendDecomposedTransforms(DecomposedTransform* out, - const DecomposedTransform& to, - const DecomposedTransform& from, - double progress) { - double scalea = progress; - double scaleb = 1.0 - progress; - Combine<3>(out->translate, to.translate, from.translate, scalea, scaleb); - Combine<3>(out->scale, to.scale, from.scale, scalea, scaleb); - Combine<3>(out->skew, to.skew, from.skew, scalea, scaleb); - Combine<4>( - out->perspective, to.perspective, from.perspective, scalea, scaleb); - return Slerp(out->quaternion, from.quaternion, to.quaternion, progress); -} - -// Taken from http://www.w3.org/TR/css3-transforms/. -bool DecomposeTransform(DecomposedTransform* decomp, - const Transform& transform) { - if (!decomp) - return false; - - // We'll operate on a copy of the matrix. - SkMatrix44 matrix = transform.matrix(); - - // If we cannot normalize the matrix, then bail early as we cannot decompose. - if (!Normalize(matrix)) - return false; - - SkMatrix44 perspectiveMatrix = matrix; - - for (int i = 0; i < 3; ++i) - perspectiveMatrix.set(3, i, 0.0); - - perspectiveMatrix.set(3, 3, 1.0); - - // If the perspective matrix is not invertible, we are also unable to - // decompose, so we'll bail early. Constant taken from SkMatrix44::invert. - if (std::abs(perspectiveMatrix.determinant()) < 1e-8) - return false; - - if (matrix.get(3, 0) != 0.0 || matrix.get(3, 1) != 0.0 || - matrix.get(3, 2) != 0.0) { - // rhs is the right hand side of the equation. - SkMScalar rhs[4] = { - matrix.get(3, 0), - matrix.get(3, 1), - matrix.get(3, 2), - matrix.get(3, 3) - }; - - // Solve the equation by inverting perspectiveMatrix and multiplying - // rhs by the inverse. - SkMatrix44 inversePerspectiveMatrix(SkMatrix44::kUninitialized_Constructor); - if (!perspectiveMatrix.invert(&inversePerspectiveMatrix)) - return false; - - SkMatrix44 transposedInversePerspectiveMatrix = - inversePerspectiveMatrix; - - transposedInversePerspectiveMatrix.transpose(); - transposedInversePerspectiveMatrix.mapMScalars(rhs); - - for (int i = 0; i < 4; ++i) - decomp->perspective[i] = rhs[i]; - - } else { - // No perspective. - for (int i = 0; i < 3; ++i) - decomp->perspective[i] = 0.0; - decomp->perspective[3] = 1.0; - } - - for (int i = 0; i < 3; i++) - decomp->translate[i] = matrix.get(i, 3); - - SkMScalar row[3][3]; - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; ++j) - row[i][j] = matrix.get(j, i); - - // Compute X scale factor and normalize first row. - decomp->scale[0] = Length3(row[0]); - if (decomp->scale[0] != 0.0) - Scale3(row[0], 1.0 / decomp->scale[0]); - - // Compute XY shear factor and make 2nd row orthogonal to 1st. - decomp->skew[0] = Dot<3>(row[0], row[1]); - Combine<3>(row[1], row[1], row[0], 1.0, -decomp->skew[0]); - - // Now, compute Y scale and normalize 2nd row. - decomp->scale[1] = Length3(row[1]); - if (decomp->scale[1] != 0.0) - Scale3(row[1], 1.0 / decomp->scale[1]); - - decomp->skew[0] /= decomp->scale[1]; - - // Compute XZ and YZ shears, orthogonalize 3rd row - decomp->skew[1] = Dot<3>(row[0], row[2]); - Combine<3>(row[2], row[2], row[0], 1.0, -decomp->skew[1]); - decomp->skew[2] = Dot<3>(row[1], row[2]); - Combine<3>(row[2], row[2], row[1], 1.0, -decomp->skew[2]); - - // Next, get Z scale and normalize 3rd row. - decomp->scale[2] = Length3(row[2]); - if (decomp->scale[2] != 0.0) - Scale3(row[2], 1.0 / decomp->scale[2]); - - decomp->skew[1] /= decomp->scale[2]; - decomp->skew[2] /= decomp->scale[2]; - - // At this point, the matrix (in rows) is orthonormal. - // Check for a coordinate system flip. If the determinant - // is -1, then negate the matrix and the scaling factors. - SkMScalar pdum3[3]; - Cross3(pdum3, row[1], row[2]); - if (Dot<3>(row[0], pdum3) < 0) { - for (int i = 0; i < 3; i++) { - decomp->scale[i] *= -1.0; - for (int j = 0; j < 3; ++j) - row[i][j] *= -1.0; - } - } - - decomp->quaternion[0] = - 0.5 * std::sqrt(std::max(1.0 + row[0][0] - row[1][1] - row[2][2], 0.0)); - decomp->quaternion[1] = - 0.5 * std::sqrt(std::max(1.0 - row[0][0] + row[1][1] - row[2][2], 0.0)); - decomp->quaternion[2] = - 0.5 * std::sqrt(std::max(1.0 - row[0][0] - row[1][1] + row[2][2], 0.0)); - decomp->quaternion[3] = - 0.5 * std::sqrt(std::max(1.0 + row[0][0] + row[1][1] + row[2][2], 0.0)); - - if (row[2][1] > row[1][2]) - decomp->quaternion[0] = -decomp->quaternion[0]; - if (row[0][2] > row[2][0]) - decomp->quaternion[1] = -decomp->quaternion[1]; - if (row[1][0] > row[0][1]) - decomp->quaternion[2] = -decomp->quaternion[2]; - - return true; -} - -// Taken from http://www.w3.org/TR/css3-transforms/. -Transform ComposeTransform(const DecomposedTransform& decomp) { - SkMatrix44 perspective = BuildPerspectiveMatrix(decomp); - SkMatrix44 translation = BuildTranslationMatrix(decomp); - SkMatrix44 rotation = BuildRotationMatrix(decomp); - SkMatrix44 skew = BuildSkewMatrix(decomp); - SkMatrix44 scale = BuildScaleMatrix(decomp); - - return ComposeTransform(perspective, translation, rotation, skew, scale); -} - -bool SnapTransform(Transform* out, - const Transform& transform, - const Rect& viewport) { - DecomposedTransform decomp; - DecomposeTransform(&decomp, transform); - - SkMatrix44 rotation_matrix = BuildSnappedRotationMatrix(decomp); - SkMatrix44 translation = BuildSnappedTranslationMatrix(decomp); - SkMatrix44 scale = BuildSnappedScaleMatrix(decomp); - - // Rebuild matrices for other unchanged components. - SkMatrix44 perspective = BuildPerspectiveMatrix(decomp); - - // Completely ignore the skew. - SkMatrix44 skew(SkMatrix44::kIdentity_Constructor); - - // Get full tranform - Transform snapped = - ComposeTransform(perspective, translation, rotation_matrix, skew, scale); - - // Verify that viewport is not moved unnaturally. - bool snappable = - CheckTransformsMapsIntViewportWithinOnePixel(viewport, transform, snapped); - if (snappable) { - *out = snapped; - } - return snappable; -} - -std::string DecomposedTransform::ToString() const { - return base::StringPrintf( - "translate: %+0.4f %+0.4f %+0.4f\n" - "scale: %+0.4f %+0.4f %+0.4f\n" - "skew: %+0.4f %+0.4f %+0.4f\n" - "perspective: %+0.4f %+0.4f %+0.4f %+0.4f\n" - "quaternion: %+0.4f %+0.4f %+0.4f %+0.4f\n", - translate[0], - translate[1], - translate[2], - scale[0], - scale[1], - scale[2], - skew[0], - skew[1], - skew[2], - perspective[0], - perspective[1], - perspective[2], - perspective[3], - quaternion[0], - quaternion[1], - quaternion[2], - quaternion[3]); -} - -float MatrixDistance(const Transform& a, const Transform& b) { - double sum = 0.0; - - const SkMatrix44& a_data = a.matrix(); - const SkMatrix44& b_data = b.matrix(); - - for (int row = 0; row < 4; ++row) { - for (int col = 0; col < 4; ++col) { - double diff = a_data.get(row, col) - b_data.get(row, col); - sum += diff * diff; - } - } - - return static_cast(std::sqrt(sum)); -} - - -} // namespace ui diff --git a/ui/gfx/transform_util.h b/ui/gfx/transform_util.h deleted file mode 100644 index 6b091a2b6..000000000 --- a/ui/gfx/transform_util.h +++ /dev/null @@ -1,66 +0,0 @@ -// 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 UI_GFX_TRANSFORM_UTIL_H_ -#define UI_GFX_TRANSFORM_UTIL_H_ - -#include "ui/gfx/gfx_export.h" -#include "ui/gfx/transform.h" - -namespace gfx { - -class Point; -class Rect; - -// Returns a scale transform at |anchor| point. -GFX_EXPORT Transform GetScaleTransform(const Point& anchor, float scale); - -// Contains the components of a factored transform. These components may be -// blended and recomposed. -struct GFX_EXPORT DecomposedTransform { - // The default constructor initializes the components in such a way that - // if used with Compose below, will produce the identity transform. - DecomposedTransform(); - - SkMScalar translate[3]; - SkMScalar scale[3]; - SkMScalar skew[3]; - SkMScalar perspective[4]; - SkMScalar quaternion[4]; - - std::string ToString() const; - - // Copy and assign are allowed. -}; - -// Interpolates the decomposed components |to| with |from| using the -// routines described in http://www.w3.org/TR/css3-3d-transform/. -// |progress| is in the range [0, 1] (0 leaves |out| unchanged, and 1 -// assigns |from| to |out|). -GFX_EXPORT bool BlendDecomposedTransforms(DecomposedTransform* out, - const DecomposedTransform& to, - const DecomposedTransform& from, - double progress); - -// Decomposes this transform into its translation, scale, skew, perspective, -// and rotation components following the routines detailed in this spec: -// http://www.w3.org/TR/css3-3d-transforms/. -GFX_EXPORT bool DecomposeTransform(DecomposedTransform* out, - const Transform& transform); - -// Composes a transform from the given translation, scale, skew, prespective, -// and rotation components following the routines detailed in this spec: -// http://www.w3.org/TR/css3-3d-transforms/. -GFX_EXPORT Transform ComposeTransform(const DecomposedTransform& decomp); - -GFX_EXPORT bool SnapTransform(Transform* out, - const Transform& transform, - const Rect& viewport); - -// Computes the Frobenius norm of (a - b). -GFX_EXPORT float MatrixDistance(const Transform& a, const Transform& b); - -} // namespace gfx - -#endif // UI_GFX_TRANSFORM_UTIL_H_ diff --git a/ui/gfx/transform_util_unittest.cc b/ui/gfx/transform_util_unittest.cc deleted file mode 100644 index 41bfc4078..000000000 --- a/ui/gfx/transform_util_unittest.cc +++ /dev/null @@ -1,180 +0,0 @@ -// 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 "ui/gfx/transform_util.h" - -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/gfx/point.h" -#include "ui/gfx/point3_f.h" -#include "ui/gfx/rect.h" - -namespace gfx { -namespace { - -TEST(TransformUtilTest, GetScaleTransform) { - const Point kAnchor(20, 40); - const float kScale = 0.5f; - - Transform scale = GetScaleTransform(kAnchor, kScale); - - const int kOffset = 10; - for (int sign_x = -1; sign_x <= 1; ++sign_x) { - for (int sign_y = -1; sign_y <= 1; ++sign_y) { - Point test(kAnchor.x() + sign_x * kOffset, - kAnchor.y() + sign_y * kOffset); - scale.TransformPoint(&test); - - EXPECT_EQ(Point(kAnchor.x() + sign_x * kOffset * kScale, - kAnchor.y() + sign_y * kOffset * kScale), - test); - } - } -} - -TEST(TransformUtilTest, SnapRotation) { - Transform result(Transform::kSkipInitialization); - Transform transform; - transform.RotateAboutZAxis(89.99); - - Rect viewport(1920, 1200); - bool snapped = SnapTransform(&result, transform, viewport); - - EXPECT_TRUE(snapped) << "Viewport should snap for this rotation."; -} - -TEST(TransformUtilTest, SnapRotationDistantViewport) { - const int kOffset = 5000; - Transform result(Transform::kSkipInitialization); - Transform transform; - - transform.RotateAboutZAxis(89.99); - - Rect viewport(kOffset, kOffset, 1920, 1200); - bool snapped = SnapTransform(&result, transform, viewport); - - EXPECT_FALSE(snapped) << "Distant viewport shouldn't snap by more than 1px."; -} - -TEST(TransformUtilTest, NoSnapRotation) { - Transform result(Transform::kSkipInitialization); - Transform transform; - const int kOffset = 5000; - - transform.RotateAboutZAxis(89.9); - - Rect viewport(kOffset, kOffset, 1920, 1200); - bool snapped = SnapTransform(&result, transform, viewport); - - EXPECT_FALSE(snapped) << "Viewport should not snap for this rotation."; -} - -// Translations should always be snappable, the most we would move is 0.5 -// pixels towards either direction to the nearest value in each component. -TEST(TransformUtilTest, SnapTranslation) { - Transform result(Transform::kSkipInitialization); - Transform transform; - - transform.Translate3d( - SkDoubleToMScalar(1.01), SkDoubleToMScalar(1.99), SkDoubleToMScalar(3.0)); - - Rect viewport(1920, 1200); - bool snapped = SnapTransform(&result, transform, viewport); - - EXPECT_TRUE(snapped) << "Viewport should snap for this translation."; -} - -TEST(TransformUtilTest, SnapTranslationDistantViewport) { - Transform result(Transform::kSkipInitialization); - Transform transform; - const int kOffset = 5000; - - transform.Translate3d( - SkDoubleToMScalar(1.01), SkDoubleToMScalar(1.99), SkDoubleToMScalar(3.0)); - - Rect viewport(kOffset, kOffset, 1920, 1200); - bool snapped = SnapTransform(&result, transform, viewport); - - EXPECT_TRUE(snapped) - << "Distant viewport should still snap by less than 1px."; -} - -TEST(TransformUtilTest, SnapScale) { - Transform result(Transform::kSkipInitialization); - Transform transform; - - transform.Scale3d(SkDoubleToMScalar(5.0), - SkDoubleToMScalar(2.00001), - SkDoubleToMScalar(1.0)); - Rect viewport(1920, 1200); - bool snapped = SnapTransform(&result, transform, viewport); - - EXPECT_TRUE(snapped) << "Viewport should snap for this scaling."; -} - -TEST(TransformUtilTest, NoSnapScale) { - Transform result(Transform::kSkipInitialization); - Transform transform; - - transform.Scale3d( - SkDoubleToMScalar(5.0), SkDoubleToMScalar(2.1), SkDoubleToMScalar(1.0)); - Rect viewport(1920, 1200); - bool snapped = SnapTransform(&result, transform, viewport); - - EXPECT_FALSE(snapped) << "Viewport shouldn't snap for this scaling."; -} - -TEST(TransformUtilTest, SnapCompositeTransform) { - Transform result(Transform::kSkipInitialization); - Transform transform; - - transform.Translate3d(SkDoubleToMScalar(30.5), SkDoubleToMScalar(20.0), - SkDoubleToMScalar(10.1)); - transform.RotateAboutZAxis(89.99); - transform.Scale3d(SkDoubleToMScalar(1.0), - SkDoubleToMScalar(3.00001), - SkDoubleToMScalar(2.0)); - - Rect viewport(1920, 1200); - bool snapped = SnapTransform(&result, transform, viewport); - ASSERT_TRUE(snapped) << "Viewport should snap all components."; - - Point3F point; - - point = Point3F(viewport.origin()); - result.TransformPoint(&point); - EXPECT_EQ(Point3F(31.f, 20.f, 10.f), point) << "Transformed origin"; - - point = Point3F(viewport.top_right()); - result.TransformPoint(&point); - EXPECT_EQ(Point3F(31.f, 1940.f, 10.f), point) << "Transformed top-right"; - - point = Point3F(viewport.bottom_left()); - result.TransformPoint(&point); - EXPECT_EQ(Point3F(-3569.f, 20.f, 10.f), point) << "Transformed bottom-left"; - - point = Point3F(viewport.bottom_right()); - result.TransformPoint(&point); - EXPECT_EQ(Point3F(-3569.f, 1940.f, 10.f), point) - << "Transformed bottom-right"; -} - -TEST(TransformUtilTest, NoSnapSkewedCompositeTransform) { - Transform result(Transform::kSkipInitialization); - Transform transform; - - - transform.RotateAboutZAxis(89.99); - transform.Scale3d(SkDoubleToMScalar(1.0), - SkDoubleToMScalar(3.00001), - SkDoubleToMScalar(2.0)); - transform.Translate3d(SkDoubleToMScalar(30.5), SkDoubleToMScalar(20.0), - SkDoubleToMScalar(10.1)); - transform.SkewX(20.0); - Rect viewport(1920, 1200); - bool snapped = SnapTransform(&result, transform, viewport); - EXPECT_FALSE(snapped) << "Skewed viewport should not snap."; -} - -} // namespace -} // namespace gfx diff --git a/ui/gfx/ui_gfx_exports.cc b/ui/gfx/ui_gfx_exports.cc deleted file mode 100644 index ca95eb331..000000000 --- a/ui/gfx/ui_gfx_exports.cc +++ /dev/null @@ -1,10 +0,0 @@ -// 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 file is for including headers that are not included in any other .cc -// files contained with the ui/gfx module. We need to include these here so -// that linker will know to include the symbols, defined by these headers, in -// the resulting dynamic library (gfx.dll). - -#include "ui/gfx/vsync_provider.h" diff --git a/ui/gfx/vsync_provider.h b/ui/gfx/vsync_provider.h deleted file mode 100644 index 90464bcbf..000000000 --- a/ui/gfx/vsync_provider.h +++ /dev/null @@ -1,33 +0,0 @@ -// 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. - -#ifndef UI_GFX_VSYNC_PROVIDER_H_ -#define UI_GFX_VSYNC_PROVIDER_H_ - -#include "base/callback.h" -#include "base/time/time.h" -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -class GFX_EXPORT VSyncProvider { - public: - virtual ~VSyncProvider() {} - - typedef base::Callback< - void(const base::TimeTicks timebase, const base::TimeDelta interval)> - UpdateVSyncCallback; - - // Get the time of the most recent screen refresh, along with the time - // between consecutive refreshes. The callback is called as soon as - // the data is available: it could be immediately from this method, - // later via a PostTask to the current MessageLoop, or never (if we have - // no data source). We provide the strong guarantee that the callback will - // not be called once the instance of this class is destroyed. - virtual void GetVSyncParameters(const UpdateVSyncCallback& callback) = 0; -}; - -} // namespace gfx - -#endif // UI_GFX_VSYNC_PROVIDER_H_ diff --git a/ui/gfx/x/BUILD.gn b/ui/gfx/x/BUILD.gn deleted file mode 100644 index 590195d48..000000000 --- a/ui/gfx/x/BUILD.gn +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2014 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. - -component("x") { - output_name = "gfx_x11" - - sources = [ - "../gfx_export.h", - "x11_atom_cache.cc", - "x11_atom_cache.h", - "x11_connection.cc", - "x11_connection.h", - "x11_error_tracker.cc", - "x11_error_tracker.h", - "x11_switches.cc", - "x11_switches.h", - "x11_types.cc", - "x11_types.h", - ] - - defines = [ "GFX_IMPLEMENTATION" ] - - configs += [ "//build/config/linux:x11" ] - - deps = [ - "//base", - ] -} diff --git a/ui/gfx/x/x11_atom_cache.cc b/ui/gfx/x/x11_atom_cache.cc deleted file mode 100644 index cc5d5eb3f..000000000 --- a/ui/gfx/x/x11_atom_cache.cc +++ /dev/null @@ -1,48 +0,0 @@ -// 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 "ui/gfx/x/x11_atom_cache.h" - -#include -#include - -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" - -namespace ui { - -X11AtomCache::X11AtomCache(XDisplay* xdisplay, const char** to_cache) - : xdisplay_(xdisplay), - uncached_atoms_allowed_(false) { - int cache_count = 0; - for (const char** i = to_cache; *i != NULL; i++) - cache_count++; - - scoped_ptr cached_atoms(new XAtom[cache_count]); - - // Grab all the atoms we need now to minimize roundtrips to the X11 server. - XInternAtoms(xdisplay_, - const_cast(to_cache), cache_count, False, - cached_atoms.get()); - - for (int i = 0; i < cache_count; ++i) - cached_atoms_.insert(std::make_pair(to_cache[i], cached_atoms[i])); -} - -X11AtomCache::~X11AtomCache() {} - -XAtom X11AtomCache::GetAtom(const char* name) const { - std::map::const_iterator it = cached_atoms_.find(name); - - if (uncached_atoms_allowed_ && it == cached_atoms_.end()) { - XAtom atom = XInternAtom(xdisplay_, name, false); - cached_atoms_.insert(std::make_pair(name, atom)); - return atom; - } - - CHECK(it != cached_atoms_.end()) << " Atom " << name << " not found"; - return it->second; -} - -} // namespace ui diff --git a/ui/gfx/x/x11_atom_cache.h b/ui/gfx/x/x11_atom_cache.h deleted file mode 100644 index 92d4db799..000000000 --- a/ui/gfx/x/x11_atom_cache.h +++ /dev/null @@ -1,46 +0,0 @@ -// 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 UI_GFX_X_X11_ATOM_CACHE_H_ -#define UI_GFX_X_X11_ATOM_CACHE_H_ - -#include -#include - -#include "base/basictypes.h" -#include "ui/gfx/gfx_export.h" -#include "ui/gfx/x/x11_types.h" - -namespace ui { - -// Pre-caches all Atoms on first use to minimize roundtrips to the X11 -// server. By default, GetAtom() will CHECK() that atoms accessed through -// GetAtom() were passed to the constructor, but this behaviour can be changed -// with allow_uncached_atoms(). -class GFX_EXPORT X11AtomCache { - public: - // Preinterns the NULL terminated list of string |to_cache_ on |xdisplay|. - X11AtomCache(XDisplay* xdisplay, const char** to_cache); - ~X11AtomCache(); - - // Returns the pre-interned Atom without having to go to the x server. - XAtom GetAtom(const char*) const; - - // When an Atom isn't in the list of items we've cached, we should look it - // up, cache it locally, and then return the result. - void allow_uncached_atoms() { uncached_atoms_allowed_ = true; } - - private: - XDisplay* xdisplay_; - - bool uncached_atoms_allowed_; - - mutable std::map cached_atoms_; - - DISALLOW_COPY_AND_ASSIGN(X11AtomCache); -}; - -} // namespace ui - -#endif // UI_GFX_X_X11_ATOM_CACHE_H_ diff --git a/ui/gfx/x/x11_connection.cc b/ui/gfx/x/x11_connection.cc deleted file mode 100644 index c5ee77f40..000000000 --- a/ui/gfx/x/x11_connection.cc +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 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 "ui/gfx/x/x11_connection.h" - -#include - -#include "ui/gfx/x/x11_types.h" - -namespace gfx { - -bool InitializeThreadedX11() { - return XInitThreads() && gfx::GetXDisplay(); -} - -} // namespace gfx diff --git a/ui/gfx/x/x11_connection.h b/ui/gfx/x/x11_connection.h deleted file mode 100644 index 06ca89fe8..000000000 --- a/ui/gfx/x/x11_connection.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 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 UI_GFX_X_X11_CONNECTION_H_ -#define UI_GFX_X_X11_CONNECTION_H_ - -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -// Initializes thread support for X11, and opens a connection to the display. -// Return false if either fails, and true otherwise. -GFX_EXPORT bool InitializeThreadedX11(); - -} // namespace gfx - -#endif // UI_GFX_X_X11_CONNECTION_H_ diff --git a/ui/gfx/x/x11_error_tracker.cc b/ui/gfx/x/x11_error_tracker.cc deleted file mode 100644 index 110f79ccd..000000000 --- a/ui/gfx/x/x11_error_tracker.cc +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2014 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/logging.h" -#include "ui/gfx/x/x11_error_tracker.h" - -#include "ui/gfx/x/x11_types.h" - -namespace { - -unsigned char g_x11_error_code = 0; -static gfx::X11ErrorTracker* g_handler = NULL; - -int X11ErrorHandler(Display* display, XErrorEvent* error) { - g_x11_error_code = error->error_code; - return 0; -} -} - -namespace gfx { - -X11ErrorTracker::X11ErrorTracker() { - // This is a poor-man's check for incorrect usage. It disallows nested - // X11ErrorTracker instances on the same thread. - DCHECK(g_handler == NULL); - g_handler = this; - XSync(GetXDisplay(), False); - old_handler_ = XSetErrorHandler(X11ErrorHandler); - g_x11_error_code = 0; -} - -X11ErrorTracker::~X11ErrorTracker() { - g_handler = NULL; - XSetErrorHandler(old_handler_); -} - -bool X11ErrorTracker::FoundNewError() { - XSync(GetXDisplay(), False); - unsigned char error = g_x11_error_code; - g_x11_error_code = 0; - return error != 0; -} - -} // namespace gfx diff --git a/ui/gfx/x/x11_error_tracker.h b/ui/gfx/x/x11_error_tracker.h deleted file mode 100644 index efcac0c70..000000000 --- a/ui/gfx/x/x11_error_tracker.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 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 UI_GFX_X_X11_ERROR_TRACKER_H_ -#define UI_GFX_X_X11_ERROR_TRACKER_H_ - -#include - -#include "base/basictypes.h" -#include "ui/gfx/gfx_export.h" - -namespace gfx { - -// X11ErrorTracker catches X11 errors in a non-fatal way. It does so by -// temporarily changing the X11 error handler. The old error handler is -// restored when the tracker is destroyed. -class GFX_EXPORT X11ErrorTracker { - public: - X11ErrorTracker(); - ~X11ErrorTracker(); - - // Returns whether an X11 error happened since this function was last called - // (or since the creation of the tracker). This is potentially expensive, - // since this causes a sync with the X server. - bool FoundNewError(); - - private: - XErrorHandler old_handler_; - - DISALLOW_COPY_AND_ASSIGN(X11ErrorTracker); -}; - -} // namespace gfx - -#endif // UI_GFX_X_X11_ERROR_TRACKER_H_ diff --git a/ui/gfx/x/x11_switches.cc b/ui/gfx/x/x11_switches.cc deleted file mode 100644 index bda0ad3c5..000000000 --- a/ui/gfx/x/x11_switches.cc +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 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 "ui/gfx/x/x11_switches.h" - -namespace switches { - -#if !defined(OS_CHROMEOS) -// Which X11 display to connect to. Emulates the GTK+ "--display=" command line -// argument. -const char kX11Display[] = "display"; -#endif - -} // namespace switches diff --git a/ui/gfx/x/x11_switches.h b/ui/gfx/x/x11_switches.h deleted file mode 100644 index 4044c5141..000000000 --- a/ui/gfx/x/x11_switches.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 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 UI_GFX_X_X11_SWITCHES_H_ -#define UI_GFX_X_X11_SWITCHES_H_ - -#include "ui/gfx/gfx_export.h" - -namespace switches { - -#if !defined(OS_CHROMEOS) -GFX_EXPORT extern const char kX11Display[]; -#endif - -} // namespace switches - -#endif // UI_GFX_X_X11_SWITCHES_H_ diff --git a/ui/gfx/x/x11_types.cc b/ui/gfx/x/x11_types.cc deleted file mode 100644 index 54a0816c6..000000000 --- a/ui/gfx/x/x11_types.cc +++ /dev/null @@ -1,170 +0,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 "ui/gfx/x/x11_types.h" - -#include - -#include "base/command_line.h" -#include "base/message_loop/message_loop.h" -#include "ui/gfx/x/x11_switches.h" - -namespace gfx { - -XDisplay* GetXDisplay() { - static XDisplay* display = NULL; - if (!display) - display = OpenNewXDisplay(); - return display; -} - -XDisplay* OpenNewXDisplay() { -#if defined(OS_CHROMEOS) - return XOpenDisplay(NULL); -#else - std::string display_str = base::CommandLine::ForCurrentProcess()-> - GetSwitchValueASCII(switches::kX11Display); - return XOpenDisplay(display_str.empty() ? NULL : display_str.c_str()); -#endif -} - -void PutARGBImage(XDisplay* display, - void* visual, int depth, - XID pixmap, void* pixmap_gc, - const uint8* data, - int width, int height) { - PutARGBImage(display, - visual, depth, - pixmap, pixmap_gc, - data, width, height, - 0, 0, // src_x, src_y - 0, 0, // dst_x, dst_y - width, height); -} - -int BitsPerPixelForPixmapDepth(XDisplay* dpy, int depth) { - int count; - XPixmapFormatValues* formats = XListPixmapFormats(dpy, &count); - if (!formats) - return -1; - - int bits_per_pixel = -1; - for (int i = 0; i < count; ++i) { - if (formats[i].depth == depth) { - bits_per_pixel = formats[i].bits_per_pixel; - break; - } - } - - XFree(formats); - return bits_per_pixel; -} - -void PutARGBImage(XDisplay* display, - void* visual, int depth, - XID pixmap, void* pixmap_gc, - const uint8* data, - int data_width, int data_height, - int src_x, int src_y, - int dst_x, int dst_y, - int copy_width, int copy_height) { - // TODO(scherkus): potential performance impact... consider passing in as a - // parameter. - int pixmap_bpp = BitsPerPixelForPixmapDepth(display, depth); - - XImage image; - memset(&image, 0, sizeof(image)); - - image.width = data_width; - image.height = data_height; - image.format = ZPixmap; - image.byte_order = LSBFirst; - image.bitmap_unit = 8; - image.bitmap_bit_order = LSBFirst; - image.depth = depth; - image.bits_per_pixel = pixmap_bpp; - image.bytes_per_line = data_width * pixmap_bpp / 8; - - if (pixmap_bpp == 32) { - image.red_mask = 0xff0000; - image.green_mask = 0xff00; - image.blue_mask = 0xff; - - // If the X server depth is already 32-bits and the color masks match, - // then our job is easy. - Visual* vis = static_cast(visual); - if (image.red_mask == vis->red_mask && - image.green_mask == vis->green_mask && - image.blue_mask == vis->blue_mask) { - image.data = const_cast(reinterpret_cast(data)); - XPutImage(display, pixmap, static_cast(pixmap_gc), &image, - src_x, src_y, dst_x, dst_y, - copy_width, copy_height); - } else { - // Otherwise, we need to shuffle the colors around. Assume red and blue - // need to be swapped. - // - // It's possible to use some fancy SSE tricks here, but since this is the - // slow path anyway, we do it slowly. - - uint8_t* bitmap32 = - static_cast(malloc(4 * data_width * data_height)); - if (!bitmap32) - return; - uint8_t* const orig_bitmap32 = bitmap32; - const uint32_t* bitmap_in = reinterpret_cast(data); - for (int y = 0; y < data_height; ++y) { - for (int x = 0; x < data_width; ++x) { - const uint32_t pixel = *(bitmap_in++); - bitmap32[0] = (pixel >> 16) & 0xff; // Red - bitmap32[1] = (pixel >> 8) & 0xff; // Green - bitmap32[2] = pixel & 0xff; // Blue - bitmap32[3] = (pixel >> 24) & 0xff; // Alpha - bitmap32 += 4; - } - } - image.data = reinterpret_cast(orig_bitmap32); - XPutImage(display, pixmap, static_cast(pixmap_gc), &image, - src_x, src_y, dst_x, dst_y, - copy_width, copy_height); - free(orig_bitmap32); - } - } else if (pixmap_bpp == 16) { - // Some folks have VNC setups which still use 16-bit visuals and VNC - // doesn't include Xrender. - - uint16_t* bitmap16 = - static_cast(malloc(2 * data_width * data_height)); - if (!bitmap16) - return; - uint16_t* const orig_bitmap16 = bitmap16; - const uint32_t* bitmap_in = reinterpret_cast(data); - for (int y = 0; y < data_height; ++y) { - for (int x = 0; x < data_width; ++x) { - const uint32_t pixel = *(bitmap_in++); - uint16_t out_pixel = ((pixel >> 8) & 0xf800) | - ((pixel >> 5) & 0x07e0) | - ((pixel >> 3) & 0x001f); - *(bitmap16++) = out_pixel; - } - } - - image.data = reinterpret_cast(orig_bitmap16); - image.red_mask = 0xf800; - image.green_mask = 0x07e0; - image.blue_mask = 0x001f; - - XPutImage(display, pixmap, static_cast(pixmap_gc), &image, - src_x, src_y, dst_x, dst_y, - copy_width, copy_height); - free(orig_bitmap16); - } else { - LOG(FATAL) << "Sorry, we don't support your visual depth without " - "Xrender support (depth:" << depth - << " bpp:" << pixmap_bpp << ")"; - } -} - -} // namespace gfx - diff --git a/ui/gfx/x/x11_types.h b/ui/gfx/x/x11_types.h deleted file mode 100644 index 82ce8389b..000000000 --- a/ui/gfx/x/x11_types.h +++ /dev/null @@ -1,69 +0,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. - -#ifndef UI_GFX_X_X11_UTIL_H_ -#define UI_GFX_X_X11_UTIL_H_ - -#include "base/basictypes.h" -#include "base/memory/scoped_ptr.h" -#include "ui/gfx/gfx_export.h" - -typedef unsigned long XAtom; -typedef unsigned long XID; -typedef struct _XImage XImage; -typedef struct _XGC *GC; -typedef struct _XDisplay XDisplay; - -extern "C" { -int XFree(void*); -} - -namespace gfx { - -template -struct XObjectDeleter { - inline void operator()(void* ptr) const { F(static_cast(ptr)); } -}; - -template > -using XScopedPtr = scoped_ptr; - -// TODO(oshima|evan): This assume there is one display and doesn't work -// undef multiple displays/monitor environment. Remove this and change the -// chrome codebase to get the display from window. -GFX_EXPORT XDisplay* GetXDisplay(); - -// This opens a new X11 XDisplay*, taking command line arguments into account. -GFX_EXPORT XDisplay* OpenNewXDisplay(); - -// Return the number of bits-per-pixel for a pixmap of the given depth -GFX_EXPORT int BitsPerPixelForPixmapDepth(XDisplay* display, int depth); - -// Draws ARGB data on the given pixmap using the given GC, converting to the -// server side visual depth as needed. Destination is assumed to be the same -// dimensions as |data| or larger. |data| is also assumed to be in row order -// with each line being exactly |width| * 4 bytes long. -GFX_EXPORT void PutARGBImage(XDisplay* display, - void* visual, int depth, - XID pixmap, void* pixmap_gc, - const uint8* data, - int width, int height); - -// Same as above only more general: -// - |data_width| and |data_height| refer to the data image -// - |src_x|, |src_y|, |copy_width| and |copy_height| define source region -// - |dst_x|, |dst_y|, |copy_width| and |copy_height| define destination region -GFX_EXPORT void PutARGBImage(XDisplay* display, - void* visual, int depth, - XID pixmap, void* pixmap_gc, - const uint8* data, - int data_width, int data_height, - int src_x, int src_y, - int dst_x, int dst_y, - int copy_width, int copy_height); - -} // namespace gfx - -#endif // UI_GFX_X_X11_UTIL_H_ - diff --git a/ui/gl/BUILD.gn b/ui/gl/BUILD.gn deleted file mode 100644 index d681dc4bf..000000000 --- a/ui/gl/BUILD.gn +++ /dev/null @@ -1,186 +0,0 @@ -# Copyright 2014 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/ui.gni") -if (is_android) { - import("//build/config/android/config.gni") - import("//build/config/android/rules.gni") -} - -source_set("gl") { - sources = [ - "gl_bindings.h", - "gl_bindings_autogen_gl.cc", - "gl_bindings_autogen_gl.h", - "gl_bindings_skia_in_process.cc", - "gl_bindings_skia_in_process.h", - "gl_context.cc", - "gl_context.h", - "gl_context_stub.cc", - "gl_context_stub.h", - "gl_context_stub_with_extensions.cc", - "gl_context_stub_with_extensions.h", - "gl_enums.cc", - "gl_enums.h", - "gl_enums_implementation_autogen.h", - "gl_export.h", - "gl_gl_api_implementation.cc", - "gl_gl_api_implementation.h", - "gl_implementation.cc", - "gl_implementation.h", - "gl_share_group.cc", - "gl_share_group.h", - "gl_surface.cc", - "gl_surface.h", - "gl_surface_stub.cc", - "gl_surface_stub.h", - "gl_switches.cc", - "gl_switches.h", - "gl_version_info.cc", - "gl_version_info.h", - "gpu_timing.cc", - "gpu_timing.h", - ] - - public_deps = [ - "//base", - "//third_party/mesa:mesa_headers", - "//ui/gfx", - "//ui/gfx/geometry", - ] - - deps = [ - "//base/third_party/dynamic_annotations", - "//skia", - ] - - if (is_android || is_linux) { - sources += [ - "gl_bindings.cc", - "gl_bindings_autogen_osmesa.cc", - "gl_bindings_autogen_osmesa.h", - "gl_context_osmesa.cc", - "gl_context_osmesa.h", - "gl_implementation_osmesa.cc", - "gl_implementation_osmesa.h", - "gl_osmesa_api_implementation.cc", - "gl_osmesa_api_implementation.h", - "gl_state_restorer.cc", - "gl_state_restorer.h", - "gl_surface_osmesa.cc", - "gl_surface_osmesa.h", - "scoped_binders.cc", - "scoped_binders.h", - "scoped_make_current.cc", - "scoped_make_current.h", - "sync_control_vsync_provider.cc", - "sync_control_vsync_provider.h", - ] - } - if (is_linux) { - deps += [ "//third_party/libevent" ] - } - if (use_glfw) { - sources += [ - "gl_context_glfw.cc", - "gl_context_glfw.h", - "gl_implementation_glfw.cc", - "gl_surface_glfw.cc", - "gl_surface_glfw.h", - ] - - deps += [ "//third_party/glfw" ] - } - if (use_x11) { - sources += [ - "gl_context_osmesa_x11.cc", - "gl_surface_osmesa_x11.cc", - "gl_surface_osmesa_x11.h", - ] - - configs += [ - "//build/config/linux:x11", - "//build/config/linux:xcomposite", - "//build/config/linux:xext", - ] - - deps += [ "//ui/gfx/x" ] - } - if (is_android) { - sources += [ - "android/gl_jni_registrar.cc", - "android/gl_jni_registrar.h", - "android/scoped_java_surface.cc", - "android/scoped_java_surface.h", - "android/surface_texture.cc", - "android/surface_texture.h", - "android/surface_texture_listener.cc", - "android/surface_texture_listener.h", - "egl_util.cc", - "egl_util.h", - "gl_bindings_autogen_egl.cc", - "gl_bindings_autogen_egl.h", - "gl_context_android.cc", - "gl_context_egl.cc", - "gl_context_egl.h", - "gl_egl_api_implementation.cc", - "gl_egl_api_implementation.h", - "gl_implementation_android.cc", - "gl_surface_android.cc", - "gl_surface_egl.cc", - "gl_surface_egl.h", - ] - - defines = [ - "GL_GLEXT_PROTOTYPES", - "EGL_EGLEXT_PROTOTYPES", - ] - - libs = [ "android" ] - - deps += [ ":gl_jni_headers" ] - } - - if (is_ios) { - sources += [ - "gl_context_ios.h", - "gl_context_ios.mm", - "gl_implementation_ios.cc", - "gl_surface_ios.h", - "gl_surface_ios.mm", - ] - } - - if (is_mac) { - sources += [ - "gl_context_cgl.cc", - "gl_context_cgl.h", - "gl_context_mac.h", - "gl_context_mac.mm", - "gl_implementation_mac.cc", - "gl_surface_mac.h", - "gl_surface_mac.mm", - "gpu_switching_manager.cc", - "gpu_switching_manager.h", - ] - } -} - -if (is_android) { - generate_jar_jni("surface_jni_headers") { - jni_package = "ui/gl" - classes = [ "android/view/Surface.class" ] - } - - generate_jni("gl_jni_headers") { - deps = [ - ":surface_jni_headers", - ] - sources = [ - "android/java/src/org/chromium/ui/gl/SurfaceTextureListener.java", - "android/java/src/org/chromium/ui/gl/SurfaceTexturePlatformWrapper.java", - ] - jni_package = "ui/gl" - } -} diff --git a/ui/gl/EGL/eglextchromium.h b/ui/gl/EGL/eglextchromium.h deleted file mode 100644 index fdde8532c..000000000 --- a/ui/gl/EGL/eglextchromium.h +++ /dev/null @@ -1,36 +0,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. - -// This file contains Chromium-specific EGL extensions declarations. - -#ifndef GPU_EGL_EGLEXTCHROMIUM_H_ -#define GPU_EGL_EGLEXTCHROMIUM_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* EGLSyncControlCHROMIUM requires 64-bit uint support */ -#if KHRONOS_SUPPORT_INT64 -#ifndef EGL_CHROMIUM_sync_control -#define EGL_CHROMIUM_sync_control 1 -typedef khronos_uint64_t EGLuint64CHROMIUM; -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncValuesCHROMIUM( - EGLDisplay dpy, EGLSurface surface, EGLuint64CHROMIUM *ust, - EGLuint64CHROMIUM *msc, EGLuint64CHROMIUM *sbc); -#endif /* EGL_EGLEXT_PROTOTYPES */ -typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCVALUESCHROMIUMPROC) - (EGLDisplay dpy, EGLSurface surface, EGLuint64CHROMIUM *ust, - EGLuint64CHROMIUM *msc, EGLuint64CHROMIUM *sbc); -#endif -#endif - -#ifdef __cplusplus -} -#endif - -#define // GPU_EGL_EGLEXTCHROMIUM_H_ diff --git a/ui/gl/GL/glextchromium.h b/ui/gl/GL/glextchromium.h deleted file mode 100644 index 41818d7f5..000000000 --- a/ui/gl/GL/glextchromium.h +++ /dev/null @@ -1,26 +0,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. - -// This file contains Chromium-specific GL extensions declarations. - -#ifndef GPU_GL_GLEXTCHROMIUM_H_ -#define GPU_GL_GLEXTCHROMIUM_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GL_NVX_gpu_memory_info -#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 -#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 -#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 -#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A -#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B -#endif - -#ifdef __cplusplus -} -#endif - -#endif // GPU_GL_GLEXTCHROMIUM_H_ diff --git a/ui/gl/OWNERS b/ui/gl/OWNERS deleted file mode 100644 index f8419dc45..000000000 --- a/ui/gl/OWNERS +++ /dev/null @@ -1,7 +0,0 @@ -kbr@chromium.org -piman@chromium.org -sievers@chromium.org -per-file gl_image*=reveman@chromium.org -per-file *_ozone*=alexst@chromium.org -per-file *_ozone*=dnicoara@chromium.org -per-file *_ozone*=spang@chromium.org diff --git a/ui/gl/android/gl_jni_registrar.cc b/ui/gl/android/gl_jni_registrar.cc deleted file mode 100644 index 91ae65f45..000000000 --- a/ui/gl/android/gl_jni_registrar.cc +++ /dev/null @@ -1,30 +0,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 "ui/gl/android/gl_jni_registrar.h" - -#include "base/android/jni_android.h" -#include "base/android/jni_registrar.h" -#include "ui/gl/android/surface_texture.h" -#include "ui/gl/android/surface_texture_listener.h" - -namespace ui { -namespace gl { -namespace android { - -static base::android::RegistrationMethod kGLRegisteredMethods[] = { - { "SurfaceTexture", - gfx::SurfaceTexture::RegisterSurfaceTexture }, - { "SurfaceTextureListener", - gfx::SurfaceTextureListener::RegisterSurfaceTextureListener }, -}; - -bool RegisterJni(JNIEnv* env) { - return RegisterNativeMethods(env, kGLRegisteredMethods, - arraysize(kGLRegisteredMethods)); -} - -} // namespace android -} // namespace gl -} // namespace ui diff --git a/ui/gl/android/gl_jni_registrar.h b/ui/gl/android/gl_jni_registrar.h deleted file mode 100644 index 3f028b7fb..000000000 --- a/ui/gl/android/gl_jni_registrar.h +++ /dev/null @@ -1,23 +0,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. - -#ifndef UI_GL_ANDROID_GL_JNI_REGISTRAR_H_ -#define UI_GL_ANDROID_GL_JNI_REGISTRAR_H_ - -#include - -#include "ui/gl/gl_export.h" - -namespace ui { -namespace gl { -namespace android { - -// Register all JNI bindings necessary for chrome. -GL_EXPORT bool RegisterJni(JNIEnv* env); - -} // namespace android -} // namespace gl -} // namespace ui - -#endif // UI_GL_ANDROID_GL_JNI_REGISTRAR_H_ diff --git a/ui/gl/android/java/src/org/chromium/ui/gl/SurfaceTextureListener.java b/ui/gl/android/java/src/org/chromium/ui/gl/SurfaceTextureListener.java deleted file mode 100644 index bc57e1fac..000000000 --- a/ui/gl/android/java/src/org/chromium/ui/gl/SurfaceTextureListener.java +++ /dev/null @@ -1,40 +0,0 @@ -// 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. - -package org.chromium.ui.gl; - -import android.graphics.SurfaceTexture; - -import org.chromium.base.JNINamespace; - -/** - * Listener to an android SurfaceTexture object for frame availability. - */ -@JNINamespace("gfx") -class SurfaceTextureListener implements SurfaceTexture.OnFrameAvailableListener { - // Used to determine the class instance to dispatch the native call to. - private final long mNativeSurfaceTextureListener; - - SurfaceTextureListener(long nativeSurfaceTextureListener) { - assert nativeSurfaceTextureListener != 0; - mNativeSurfaceTextureListener = nativeSurfaceTextureListener; - } - - @Override - public void onFrameAvailable(SurfaceTexture surfaceTexture) { - nativeFrameAvailable(mNativeSurfaceTextureListener); - } - - @Override - protected void finalize() throws Throwable { - try { - nativeDestroy(mNativeSurfaceTextureListener); - } finally { - super.finalize(); - } - } - - private native void nativeFrameAvailable(long nativeSurfaceTextureListener); - private native void nativeDestroy(long nativeSurfaceTextureListener); -} diff --git a/ui/gl/android/java/src/org/chromium/ui/gl/SurfaceTexturePlatformWrapper.java b/ui/gl/android/java/src/org/chromium/ui/gl/SurfaceTexturePlatformWrapper.java deleted file mode 100644 index e785af6a1..000000000 --- a/ui/gl/android/java/src/org/chromium/ui/gl/SurfaceTexturePlatformWrapper.java +++ /dev/null @@ -1,78 +0,0 @@ -// 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. - -package org.chromium.ui.gl; - -import android.graphics.SurfaceTexture; -import android.os.Build; -import android.util.Log; - -import org.chromium.base.CalledByNative; -import org.chromium.base.JNINamespace; - -/** - * Wrapper class for the underlying platform's SurfaceTexture in order to - * provide a stable JNI API. - */ -@JNINamespace("gfx") -class SurfaceTexturePlatformWrapper { - - private static final String TAG = "SurfaceTexturePlatformWrapper"; - - @CalledByNative - private static SurfaceTexture create(int textureId) { - return new SurfaceTexture(textureId); - } - - @CalledByNative - private static SurfaceTexture createSingleBuffered(int textureId) { - assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; - return new SurfaceTexture(textureId, true); - } - - @CalledByNative - private static void destroy(SurfaceTexture surfaceTexture) { - surfaceTexture.setOnFrameAvailableListener(null); - surfaceTexture.release(); - } - - @CalledByNative - private static void setFrameAvailableCallback(SurfaceTexture surfaceTexture, - long nativeSurfaceTextureListener) { - surfaceTexture.setOnFrameAvailableListener( - new SurfaceTextureListener(nativeSurfaceTextureListener)); - } - - @CalledByNative - private static void updateTexImage(SurfaceTexture surfaceTexture) { - try { - surfaceTexture.updateTexImage(); - } catch (RuntimeException e) { - Log.e(TAG, "Error calling updateTexImage", e); - } - } - - @CalledByNative - private static void releaseTexImage(SurfaceTexture surfaceTexture) { - assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; - surfaceTexture.releaseTexImage(); - } - - @CalledByNative - private static void getTransformMatrix(SurfaceTexture surfaceTexture, float[] matrix) { - surfaceTexture.getTransformMatrix(matrix); - } - - @CalledByNative - private static void attachToGLContext(SurfaceTexture surfaceTexture, int texName) { - assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; - surfaceTexture.attachToGLContext(texName); - } - - @CalledByNative - private static void detachFromGLContext(SurfaceTexture surfaceTexture) { - assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; - surfaceTexture.detachFromGLContext(); - } -} diff --git a/ui/gl/android/scoped_java_surface.cc b/ui/gl/android/scoped_java_surface.cc deleted file mode 100644 index ae4f81a44..000000000 --- a/ui/gl/android/scoped_java_surface.cc +++ /dev/null @@ -1,89 +0,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 "ui/gl/android/scoped_java_surface.h" - -#include "base/logging.h" -#include "jni/Surface_jni.h" -#include "ui/gl/android/surface_texture.h" - -namespace { - -bool g_jni_initialized = false; - -void RegisterNativesIfNeeded(JNIEnv* env) { - if (!g_jni_initialized) { - JNI_Surface::RegisterNativesImpl(env); - g_jni_initialized = true; - } -} - -} // anonymous namespace - -namespace gfx { - -ScopedJavaSurface::ScopedJavaSurface() { -} - -ScopedJavaSurface::ScopedJavaSurface( - const base::android::JavaRef& surface) - : auto_release_(true), - is_protected_(false) { - JNIEnv* env = base::android::AttachCurrentThread(); - RegisterNativesIfNeeded(env); - DCHECK(env->IsInstanceOf(surface.obj(), Surface_clazz(env))); - j_surface_.Reset(surface); -} - -ScopedJavaSurface::ScopedJavaSurface( - const SurfaceTexture* surface_texture) - : auto_release_(true), - is_protected_(false) { - JNIEnv* env = base::android::AttachCurrentThread(); - RegisterNativesIfNeeded(env); - ScopedJavaLocalRef tmp(JNI_Surface::Java_Surface_Constructor( - env, surface_texture->j_surface_texture().obj())); - DCHECK(!tmp.is_null()); - j_surface_.Reset(tmp); -} - -ScopedJavaSurface::ScopedJavaSurface(RValue rvalue) { - MoveFrom(*rvalue.object); -} - -ScopedJavaSurface& ScopedJavaSurface::operator=(RValue rhs) { - MoveFrom(*rhs.object); - return *this; -} - -ScopedJavaSurface::~ScopedJavaSurface() { - if (auto_release_ && !j_surface_.is_null()) { - JNIEnv* env = base::android::AttachCurrentThread(); - JNI_Surface::Java_Surface_release(env, j_surface_.obj()); - } -} - -void ScopedJavaSurface::MoveFrom(ScopedJavaSurface& other) { - JNIEnv* env = base::android::AttachCurrentThread(); - j_surface_.Reset(env, other.j_surface_.Release()); - auto_release_ = other.auto_release_; - is_protected_ = other.is_protected_; -} - -bool ScopedJavaSurface::IsEmpty() const { - return j_surface_.is_null(); -} - -// static -ScopedJavaSurface ScopedJavaSurface::AcquireExternalSurface(jobject surface) { - JNIEnv* env = base::android::AttachCurrentThread(); - ScopedJavaLocalRef surface_ref; - surface_ref.Reset(env, surface); - gfx::ScopedJavaSurface scoped_surface(surface_ref); - scoped_surface.auto_release_ = false; - scoped_surface.is_protected_ = true; - return scoped_surface; -} - -} // namespace gfx diff --git a/ui/gl/android/scoped_java_surface.h b/ui/gl/android/scoped_java_surface.h deleted file mode 100644 index 54ed2a451..000000000 --- a/ui/gl/android/scoped_java_surface.h +++ /dev/null @@ -1,68 +0,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. - -#ifndef UI_GL_ANDROID_SCOPED_JAVA_SURFACE_H_ -#define UI_GL_ANDROID_SCOPED_JAVA_SURFACE_H_ - -#include - -#include "base/android/scoped_java_ref.h" -#include "base/move.h" -#include "ui/gl/gl_export.h" - -namespace gfx { - -class SurfaceTexture; - -// A helper class for holding a scoped reference to a Java Surface instance. -// When going out of scope, Surface.release() is called on the Java object to -// make sure server-side references (esp. wrt graphics memory) are released. -class GL_EXPORT ScopedJavaSurface { - MOVE_ONLY_TYPE_FOR_CPP_03(ScopedJavaSurface, RValue); - - public: - ScopedJavaSurface(); - - // Wraps an existing Java Surface object in a ScopedJavaSurface. - explicit ScopedJavaSurface(const base::android::JavaRef& surface); - - // Creates a Java Surface from a SurfaceTexture and wraps it in a - // ScopedJavaSurface. - explicit ScopedJavaSurface(const SurfaceTexture* surface_texture); - - // Move constructor. Take the surface from another ScopedJavaSurface object, - // the latter no longer owns the surface afterwards. - ScopedJavaSurface(RValue rvalue); - ScopedJavaSurface& operator=(RValue rhs); - - // Creates a ScopedJavaSurface that is owned externally, i.e., - // someone else is responsible to call Surface.release(). - static ScopedJavaSurface AcquireExternalSurface(jobject surface); - - ~ScopedJavaSurface(); - - // Check whether the surface is an empty one. - bool IsEmpty() const; - - // Check whether the surface is hardware protected so that no readback is - // possible. - bool is_protected() const { return is_protected_; } - - const base::android::JavaRef& j_surface() const { - return j_surface_; - } - - private: - // Performs destructive move from |other| to this. - void MoveFrom(ScopedJavaSurface& other); - - bool auto_release_; - bool is_protected_; - - base::android::ScopedJavaGlobalRef j_surface_; -}; - -} // namespace gfx - -#endif // UI_GL_ANDROID_SCOPED_JAVA_SURFACE_H_ diff --git a/ui/gl/android/surface_texture.cc b/ui/gl/android/surface_texture.cc deleted file mode 100644 index a9f52dc56..000000000 --- a/ui/gl/android/surface_texture.cc +++ /dev/null @@ -1,130 +0,0 @@ -// 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. - -#include "ui/gl/android/surface_texture.h" - -#include - -// TODO(boliu): Remove this include when we move off ICS. -#include "base/android/build_info.h" -#include "base/android/jni_android.h" -#include "base/logging.h" -#include "jni/SurfaceTexturePlatformWrapper_jni.h" -#include "ui/gl/android/scoped_java_surface.h" -#include "ui/gl/android/surface_texture_listener.h" -#include "ui/gl/gl_bindings.h" - -// TODO(boliu): Remove this method when Chromium stops supporting ICS. -bool GlContextMethodsAvailable() { - bool available = base::android::BuildInfo::GetInstance()->sdk_int() >= 16; - if (!available) - LOG(WARNING) << "Running on unsupported device: rendering may not work"; - return available; -} - -namespace gfx { - -scoped_refptr SurfaceTexture::Create(int texture_id) { - JNIEnv* env = base::android::AttachCurrentThread(); - return new SurfaceTexture( - Java_SurfaceTexturePlatformWrapper_create(env, texture_id)); -} - -scoped_refptr SurfaceTexture::CreateSingleBuffered( - int texture_id) { - DCHECK(IsSingleBufferModeSupported()); - JNIEnv* env = base::android::AttachCurrentThread(); - return new SurfaceTexture( - Java_SurfaceTexturePlatformWrapper_createSingleBuffered(env, texture_id)); -} - -SurfaceTexture::SurfaceTexture( - const base::android::ScopedJavaLocalRef& j_surface_texture) { - j_surface_texture_.Reset(j_surface_texture); -} - -SurfaceTexture::~SurfaceTexture() { - JNIEnv* env = base::android::AttachCurrentThread(); - Java_SurfaceTexturePlatformWrapper_destroy(env, j_surface_texture_.obj()); -} - -void SurfaceTexture::SetFrameAvailableCallback( - const base::Closure& callback) { - JNIEnv* env = base::android::AttachCurrentThread(); - Java_SurfaceTexturePlatformWrapper_setFrameAvailableCallback( - env, - j_surface_texture_.obj(), - reinterpret_cast(new SurfaceTextureListener(callback))); -} - -void SurfaceTexture::UpdateTexImage() { - JNIEnv* env = base::android::AttachCurrentThread(); - Java_SurfaceTexturePlatformWrapper_updateTexImage(env, - j_surface_texture_.obj()); -} - -void SurfaceTexture::ReleaseTexImage() { - DCHECK(IsSingleBufferModeSupported()); - JNIEnv* env = base::android::AttachCurrentThread(); - Java_SurfaceTexturePlatformWrapper_releaseTexImage(env, - j_surface_texture_.obj()); -} - -void SurfaceTexture::GetTransformMatrix(float mtx[16]) { - JNIEnv* env = base::android::AttachCurrentThread(); - - base::android::ScopedJavaLocalRef jmatrix( - env, env->NewFloatArray(16)); - Java_SurfaceTexturePlatformWrapper_getTransformMatrix( - env, j_surface_texture_.obj(), jmatrix.obj()); - - jboolean is_copy; - jfloat* elements = env->GetFloatArrayElements(jmatrix.obj(), &is_copy); - for (int i = 0; i < 16; ++i) { - mtx[i] = static_cast(elements[i]); - } - env->ReleaseFloatArrayElements(jmatrix.obj(), elements, JNI_ABORT); -} - -void SurfaceTexture::AttachToGLContext() { - if (GlContextMethodsAvailable()) { - int texture_id; - glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texture_id); - DCHECK(texture_id); - JNIEnv* env = base::android::AttachCurrentThread(); - Java_SurfaceTexturePlatformWrapper_attachToGLContext( - env, j_surface_texture_.obj(), texture_id); - } -} - -void SurfaceTexture::DetachFromGLContext() { - if (GlContextMethodsAvailable()) { - JNIEnv* env = base::android::AttachCurrentThread(); - Java_SurfaceTexturePlatformWrapper_detachFromGLContext( - env, j_surface_texture_.obj()); - } -} - -ANativeWindow* SurfaceTexture::CreateSurface() { - JNIEnv* env = base::android::AttachCurrentThread(); - ScopedJavaSurface surface(this); - // Note: This ensures that any local references used by - // ANativeWindow_fromSurface are released immediately. This is needed as a - // workaround for https://code.google.com/p/android/issues/detail?id=68174 - base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); - ANativeWindow* native_window = ANativeWindow_fromSurface( - env, surface.j_surface().obj()); - return native_window; -} - -// static -bool SurfaceTexture::IsSingleBufferModeSupported() { - return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; -} - -bool SurfaceTexture::RegisterSurfaceTexture(JNIEnv* env) { - return RegisterNativesImpl(env); -} - -} // namespace gfx diff --git a/ui/gl/android/surface_texture.h b/ui/gl/android/surface_texture.h deleted file mode 100644 index b22e5c4bc..000000000 --- a/ui/gl/android/surface_texture.h +++ /dev/null @@ -1,88 +0,0 @@ -// 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. - -#ifndef UI_GL_ANDROID_SURFACE_TEXTURE_H_ -#define UI_GL_ANDROID_SURFACE_TEXTURE_H_ - -#include - -#include "base/android/scoped_java_ref.h" -#include "base/callback.h" -#include "base/memory/ref_counted.h" -#include "ui/gl/gl_export.h" - -struct ANativeWindow; - -namespace gfx { - -// This class serves as a bridge for native code to call java functions inside -// android SurfaceTexture class. -class GL_EXPORT SurfaceTexture - : public base::RefCountedThreadSafe{ - public: - static scoped_refptr Create(int texture_id); - - static scoped_refptr CreateSingleBuffered(int texture_id); - - // Set the listener callback, which will be invoked on the same thread that - // is being called from here for registration. - // Note: Since callbacks come in from Java objects that might outlive objects - // being referenced from the callback, the only robust way here is to create - // the callback from a weak pointer to your object. - void SetFrameAvailableCallback(const base::Closure& callback); - - // Update the texture image to the most recent frame from the image stream. - void UpdateTexImage(); - - // Release the texture content. This is needed only in single buffered mode - // to allow the image content producer to take ownership - // of the image buffer. - // This is *only* supported on SurfaceTexture instantiated via - // |CreateSingleBuffered(...)|. - void ReleaseTexImage(); - - // Retrieve the 4x4 texture coordinate transform matrix associated with the - // texture image set by the most recent call to updateTexImage. - void GetTransformMatrix(float mtx[16]); - - // Attach the SurfaceTexture to the texture currently bound to - // GL_TEXTURE_EXTERNAL_OES. - void AttachToGLContext(); - - // Detaches the SurfaceTexture from the context that owns its current GL - // texture. Must be called with that context current on the calling thread. - void DetachFromGLContext(); - - // Creates a native render surface for this surface texture. - // The caller must release the underlying reference when done with the handle - // by calling ANativeWindow_release(). - ANativeWindow* CreateSurface(); - - const base::android::JavaRef& j_surface_texture() const { - return j_surface_texture_; - } - - // This should only be used to guard the SurfaceTexture instantiated via - // |CreateSingleBuffered(...)| - static bool IsSingleBufferModeSupported(); - - static bool RegisterSurfaceTexture(JNIEnv* env); - - protected: - explicit SurfaceTexture( - const base::android::ScopedJavaLocalRef& j_surface_texture); - - private: - friend class base::RefCountedThreadSafe; - ~SurfaceTexture(); - - // Java SurfaceTexture instance. - base::android::ScopedJavaGlobalRef j_surface_texture_; - - DISALLOW_COPY_AND_ASSIGN(SurfaceTexture); -}; - -} // namespace gfx - -#endif // UI_GL_ANDROID_SURFACE_TEXTURE_H_ diff --git a/ui/gl/android/surface_texture_listener.cc b/ui/gl/android/surface_texture_listener.cc deleted file mode 100644 index 4660d29c8..000000000 --- a/ui/gl/android/surface_texture_listener.cc +++ /dev/null @@ -1,39 +0,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 "ui/gl/android/surface_texture_listener.h" - -#include "base/location.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" -#include "jni/SurfaceTextureListener_jni.h" - -namespace gfx { - -SurfaceTextureListener::SurfaceTextureListener(const base::Closure& callback) - : callback_(callback), - browser_loop_(base::ThreadTaskRunnerHandle::Get()) { -} - -SurfaceTextureListener::~SurfaceTextureListener() { -} - -void SurfaceTextureListener::Destroy(JNIEnv* env, jobject obj) { - delete this; -} - -void SurfaceTextureListener::FrameAvailable(JNIEnv* env, jobject obj) { - if (!browser_loop_->BelongsToCurrentThread()) { - browser_loop_->PostTask(FROM_HERE, callback_); - } else { - callback_.Run(); - } -} - -// static -bool SurfaceTextureListener::RegisterSurfaceTextureListener(JNIEnv* env) { - return RegisterNativesImpl(env); -} - -} // namespace gfx diff --git a/ui/gl/android/surface_texture_listener.h b/ui/gl/android/surface_texture_listener.h deleted file mode 100644 index f1e781aec..000000000 --- a/ui/gl/android/surface_texture_listener.h +++ /dev/null @@ -1,47 +0,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. - -#ifndef UI_GL_ANDROID_SURFACE_TEXTURE_LISTENER_H_ -#define UI_GL_ANDROID_SURFACE_TEXTURE_LISTENER_H_ - -#include -#include "base/callback.h" -#include "base/memory/ref_counted.h" -#include "ui/gl/gl_export.h" - -namespace base { -class SingleThreadTaskRunner; -} - -namespace gfx { - -// Listener class for all the callbacks from android SurfaceTexture. -class GL_EXPORT SurfaceTextureListener { - public: - // Destroy this listener. - void Destroy(JNIEnv* env, jobject obj); - - // A new frame is available to consume. - void FrameAvailable(JNIEnv* env, jobject obj); - - static bool RegisterSurfaceTextureListener(JNIEnv* env); - - private: - // Native code should not hold any reference to this object, and instead pass - // it up to Java for being referenced by a SurfaceTexture instance. - SurfaceTextureListener(const base::Closure& callback); - ~SurfaceTextureListener(); - - friend class SurfaceTexture; - - base::Closure callback_; - - scoped_refptr browser_loop_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(SurfaceTextureListener); -}; - -} // namespace gfx - -#endif // UI_GL_ANDROID_SURFACE_TEXTURE_LISTENER_H_ diff --git a/ui/gl/angle_platform_impl.cc b/ui/gl/angle_platform_impl.cc deleted file mode 100644 index 2ce12b823..000000000 --- a/ui/gl/angle_platform_impl.cc +++ /dev/null @@ -1,50 +0,0 @@ -// 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 "ui/gl/angle_platform_impl.h" - -#include "base/metrics/histogram.h" -#include "base/metrics/sparse_histogram.h" - -namespace gfx { - -ANGLEPlatformImpl::ANGLEPlatformImpl() { -} - -ANGLEPlatformImpl::~ANGLEPlatformImpl() { -} - -void ANGLEPlatformImpl::histogramCustomCounts(const char* name, - int sample, - int min, - int max, - int bucket_count) { - // Copied from histogram macro, but without the static variable caching - // the histogram because name is dynamic. - base::HistogramBase* counter = base::Histogram::FactoryGet( - name, min, max, bucket_count, - base::HistogramBase::kUmaTargetedHistogramFlag); - DCHECK_EQ(name, counter->histogram_name()); - counter->Add(sample); -} - -void ANGLEPlatformImpl::histogramEnumeration(const char* name, - int sample, - int boundary_value) { - // Copied from histogram macro, but without the static variable caching - // the histogram because name is dynamic. - base::HistogramBase* counter = base::LinearHistogram::FactoryGet( - name, 1, boundary_value, boundary_value + 1, - base::HistogramBase::kUmaTargetedHistogramFlag); - DCHECK_EQ(name, counter->histogram_name()); - counter->Add(sample); -} - -void ANGLEPlatformImpl::histogramSparse(const char* name, int sample) { - // For sparse histograms, we can use the macro, as it does not incorporate a - // static. - UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample); -} - -} // namespace gfx diff --git a/ui/gl/angle_platform_impl.h b/ui/gl/angle_platform_impl.h deleted file mode 100644 index 2d12f60b1..000000000 --- a/ui/gl/angle_platform_impl.h +++ /dev/null @@ -1,39 +0,0 @@ -// 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. - -#ifndef UI_GL_ANGLE_PLATFORM_IMPL_H_ -#define UI_GL_ANGLE_PLATFORM_IMPL_H_ - -// Implements the ANGLE platform interface, for functionality like -// histograms and trace profiling. - -#include "base/macros.h" -#include "third_party/angle/include/platform/Platform.h" - -namespace gfx { - -// Derives the base ANGLE platform and provides implementations -class ANGLEPlatformImpl : public angle::Platform { - public: - ANGLEPlatformImpl(); - ~ANGLEPlatformImpl() override; - - // angle::Platform: - void histogramCustomCounts(const char* name, - int sample, - int min, - int max, - int bucket_count) override; - void histogramEnumeration(const char* name, - int sample, - int boundary_value) override; - void histogramSparse(const char* name, int sample) override; - - private: - DISALLOW_COPY_AND_ASSIGN(ANGLEPlatformImpl); -}; - -} // namespace gfx - -#endif // UI_GL_ANGLE_PLATFORM_IMPL_H_ diff --git a/ui/gl/egl_util.cc b/ui/gl/egl_util.cc deleted file mode 100644 index 024c84188..000000000 --- a/ui/gl/egl_util.cc +++ /dev/null @@ -1,49 +0,0 @@ -// 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 "ui/gl/egl_util.h" - -#include - -// This needs to be after the EGL includes -#include "ui/gl/gl_bindings.h" - -namespace ui { - -// Returns the last EGL error as a string. -const char* GetLastEGLErrorString() { - EGLint error = eglGetError(); - switch (error) { - case EGL_SUCCESS: - return "EGL_SUCCESS"; - case EGL_BAD_ACCESS: - return "EGL_BAD_ACCESS"; - case EGL_BAD_ALLOC: - return "EGL_BAD_ALLOC"; - case EGL_BAD_ATTRIBUTE: - return "EGL_BAD_ATTRIBUTE"; - case EGL_BAD_CONTEXT: - return "EGL_BAD_CONTEXT"; - case EGL_BAD_CONFIG: - return "EGL_BAD_CONFIG"; - case EGL_BAD_CURRENT_SURFACE: - return "EGL_BAD_CURRENT_SURFACE"; - case EGL_BAD_DISPLAY: - return "EGL_BAD_DISPLAY"; - case EGL_BAD_SURFACE: - return "EGL_BAD_SURFACE"; - case EGL_BAD_MATCH: - return "EGL_BAD_MATCH"; - case EGL_BAD_PARAMETER: - return "EGL_BAD_PARAMETER"; - case EGL_BAD_NATIVE_PIXMAP: - return "EGL_BAD_NATIVE_PIXMAP"; - case EGL_BAD_NATIVE_WINDOW: - return "EGL_BAD_NATIVE_WINDOW"; - default: - return "UNKNOWN"; - } -} - -} // namespace ui diff --git a/ui/gl/egl_util.h b/ui/gl/egl_util.h deleted file mode 100644 index 0ef909525..000000000 --- a/ui/gl/egl_util.h +++ /dev/null @@ -1,17 +0,0 @@ -// 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 UI_GL_EGL_UTIL_H_ -#define UI_GL_EGL_UTIL_H_ - -#include "ui/gl/gl_export.h" - -namespace ui { - -// Returns the last EGL error as a string. -GL_EXPORT const char* GetLastEGLErrorString(); - -} // namespace ui - -#endif // UI_GL_EGL_UTIL_H_ diff --git a/ui/gl/generate_bindings.py b/ui/gl/generate_bindings.py deleted file mode 100755 index 41dc968ed..000000000 --- a/ui/gl/generate_bindings.py +++ /dev/null @@ -1,2595 +0,0 @@ -#!/usr/bin/env python -# 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. - -"""code generator for GL/GLES extension wrangler.""" - -import optparse -import os -import collections -import re -import platform -import sys -from subprocess import call -from collections import namedtuple - -HEADER_PATHS = [ - '../../third_party/khronos', - '../../third_party/mesa/src/include', - '.', - '../../gpu', -] - -UNCONDITIONALLY_BOUND_EXTENSIONS = set([ - 'WGL_ARB_extensions_string', - 'WGL_EXT_extensions_string', - 'GL_CHROMIUM_gles_depth_binding_hack', # crbug.com/448206 -]) - -"""Function binding conditions can be specified manually by supplying a versions -array instead of the names array. Each version has the following keys: - name: Mandatory. Name of the function. Multiple versions can have the same - name but different conditions. - extensions: Extra Extensions for which the function is bound. Only needed - in some cases where the extension cannot be parsed from the - headers. - -By default, the function gets its name from the first name in its names or -versions array. This can be overridden by supplying a 'known_as' key. -""" -GL_FUNCTIONS = [ -{ 'return_type': 'void', - 'names': ['glActiveTexture'], - 'arguments': 'GLenum texture', }, -{ 'return_type': 'void', - 'names': ['glAttachShader'], - 'arguments': 'GLuint program, GLuint shader', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glBeginQuery' }, - { 'name': 'glBeginQueryARB' }, - { 'name': 'glBeginQueryEXT', - 'extensions': ['GL_EXT_occlusion_query_boolean'] }], - 'arguments': 'GLenum target, GLuint id', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glBeginTransformFeedback' }], - 'arguments': 'GLenum primitiveMode', }, -{ 'return_type': 'void', - 'names': ['glBindAttribLocation'], - 'arguments': 'GLuint program, GLuint index, const char* name', }, -{ 'return_type': 'void', - 'names': ['glBindBuffer'], - 'arguments': 'GLenum target, GLuint buffer', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glBindBufferBase' }], - 'arguments': 'GLenum target, GLuint index, GLuint buffer', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glBindBufferRange' }], - 'arguments': 'GLenum target, GLuint index, GLuint buffer, GLintptr offset, ' - 'GLsizeiptr size', }, -{ 'return_type': 'void', - 'names': ['glBindFragDataLocation'], - 'arguments': 'GLuint program, GLuint colorNumber, const char* name', }, -{ 'return_type': 'void', - 'names': ['glBindFragDataLocationIndexed'], - 'arguments': - 'GLuint program, GLuint colorNumber, GLuint index, const char* name', }, -{ 'return_type': 'void', - 'names': ['glBindFramebufferEXT', 'glBindFramebuffer'], - 'arguments': 'GLenum target, GLuint framebuffer', }, -{ 'return_type': 'void', - 'names': ['glBindRenderbufferEXT', 'glBindRenderbuffer'], - 'arguments': 'GLenum target, GLuint renderbuffer', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glBindSampler' }], - 'arguments': 'GLuint unit, GLuint sampler', }, -{ 'return_type': 'void', - 'names': ['glBindTexture'], - 'arguments': 'GLenum target, GLuint texture', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glBindTransformFeedback' }], - 'arguments': 'GLenum target, GLuint id', }, -{ 'return_type': 'void', - 'known_as': 'glBindVertexArrayOES', - 'versions': [{ 'name': 'glBindVertexArray', - 'extensions': ['GL_ARB_vertex_array_object'], }, - { 'name': 'glBindVertexArrayOES' }, - { 'name': 'glBindVertexArrayAPPLE', - 'extensions': ['GL_APPLE_vertex_array_object'] }], - 'arguments': 'GLuint array' }, -{ 'return_type': 'void', - 'known_as': 'glBlendBarrierKHR', - 'versions': [{ 'name': 'glBlendBarrierNV', - 'extensions': ['GL_NV_blend_equation_advanced'] }, - { 'name': 'glBlendBarrierKHR', - 'extensions': ['GL_KHR_blend_equation_advanced'] }], - 'arguments': 'void' }, -{ 'return_type': 'void', - 'names': ['glBlendColor'], - 'arguments': 'GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha', }, -{ 'return_type': 'void', - 'names': ['glBlendEquation'], - 'arguments': ' GLenum mode ', }, -{ 'return_type': 'void', - 'names': ['glBlendEquationSeparate'], - 'arguments': 'GLenum modeRGB, GLenum modeAlpha', }, -{ 'return_type': 'void', - 'names': ['glBlendFunc'], - 'arguments': 'GLenum sfactor, GLenum dfactor', }, -{ 'return_type': 'void', - 'names': ['glBlendFuncSeparate'], - 'arguments': - 'GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha', }, -{ 'return_type': 'void', - 'names': ['glBlitFramebuffer'], - 'arguments': 'GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, ' - 'GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, ' - 'GLbitfield mask, GLenum filter', }, -{ 'return_type': 'void', - 'names': ['glBlitFramebufferANGLE', 'glBlitFramebuffer'], - 'arguments': 'GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, ' - 'GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, ' - 'GLbitfield mask, GLenum filter', }, -{ 'return_type': 'void', - 'names': ['glBlitFramebufferEXT', 'glBlitFramebuffer'], - 'arguments': 'GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, ' - 'GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, ' - 'GLbitfield mask, GLenum filter', }, -{ 'return_type': 'void', - 'names': ['glBufferData'], - 'arguments': - 'GLenum target, GLsizeiptr size, const void* data, GLenum usage', }, -{ 'return_type': 'void', - 'names': ['glBufferSubData'], - 'arguments': - 'GLenum target, GLintptr offset, GLsizeiptr size, const void* data', }, -{ 'return_type': 'GLenum', - 'names': ['glCheckFramebufferStatusEXT', - 'glCheckFramebufferStatus'], - 'arguments': 'GLenum target', - 'logging_code': """ - GL_SERVICE_LOG("GL_RESULT: " << GLEnums::GetStringEnum(result)); -""", }, -{ 'return_type': 'void', - 'names': ['glClear'], - 'arguments': 'GLbitfield mask', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glClearBufferfi' }], - 'arguments': 'GLenum buffer, GLint drawbuffer, const GLfloat depth, ' - 'GLint stencil', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glClearBufferfv' }], - 'arguments': 'GLenum buffer, GLint drawbuffer, const GLfloat* value', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glClearBufferiv' }], - 'arguments': 'GLenum buffer, GLint drawbuffer, const GLint* value', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glClearBufferuiv' }], - 'arguments': 'GLenum buffer, GLint drawbuffer, const GLuint* value', }, -{ 'return_type': 'void', - 'names': ['glClearColor'], - 'arguments': 'GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glClearDepth', - 'extensions': ['GL_CHROMIUM_gles_depth_binding_hack'] }], - 'arguments': 'GLclampd depth', }, -{ 'return_type': 'void', - 'names': ['glClearDepthf'], - 'arguments': 'GLclampf depth', }, -{ 'return_type': 'void', - 'names': ['glClearStencil'], - 'arguments': 'GLint s', }, -{ 'return_type': 'GLenum', - 'versions': [{ 'name': 'glClientWaitSync', - 'extensions': ['GL_ARB_sync'] }], - 'arguments': 'GLsync sync, GLbitfield flags, GLuint64 timeout', }, -{ 'return_type': 'void', - 'names': ['glColorMask'], - 'arguments': - 'GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha', }, -{ 'return_type': 'void', - 'names': ['glCompileShader'], - 'arguments': 'GLuint shader', }, -{ 'return_type': 'void', - 'names': ['glCompressedTexImage2D'], - 'arguments': - 'GLenum target, GLint level, GLenum internalformat, GLsizei width, ' - 'GLsizei height, GLint border, GLsizei imageSize, const void* data', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glCompressedTexImage3D' }], - 'arguments': - 'GLenum target, GLint level, GLenum internalformat, GLsizei width, ' - 'GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, ' - 'const void* data', }, -{ 'return_type': 'void', - 'names': ['glCompressedTexSubImage2D'], - 'arguments': - 'GLenum target, GLint level, GLint xoffset, GLint yoffset, ' - 'GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, ' - 'const void* data', }, -# TODO(zmo): wait for MOCK_METHOD11. -# { 'return_type': 'void', -# 'versions': [{ 'name': 'glCompressedTexSubImage3D' }], -# 'arguments': -# 'GLenum target, GLint level, GLint xoffset, GLint yoffset, ' -# 'GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, ' -# 'GLenum format, GLsizei imageSize, const void* data', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glCopyBufferSubData' }], - 'arguments': - 'GLenum readTarget, GLenum writeTarget, GLintptr readOffset, ' - 'GLintptr writeOffset, GLsizeiptr size', }, -{ 'return_type': 'void', - 'names': ['glCopyTexImage2D'], - 'arguments': - 'GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, ' - 'GLsizei width, GLsizei height, GLint border', }, -{ 'return_type': 'void', - 'names': ['glCopyTexSubImage2D'], - 'arguments': - 'GLenum target, GLint level, GLint xoffset, ' - 'GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glCopyTexSubImage3D' }], - 'arguments': - 'GLenum target, GLint level, GLint xoffset, GLint yoffset, ' - 'GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height', }, -{ 'return_type': 'GLuint', - 'names': ['glCreateProgram'], - 'arguments': 'void', }, -{ 'return_type': 'GLuint', - 'names': ['glCreateShader'], - 'arguments': 'GLenum type', }, -{ 'return_type': 'void', - 'names': ['glCullFace'], - 'arguments': 'GLenum mode', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glDebugMessageCallbackKHR', - 'extensions': ['GL_KHR_debug'] }], - 'arguments': 'GLDEBUGPROCKHR callback, const void* userparam' }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glDebugMessageControlKHR', - 'extensions': ['GL_KHR_debug'] }], - 'arguments': 'GLenum source, GLenum type, GLenum severity, GLsizei count, ' - 'const GLuint* ids, GLboolean enabled' }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glDebugMessageInsertKHR', - 'extensions': ['GL_KHR_debug'] }], - 'arguments': 'GLenum source, GLenum type, GLuint id, GLenum severity, ' - 'GLsizei length, const GLchar* buf' }, -{ 'return_type': 'void', - 'names': ['glDeleteBuffers'], - 'known_as': 'glDeleteBuffersARB', - 'arguments': 'GLsizei n, const GLuint* buffers', }, -{ 'return_type': 'void', - 'known_as': 'glDeleteFencesAPPLE', - 'versions': [{ 'name': 'glDeleteFencesAPPLE', - 'extensions': ['GL_APPLE_fence'] }], - 'arguments': 'GLsizei n, const GLuint* fences', }, -{ 'return_type': 'void', - 'names': ['glDeleteFencesNV'], - 'arguments': 'GLsizei n, const GLuint* fences', }, -{ 'return_type': 'void', - 'names': ['glDeleteFramebuffersEXT', 'glDeleteFramebuffers'], - 'arguments': 'GLsizei n, const GLuint* framebuffers', }, -{ 'return_type': 'void', - 'names': ['glDeleteProgram'], - 'arguments': 'GLuint program', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glDeleteQueries' }, - { 'name': 'glDeleteQueriesARB'}, - { 'name': 'glDeleteQueriesEXT', - 'extensions': ['GL_EXT_occlusion_query_boolean'] }], - 'arguments': 'GLsizei n, const GLuint* ids', }, -{ 'return_type': 'void', - 'names': ['glDeleteRenderbuffersEXT', 'glDeleteRenderbuffers'], - 'arguments': 'GLsizei n, const GLuint* renderbuffers', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glDeleteSamplers' }], - 'arguments': 'GLsizei n, const GLuint* samplers', }, -{ 'return_type': 'void', - 'names': ['glDeleteShader'], - 'arguments': 'GLuint shader', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glDeleteSync', - 'extensions': ['GL_ARB_sync'] }], - 'arguments': 'GLsync sync', }, -{ 'return_type': 'void', - 'names': ['glDeleteTextures'], - 'arguments': 'GLsizei n, const GLuint* textures', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glDeleteTransformFeedbacks' }], - 'arguments': 'GLsizei n, const GLuint* ids', }, -{ 'return_type': 'void', - 'known_as': 'glDeleteVertexArraysOES', - 'versions': [{ 'name': 'glDeleteVertexArrays', - 'extensions': ['GL_ARB_vertex_array_object'], }, - { 'name': 'glDeleteVertexArraysOES' }, - { 'name': 'glDeleteVertexArraysAPPLE', - 'extensions': ['GL_APPLE_vertex_array_object'] }], - 'arguments': 'GLsizei n, const GLuint* arrays' }, -{ 'return_type': 'void', - 'names': ['glDepthFunc'], - 'arguments': 'GLenum func', }, -{ 'return_type': 'void', - 'names': ['glDepthMask'], - 'arguments': 'GLboolean flag', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glDepthRange', - 'extensions': ['GL_CHROMIUM_gles_depth_binding_hack'] }], - 'arguments': 'GLclampd zNear, GLclampd zFar', }, -{ 'return_type': 'void', - 'names': ['glDepthRangef'], - 'arguments': 'GLclampf zNear, GLclampf zFar', }, -{ 'return_type': 'void', - 'names': ['glDetachShader'], - 'arguments': 'GLuint program, GLuint shader', }, -{ 'return_type': 'void', - 'names': ['glDisable'], - 'arguments': 'GLenum cap', }, -{ 'return_type': 'void', - 'names': ['glDisableVertexAttribArray'], - 'arguments': 'GLuint index', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glDiscardFramebufferEXT', - 'extensions': ['GL_EXT_discard_framebuffer'] }], - 'arguments': 'GLenum target, GLsizei numAttachments, ' - 'const GLenum* attachments' }, -{ 'return_type': 'void', - 'names': ['glDrawArrays'], - 'arguments': 'GLenum mode, GLint first, GLsizei count', }, -{ 'return_type': 'void', - 'known_as': 'glDrawArraysInstancedANGLE', - 'names': ['glDrawArraysInstancedARB', 'glDrawArraysInstancedANGLE', - 'glDrawArraysInstanced'], - 'arguments': 'GLenum mode, GLint first, GLsizei count, GLsizei primcount', }, -{ 'return_type': 'void', - 'names': ['glDrawBuffer'], - 'arguments': 'GLenum mode', }, -{ 'return_type': 'void', - 'names': ['glDrawBuffersARB', 'glDrawBuffersEXT', 'glDrawBuffers'], - 'arguments': 'GLsizei n, const GLenum* bufs', }, -{ 'return_type': 'void', - 'names': ['glDrawElements'], - 'arguments': - 'GLenum mode, GLsizei count, GLenum type, const void* indices', }, -{ 'return_type': 'void', - 'known_as': 'glDrawElementsInstancedANGLE', - 'names': ['glDrawElementsInstancedARB', 'glDrawElementsInstancedANGLE', - 'glDrawElementsInstanced'], - 'arguments': - 'GLenum mode, GLsizei count, GLenum type, const void* indices, ' - 'GLsizei primcount', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glDrawRangeElements' }], - 'arguments': 'GLenum mode, GLuint start, GLuint end, GLsizei count, ' - 'GLenum type, const void* indices', }, -{ 'return_type': 'void', - 'names': ['glEGLImageTargetRenderbufferStorageOES'], - 'arguments': 'GLenum target, GLeglImageOES image', }, -{ 'return_type': 'void', - 'names': ['glEGLImageTargetTexture2DOES'], - 'arguments': 'GLenum target, GLeglImageOES image', }, -{ 'return_type': 'void', - 'names': ['glEnable'], - 'arguments': 'GLenum cap', }, -{ 'return_type': 'void', - 'names': ['glEnableVertexAttribArray'], - 'arguments': 'GLuint index', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glEndQuery' }, - { 'name': 'glEndQueryARB' }, - { 'name': 'glEndQueryEXT', - 'extensions': ['GL_EXT_occlusion_query_boolean'] }], - 'arguments': 'GLenum target', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glEndTransformFeedback' }], - 'arguments': 'void', }, -{ 'return_type': 'GLsync', - 'versions': [{ 'name': 'glFenceSync', - 'extensions': ['GL_ARB_sync'] }], - 'arguments': 'GLenum condition, GLbitfield flags', }, -{ 'return_type': 'void', - 'names': ['glFinish'], - 'arguments': 'void', }, -{ 'return_type': 'void', - 'known_as': 'glFinishFenceAPPLE', - 'versions': [{ 'name': 'glFinishFenceAPPLE', - 'extensions': ['GL_APPLE_fence'] }], - 'arguments': 'GLuint fence', }, -{ 'return_type': 'void', - 'names': ['glFinishFenceNV'], - 'arguments': 'GLuint fence', }, -{ 'return_type': 'void', - 'names': ['glFlush'], - 'arguments': 'void', }, -{ 'return_type': 'void', - 'names': ['glFlushMappedBufferRange'], - 'arguments': 'GLenum target, GLintptr offset, GLsizeiptr length', }, -{ 'return_type': 'void', - 'names': ['glFramebufferRenderbufferEXT', 'glFramebufferRenderbuffer'], - 'arguments': - 'GLenum target, GLenum attachment, GLenum renderbuffertarget, ' - 'GLuint renderbuffer', }, -{ 'return_type': 'void', - 'names': ['glFramebufferTexture2DEXT', 'glFramebufferTexture2D'], - 'arguments': - 'GLenum target, GLenum attachment, GLenum textarget, GLuint texture, ' - 'GLint level', }, -{ 'return_type': 'void', - 'names': ['glFramebufferTexture2DMultisampleEXT'], - 'arguments': - 'GLenum target, GLenum attachment, GLenum textarget, GLuint texture, ' - 'GLint level, GLsizei samples', }, -{ 'return_type': 'void', - 'names': ['glFramebufferTexture2DMultisampleIMG'], - 'arguments': - 'GLenum target, GLenum attachment, GLenum textarget, GLuint texture, ' - 'GLint level, GLsizei samples', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glFramebufferTextureLayer' }], - 'arguments': 'GLenum target, GLenum attachment, GLuint texture, GLint level, ' - 'GLint layer', }, -{ 'return_type': 'void', - 'names': ['glFrontFace'], - 'arguments': 'GLenum mode', }, -{ 'return_type': 'void', - 'names': ['glGenBuffers'], - 'known_as': 'glGenBuffersARB', - 'arguments': 'GLsizei n, GLuint* buffers', }, -{ 'return_type': 'void', - 'names': ['glGenerateMipmapEXT', 'glGenerateMipmap'], - 'arguments': 'GLenum target', }, -{ 'return_type': 'void', - 'known_as': 'glGenFencesAPPLE', - 'versions': [{ 'name': 'glGenFencesAPPLE', - 'extensions': ['GL_APPLE_fence'] }], - 'arguments': 'GLsizei n, GLuint* fences', }, -{ 'return_type': 'void', - 'names': ['glGenFencesNV'], - 'arguments': 'GLsizei n, GLuint* fences', }, -{ 'return_type': 'void', - 'names': ['glGenFramebuffersEXT', 'glGenFramebuffers'], - 'arguments': 'GLsizei n, GLuint* framebuffers', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGenQueries' }, - { 'name': 'glGenQueriesARB', }, - { 'name' : 'glGenQueriesEXT', - 'extensions': ['GL_EXT_occlusion_query_boolean'] }], - 'arguments': 'GLsizei n, GLuint* ids', }, -{ 'return_type': 'void', - 'names': ['glGenRenderbuffersEXT', 'glGenRenderbuffers'], - 'arguments': 'GLsizei n, GLuint* renderbuffers', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGenSamplers' }], - 'arguments': 'GLsizei n, GLuint* samplers', }, -{ 'return_type': 'void', - 'names': ['glGenTextures'], - 'arguments': 'GLsizei n, GLuint* textures', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGenTransformFeedbacks' }], - 'arguments': 'GLsizei n, GLuint* ids', }, -{ 'return_type': 'void', - 'known_as': 'glGenVertexArraysOES', - 'versions': [{ 'name': 'glGenVertexArrays', - 'extensions': ['GL_ARB_vertex_array_object'], }, - { 'name': 'glGenVertexArraysOES' }, - { 'name': 'glGenVertexArraysAPPLE', - 'extensions': ['GL_APPLE_vertex_array_object'] }], - 'arguments': 'GLsizei n, GLuint* arrays', }, -{ 'return_type': 'void', - 'names': ['glGetActiveAttrib'], - 'arguments': - 'GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, ' - 'GLint* size, GLenum* type, char* name', }, -{ 'return_type': 'void', - 'names': ['glGetActiveUniform'], - 'arguments': - 'GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, ' - 'GLint* size, GLenum* type, char* name', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGetActiveUniformBlockiv' }], - 'arguments': 'GLuint program, GLuint uniformBlockIndex, GLenum pname, ' - 'GLint* params', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGetActiveUniformBlockName' }], - 'arguments': 'GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, ' - 'GLsizei* length, char* uniformBlockName', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGetActiveUniformsiv' }], - 'arguments': 'GLuint program, GLsizei uniformCount, ' - 'const GLuint* uniformIndices, GLenum pname, GLint* params', }, -{ 'return_type': 'void', - 'names': ['glGetAttachedShaders'], - 'arguments': - 'GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders', }, -{ 'return_type': 'GLint', - 'names': ['glGetAttribLocation'], - 'arguments': 'GLuint program, const char* name', }, -{ 'return_type': 'void', - 'names': ['glGetBooleanv'], - 'arguments': 'GLenum pname, GLboolean* params', }, -{ 'return_type': 'void', - 'names': ['glGetBufferParameteriv'], - 'arguments': 'GLenum target, GLenum pname, GLint* params', }, -{ 'return_type': 'GLuint', - 'versions': [{ 'name': 'glGetDebugMessageLogKHR', - 'extensions': ['GL_KHR_debug'] }], - 'arguments': 'GLuint count, GLsizei bufSize, GLenum* sources, GLenum* types, ' - 'GLuint* ids, GLenum* severities, GLsizei* lengths, ' - 'GLchar* messageLog' }, -{ 'return_type': 'GLenum', - 'names': ['glGetError'], - 'arguments': 'void', - 'logging_code': """ - GL_SERVICE_LOG("GL_RESULT: " << GLEnums::GetStringError(result)); -""", }, -{ 'return_type': 'void', - 'names': ['glGetFenceivNV'], - 'arguments': 'GLuint fence, GLenum pname, GLint* params', }, -{ 'return_type': 'void', - 'names': ['glGetFloatv'], - 'arguments': 'GLenum pname, GLfloat* params', }, -{ 'return_type': 'GLint', - 'versions': [{ 'name': 'glGetFragDataLocation' }], - 'arguments': 'GLuint program, const char* name', }, -{ 'return_type': 'void', - 'names': ['glGetFramebufferAttachmentParameterivEXT', - 'glGetFramebufferAttachmentParameteriv'], - 'arguments': 'GLenum target, ' - 'GLenum attachment, GLenum pname, GLint* params', }, -{ 'return_type': 'GLenum', - 'names': ['glGetGraphicsResetStatusARB', - 'glGetGraphicsResetStatusKHR', - 'glGetGraphicsResetStatusEXT', - 'glGetGraphicsResetStatus'], - 'arguments': 'void', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGetInteger64i_v' }], - 'arguments': 'GLenum target, GLuint index, GLint64* data', }, -{ 'return_type': 'void', - 'names': ['glGetInteger64v'], - 'arguments': 'GLenum pname, GLint64* params', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGetIntegeri_v' }], - 'arguments': 'GLenum target, GLuint index, GLint* data', }, -{ 'return_type': 'void', - 'names': ['glGetIntegerv'], - 'arguments': 'GLenum pname, GLint* params', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGetInternalformativ' }], - 'arguments': 'GLenum target, GLenum internalformat, GLenum pname, ' - 'GLsizei bufSize, GLint* params', }, -{ 'return_type': 'void', - 'known_as': 'glGetProgramBinary', - 'versions': [{ 'name': 'glGetProgramBinaryOES' }, - { 'name': 'glGetProgramBinary', - 'extensions': ['GL_ARB_get_program_binary'] }], - 'arguments': 'GLuint program, GLsizei bufSize, GLsizei* length, ' - 'GLenum* binaryFormat, GLvoid* binary' }, -{ 'return_type': 'void', - 'names': ['glGetProgramInfoLog'], - 'arguments': - 'GLuint program, GLsizei bufsize, GLsizei* length, char* infolog', }, -{ 'return_type': 'void', - 'names': ['glGetProgramiv'], - 'arguments': 'GLuint program, GLenum pname, GLint* params', }, -{ 'return_type': 'GLint', - 'names': ['glGetProgramResourceLocation'], - 'arguments': 'GLuint program, GLenum programInterface, const char* name', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGetQueryiv' }, - { 'name': 'glGetQueryivARB' }, - { 'name': 'glGetQueryivEXT', - 'extensions': ['GL_EXT_occlusion_query_boolean'] }], - 'arguments': 'GLenum target, GLenum pname, GLint* params', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGetQueryObjecti64v', - 'extensions': ['GL_ARB_timer_query'] }, - { 'name': 'glGetQueryObjecti64vEXT' }], - 'arguments': 'GLuint id, GLenum pname, GLint64* params', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGetQueryObjectiv' }, - { 'name': 'glGetQueryObjectivARB' }, - { 'name': 'glGetQueryObjectivEXT' }], - 'arguments': 'GLuint id, GLenum pname, GLint* params', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGetQueryObjectui64v', - 'extensions': ['GL_ARB_timer_query'] }, - { 'name': 'glGetQueryObjectui64vEXT' }], - 'arguments': 'GLuint id, GLenum pname, GLuint64* params', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGetQueryObjectuiv' }, - { 'name': 'glGetQueryObjectuivARB' }, - { 'name': 'glGetQueryObjectuivEXT', - 'extensions': ['GL_EXT_occlusion_query_boolean'] }], - 'arguments': 'GLuint id, GLenum pname, GLuint* params', }, -{ 'return_type': 'void', - 'names': ['glGetRenderbufferParameterivEXT', 'glGetRenderbufferParameteriv'], - 'arguments': 'GLenum target, GLenum pname, GLint* params', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGetSamplerParameterfv' }], - 'arguments': 'GLuint sampler, GLenum pname, GLfloat* params', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGetSamplerParameteriv' }], - 'arguments': 'GLuint sampler, GLenum pname, GLint* params', }, -{ 'return_type': 'void', - 'names': ['glGetShaderInfoLog'], - 'arguments': - 'GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog', }, -{ 'return_type': 'void', - 'names': ['glGetShaderiv'], - 'arguments': 'GLuint shader, GLenum pname, GLint* params', }, -{ 'return_type': 'void', - 'names': ['glGetShaderPrecisionFormat'], - 'arguments': 'GLenum shadertype, GLenum precisiontype, ' - 'GLint* range, GLint* precision', }, -{ 'return_type': 'void', - 'names': ['glGetShaderSource'], - 'arguments': - 'GLuint shader, GLsizei bufsize, GLsizei* length, char* source', }, -{ 'return_type': 'const GLubyte*', - 'names': ['glGetString'], - 'arguments': 'GLenum name', }, -{ 'return_type': 'const GLubyte*', - 'names': ['glGetStringi'], - 'arguments': 'GLenum name, GLuint index', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGetSynciv', - 'extensions': ['GL_ARB_sync'] }], - 'arguments': - 'GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length,' - 'GLint* values', }, -{ 'return_type': 'void', - 'names': ['glGetTexLevelParameterfv'], - 'arguments': 'GLenum target, GLint level, GLenum pname, GLfloat* params', }, -{ 'return_type': 'void', - 'names': ['glGetTexLevelParameteriv'], - 'arguments': 'GLenum target, GLint level, GLenum pname, GLint* params', }, -{ 'return_type': 'void', - 'names': ['glGetTexParameterfv'], - 'arguments': 'GLenum target, GLenum pname, GLfloat* params', }, -{ 'return_type': 'void', - 'names': ['glGetTexParameteriv'], - 'arguments': 'GLenum target, GLenum pname, GLint* params', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGetTransformFeedbackVarying' }], - 'arguments': 'GLuint program, GLuint index, GLsizei bufSize, ' - 'GLsizei* length, GLsizei* size, GLenum* type, char* name', }, -{ 'return_type': 'void', - 'names': ['glGetTranslatedShaderSourceANGLE'], - 'arguments': - 'GLuint shader, GLsizei bufsize, GLsizei* length, char* source', }, -{ 'return_type': 'GLuint', - 'versions': [{ 'name': 'glGetUniformBlockIndex' }], - 'arguments': 'GLuint program, const char* uniformBlockName', }, -{ 'return_type': 'void', - 'names': ['glGetUniformfv'], - 'arguments': 'GLuint program, GLint location, GLfloat* params', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glGetUniformIndices' }], - 'arguments': 'GLuint program, GLsizei uniformCount, ' - 'const char* const* uniformNames, GLuint* uniformIndices', }, -{ 'return_type': 'void', - 'names': ['glGetUniformiv'], - 'arguments': 'GLuint program, GLint location, GLint* params', }, -{ 'return_type': 'GLint', - 'names': ['glGetUniformLocation'], - 'arguments': 'GLuint program, const char* name', }, -{ 'return_type': 'void', - 'names': ['glGetVertexAttribfv'], - 'arguments': 'GLuint index, GLenum pname, GLfloat* params', }, -{ 'return_type': 'void', - 'names': ['glGetVertexAttribiv'], - 'arguments': 'GLuint index, GLenum pname, GLint* params', }, -{ 'return_type': 'void', - 'names': ['glGetVertexAttribPointerv'], - 'arguments': 'GLuint index, GLenum pname, void** pointer', }, -{ 'return_type': 'void', - 'names': ['glHint'], - 'arguments': 'GLenum target, GLenum mode', }, -{ 'return_type': 'void', - 'names': ['glInsertEventMarkerEXT'], - 'arguments': 'GLsizei length, const char* marker', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glInvalidateFramebuffer' }], - 'arguments': 'GLenum target, GLsizei numAttachments, ' - 'const GLenum* attachments' }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glInvalidateSubFramebuffer' }], - 'arguments': - 'GLenum target, GLsizei numAttachments, const GLenum* attachments, ' - 'GLint x, GLint y, GLint width, GLint height', }, -{ 'return_type': 'GLboolean', - 'names': ['glIsBuffer'], - 'arguments': 'GLuint buffer', }, -{ 'return_type': 'GLboolean', - 'names': ['glIsEnabled'], - 'arguments': 'GLenum cap', }, -{ 'return_type': 'GLboolean', - 'known_as': 'glIsFenceAPPLE', - 'versions': [{ 'name': 'glIsFenceAPPLE', - 'extensions': ['GL_APPLE_fence'] }], - 'arguments': 'GLuint fence', }, -{ 'return_type': 'GLboolean', - 'names': ['glIsFenceNV'], - 'arguments': 'GLuint fence', }, -{ 'return_type': 'GLboolean', - 'names': ['glIsFramebufferEXT', 'glIsFramebuffer'], - 'arguments': 'GLuint framebuffer', }, -{ 'return_type': 'GLboolean', - 'names': ['glIsProgram'], - 'arguments': 'GLuint program', }, -{ 'return_type': 'GLboolean', - 'versions': [{ 'name': 'glIsQuery' }, - { 'name': 'glIsQueryARB' }, - { 'name': 'glIsQueryEXT', - 'extensions': ['GL_EXT_occlusion_query_boolean'] }], - 'arguments': 'GLuint query', }, -{ 'return_type': 'GLboolean', - 'names': ['glIsRenderbufferEXT', 'glIsRenderbuffer'], - 'arguments': 'GLuint renderbuffer', }, -{ 'return_type': 'GLboolean', - 'versions': [{ 'name': 'glIsSampler' }], - 'arguments': 'GLuint sampler', }, -{ 'return_type': 'GLboolean', - 'names': ['glIsShader'], - 'arguments': 'GLuint shader', }, -{ 'return_type': 'GLboolean', - 'versions': [{ 'name': 'glIsSync', - 'extensions': ['GL_ARB_sync'] }], - 'arguments': 'GLsync sync', }, -{ 'return_type': 'GLboolean', - 'names': ['glIsTexture'], - 'arguments': 'GLuint texture', }, -{ 'return_type': 'GLboolean', - 'versions': [{ 'name': 'glIsTransformFeedback' }], - 'arguments': 'GLuint id', }, -{ 'return_type': 'GLboolean', - 'known_as': 'glIsVertexArrayOES', - 'versions': [{ 'name': 'glIsVertexArray', - 'extensions': ['GL_ARB_vertex_array_object'], }, - { 'name': 'glIsVertexArrayOES' }, - { 'name': 'glIsVertexArrayAPPLE', - 'extensions': ['GL_APPLE_vertex_array_object'] }], - 'arguments': 'GLuint array' }, -{ 'return_type': 'void', - 'names': ['glLineWidth'], - 'arguments': 'GLfloat width', }, -{ 'return_type': 'void', - 'names': ['glLinkProgram'], - 'arguments': 'GLuint program', }, -{ 'return_type': 'void*', - 'known_as': 'glMapBuffer', - 'names': ['glMapBufferOES', 'glMapBuffer'], - 'arguments': 'GLenum target, GLenum access', }, -{ 'return_type': 'void*', - 'known_as': 'glMapBufferRange', - 'versions': [{ 'name': 'glMapBufferRange', - 'extensions': ['GL_ARB_map_buffer_range'] }, - { 'name': 'glMapBufferRangeEXT', - 'extensions': ['GL_EXT_map_buffer_range'] }], - 'arguments': - 'GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access', }, -{ 'return_type': 'void', - 'known_as': 'glMatrixLoadfEXT', - 'versions': [{ 'name': 'glMatrixLoadfEXT', - 'extensions': ['GL_EXT_direct_state_access', - 'GL_NV_path_rendering'] }], - 'arguments': 'GLenum matrixMode, const GLfloat* m' }, -{ 'return_type': 'void', - 'known_as': 'glMatrixLoadIdentityEXT', - 'versions': [{ 'name': 'glMatrixLoadIdentityEXT', - 'extensions': ['GL_EXT_direct_state_access', - 'GL_NV_path_rendering'] },], - 'arguments': 'GLenum matrixMode' }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glObjectLabelKHR', - 'extensions': ['GL_KHR_debug'] }], - 'arguments': 'GLenum identifier, GLuint name, GLsizei length, ' - 'const GLchar* label' }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glPauseTransformFeedback' }], - 'arguments': 'void', }, -{ 'return_type': 'void', - 'names': ['glPixelStorei'], - 'arguments': 'GLenum pname, GLint param', }, -{ 'return_type': 'void', - 'names': ['glPointParameteri'], - 'arguments': 'GLenum pname, GLint param', }, -{ 'return_type': 'void', - 'names': ['glPolygonOffset'], - 'arguments': 'GLfloat factor, GLfloat units', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glPopDebugGroupKHR', - 'extensions': ['GL_KHR_debug'] }], - 'arguments': 'void' }, -{ 'return_type': 'void', - 'names': ['glPopGroupMarkerEXT'], - 'arguments': 'void', }, -{ 'return_type': 'void', - 'known_as': 'glProgramBinary', - 'versions': [{ 'name': 'glProgramBinaryOES' }, - { 'name': 'glProgramBinary', - 'extensions': ['GL_ARB_get_program_binary'] }], - 'arguments': 'GLuint program, GLenum binaryFormat, ' - 'const GLvoid* binary, GLsizei length' }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glProgramParameteri', - 'extensions': ['GL_ARB_get_program_binary'] }], - 'arguments': 'GLuint program, GLenum pname, GLint value' }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glPushDebugGroupKHR', - 'extensions': ['GL_KHR_debug'] }], - 'arguments': 'GLenum source, GLuint id, GLsizei length, ' - 'const GLchar* message' }, -{ 'return_type': 'void', - 'names': ['glPushGroupMarkerEXT'], - 'arguments': 'GLsizei length, const char* marker', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glQueryCounter', - 'extensions': ['GL_ARB_timer_query'] }, - { 'name': 'glQueryCounterEXT' }], - 'arguments': 'GLuint id, GLenum target', }, -{ 'return_type': 'void', - 'names': ['glReadBuffer'], - 'arguments': 'GLenum src', }, -{ 'return_type': 'void', - 'names': ['glReadPixels'], - 'arguments': - 'GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, ' - 'GLenum type, void* pixels', }, -{ 'return_type': 'void', - 'names': ['glReleaseShaderCompiler'], - 'arguments': 'void', }, -{ 'return_type': 'void', - 'names': ['glRenderbufferStorageEXT', 'glRenderbufferStorage'], - 'arguments': - 'GLenum target, GLenum internalformat, GLsizei width, GLsizei height', }, -{ 'return_type': 'void', - 'names': ['glRenderbufferStorageMultisample'], - 'arguments': 'GLenum target, GLsizei samples, GLenum internalformat, ' - 'GLsizei width, GLsizei height', }, -{ 'return_type': 'void', - 'names': ['glRenderbufferStorageMultisampleANGLE'], - 'arguments': 'GLenum target, GLsizei samples, GLenum internalformat, ' - 'GLsizei width, GLsizei height', }, -{ 'return_type': 'void', - 'names': ['glRenderbufferStorageMultisampleAPPLE'], - 'arguments': 'GLenum target, GLsizei samples, GLenum internalformat, ' - 'GLsizei width, GLsizei height', }, -{ 'return_type': 'void', - 'names': ['glRenderbufferStorageMultisampleEXT'], - 'arguments': 'GLenum target, GLsizei samples, GLenum internalformat, ' - 'GLsizei width, GLsizei height', }, -{ 'return_type': 'void', - 'names': ['glRenderbufferStorageMultisampleIMG'], - 'arguments': 'GLenum target, GLsizei samples, GLenum internalformat, ' - 'GLsizei width, GLsizei height', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glResolveMultisampleFramebufferAPPLE' }], - 'arguments': 'void', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glResumeTransformFeedback' }], - 'arguments': 'void', }, -{ 'return_type': 'void', - 'names': ['glSampleCoverage'], - 'arguments': 'GLclampf value, GLboolean invert', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glSamplerParameterf' }], - 'arguments': 'GLuint sampler, GLenum pname, GLfloat param', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glSamplerParameterfv' }], - 'arguments': 'GLuint sampler, GLenum pname, const GLfloat* params', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glSamplerParameteri' }], - 'arguments': 'GLuint sampler, GLenum pname, GLint param', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glSamplerParameteriv' }], - 'arguments': 'GLuint sampler, GLenum pname, const GLint* params', }, -{ 'return_type': 'void', - 'names': ['glScissor'], - 'arguments': 'GLint x, GLint y, GLsizei width, GLsizei height', }, -{ 'return_type': 'void', - 'known_as': 'glSetFenceAPPLE', - 'versions': [{ 'name': 'glSetFenceAPPLE', - 'extensions': ['GL_APPLE_fence'] }], - 'arguments': 'GLuint fence', }, -{ 'return_type': 'void', - 'names': ['glSetFenceNV'], - 'arguments': 'GLuint fence, GLenum condition', }, -{ 'return_type': 'void', - 'names': ['glShaderBinary'], - 'arguments': 'GLsizei n, const GLuint* shaders, GLenum binaryformat, ' - 'const void* binary, GLsizei length', }, -{ 'return_type': 'void', - 'names': ['glShaderSource'], - 'arguments': 'GLuint shader, GLsizei count, const char* const* str, ' - 'const GLint* length', - 'logging_code': """ - GL_SERVICE_LOG_CODE_BLOCK({ - for (GLsizei ii = 0; ii < count; ++ii) { - if (str[ii]) { - if (length && length[ii] >= 0) { - std::string source(str[ii], length[ii]); - GL_SERVICE_LOG(" " << ii << ": ---\\n" << source << "\\n---"); - } else { - GL_SERVICE_LOG(" " << ii << ": ---\\n" << str[ii] << "\\n---"); - } - } else { - GL_SERVICE_LOG(" " << ii << ": NULL"); - } - } - }); -""", }, -{ 'return_type': 'void', - 'names': ['glStencilFunc'], - 'arguments': 'GLenum func, GLint ref, GLuint mask', }, -{ 'return_type': 'void', - 'names': ['glStencilFuncSeparate'], - 'arguments': 'GLenum face, GLenum func, GLint ref, GLuint mask', }, -{ 'return_type': 'void', - 'names': ['glStencilMask'], - 'arguments': 'GLuint mask', }, -{ 'return_type': 'void', - 'names': ['glStencilMaskSeparate'], - 'arguments': 'GLenum face, GLuint mask', }, -{ 'return_type': 'void', - 'names': ['glStencilOp'], - 'arguments': 'GLenum fail, GLenum zfail, GLenum zpass', }, -{ 'return_type': 'void', - 'names': ['glStencilOpSeparate'], - 'arguments': 'GLenum face, GLenum fail, GLenum zfail, GLenum zpass', }, -{ 'return_type': 'GLboolean', - 'known_as': 'glTestFenceAPPLE', - 'versions': [{ 'name': 'glTestFenceAPPLE', - 'extensions': ['GL_APPLE_fence'] }], - 'arguments': 'GLuint fence', }, -{ 'return_type': 'GLboolean', - 'names': ['glTestFenceNV'], - 'arguments': 'GLuint fence', }, -{ 'return_type': 'void', - 'names': ['glTexImage2D'], - 'arguments': - 'GLenum target, GLint level, GLint internalformat, GLsizei width, ' - 'GLsizei height, GLint border, GLenum format, GLenum type, ' - 'const void* pixels', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glTexImage3D' }], - 'arguments': - 'GLenum target, GLint level, GLint internalformat, GLsizei width, ' - 'GLsizei height, GLsizei depth, GLint border, GLenum format, ' - 'GLenum type, const void* pixels', }, -{ 'return_type': 'void', - 'names': ['glTexParameterf'], - 'arguments': 'GLenum target, GLenum pname, GLfloat param', }, -{ 'return_type': 'void', - 'names': ['glTexParameterfv'], - 'arguments': 'GLenum target, GLenum pname, const GLfloat* params', }, -{ 'return_type': 'void', - 'names': ['glTexParameteri'], - 'arguments': 'GLenum target, GLenum pname, GLint param', }, -{ 'return_type': 'void', - 'names': ['glTexParameteriv'], - 'arguments': 'GLenum target, GLenum pname, const GLint* params', }, -{ 'return_type': 'void', - 'known_as': 'glTexStorage2DEXT', - 'versions': [{ 'name': 'glTexStorage2D', - 'extensions': ['GL_ARB_texture_storage'] }, - { 'name': 'glTexStorage2DEXT', - 'extensions': ['GL_EXT_texture_storage'] }], - 'arguments': 'GLenum target, GLsizei levels, GLenum internalformat, ' - 'GLsizei width, GLsizei height', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glTexStorage3D' }], - 'arguments': 'GLenum target, GLsizei levels, GLenum internalformat, ' - 'GLsizei width, GLsizei height, GLsizei depth', }, -{ 'return_type': 'void', - 'names': ['glTexSubImage2D'], - 'arguments': - 'GLenum target, GLint level, GLint xoffset, GLint yoffset, ' - 'GLsizei width, GLsizei height, GLenum format, GLenum type, ' - 'const void* pixels', }, -# TODO(zmo): wait for MOCK_METHOD11. -# { 'return_type': 'void', -# 'versions': [{ 'name': 'glTexSubImage3D' }], -# 'arguments': -# 'GLenum target, GLint level, GLint xoffset, GLint yoffset, ' -# 'GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, ' -# 'GLenum format, GLenum type, const void* pixels', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glTextureBarrierNV', - 'extensions': ['GL_NV_texture_barrier'] }], - 'arguments': 'void' }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glTransformFeedbackVaryings' }], - 'arguments': 'GLuint program, GLsizei count, const char* const* varyings, ' - 'GLenum bufferMode', }, -{ 'return_type': 'void', - 'names': ['glUniform1f'], - 'arguments': 'GLint location, GLfloat x', }, -{ 'return_type': 'void', - 'names': ['glUniform1fv'], - 'arguments': 'GLint location, GLsizei count, const GLfloat* v', }, -{ 'return_type': 'void', - 'names': ['glUniform1i'], - 'arguments': 'GLint location, GLint x', }, -{ 'return_type': 'void', - 'names': ['glUniform1iv'], - 'arguments': 'GLint location, GLsizei count, const GLint* v', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glUniform1ui' }], - 'arguments': 'GLint location, GLuint v0', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glUniform1uiv' }], - 'arguments': 'GLint location, GLsizei count, const GLuint* v', }, -{ 'return_type': 'void', - 'names': ['glUniform2f'], - 'arguments': 'GLint location, GLfloat x, GLfloat y', }, -{ 'return_type': 'void', - 'names': ['glUniform2fv'], - 'arguments': 'GLint location, GLsizei count, const GLfloat* v', }, -{ 'return_type': 'void', - 'names': ['glUniform2i'], - 'arguments': 'GLint location, GLint x, GLint y', }, -{ 'return_type': 'void', - 'names': ['glUniform2iv'], - 'arguments': 'GLint location, GLsizei count, const GLint* v', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glUniform2ui' }], - 'arguments': 'GLint location, GLuint v0, GLuint v1', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glUniform2uiv' }], - 'arguments': 'GLint location, GLsizei count, const GLuint* v', }, -{ 'return_type': 'void', - 'names': ['glUniform3f'], - 'arguments': 'GLint location, GLfloat x, GLfloat y, GLfloat z', }, -{ 'return_type': 'void', - 'names': ['glUniform3fv'], - 'arguments': 'GLint location, GLsizei count, const GLfloat* v', }, -{ 'return_type': 'void', - 'names': ['glUniform3i'], - 'arguments': 'GLint location, GLint x, GLint y, GLint z', }, -{ 'return_type': 'void', - 'names': ['glUniform3iv'], - 'arguments': 'GLint location, GLsizei count, const GLint* v', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glUniform3ui' }], - 'arguments': 'GLint location, GLuint v0, GLuint v1, GLuint v2', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glUniform3uiv' }], - 'arguments': 'GLint location, GLsizei count, const GLuint* v', }, -{ 'return_type': 'void', - 'names': ['glUniform4f'], - 'arguments': 'GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w', }, -{ 'return_type': 'void', - 'names': ['glUniform4fv'], - 'arguments': 'GLint location, GLsizei count, const GLfloat* v', }, -{ 'return_type': 'void', - 'names': ['glUniform4i'], - 'arguments': 'GLint location, GLint x, GLint y, GLint z, GLint w', }, -{ 'return_type': 'void', - 'names': ['glUniform4iv'], - 'arguments': 'GLint location, GLsizei count, const GLint* v', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glUniform4ui' }], - 'arguments': 'GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glUniform4uiv' }], - 'arguments': 'GLint location, GLsizei count, const GLuint* v', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glUniformBlockBinding' }], - 'arguments': 'GLuint program, GLuint uniformBlockIndex, ' - 'GLuint uniformBlockBinding', }, -{ 'return_type': 'void', - 'names': ['glUniformMatrix2fv'], - 'arguments': 'GLint location, GLsizei count, ' - 'GLboolean transpose, const GLfloat* value', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glUniformMatrix2x3fv' }], - 'arguments': 'GLint location, GLsizei count, ' - 'GLboolean transpose, const GLfloat* value', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glUniformMatrix2x4fv' }], - 'arguments': 'GLint location, GLsizei count, ' - 'GLboolean transpose, const GLfloat* value', }, -{ 'return_type': 'void', - 'names': ['glUniformMatrix3fv'], - 'arguments': 'GLint location, GLsizei count, ' - 'GLboolean transpose, const GLfloat* value', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glUniformMatrix3x2fv' }], - 'arguments': 'GLint location, GLsizei count, ' - 'GLboolean transpose, const GLfloat* value', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glUniformMatrix3x4fv' }], - 'arguments': 'GLint location, GLsizei count, ' - 'GLboolean transpose, const GLfloat* value', }, -{ 'return_type': 'void', - 'names': ['glUniformMatrix4fv'], - 'arguments': 'GLint location, GLsizei count, ' - 'GLboolean transpose, const GLfloat* value', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glUniformMatrix4x2fv' }], - 'arguments': 'GLint location, GLsizei count, ' - 'GLboolean transpose, const GLfloat* value', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glUniformMatrix4x3fv' }], - 'arguments': 'GLint location, GLsizei count, ' - 'GLboolean transpose, const GLfloat* value', }, -{ 'return_type': 'GLboolean', - 'known_as': 'glUnmapBuffer', - 'names': ['glUnmapBufferOES', 'glUnmapBuffer'], - 'arguments': 'GLenum target', }, -{ 'return_type': 'void', - 'names': ['glUseProgram'], - 'arguments': 'GLuint program', }, -{ 'return_type': 'void', - 'names': ['glValidateProgram'], - 'arguments': 'GLuint program', }, -{ 'return_type': 'void', - 'names': ['glVertexAttrib1f'], - 'arguments': 'GLuint indx, GLfloat x', }, -{ 'return_type': 'void', - 'names': ['glVertexAttrib1fv'], - 'arguments': 'GLuint indx, const GLfloat* values', }, -{ 'return_type': 'void', - 'names': ['glVertexAttrib2f'], - 'arguments': 'GLuint indx, GLfloat x, GLfloat y', }, -{ 'return_type': 'void', - 'names': ['glVertexAttrib2fv'], - 'arguments': 'GLuint indx, const GLfloat* values', }, -{ 'return_type': 'void', - 'names': ['glVertexAttrib3f'], - 'arguments': 'GLuint indx, GLfloat x, GLfloat y, GLfloat z', }, -{ 'return_type': 'void', - 'names': ['glVertexAttrib3fv'], - 'arguments': 'GLuint indx, const GLfloat* values', }, -{ 'return_type': 'void', - 'names': ['glVertexAttrib4f'], - 'arguments': 'GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w', }, -{ 'return_type': 'void', - 'names': ['glVertexAttrib4fv'], - 'arguments': 'GLuint indx, const GLfloat* values', }, -{ 'return_type': 'void', - 'known_as': 'glVertexAttribDivisorANGLE', - 'names': ['glVertexAttribDivisorARB', 'glVertexAttribDivisorANGLE', - 'glVertexAttribDivisor'], - 'arguments': - 'GLuint index, GLuint divisor', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glVertexAttribI4i' }], - 'arguments': 'GLuint indx, GLint x, GLint y, GLint z, GLint w', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glVertexAttribI4iv' }], - 'arguments': 'GLuint indx, const GLint* values', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glVertexAttribI4ui' }], - 'arguments': 'GLuint indx, GLuint x, GLuint y, GLuint z, GLuint w', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glVertexAttribI4uiv' }], - 'arguments': 'GLuint indx, const GLuint* values', }, -{ 'return_type': 'void', - 'versions': [{ 'name': 'glVertexAttribIPointer' }], - 'arguments': 'GLuint indx, GLint size, GLenum type, GLsizei stride, ' - 'const void* ptr', }, -{ 'return_type': 'void', - 'names': ['glVertexAttribPointer'], - 'arguments': 'GLuint indx, GLint size, GLenum type, GLboolean normalized, ' - 'GLsizei stride, const void* ptr', }, -{ 'return_type': 'void', - 'names': ['glViewport'], - 'arguments': 'GLint x, GLint y, GLsizei width, GLsizei height', }, -{ 'return_type': 'GLenum', - 'versions': [{ 'name': 'glWaitSync', - 'extensions': ['GL_ARB_sync'] }], - 'arguments': - 'GLsync sync, GLbitfield flags, GLuint64 timeout', }, -] - -OSMESA_FUNCTIONS = [ -{ 'return_type': 'void', - 'names': ['OSMesaColorClamp'], - 'arguments': 'GLboolean enable', }, -{ 'return_type': 'OSMesaContext', - 'names': ['OSMesaCreateContext'], - 'arguments': 'GLenum format, OSMesaContext sharelist', }, -{ 'return_type': 'OSMesaContext', - 'names': ['OSMesaCreateContextExt'], - 'arguments': - 'GLenum format, GLint depthBits, GLint stencilBits, GLint accumBits, ' - 'OSMesaContext sharelist', }, -{ 'return_type': 'void', - 'names': ['OSMesaDestroyContext'], - 'arguments': 'OSMesaContext ctx', }, -{ 'return_type': 'GLboolean', - 'names': ['OSMesaGetColorBuffer'], - 'arguments': 'OSMesaContext c, GLint* width, GLint* height, GLint* format, ' - 'void** buffer', }, -{ 'return_type': 'OSMesaContext', - 'names': ['OSMesaGetCurrentContext'], - 'arguments': 'void', }, -{ 'return_type': 'GLboolean', - 'names': ['OSMesaGetDepthBuffer'], - 'arguments': - 'OSMesaContext c, GLint* width, GLint* height, GLint* bytesPerValue, ' - 'void** buffer', }, -{ 'return_type': 'void', - 'names': ['OSMesaGetIntegerv'], - 'arguments': 'GLint pname, GLint* value', }, -{ 'return_type': 'OSMESAproc', - 'names': ['OSMesaGetProcAddress'], - 'arguments': 'const char* funcName', }, -{ 'return_type': 'GLboolean', - 'names': ['OSMesaMakeCurrent'], - 'arguments': 'OSMesaContext ctx, void* buffer, GLenum type, GLsizei width, ' - 'GLsizei height', }, -{ 'return_type': 'void', - 'names': ['OSMesaPixelStore'], - 'arguments': 'GLint pname, GLint value', }, -] - -EGL_FUNCTIONS = [ -{ 'return_type': 'EGLBoolean', - 'names': ['eglBindAPI'], - 'arguments': 'EGLenum api', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglBindTexImage'], - 'arguments': 'EGLDisplay dpy, EGLSurface surface, EGLint buffer', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglChooseConfig'], - 'arguments': 'EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, ' - 'EGLint config_size, EGLint* num_config', }, -{ 'return_type': 'EGLint', - 'versions': [{ 'name': 'eglClientWaitSyncKHR', - 'extensions': ['EGL_KHR_fence_sync'] }], - 'arguments': 'EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, ' - 'EGLTimeKHR timeout' }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglCopyBuffers'], - 'arguments': - 'EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target', }, -{ 'return_type': 'EGLContext', - 'names': ['eglCreateContext'], - 'arguments': 'EGLDisplay dpy, EGLConfig config, EGLContext share_context, ' - 'const EGLint* attrib_list', }, -{ 'return_type': 'EGLImageKHR', - 'versions': [{ 'name': 'eglCreateImageKHR', - 'extensions': - ['EGL_KHR_image_base', 'EGL_KHR_gl_texture_2D_image'] }], - 'arguments': - 'EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, ' - 'const EGLint* attrib_list' }, -{ 'return_type': 'EGLSurface', - 'names': ['eglCreatePbufferFromClientBuffer'], - 'arguments': - 'EGLDisplay dpy, EGLenum buftype, void* buffer, EGLConfig config, ' - 'const EGLint* attrib_list', }, -{ 'return_type': 'EGLSurface', - 'names': ['eglCreatePbufferSurface'], - 'arguments': 'EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list', }, -{ 'return_type': 'EGLSurface', - 'names': ['eglCreatePixmapSurface'], - 'arguments': 'EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, ' - 'const EGLint* attrib_list', }, -{ 'return_type': 'EGLSyncKHR', - 'versions': [{ 'name': 'eglCreateSyncKHR', - 'extensions': ['EGL_KHR_fence_sync'] }], - 'arguments': 'EGLDisplay dpy, EGLenum type, const EGLint* attrib_list' }, -{ 'return_type': 'EGLSurface', - 'names': ['eglCreateWindowSurface'], - 'arguments': 'EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, ' - 'const EGLint* attrib_list', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglDestroyContext'], - 'arguments': 'EGLDisplay dpy, EGLContext ctx', }, -{ 'return_type': 'EGLBoolean', - 'versions': [{ 'name' : 'eglDestroyImageKHR', - 'extensions': ['EGL_KHR_image_base'] }], - 'arguments': 'EGLDisplay dpy, EGLImageKHR image' }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglDestroySurface'], - 'arguments': 'EGLDisplay dpy, EGLSurface surface', }, -{ 'return_type': 'EGLBoolean', - 'versions': [{ 'name': 'eglDestroySyncKHR', - 'extensions': ['EGL_KHR_fence_sync'] }], - 'arguments': 'EGLDisplay dpy, EGLSyncKHR sync' }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglGetConfigAttrib'], - 'arguments': - 'EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglGetConfigs'], - 'arguments': 'EGLDisplay dpy, EGLConfig* configs, EGLint config_size, ' - 'EGLint* num_config', }, -{ 'return_type': 'EGLContext', - 'names': ['eglGetCurrentContext'], - 'arguments': 'void', }, -{ 'return_type': 'EGLDisplay', - 'names': ['eglGetCurrentDisplay'], - 'arguments': 'void', }, -{ 'return_type': 'EGLSurface', - 'names': ['eglGetCurrentSurface'], - 'arguments': 'EGLint readdraw', }, -{ 'return_type': 'EGLDisplay', - 'names': ['eglGetDisplay'], - 'arguments': 'EGLNativeDisplayType display_id', }, -{ 'return_type': 'EGLint', - 'names': ['eglGetError'], - 'arguments': 'void', }, -{ 'return_type': 'EGLDisplay', - 'known_as': 'eglGetPlatformDisplayEXT', - 'versions': [{ 'name': 'eglGetPlatformDisplayEXT', - 'extensions': ['EGL_ANGLE_platform_angle'] }], - 'arguments': 'EGLenum platform, void* native_display, ' - 'const EGLint* attrib_list', }, -{ 'return_type': '__eglMustCastToProperFunctionPointerType', - 'names': ['eglGetProcAddress'], - 'arguments': 'const char* procname', }, -{ 'return_type': 'EGLBoolean', - 'versions': [{ 'name': 'eglGetSyncAttribKHR', - 'extensions': ['EGL_KHR_fence_sync'] }], - 'arguments': 'EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, ' - 'EGLint* value' }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglGetSyncValuesCHROMIUM'], - 'arguments': - 'EGLDisplay dpy, EGLSurface surface, ' - 'EGLuint64CHROMIUM* ust, EGLuint64CHROMIUM* msc, ' - 'EGLuint64CHROMIUM* sbc', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglInitialize'], - 'arguments': 'EGLDisplay dpy, EGLint* major, EGLint* minor', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglMakeCurrent'], - 'arguments': - 'EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglPostSubBufferNV'], - 'arguments': 'EGLDisplay dpy, EGLSurface surface, ' - 'EGLint x, EGLint y, EGLint width, EGLint height', }, -{ 'return_type': 'EGLenum', - 'names': ['eglQueryAPI'], - 'arguments': 'void', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglQueryContext'], - 'arguments': - 'EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value', }, -{ 'return_type': 'const char*', - 'names': ['eglQueryString'], - 'arguments': 'EGLDisplay dpy, EGLint name', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglQuerySurface'], - 'arguments': - 'EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* value', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglQuerySurfacePointerANGLE'], - 'arguments': - 'EGLDisplay dpy, EGLSurface surface, EGLint attribute, void** value', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglReleaseTexImage'], - 'arguments': 'EGLDisplay dpy, EGLSurface surface, EGLint buffer', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglReleaseThread'], - 'arguments': 'void', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglSurfaceAttrib'], - 'arguments': - 'EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglSwapBuffers'], - 'arguments': 'EGLDisplay dpy, EGLSurface surface', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglSwapInterval'], - 'arguments': 'EGLDisplay dpy, EGLint interval', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglTerminate'], - 'arguments': 'EGLDisplay dpy', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglWaitClient'], - 'arguments': 'void', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglWaitGL'], - 'arguments': 'void', }, -{ 'return_type': 'EGLBoolean', - 'names': ['eglWaitNative'], - 'arguments': 'EGLint engine', }, -{ 'return_type': 'EGLint', - 'versions': [{ 'name': 'eglWaitSyncKHR', - 'extensions': ['EGL_KHR_wait_sync'] }], - 'arguments': 'EGLDisplay dpy, EGLSyncKHR sync, EGLint flags' }, -] - -WGL_FUNCTIONS = [ -{ 'return_type': 'BOOL', - 'names': ['wglChoosePixelFormatARB'], - 'arguments': - 'HDC dc, const int* int_attrib_list, const float* float_attrib_list, ' - 'UINT max_formats, int* formats, UINT* num_formats', }, -{ 'return_type': 'BOOL', - 'names': ['wglCopyContext'], - 'arguments': 'HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask', }, -{ 'return_type': 'HGLRC', - 'names': ['wglCreateContext'], - 'arguments': 'HDC hdc', }, -{ 'return_type': 'HGLRC', - 'names': ['wglCreateLayerContext'], - 'arguments': 'HDC hdc, int iLayerPlane', }, -{ 'return_type': 'HPBUFFERARB', - 'names': ['wglCreatePbufferARB'], - 'arguments': 'HDC hDC, int iPixelFormat, int iWidth, int iHeight, ' - 'const int* piAttribList', }, -{ 'return_type': 'BOOL', - 'names': ['wglDeleteContext'], - 'arguments': 'HGLRC hglrc', }, -{ 'return_type': 'BOOL', - 'names': ['wglDestroyPbufferARB'], - 'arguments': 'HPBUFFERARB hPbuffer', }, -{ 'return_type': 'HGLRC', - 'names': ['wglGetCurrentContext'], - 'arguments': '', }, -{ 'return_type': 'HDC', - 'names': ['wglGetCurrentDC'], - 'arguments': '', }, -{ 'return_type': 'const char*', - 'names': ['wglGetExtensionsStringARB'], - 'arguments': 'HDC hDC', }, -{ 'return_type': 'const char*', - 'names': ['wglGetExtensionsStringEXT'], - 'arguments': '', }, -{ 'return_type': 'HDC', - 'names': ['wglGetPbufferDCARB'], - 'arguments': 'HPBUFFERARB hPbuffer', }, -{ 'return_type': 'BOOL', - 'names': ['wglMakeCurrent'], - 'arguments': 'HDC hdc, HGLRC hglrc', }, -{ 'return_type': 'BOOL', - 'names': ['wglQueryPbufferARB'], - 'arguments': 'HPBUFFERARB hPbuffer, int iAttribute, int* piValue', }, -{ 'return_type': 'int', - 'names': ['wglReleasePbufferDCARB'], - 'arguments': 'HPBUFFERARB hPbuffer, HDC hDC', }, -{ 'return_type': 'BOOL', - 'names': ['wglShareLists'], - 'arguments': 'HGLRC hglrc1, HGLRC hglrc2', }, -{ 'return_type': 'BOOL', - 'names': ['wglSwapIntervalEXT'], - 'arguments': 'int interval', }, -{ 'return_type': 'BOOL', - 'names': ['wglSwapLayerBuffers'], - 'arguments': 'HDC hdc, UINT fuPlanes', }, -] - -GLX_FUNCTIONS = [ -{ 'return_type': 'void', - 'names': ['glXBindTexImageEXT'], - 'arguments': - 'Display* dpy, GLXDrawable drawable, int buffer, int* attribList', }, -{ 'return_type': 'GLXFBConfig*', - 'names': ['glXChooseFBConfig'], - 'arguments': - 'Display* dpy, int screen, const int* attribList, int* nitems', }, -{ 'return_type': 'XVisualInfo*', - 'names': ['glXChooseVisual'], - 'arguments': 'Display* dpy, int screen, int* attribList', }, -{ 'return_type': 'void', - 'names': ['glXCopyContext'], - 'arguments': - 'Display* dpy, GLXContext src, GLXContext dst, unsigned long mask', }, -{ 'return_type': 'void', - 'names': ['glXCopySubBufferMESA'], - 'arguments': 'Display* dpy, GLXDrawable drawable, ' - 'int x, int y, int width, int height', }, -{ 'return_type': 'GLXContext', - 'names': ['glXCreateContext'], - 'arguments': - 'Display* dpy, XVisualInfo* vis, GLXContext shareList, int direct', }, -{ 'return_type': 'GLXContext', - 'names': ['glXCreateContextAttribsARB'], - 'arguments': - 'Display* dpy, GLXFBConfig config, GLXContext share_context, int direct, ' - 'const int* attrib_list', }, -{ 'return_type': 'GLXPixmap', - 'names': ['glXCreateGLXPixmap'], - 'arguments': 'Display* dpy, XVisualInfo* visual, Pixmap pixmap', }, -{ 'return_type': 'GLXContext', - 'names': ['glXCreateNewContext'], - 'arguments': 'Display* dpy, GLXFBConfig config, int renderType, ' - 'GLXContext shareList, int direct', }, -{ 'return_type': 'GLXPbuffer', - 'names': ['glXCreatePbuffer'], - 'arguments': 'Display* dpy, GLXFBConfig config, const int* attribList', }, -{ 'return_type': 'GLXPixmap', - 'names': ['glXCreatePixmap'], - 'arguments': 'Display* dpy, GLXFBConfig config, ' - 'Pixmap pixmap, const int* attribList', }, -{ 'return_type': 'GLXWindow', - 'names': ['glXCreateWindow'], - 'arguments': - 'Display* dpy, GLXFBConfig config, Window win, const int* attribList', }, -{ 'return_type': 'void', - 'names': ['glXDestroyContext'], - 'arguments': 'Display* dpy, GLXContext ctx', }, -{ 'return_type': 'void', - 'names': ['glXDestroyGLXPixmap'], - 'arguments': 'Display* dpy, GLXPixmap pixmap', }, -{ 'return_type': 'void', - 'names': ['glXDestroyPbuffer'], - 'arguments': 'Display* dpy, GLXPbuffer pbuf', }, -{ 'return_type': 'void', - 'names': ['glXDestroyPixmap'], - 'arguments': 'Display* dpy, GLXPixmap pixmap', }, -{ 'return_type': 'void', - 'names': ['glXDestroyWindow'], - 'arguments': 'Display* dpy, GLXWindow window', }, -{ 'return_type': 'const char*', - 'names': ['glXGetClientString'], - 'arguments': 'Display* dpy, int name', }, -{ 'return_type': 'int', - 'names': ['glXGetConfig'], - 'arguments': 'Display* dpy, XVisualInfo* visual, int attrib, int* value', }, -{ 'return_type': 'GLXContext', - 'names': ['glXGetCurrentContext'], - 'arguments': 'void', }, -{ 'return_type': 'Display*', - 'names': ['glXGetCurrentDisplay'], - 'arguments': 'void', }, -{ 'return_type': 'GLXDrawable', - 'names': ['glXGetCurrentDrawable'], - 'arguments': 'void', }, -{ 'return_type': 'GLXDrawable', - 'names': ['glXGetCurrentReadDrawable'], - 'arguments': 'void', }, -{ 'return_type': 'int', - 'names': ['glXGetFBConfigAttrib'], - 'arguments': 'Display* dpy, GLXFBConfig config, int attribute, int* value', }, -{ 'return_type': 'GLXFBConfig', - 'names': ['glXGetFBConfigFromVisualSGIX'], - 'arguments': 'Display* dpy, XVisualInfo* visualInfo', }, -{ 'return_type': 'GLXFBConfig*', - 'names': ['glXGetFBConfigs'], - 'arguments': 'Display* dpy, int screen, int* nelements', }, -{ 'return_type': 'bool', - 'names': ['glXGetMscRateOML'], - 'arguments': - 'Display* dpy, GLXDrawable drawable, int32* numerator, ' - 'int32* denominator' }, -{ 'return_type': 'void', - 'names': ['glXGetSelectedEvent'], - 'arguments': 'Display* dpy, GLXDrawable drawable, unsigned long* mask', }, -{ 'return_type': 'bool', - 'names': ['glXGetSyncValuesOML'], - 'arguments': - 'Display* dpy, GLXDrawable drawable, int64* ust, int64* msc, ' - 'int64* sbc' }, -{ 'return_type': 'XVisualInfo*', - 'names': ['glXGetVisualFromFBConfig'], - 'arguments': 'Display* dpy, GLXFBConfig config', }, -{ 'return_type': 'int', - 'names': ['glXIsDirect'], - 'arguments': 'Display* dpy, GLXContext ctx', }, -{ 'return_type': 'int', - 'names': ['glXMakeContextCurrent'], - 'arguments': - 'Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx', }, -{ 'return_type': 'int', - 'names': ['glXMakeCurrent'], - 'arguments': 'Display* dpy, GLXDrawable drawable, GLXContext ctx', }, -{ 'return_type': 'int', - 'names': ['glXQueryContext'], - 'arguments': 'Display* dpy, GLXContext ctx, int attribute, int* value', }, -{ 'return_type': 'void', - 'names': ['glXQueryDrawable'], - 'arguments': - 'Display* dpy, GLXDrawable draw, int attribute, unsigned int* value', }, -{ 'return_type': 'int', - 'names': ['glXQueryExtension'], - 'arguments': 'Display* dpy, int* errorb, int* event', }, -{ 'return_type': 'const char*', - 'names': ['glXQueryExtensionsString'], - 'arguments': 'Display* dpy, int screen', }, -{ 'return_type': 'const char*', - 'names': ['glXQueryServerString'], - 'arguments': 'Display* dpy, int screen, int name', }, -{ 'return_type': 'int', - 'names': ['glXQueryVersion'], - 'arguments': 'Display* dpy, int* maj, int* min', }, -{ 'return_type': 'void', - 'names': ['glXReleaseTexImageEXT'], - 'arguments': 'Display* dpy, GLXDrawable drawable, int buffer', }, -{ 'return_type': 'void', - 'names': ['glXSelectEvent'], - 'arguments': 'Display* dpy, GLXDrawable drawable, unsigned long mask', }, -{ 'return_type': 'void', - 'names': ['glXSwapBuffers'], - 'arguments': 'Display* dpy, GLXDrawable drawable', }, -{ 'return_type': 'void', - 'names': ['glXSwapIntervalEXT'], - 'arguments': 'Display* dpy, GLXDrawable drawable, int interval', }, -{ 'return_type': 'void', - 'names': ['glXSwapIntervalMESA'], - 'arguments': 'unsigned int interval', }, -{ 'return_type': 'void', - 'names': ['glXUseXFont'], - 'arguments': 'Font font, int first, int count, int list', }, -{ 'return_type': 'void', - 'names': ['glXWaitGL'], - 'arguments': 'void', }, -{ 'return_type': 'int', - 'names': ['glXWaitVideoSyncSGI'], - 'arguments': 'int divisor, int remainder, unsigned int* count', }, -{ 'return_type': 'void', - 'names': ['glXWaitX'], - 'arguments': 'void', }, -] - -FUNCTION_SETS = [ - [GL_FUNCTIONS, 'gl', [ - 'GL/gl.h', - 'noninclude/GL/glext.h', - 'GLES2/gl2ext.h', - 'GLES3/gl3.h', - 'GLES3/gl31.h', - # Files below are Chromium-specific and shipped with Chromium sources. - 'GL/glextchromium.h', - 'GLES2/gl2chromium.h', - 'GLES2/gl2extchromium.h' - ], []], - [OSMESA_FUNCTIONS, 'osmesa', [], []], - [EGL_FUNCTIONS, 'egl', [ - 'EGL/eglext.h', - # Files below are Chromium-specific and shipped with Chromium sources. - 'EGL/eglextchromium.h', - ], - [ - 'EGL_ANGLE_d3d_share_handle_client_buffer', - 'EGL_ANGLE_surface_d3d_texture_2d_share_handle', - ], - ], - [WGL_FUNCTIONS, 'wgl', ['noninclude/GL/wglext.h'], []], - [GLX_FUNCTIONS, 'glx', ['GL/glx.h', 'noninclude/GL/glxext.h'], []], -] - -GLES2_HEADERS_WITH_ENUMS = [ - 'GLES2/gl2.h', - 'GLES2/gl2ext.h', - 'GLES2/gl2chromium.h', - 'GLES2/gl2extchromium.h', - 'GLES3/gl3.h', -] - -SELF_LOCATION = os.path.dirname(os.path.abspath(__file__)) - -LICENSE_AND_HEADER = """\ -// Copyright 2014 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 is auto-generated from -// ui/gl/generate_bindings.py -// It's formatted by clang-format using chromium coding style: -// clang-format -i -style=chromium filename -// DO NOT EDIT! - -""" - -GLVersion = namedtuple('GLVersion', 'is_es major_version minor_version') - -def GLVersionBindAlways(version): - return version.major_version <= 2 - - -def GetStaticBinding(func): - """If this function has a name assigned to it that should be bound always, - then return this name. - - This will be the case if either a function name is specified - that depends on an extension from UNCONDITIONALLY_BOUND_EXTENSIONS, - or if the GL version it depends on is assumed to be available (e.g. <=2.1). - There can only be one name that satisfies this condition (or the bindings - would be ambiguous).""" - - static_bindings = set([]) - - for version in func['versions']: - if 'extensions' in version: - extensions = version['extensions'] - num_unconditional_extensions = len( - extensions & UNCONDITIONALLY_BOUND_EXTENSIONS) - if num_unconditional_extensions: - static_bindings.add(version['name']) - elif 'gl_versions' in version: - versions = [v for v in version['gl_versions'] if GLVersionBindAlways(v)] - # It's only unconditional if it exists in GL and GLES - if len(versions) == 2: - assert versions[0].is_es != versions[1].is_es - static_bindings.add(version['name']) - else: - static_bindings.add(version['name']) - - # Avoid ambiguous bindings (static binding with different names) - assert len(static_bindings) <= 1 - if len(static_bindings): - static_name = static_bindings.pop() - # Avoid ambiguous bindings (static and dynamic bindings with - # different names) - assert len([v['name'] for v in func['versions'] - if v['name'] != static_name]) == 0, func - return static_name - else: - return None - - -def GenerateHeader(file, functions, set_name, used_extensions): - """Generates gl_bindings_autogen_x.h""" - - # Write file header. - file.write(LICENSE_AND_HEADER + -""" - -#ifndef UI_GFX_GL_GL_BINDINGS_AUTOGEN_%(name)s_H_ -#define UI_GFX_GL_GL_BINDINGS_AUTOGEN_%(name)s_H_ - -namespace gfx { - -class GLContext; - -""" % {'name': set_name.upper()}) - - # Write typedefs for function pointer types. Always use the GL name for the - # typedef. - file.write('\n') - for func in functions: - file.write('typedef %s (GL_BINDING_CALL *%sProc)(%s);\n' % - (func['return_type'], func['known_as'], func['arguments'])) - - # Write declarations for booleans indicating which extensions are available. - file.write('\n') - file.write("struct Extensions%s {\n" % set_name.upper()) - for extension in sorted(used_extensions): - file.write(' bool b_%s;\n' % extension) - file.write('};\n') - file.write('\n') - - # Write Procs struct. - file.write("struct Procs%s {\n" % set_name.upper()) - for func in functions: - file.write(' %sProc %sFn;\n' % (func['known_as'], func['known_as'])) - file.write('};\n') - file.write('\n') - - # Write Api class. - file.write( -"""class GL_EXPORT %(name)sApi { - public: - %(name)sApi(); - virtual ~%(name)sApi(); - -""" % {'name': set_name.upper()}) - for func in functions: - file.write(' virtual %s %sFn(%s) = 0;\n' % - (func['return_type'], func['known_as'], func['arguments'])) - file.write('};\n') - file.write('\n') - - file.write( '} // namespace gfx\n') - - # Write macros to invoke function pointers. Always use the GL name for the - # macro. - file.write('\n') - for func in functions: - file.write('#define %s ::gfx::g_current_%s_context->%sFn\n' % - (func['known_as'], set_name.lower(), func['known_as'])) - - file.write('\n') - file.write('#endif // UI_GFX_GL_GL_BINDINGS_AUTOGEN_%s_H_\n' % - set_name.upper()) - - -def GenerateAPIHeader(file, functions, set_name): - """Generates gl_bindings_api_autogen_x.h""" - - # Write file header. - file.write(LICENSE_AND_HEADER) - - # Write API declaration. - for func in functions: - file.write(' %s %sFn(%s) override;\n' % - (func['return_type'], func['known_as'], func['arguments'])) - - file.write('\n') - - -def GenerateMockHeader(file, functions, set_name): - """Generates gl_mock_autogen_x.h""" - - # Write file header. - file.write(LICENSE_AND_HEADER) - - # Write API declaration. - for func in functions: - args = func['arguments'] - if args == 'void': - args = '' - arg_count = 0 - if len(args): - arg_count = func['arguments'].count(',') + 1 - file.write(' MOCK_METHOD%d(%s, %s(%s));\n' % - (arg_count, func['known_as'][2:], func['return_type'], args)) - - file.write('\n') - - -def GenerateSource(file, functions, set_name, used_extensions): - """Generates gl_bindings_autogen_x.cc""" - - set_header_name = "ui/gl/gl_" + set_name.lower() + "_api_implementation.h" - include_list = [ 'base/trace_event/trace_event.h', - 'ui/gl/gl_enums.h', - 'ui/gl/gl_bindings.h', - 'ui/gl/gl_context.h', - 'ui/gl/gl_implementation.h', - 'ui/gl/gl_version_info.h', - set_header_name ] - - includes_string = "\n".join(["#include \"{0}\"".format(h) - for h in sorted(include_list)]) - - # Write file header. - file.write(LICENSE_AND_HEADER + -""" - -#include - -%s - -namespace gfx { -""" % includes_string) - - file.write('\n') - file.write('static bool g_debugBindingsInitialized;\n') - file.write('Driver%s g_driver_%s;\n' % (set_name.upper(), set_name.lower())) - file.write('\n') - - # Write stub functions that take the place of some functions before a context - # is initialized. This is done to provide clear asserts on debug build and to - # avoid crashing in case of a bug on release build. - file.write('\n') - num_dynamic = 0 - for func in functions: - static_binding = GetStaticBinding(func) - if static_binding: - func['static_binding'] = static_binding - else: - num_dynamic = num_dynamic + 1 - - print "[%s] %d static bindings, %d dynamic bindings" % ( - set_name, len(functions) - num_dynamic, num_dynamic) - - # Write function to initialize the function pointers that are always the same - # and to initialize bindings where choice of the function depends on the - # extension string or the GL version to point to stub functions. - file.write('\n') - file.write('void Driver%s::InitializeStaticBindings() {\n' % - set_name.upper()) - - def WriteFuncBinding(file, known_as, version_name): - file.write( - ' fn.%sFn = reinterpret_cast<%sProc>(GetGLProcAddress("%s"));\n' % - (known_as, known_as, version_name)) - - for func in functions: - if 'static_binding' in func: - WriteFuncBinding(file, func['known_as'], func['static_binding']) - else: - file.write(' fn.%sFn = 0;\n' % func['known_as']) - - if set_name == 'gl': - # Write the deferred bindings for GL that need a current context and depend - # on GL_VERSION and GL_EXTENSIONS. - file.write('}\n\n') - file.write("""void DriverGL::InitializeDynamicBindings(GLContext* context) { - DCHECK(context && context->IsCurrent(NULL)); - const GLVersionInfo* ver = context->GetVersionInfo(); - ALLOW_UNUSED_LOCAL(ver); - std::string extensions = context->GetExtensions() + " "; - ALLOW_UNUSED_LOCAL(extensions); - -""") - else: - file.write("""std::string extensions(GetPlatformExtensions()); - extensions += " "; - ALLOW_UNUSED_LOCAL(extensions); - -""") - - for extension in sorted(used_extensions): - # Extra space at the end of the extension name is intentional, it is used - # as a separator - file.write(' ext.b_%s = extensions.find("%s ") != std::string::npos;\n' % - (extension, extension)) - - def GetGLVersionCondition(gl_version): - if GLVersionBindAlways(gl_version): - if gl_version.is_es: - return 'ver->is_es' - else: - return '!ver->is_es' - elif gl_version.is_es: - return 'ver->IsAtLeastGLES(%du, %du)' % ( - gl_version.major_version, gl_version.minor_version) - else: - return 'ver->IsAtLeastGL(%du, %du)' % ( - gl_version.major_version, gl_version.minor_version) - - def GetBindingCondition(version): - conditions = [] - if 'gl_versions' in version: - conditions.extend( - [GetGLVersionCondition(v) for v in version['gl_versions']]) - if 'extensions' in version and version['extensions']: - conditions.extend( - ['ext.b_%s' % e for e in version['extensions']]) - return ' || '.join(conditions) - - def WriteConditionalFuncBinding(file, func): - assert len(func['versions']) > 0 - known_as = func['known_as'] - i = 0 - first_version = True - while i < len(func['versions']): - version = func['versions'][i] - cond = GetBindingCondition(version) - if first_version: - file.write(' if (%s) {\n ' % cond) - else: - file.write(' else if (%s) {\n ' % (cond)) - - WriteFuncBinding(file, known_as, version['name']) - file.write('DCHECK(fn.%sFn);\n' % known_as) - file.write('}\n') - i += 1 - first_version = False - - for func in functions: - if not 'static_binding' in func: - file.write('\n') - file.write(' debug_fn.%sFn = 0;\n' % func['known_as']) - WriteConditionalFuncBinding(file, func) - - # Some new function pointers have been added, so update them in debug bindings - file.write('\n') - file.write(' if (g_debugBindingsInitialized)\n') - file.write(' InitializeDebugBindings();\n') - file.write('}\n') - file.write('\n') - - # Write logging wrappers for each function. - file.write('extern "C" {\n') - for func in functions: - return_type = func['return_type'] - arguments = func['arguments'] - file.write('\n') - file.write('static %s GL_BINDING_CALL Debug_%s(%s) {\n' % - (return_type, func['known_as'], arguments)) - argument_names = re.sub( - r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', arguments) - argument_names = re.sub( - r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', argument_names) - log_argument_names = re.sub( - r'const char\* ([a-zA-Z0-9_]+)', r'CONSTCHAR_\1', arguments) - log_argument_names = re.sub( - r'(const )?[a-zA-Z0-9_]+\* ([a-zA-Z0-9_]+)', - r'CONSTVOID_\2', log_argument_names) - log_argument_names = re.sub( - r'(?(\1)', log_argument_names) - log_argument_names = re.sub( - r'CONSTCHAR_([a-zA-Z0-9_]+)', r'\1', log_argument_names) - log_argument_names = re.sub( - r'GLenum_([a-zA-Z0-9_]+)', r'GLEnums::GetStringEnum(\1)', - log_argument_names) - log_argument_names = re.sub( - r'GLboolean_([a-zA-Z0-9_]+)', r'GLEnums::GetStringBool(\1)', - log_argument_names) - log_argument_names = log_argument_names.replace(',', ' << ", " <<') - if argument_names == 'void' or argument_names == '': - argument_names = '' - log_argument_names = '' - else: - log_argument_names = " << " + log_argument_names - function_name = func['known_as'] - if return_type == 'void': - file.write(' GL_SERVICE_LOG("%s" << "(" %s << ")");\n' % - (function_name, log_argument_names)) - file.write(' g_driver_%s.debug_fn.%sFn(%s);\n' % - (set_name.lower(), function_name, argument_names)) - if 'logging_code' in func: - file.write("%s\n" % func['logging_code']) - else: - file.write(' GL_SERVICE_LOG("%s" << "(" %s << ")");\n' % - (function_name, log_argument_names)) - file.write(' %s result = g_driver_%s.debug_fn.%sFn(%s);\n' % - (return_type, set_name.lower(), function_name, argument_names)) - if 'logging_code' in func: - file.write("%s\n" % func['logging_code']) - else: - file.write(' GL_SERVICE_LOG("GL_RESULT: " << result);\n') - file.write(' return result;\n') - file.write('}\n') - file.write('} // extern "C"\n') - - # Write function to initialize the debug function pointers. - file.write('\n') - file.write('void Driver%s::InitializeDebugBindings() {\n' % - set_name.upper()) - for func in functions: - first_name = func['known_as'] - file.write(' if (!debug_fn.%sFn) {\n' % first_name) - file.write(' debug_fn.%sFn = fn.%sFn;\n' % (first_name, first_name)) - file.write(' fn.%sFn = Debug_%s;\n' % (first_name, first_name)) - file.write(' }\n') - file.write(' g_debugBindingsInitialized = true;\n') - file.write('}\n') - - # Write function to clear all function pointers. - file.write('\n') - file.write("""void Driver%s::ClearBindings() { - memset(this, 0, sizeof(*this)); -} -""" % set_name.upper()) - - def MakeArgNames(arguments): - argument_names = re.sub( - r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', arguments) - argument_names = re.sub( - r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', argument_names) - if argument_names == 'void' or argument_names == '': - argument_names = '' - return argument_names - - # Write GLApiBase functions - for func in functions: - function_name = func['known_as'] - return_type = func['return_type'] - arguments = func['arguments'] - file.write('\n') - file.write('%s %sApiBase::%sFn(%s) {\n' % - (return_type, set_name.upper(), function_name, arguments)) - argument_names = MakeArgNames(arguments) - if return_type == 'void': - file.write(' driver_->fn.%sFn(%s);\n' % - (function_name, argument_names)) - else: - file.write(' return driver_->fn.%sFn(%s);\n' % - (function_name, argument_names)) - file.write('}\n') - - # Write TraceGLApi functions - for func in functions: - function_name = func['known_as'] - return_type = func['return_type'] - arguments = func['arguments'] - file.write('\n') - file.write('%s Trace%sApi::%sFn(%s) {\n' % - (return_type, set_name.upper(), function_name, arguments)) - argument_names = MakeArgNames(arguments) - file.write(' TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::%s")\n' % - function_name) - if return_type == 'void': - file.write(' %s_api_->%sFn(%s);\n' % - (set_name.lower(), function_name, argument_names)) - else: - file.write(' return %s_api_->%sFn(%s);\n' % - (set_name.lower(), function_name, argument_names)) - file.write('}\n') - - # Write NoContextGLApi functions - if set_name.upper() == "GL": - for func in functions: - function_name = func['known_as'] - return_type = func['return_type'] - arguments = func['arguments'] - file.write('\n') - file.write('%s NoContextGLApi::%sFn(%s) {\n' % - (return_type, function_name, arguments)) - argument_names = MakeArgNames(arguments) - no_context_error = "Trying to call %s() without current GL context" % function_name - file.write(' NOTREACHED() << "%s";\n' % no_context_error) - file.write(' LOG(ERROR) << "%s";\n' % no_context_error) - default_value = { 'GLenum': 'static_cast(0)', - 'GLuint': '0U', - 'GLint': '0', - 'GLboolean': 'GL_FALSE', - 'GLbyte': '0', - 'GLubyte': '0', - 'GLbutfield': '0', - 'GLushort': '0', - 'GLsizei': '0', - 'GLfloat': '0.0f', - 'GLdouble': '0.0', - 'GLsync': 'NULL'} - if return_type.endswith('*'): - file.write(' return NULL;\n') - elif return_type != 'void': - file.write(' return %s;\n' % default_value[return_type]) - file.write('}\n') - - file.write('\n') - file.write('} // namespace gfx\n') - - -def GetUniquelyNamedFunctions(functions): - uniquely_named_functions = {} - - for func in functions: - for version in func['versions']: - uniquely_named_functions[version['name']] = ({ - 'name': version['name'], - 'return_type': func['return_type'], - 'arguments': func['arguments'], - 'known_as': func['known_as'] - }) - return uniquely_named_functions - - -def GenerateMockBindingsHeader(file, functions): - """Headers for functions that invoke MockGLInterface members""" - - file.write(LICENSE_AND_HEADER) - uniquely_named_functions = GetUniquelyNamedFunctions(functions) - - for key in sorted(uniquely_named_functions.iterkeys()): - func = uniquely_named_functions[key] - file.write('static %s GL_BINDING_CALL Mock_%s(%s);\n' % - (func['return_type'], func['name'], func['arguments'])) - - -def GenerateMockBindingsSource(file, functions): - """Generates functions that invoke MockGLInterface members and a - GetGLProcAddress function that returns addresses to those functions.""" - - file.write(LICENSE_AND_HEADER + -""" - -#include - -#include "ui/gl/gl_mock.h" - -namespace gfx { - -// This is called mainly to prevent the compiler combining the code of mock -// functions with identical contents, so that their function pointers will be -// different. -void MakeFunctionUnique(const char *func_name) { - VLOG(2) << "Calling mock " << func_name; -} - -""") - # Write functions that trampoline into the set MockGLInterface instance. - uniquely_named_functions = GetUniquelyNamedFunctions(functions) - sorted_function_names = sorted(uniquely_named_functions.iterkeys()) - - for key in sorted_function_names: - func = uniquely_named_functions[key] - file.write('\n') - file.write('%s GL_BINDING_CALL MockGLInterface::Mock_%s(%s) {\n' % - (func['return_type'], func['name'], func['arguments'])) - file.write(' MakeFunctionUnique("%s");\n' % func['name']) - arg_re = r'(const )?[a-zA-Z0-9]+((\s*const\s*)?\*)* ([a-zA-Z0-9]+)' - argument_names = re.sub(arg_re, r'\4', func['arguments']) - if argument_names == 'void': - argument_names = '' - function_name = func['known_as'][2:] - if func['return_type'] == 'void': - file.write(' interface_->%s(%s);\n' % - (function_name, argument_names)) - else: - file.write(' return interface_->%s(%s);\n' % - (function_name, argument_names)) - file.write('}\n') - - # Write an 'invalid' function to catch code calling through uninitialized - # function pointers or trying to interpret the return value of - # GLProcAddress(). - file.write('\n') - file.write('static void MockInvalidFunction() {\n') - file.write(' NOTREACHED();\n') - file.write('}\n') - - # Write a function to lookup a mock GL function based on its name. - file.write('\n') - file.write('void* GL_BINDING_CALL ' + - 'MockGLInterface::GetGLProcAddress(const char* name) {\n') - for key in sorted_function_names: - name = uniquely_named_functions[key]['name'] - file.write(' if (strcmp(name, "%s") == 0)\n' % name) - file.write(' return reinterpret_cast(Mock_%s);\n' % name) - # Always return a non-NULL pointer like some EGL implementations do. - file.write(' return reinterpret_cast(&MockInvalidFunction);\n') - file.write('}\n') - - file.write('\n') - file.write('} // namespace gfx\n') - -def GenerateEnumUtils(out_file, input_filenames): - enum_re = re.compile(r'\#define\s+(GL_[a-zA-Z0-9_]+)\s+([0-9A-Fa-fx]+)') - dict = {} - for fname in input_filenames: - lines = open(fname).readlines() - for line in lines: - m = enum_re.match(line) - if m: - name = m.group(1) - value = m.group(2) - if len(value) <= 10: - if not value in dict: - dict[value] = name - # check our own _CHROMIUM macro conflicts with khronos GL headers. - elif dict[value] != name and (name.endswith('_CHROMIUM') or - dict[value].endswith('_CHROMIUM')): - raise RunTimeError("code collision: %s and %s have the same code %s" - % (dict[value], name, value)) - - out_file.write(LICENSE_AND_HEADER) - out_file.write("static const GLEnums::EnumToString " - "enum_to_string_table[] = {\n") - for value in dict: - out_file.write(' { %s, "%s", },\n' % (value, dict[value])) - out_file.write("""}; - -const GLEnums::EnumToString* const GLEnums::enum_to_string_table_ = - enum_to_string_table; -const size_t GLEnums::enum_to_string_table_len_ = - sizeof(enum_to_string_table) / sizeof(enum_to_string_table[0]); - -""") - - -def ParseFunctionsFromHeader(header_file, extensions, versions): - """Parse a C extension header file and return a map from extension names to - a list of functions. - - Args: - header_file: Line-iterable C header file. - Returns: - Map of extension name => functions, Map of gl version => functions. - Functions will only be in either one of the two maps. - """ - version_start = re.compile( - r'#ifndef GL_(ES_|)VERSION((?:_[0-9])+)$') - extension_start = re.compile( - r'#ifndef ((?:GL|EGL|WGL|GLX)_[A-Z]+_[a-zA-Z]\w+)') - extension_function = re.compile(r'.+\s+([a-z]+\w+)\s*\(') - typedef = re.compile(r'typedef .*') - macro_start = re.compile(r'^#(if|ifdef|ifndef).*') - macro_end = re.compile(r'^#endif.*') - macro_depth = 0 - current_version = None - current_version_depth = 0 - current_extension = None - current_extension_depth = 0 - - # Pick up all core functions here, since some of them are missing in the - # Khronos headers. - hdr = os.path.basename(header_file.name) - if hdr == "gl.h": - current_version = GLVersion(False, 1, 0) - - line_num = 1 - for line in header_file: - version_match = version_start.match(line) - if macro_start.match(line): - macro_depth += 1 - if version_match: - if current_version: - raise RuntimeError('Nested GL version macro in %s at line %d' % ( - header_file.name, line_num)) - current_version_depth = macro_depth - es = version_match.group(1) - major_version, minor_version =\ - version_match.group(2).lstrip('_').split('_') - is_es = len(es) > 0 - if (not is_es) and (major_version == '1'): - minor_version = 0 - current_version = GLVersion( - is_es, int(major_version), int(minor_version)) - elif macro_end.match(line): - macro_depth -= 1 - if macro_depth < current_extension_depth: - current_extension = None - if macro_depth < current_version_depth: - current_version = None - - match = extension_start.match(line) - if match and not version_match: - if current_version and hdr != "gl.h": - raise RuntimeError('Nested GL version macro in %s at line %d' % ( - header_file.name, line_num)) - current_extension = match.group(1) - current_extension_depth = macro_depth - - match = extension_function.match(line) - if match and not typedef.match(line): - if current_extension: - extensions[current_extension].add(match.group(1)) - elif current_version: - versions[current_version].add(match.group(1)) - line_num = line_num + 1 - - -def GetDynamicFunctions(extension_headers): - """Parse all optional functions from a list of header files. - - Args: - extension_headers: List of header file names. - Returns: - Map of extension name => list of functions, - Map of gl version => list of functions. - """ - extensions = collections.defaultdict(lambda: set([])) - gl_versions = collections.defaultdict(lambda: set([])) - for header in extension_headers: - ParseFunctionsFromHeader(open(header), extensions, gl_versions) - return extensions, gl_versions - - -def GetFunctionToExtensionsMap(extensions): - """Construct map from a function names to extensions which define the - function. - - Args: - extensions: Map of extension name => functions. - Returns: - Map of function name => extension names. - """ - function_to_extensions = {} - for extension, functions in extensions.items(): - for function in functions: - if not function in function_to_extensions: - function_to_extensions[function] = set([]) - function_to_extensions[function].add(extension) - return function_to_extensions - -def GetFunctionToGLVersionsMap(gl_versions): - """Construct map from a function names to GL versions which define the - function. - - Args: - extensions: Map of gl versions => functions. - Returns: - Map of function name => gl versions. - """ - function_to_gl_versions = {} - for gl_version, functions in gl_versions.items(): - for function in functions: - if not function in function_to_gl_versions: - function_to_gl_versions[function] = set([]) - function_to_gl_versions[function].add(gl_version) - return function_to_gl_versions - - -def LooksLikeExtensionFunction(function): - """Heuristic to see if a function name is consistent with extension function - naming.""" - vendor = re.match(r'\w+?([A-Z][A-Z]+)$', function) - return vendor is not None and not vendor.group(1) in ['GL', 'API', 'DC'] - - -def SortVersions(key): - # Prefer functions from the core for binding - if 'gl_versions' in key: - return 0 - else: - return 1 - -def FillExtensionsFromHeaders(functions, extension_headers, extra_extensions): - """Determine which functions belong to extensions based on extension headers, - and fill in this information to the functions table for functions that don't - already have the information. - - Args: - functions: List of (return type, function versions, arguments). - extension_headers: List of header file names. - extra_extensions: Extensions to add to the list. - Returns: - Set of used extensions. - """ - # Parse known extensions. - extensions, gl_versions = GetDynamicFunctions(extension_headers) - functions_to_extensions = GetFunctionToExtensionsMap(extensions) - functions_to_gl_versions = GetFunctionToGLVersionsMap(gl_versions) - - # Fill in the extension information. - used_extensions = set() - used_functions_by_version = collections.defaultdict(lambda: set([])) - for func in functions: - for version in func['versions']: - name = version['name'] - - # There should only be one version entry per name string. - if len([v for v in func['versions'] if v['name'] == name]) > 1: - raise RuntimeError( - 'Duplicate version entries with same name for %s' % name) - - # Make sure we know about all extensions and extension functions. - extensions_from_headers = set([]) - if name in functions_to_extensions: - extensions_from_headers = set(functions_to_extensions[name]) - - explicit_extensions = set([]) - if 'extensions' in version: - explicit_extensions = set(version['extensions']) - - in_both = explicit_extensions.intersection(extensions_from_headers) - if len(in_both): - print "[%s] Specified redundant extensions for binding: %s" % ( - name, ', '.join(in_both)) - diff = explicit_extensions - extensions_from_headers - if len(diff): - print "[%s] Specified extra extensions for binding: %s" % ( - name, ', '.join(diff)) - - all_extensions = extensions_from_headers.union(explicit_extensions) - if len(all_extensions): - version['extensions'] = all_extensions - - if 'extensions' in version: - assert len(version['extensions']) - used_extensions.update(version['extensions']) - - if not 'extensions' in version and LooksLikeExtensionFunction(name): - raise RuntimeError('%s looks like an extension function but does not ' - 'belong to any of the known extensions.' % name) - - if name in functions_to_gl_versions: - assert not 'gl_versions' in version - version['gl_versions'] = functions_to_gl_versions[name] - for v in version['gl_versions']: - used_functions_by_version[v].add(name) - - func['versions'] = sorted(func['versions'], key=SortVersions) - - # Add extensions that do not have any functions. - used_extensions.update(extra_extensions) - - # Print out used function count by GL(ES) version. - for v in sorted([v for v in used_functions_by_version if v.is_es]): - print "OpenGL ES %d.%d: %d used functions" % ( - v.major_version, v.minor_version, len(used_functions_by_version[v])) - for v in sorted([v for v in used_functions_by_version if not v.is_es]): - print "OpenGL %d.%d: %d used functions" % ( - v.major_version, v.minor_version, len(used_functions_by_version[v])) - - return used_extensions - - -def ResolveHeader(header, header_paths): - for path in header_paths: - result = os.path.join(path, header) - if not os.path.isabs(path): - result = os.path.abspath(os.path.join(SELF_LOCATION, result)) - if os.path.exists(result): - # Always use forward slashes as path separators. Otherwise backslashes - # may be incorrectly interpreted as escape characters. - return result.replace(os.path.sep, '/') - - raise Exception('Header %s not found.' % header) - - -def main(argv): - """This is the main function.""" - - parser = optparse.OptionParser() - parser.add_option('--inputs', action='store_true') - parser.add_option('--verify-order', action='store_true') - - options, args = parser.parse_args(argv) - - if options.inputs: - for [_, _, headers, _] in FUNCTION_SETS: - for header in headers: - print ResolveHeader(header, HEADER_PATHS) - return 0 - - directory = SELF_LOCATION - if len(args) >= 1: - directory = args[0] - - def ClangFormat(filename): - formatter = "clang-format" - if platform.system() == "Windows": - formatter += ".bat" - call([formatter, "-i", "-style=chromium", filename]) - - for [functions, set_name, extension_headers, extensions] in FUNCTION_SETS: - # Function names can be specified in two ways (list of unique names or list - # of versions with different binding conditions). Fill in the data to the - # versions list in case it is missing, so that can be used from here on: - for func in functions: - assert 'versions' in func or 'names' in func, 'Function with no names' - if 'versions' not in func: - func['versions'] = [{'name': n} for n in func['names']] - # Use the first version's name unless otherwise specified - if 'known_as' not in func: - func['known_as'] = func['versions'][0]['name'] - # Make sure that 'names' is not accidentally used instead of 'versions' - if 'names' in func: - del func['names'] - - # Check function names in each set is sorted in alphabetical order. - for index in range(len(functions) - 1): - func_name = functions[index]['known_as'] - next_func_name = functions[index + 1]['known_as'] - if func_name.lower() > next_func_name.lower(): - raise Exception( - 'function %s is not in alphabetical order' % next_func_name) - if options.verify_order: - continue - - extension_headers = [ResolveHeader(h, HEADER_PATHS) - for h in extension_headers] - used_extensions = FillExtensionsFromHeaders( - functions, extension_headers, extensions) - - header_file = open( - os.path.join(directory, 'gl_bindings_autogen_%s.h' % set_name), 'wb') - GenerateHeader(header_file, functions, set_name, used_extensions) - header_file.close() - ClangFormat(header_file.name) - - header_file = open( - os.path.join(directory, 'gl_bindings_api_autogen_%s.h' % set_name), - 'wb') - GenerateAPIHeader(header_file, functions, set_name) - header_file.close() - ClangFormat(header_file.name) - - source_file = open( - os.path.join(directory, 'gl_bindings_autogen_%s.cc' % set_name), 'wb') - GenerateSource(source_file, functions, set_name, used_extensions) - source_file.close() - ClangFormat(source_file.name) - - if not options.verify_order: - header_file = open( - os.path.join(directory, 'gl_mock_autogen_gl.h'), 'wb') - GenerateMockHeader(header_file, GL_FUNCTIONS, 'gl') - header_file.close() - ClangFormat(header_file.name) - - header_file = open(os.path.join(directory, 'gl_bindings_autogen_mock.h'), - 'wb') - GenerateMockBindingsHeader(header_file, GL_FUNCTIONS) - header_file.close() - ClangFormat(header_file.name) - - source_file = open(os.path.join(directory, 'gl_bindings_autogen_mock.cc'), - 'wb') - GenerateMockBindingsSource(source_file, GL_FUNCTIONS) - source_file.close() - ClangFormat(source_file.name) - - enum_header_filenames = [ResolveHeader(h, HEADER_PATHS) - for h in GLES2_HEADERS_WITH_ENUMS] - header_file = open(os.path.join(directory, - 'gl_enums_implementation_autogen.h'), - 'wb') - GenerateEnumUtils(header_file, enum_header_filenames) - header_file.close() - ClangFormat(header_file.name) - return 0 - - -if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) diff --git a/ui/gl/gl_bindings.cc b/ui/gl/gl_bindings.cc deleted file mode 100644 index fe9375216..000000000 --- a/ui/gl/gl_bindings.cc +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 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. - -#if defined(USE_X11) || defined(OS_ANDROID) || defined(USE_OZONE) -#include -#endif - -#include "ui/gl/gl_bindings.h" - -#if defined(USE_X11) -#include "ui/gfx/x/x11_types.h" -#endif - -#if defined(USE_X11) || defined(OS_ANDROID) || defined(USE_OZONE) -#include "ui/gl/gl_surface_egl.h" -#endif - -namespace gfx { - -std::string DriverOSMESA::GetPlatformExtensions() { - return ""; -} - -#if defined(OS_ANDROID) -std::string DriverEGL::GetPlatformExtensions() { - EGLDisplay display = - g_driver_egl.fn.eglGetDisplayFn(GetPlatformDefaultEGLNativeDisplay()); - - DCHECK(g_driver_egl.fn.eglInitializeFn); - g_driver_egl.fn.eglInitializeFn(display, NULL, NULL); - DCHECK(g_driver_egl.fn.eglQueryStringFn); - const char* str = g_driver_egl.fn.eglQueryStringFn(display, EGL_EXTENSIONS); - return str ? std::string(str) : ""; -} -#endif - -} // namespace gfx diff --git a/ui/gl/gl_bindings.h b/ui/gl/gl_bindings.h deleted file mode 100644 index afcf1fea7..000000000 --- a/ui/gl/gl_bindings.h +++ /dev/null @@ -1,378 +0,0 @@ -// 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 UI_GL_GL_BINDINGS_H_ -#define UI_GL_GL_BINDINGS_H_ - -#include - -// Includes the platform independent and platform dependent GL headers. -// Only include this in cc files. - -#include -#include - -#include "build/build_config.h" - -#if defined(OS_ANDROID) || defined(USE_X11) || defined(USE_GLFW) -#include -#include -#endif - -#include "base/logging.h" -#include "base/threading/thread_local.h" -#include "build/build_config.h" -#include "ui/gl/gl_export.h" - -// GLES2 defines not part of Desktop GL -// Shader Precision-Specified Types -#define GL_LOW_FLOAT 0x8DF0 -#define GL_MEDIUM_FLOAT 0x8DF1 -#define GL_HIGH_FLOAT 0x8DF2 -#define GL_LOW_INT 0x8DF3 -#define GL_MEDIUM_INT 0x8DF4 -#define GL_HIGH_INT 0x8DF5 -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_RGB565 0x8D62 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B -#define GL_RGB8_OES 0x8051 -#define GL_RGBA8_OES 0x8058 -#define GL_HALF_FLOAT_OES 0x8D61 - -// GL_OES_EGL_image_external -#define GL_TEXTURE_EXTERNAL_OES 0x8D65 -#define GL_SAMPLER_EXTERNAL_OES 0x8D66 -#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 -#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 - -// GL_ANGLE_translated_shader_source -#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0 - -// GL_CHROMIUM_flipy -#define GL_UNPACK_FLIP_Y_CHROMIUM 0x9240 - -#define GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM 0x9241 -#define GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM 0x9242 -#define GL_UNPACK_COLORSPACE_CONVERSION_CHROMIUM 0x9243 -#define GL_BIND_GENERATES_RESOURCE_CHROMIUM 0x9244 - -// GL_CHROMIUM_gpu_memory_manager -#define GL_TEXTURE_POOL_CHROMIUM 0x6000 -#define GL_TEXTURE_POOL_MANAGED_CHROMIUM 0x6001 -#define GL_TEXTURE_POOL_UNMANAGED_CHROMIUM 0x6002 - -// GL_ANGLE_pack_reverse_row_order -#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 - -// GL_ANGLE_texture_usage -#define GL_TEXTURE_USAGE_ANGLE 0x93A2 -#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 - -// GL_EXT_texture_storage -#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F -#define GL_ALPHA8_EXT 0x803C -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_RGBA32F_EXT 0x8814 -#define GL_RGB32F_EXT 0x8815 -#define GL_ALPHA32F_EXT 0x8816 -#define GL_LUMINANCE32F_EXT 0x8818 -#define GL_LUMINANCE_ALPHA32F_EXT 0x8819 -#define GL_RGBA16F_EXT 0x881A -#define GL_RGB16F_EXT 0x881B -#define GL_RG16F_EXT 0x822F -#define GL_R16F_EXT 0x822D -#define GL_ALPHA16F_EXT 0x881C -#define GL_LUMINANCE16F_EXT 0x881E -#define GL_LUMINANCE_ALPHA16F_EXT 0x881F -#define GL_R32F_EXT 0x822E -#define GL_RG32F_EXT 0x8230 -#define GL_BGRA8_EXT 0x93A1 - -// GL_ANGLE_instanced_arrays -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE - -// GL_EXT_occlusion_query_boolean -#define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F -#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A -#define GL_CURRENT_QUERY_EXT 0x8865 -#define GL_QUERY_RESULT_EXT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867 - -// GL_CHROMIUM_command_buffer_query -#define GL_COMMANDS_ISSUED_CHROMIUM 0x6004 - -/* GL_CHROMIUM_get_error_query */ -#define GL_GET_ERROR_QUERY_CHROMIUM 0x6003 - -/* GL_CHROMIUM_command_buffer_latency_query */ -#define GL_LATENCY_QUERY_CHROMIUM 0x6007 - -/* GL_CHROMIUM_async_pixel_transfers */ -#define GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM 0x6005 -#define GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM 0x6006 - -// GL_CHROMIUM_sync_query -#define GL_COMMANDS_COMPLETED_CHROMIUM 0x84F7 - -// GL_CHROMIUM_gpu_memory_buffer_image -#define GL_MAP_CHROMIUM 0x78F1 -#define GL_SCANOUT_CHROMIUM 0x78F2 - -// GL_CHROMIUM_schedule_overlay_plane -#define GL_OVERLAY_TRANSFORM_NONE_CHROMIUM 0x9245 -#define GL_OVERLAY_TRANSFORM_FLIP_HORIZONTAL_CHROMIUM 0x9246 -#define GL_OVERLAY_TRANSFORM_FLIP_VERTICAL_CHROMIUM 0x9247 -#define GL_OVERLAY_TRANSFORM_ROTATE_90_CHROMIUM 0x9248 -#define GL_OVERLAY_TRANSFORM_ROTATE_180_CHROMIUM 0x9249 -#define GL_OVERLAY_TRANSFORM_ROTATE_270_CHROMIUM 0x924A - -// GL_CHROMIUM_subscribe_uniforms -#define GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM 0x924B -#define GL_MOUSE_POSITION_CHROMIUM 0x924C - -// GL_OES_texure_3D -#define GL_SAMPLER_3D_OES 0x8B5F - -// GL_OES_depth24 -#define GL_DEPTH_COMPONENT24_OES 0x81A6 - -// GL_OES_depth32 -#define GL_DEPTH_COMPONENT32_OES 0x81A7 - -// GL_OES_packed_depth_stencil -#ifndef GL_DEPTH24_STENCIL8_OES -#define GL_DEPTH24_STENCIL8_OES 0x88F0 -#endif - -#ifndef GL_DEPTH24_STENCIL8 -#define GL_DEPTH24_STENCIL8 0x88F0 -#endif - -// GL_OES_compressed_ETC1_RGB8_texture -#define GL_ETC1_RGB8_OES 0x8D64 - -// GL_AMD_compressed_ATC_texture -#define GL_ATC_RGB_AMD 0x8C92 -#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 -#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE - -// GL_IMG_texture_compression_pvrtc -#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 -#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 -#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 -#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 - -// GL_OES_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 - -// GL_CHROMIUM_pixel_transfer_buffer_object -#define GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM 0x78EC -#define GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM 0x78ED -#define GL_PIXEL_PACK_TRANSFER_BUFFER_BINDING_CHROMIUM 0x78EE -#define GL_PIXEL_UNPACK_TRANSFER_BUFFER_BINDING_CHROMIUM 0x78EF - -/* GL_EXT_discard_framebuffer */ -#ifndef GL_EXT_discard_framebuffer -#define GL_COLOR_EXT 0x1800 -#define GL_DEPTH_EXT 0x1801 -#define GL_STENCIL_EXT 0x1802 -#endif - -// GL_EXT_sRGB -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210 - -// GL_ARB_get_program_binary -#define PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 -// GL_OES_get_program_binary -#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE -#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF - -#ifndef GL_EXT_multisampled_render_to_texture -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C -#endif - -#ifndef GL_IMG_multisampled_render_to_texture -#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 -#define GL_MAX_SAMPLES_IMG 0x9135 -#define GL_TEXTURE_SAMPLES_IMG 0x9136 -#endif - -#ifndef GL_CHROMIUM_path_rendering -// These match the corresponding values in NV_path_rendering -// extension, eg tokens with CHROMIUM replaced with NV. -#define GL_PATH_MODELVIEW_MATRIX_CHROMIUM 0x0BA6 -#define GL_PATH_PROJECTION_MATRIX_CHROMIUM 0x0BA7 -#define GL_PATH_MODELVIEW_CHROMIUM 0x1700 -#define GL_PATH_PROJECTION_CHROMIUM 0x1701 -#endif - -#ifndef GL_KHR_blend_equation_advanced -#define GL_KHR_blend_equation_advanced 1 -#define GL_COLORBURN_KHR 0x929A -#define GL_COLORDODGE_KHR 0x9299 -#define GL_DARKEN_KHR 0x9297 -#define GL_DIFFERENCE_KHR 0x929E -#define GL_EXCLUSION_KHR 0x92A0 -#define GL_HARDLIGHT_KHR 0x929B -#define GL_HSL_COLOR_KHR 0x92AF -#define GL_HSL_HUE_KHR 0x92AD -#define GL_HSL_LUMINOSITY_KHR 0x92B0 -#define GL_HSL_SATURATION_KHR 0x92AE -#define GL_LIGHTEN_KHR 0x9298 -#define GL_MULTIPLY_KHR 0x9294 -#define GL_OVERLAY_KHR 0x9296 -#define GL_SCREEN_KHR 0x9295 -#define GL_SOFTLIGHT_KHR 0x929C -#endif /* GL_KHR_blend_equation_advanced */ - -#ifndef GL_KHR_blend_equation_advanced_coherent -#define GL_KHR_blend_equation_advanced_coherent 1 -#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 -#endif /* GL_KHR_blend_equation_advanced_coherent */ - -#ifndef GL_EXT_disjoint_timer_query -#define GL_EXT_disjoint_timer_query 1 -#define GL_QUERY_COUNTER_BITS_EXT 0x8864 -#define GL_TIME_ELAPSED_EXT 0x88BF -#define GL_TIMESTAMP_EXT 0x8E28 -#define GL_GPU_DISJOINT_EXT 0x8FBB -#endif - -#ifndef GL_KHR_robustness -#define GL_KHR_robustness 1 -#define GL_CONTEXT_ROBUST_ACCESS_KHR 0x90F3 -#define GL_LOSE_CONTEXT_ON_RESET_KHR 0x8252 -#define GL_GUILTY_CONTEXT_RESET_KHR 0x8253 -#define GL_INNOCENT_CONTEXT_RESET_KHR 0x8254 -#define GL_UNKNOWN_CONTEXT_RESET_KHR 0x8255 -#define GL_RESET_NOTIFICATION_STRATEGY_KHR 0x8256 -#define GL_NO_RESET_NOTIFICATION_KHR 0x8261 -#define GL_CONTEXT_LOST_KHR 0x0507 -#endif /* GL_KHR_robustness */ - -#ifndef GL_EXT_texture_rg -#define GL_EXT_texture_rg 1 -#define GL_RED_EXT 0x1903 -#define GL_RG_EXT 0x8227 -#define GL_R8_EXT 0x8229 -#define GL_RG8_EXT 0x822B -#endif /* GL_EXT_texture_rg */ - -#define GL_GLEXT_PROTOTYPES 1 - -#define GL_BINDING_CALL - -#define GL_SERVICE_LOG(args) DLOG(INFO) << args; -#if defined(NDEBUG) - #define GL_SERVICE_LOG_CODE_BLOCK(code) -#else - #define GL_SERVICE_LOG_CODE_BLOCK(code) code -#endif - -// Forward declare OSMesa types. -typedef struct osmesa_context *OSMesaContext; -typedef void (*OSMESAproc)(); - -// Forward declare EGL types. -typedef uint64 EGLuint64CHROMIUM; - -typedef void (*GLDEBUGPROCKHR)(GLenum source, GLenum type, GLuint id, - GLenum severity, GLsizei length, - const GLchar *message, void *userParam); - -#include "gl_bindings_autogen_gl.h" -#include "gl_bindings_autogen_osmesa.h" - -#if defined(USE_X11) -#include "gl_bindings_autogen_egl.h" -#elif defined(USE_OZONE) -#include "gl_bindings_autogen_egl.h" -#elif defined(OS_ANDROID) -#include "gl_bindings_autogen_egl.h" -#endif - -namespace gfx { - -struct GL_EXPORT DriverGL { - void InitializeStaticBindings(); - void InitializeCustomDynamicBindings(GLContext* context); - void InitializeDebugBindings(); - void InitializeNullDrawBindings(); - // TODO(danakj): Remove this when all test suites are using null-draw. - bool HasInitializedNullDrawBindings(); - bool SetNullDrawBindingsEnabled(bool enabled); - void ClearBindings(); - - ProcsGL fn; - ProcsGL orig_fn; - ProcsGL debug_fn; - ExtensionsGL ext; - bool null_draw_bindings_enabled; - - private: - void InitializeDynamicBindings(GLContext* context); -}; - -struct GL_EXPORT DriverOSMESA { - void InitializeStaticBindings(); - void InitializeDebugBindings(); - void ClearBindings(); - - ProcsOSMESA fn; - ProcsOSMESA debug_fn; - ExtensionsOSMESA ext; - - private: - static std::string GetPlatformExtensions(); -}; - -// TODO(dalyj): Clean up the conditionals here (there should be a generic -// "USE_EGL"-type define for this, particularly since GLFW is happy to use -// EGL in some configurations). -#if !defined(OS_MACOSX) && !defined(USE_GLFW) -struct GL_EXPORT DriverEGL { - void InitializeStaticBindings(); - void InitializeDebugBindings(); - void ClearBindings(); - - ProcsEGL fn; - ProcsEGL debug_fn; - ExtensionsEGL ext; - - private: - static std::string GetPlatformExtensions(); -}; -#endif - -// This #define is here to support autogenerated code. -#define g_current_gl_context g_current_gl_context_tls->Get() -GL_EXPORT extern base::ThreadLocalPointer* g_current_gl_context_tls; - -GL_EXPORT extern OSMESAApi* g_current_osmesa_context; -GL_EXPORT extern DriverGL g_driver_gl; -GL_EXPORT extern DriverOSMESA g_driver_osmesa; - -#if defined(OS_ANDROID) - -GL_EXPORT extern EGLApi* g_current_egl_context; -GL_EXPORT extern DriverEGL g_driver_egl; - -#endif - -} // namespace gfx - -#endif // UI_GL_GL_BINDINGS_H_ diff --git a/ui/gl/gl_bindings_api_autogen_egl.h b/ui/gl/gl_bindings_api_autogen_egl.h deleted file mode 100644 index 43337bef0..000000000 --- a/ui/gl/gl_bindings_api_autogen_egl.h +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright 2014 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 is auto-generated from -// ui/gl/generate_bindings.py -// It's formatted by clang-format using chromium coding style: -// clang-format -i -style=chromium filename -// DO NOT EDIT! - -EGLBoolean eglBindAPIFn(EGLenum api) override; -EGLBoolean eglBindTexImageFn(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer) override; -EGLBoolean eglChooseConfigFn(EGLDisplay dpy, - const EGLint* attrib_list, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config) override; -EGLint eglClientWaitSyncKHRFn(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint flags, - EGLTimeKHR timeout) override; -EGLBoolean eglCopyBuffersFn(EGLDisplay dpy, - EGLSurface surface, - EGLNativePixmapType target) override; -EGLContext eglCreateContextFn(EGLDisplay dpy, - EGLConfig config, - EGLContext share_context, - const EGLint* attrib_list) override; -EGLImageKHR eglCreateImageKHRFn(EGLDisplay dpy, - EGLContext ctx, - EGLenum target, - EGLClientBuffer buffer, - const EGLint* attrib_list) override; -EGLSurface eglCreatePbufferFromClientBufferFn( - EGLDisplay dpy, - EGLenum buftype, - void* buffer, - EGLConfig config, - const EGLint* attrib_list) override; -EGLSurface eglCreatePbufferSurfaceFn(EGLDisplay dpy, - EGLConfig config, - const EGLint* attrib_list) override; -EGLSurface eglCreatePixmapSurfaceFn(EGLDisplay dpy, - EGLConfig config, - EGLNativePixmapType pixmap, - const EGLint* attrib_list) override; -EGLSyncKHR eglCreateSyncKHRFn(EGLDisplay dpy, - EGLenum type, - const EGLint* attrib_list) override; -EGLSurface eglCreateWindowSurfaceFn(EGLDisplay dpy, - EGLConfig config, - EGLNativeWindowType win, - const EGLint* attrib_list) override; -EGLBoolean eglDestroyContextFn(EGLDisplay dpy, EGLContext ctx) override; -EGLBoolean eglDestroyImageKHRFn(EGLDisplay dpy, EGLImageKHR image) override; -EGLBoolean eglDestroySurfaceFn(EGLDisplay dpy, EGLSurface surface) override; -EGLBoolean eglDestroySyncKHRFn(EGLDisplay dpy, EGLSyncKHR sync) override; -EGLBoolean eglGetConfigAttribFn(EGLDisplay dpy, - EGLConfig config, - EGLint attribute, - EGLint* value) override; -EGLBoolean eglGetConfigsFn(EGLDisplay dpy, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config) override; -EGLContext eglGetCurrentContextFn(void) override; -EGLDisplay eglGetCurrentDisplayFn(void) override; -EGLSurface eglGetCurrentSurfaceFn(EGLint readdraw) override; -EGLDisplay eglGetDisplayFn(EGLNativeDisplayType display_id) override; -EGLint eglGetErrorFn(void) override; -EGLDisplay eglGetPlatformDisplayEXTFn(EGLenum platform, - void* native_display, - const EGLint* attrib_list) override; -__eglMustCastToProperFunctionPointerType eglGetProcAddressFn( - const char* procname) override; -EGLBoolean eglGetSyncAttribKHRFn(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint attribute, - EGLint* value) override; -EGLBoolean eglGetSyncValuesCHROMIUMFn(EGLDisplay dpy, - EGLSurface surface, - EGLuint64CHROMIUM* ust, - EGLuint64CHROMIUM* msc, - EGLuint64CHROMIUM* sbc) override; -EGLBoolean eglInitializeFn(EGLDisplay dpy, - EGLint* major, - EGLint* minor) override; -EGLBoolean eglMakeCurrentFn(EGLDisplay dpy, - EGLSurface draw, - EGLSurface read, - EGLContext ctx) override; -EGLBoolean eglPostSubBufferNVFn(EGLDisplay dpy, - EGLSurface surface, - EGLint x, - EGLint y, - EGLint width, - EGLint height) override; -EGLenum eglQueryAPIFn(void) override; -EGLBoolean eglQueryContextFn(EGLDisplay dpy, - EGLContext ctx, - EGLint attribute, - EGLint* value) override; -const char* eglQueryStringFn(EGLDisplay dpy, EGLint name) override; -EGLBoolean eglQuerySurfaceFn(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint* value) override; -EGLBoolean eglQuerySurfacePointerANGLEFn(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - void** value) override; -EGLBoolean eglReleaseTexImageFn(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer) override; -EGLBoolean eglReleaseThreadFn(void) override; -EGLBoolean eglSurfaceAttribFn(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint value) override; -EGLBoolean eglSwapBuffersFn(EGLDisplay dpy, EGLSurface surface) override; -EGLBoolean eglSwapIntervalFn(EGLDisplay dpy, EGLint interval) override; -EGLBoolean eglTerminateFn(EGLDisplay dpy) override; -EGLBoolean eglWaitClientFn(void) override; -EGLBoolean eglWaitGLFn(void) override; -EGLBoolean eglWaitNativeFn(EGLint engine) override; -EGLint eglWaitSyncKHRFn(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags) override; diff --git a/ui/gl/gl_bindings_api_autogen_gl.h b/ui/gl/gl_bindings_api_autogen_gl.h deleted file mode 100644 index 439d77bb9..000000000 --- a/ui/gl/gl_bindings_api_autogen_gl.h +++ /dev/null @@ -1,738 +0,0 @@ -// Copyright 2014 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 is auto-generated from -// ui/gl/generate_bindings.py -// It's formatted by clang-format using chromium coding style: -// clang-format -i -style=chromium filename -// DO NOT EDIT! - -void glActiveTextureFn(GLenum texture) override; -void glAttachShaderFn(GLuint program, GLuint shader) override; -void glBeginQueryFn(GLenum target, GLuint id) override; -void glBeginTransformFeedbackFn(GLenum primitiveMode) override; -void glBindAttribLocationFn(GLuint program, - GLuint index, - const char* name) override; -void glBindBufferFn(GLenum target, GLuint buffer) override; -void glBindBufferBaseFn(GLenum target, GLuint index, GLuint buffer) override; -void glBindBufferRangeFn(GLenum target, - GLuint index, - GLuint buffer, - GLintptr offset, - GLsizeiptr size) override; -void glBindFragDataLocationFn(GLuint program, - GLuint colorNumber, - const char* name) override; -void glBindFragDataLocationIndexedFn(GLuint program, - GLuint colorNumber, - GLuint index, - const char* name) override; -void glBindFramebufferEXTFn(GLenum target, GLuint framebuffer) override; -void glBindRenderbufferEXTFn(GLenum target, GLuint renderbuffer) override; -void glBindSamplerFn(GLuint unit, GLuint sampler) override; -void glBindTextureFn(GLenum target, GLuint texture) override; -void glBindTransformFeedbackFn(GLenum target, GLuint id) override; -void glBindVertexArrayOESFn(GLuint array) override; -void glBlendBarrierKHRFn(void) override; -void glBlendColorFn(GLclampf red, - GLclampf green, - GLclampf blue, - GLclampf alpha) override; -void glBlendEquationFn(GLenum mode) override; -void glBlendEquationSeparateFn(GLenum modeRGB, GLenum modeAlpha) override; -void glBlendFuncFn(GLenum sfactor, GLenum dfactor) override; -void glBlendFuncSeparateFn(GLenum srcRGB, - GLenum dstRGB, - GLenum srcAlpha, - GLenum dstAlpha) override; -void glBlitFramebufferFn(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) override; -void glBlitFramebufferANGLEFn(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) override; -void glBlitFramebufferEXTFn(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) override; -void glBufferDataFn(GLenum target, - GLsizeiptr size, - const void* data, - GLenum usage) override; -void glBufferSubDataFn(GLenum target, - GLintptr offset, - GLsizeiptr size, - const void* data) override; -GLenum glCheckFramebufferStatusEXTFn(GLenum target) override; -void glClearFn(GLbitfield mask) override; -void glClearBufferfiFn(GLenum buffer, - GLint drawbuffer, - const GLfloat depth, - GLint stencil) override; -void glClearBufferfvFn(GLenum buffer, - GLint drawbuffer, - const GLfloat* value) override; -void glClearBufferivFn(GLenum buffer, - GLint drawbuffer, - const GLint* value) override; -void glClearBufferuivFn(GLenum buffer, - GLint drawbuffer, - const GLuint* value) override; -void glClearColorFn(GLclampf red, - GLclampf green, - GLclampf blue, - GLclampf alpha) override; -void glClearDepthFn(GLclampd depth) override; -void glClearDepthfFn(GLclampf depth) override; -void glClearStencilFn(GLint s) override; -GLenum glClientWaitSyncFn(GLsync sync, - GLbitfield flags, - GLuint64 timeout) override; -void glColorMaskFn(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha) override; -void glCompileShaderFn(GLuint shader) override; -void glCompressedTexImage2DFn(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const void* data) override; -void glCompressedTexImage3DFn(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLsizei imageSize, - const void* data) override; -void glCompressedTexSubImage2DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const void* data) override; -void glCopyBufferSubDataFn(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size) override; -void glCopyTexImage2DFn(GLenum target, - GLint level, - GLenum internalformat, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLint border) override; -void glCopyTexSubImage2DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height) override; -void glCopyTexSubImage3DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height) override; -GLuint glCreateProgramFn(void) override; -GLuint glCreateShaderFn(GLenum type) override; -void glCullFaceFn(GLenum mode) override; -void glDebugMessageCallbackKHRFn(GLDEBUGPROCKHR callback, - const void* userparam) override; -void glDebugMessageControlKHRFn(GLenum source, - GLenum type, - GLenum severity, - GLsizei count, - const GLuint* ids, - GLboolean enabled) override; -void glDebugMessageInsertKHRFn(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar* buf) override; -void glDeleteBuffersARBFn(GLsizei n, const GLuint* buffers) override; -void glDeleteFencesAPPLEFn(GLsizei n, const GLuint* fences) override; -void glDeleteFencesNVFn(GLsizei n, const GLuint* fences) override; -void glDeleteFramebuffersEXTFn(GLsizei n, const GLuint* framebuffers) override; -void glDeleteProgramFn(GLuint program) override; -void glDeleteQueriesFn(GLsizei n, const GLuint* ids) override; -void glDeleteRenderbuffersEXTFn(GLsizei n, - const GLuint* renderbuffers) override; -void glDeleteSamplersFn(GLsizei n, const GLuint* samplers) override; -void glDeleteShaderFn(GLuint shader) override; -void glDeleteSyncFn(GLsync sync) override; -void glDeleteTexturesFn(GLsizei n, const GLuint* textures) override; -void glDeleteTransformFeedbacksFn(GLsizei n, const GLuint* ids) override; -void glDeleteVertexArraysOESFn(GLsizei n, const GLuint* arrays) override; -void glDepthFuncFn(GLenum func) override; -void glDepthMaskFn(GLboolean flag) override; -void glDepthRangeFn(GLclampd zNear, GLclampd zFar) override; -void glDepthRangefFn(GLclampf zNear, GLclampf zFar) override; -void glDetachShaderFn(GLuint program, GLuint shader) override; -void glDisableFn(GLenum cap) override; -void glDisableVertexAttribArrayFn(GLuint index) override; -void glDiscardFramebufferEXTFn(GLenum target, - GLsizei numAttachments, - const GLenum* attachments) override; -void glDrawArraysFn(GLenum mode, GLint first, GLsizei count) override; -void glDrawArraysInstancedANGLEFn(GLenum mode, - GLint first, - GLsizei count, - GLsizei primcount) override; -void glDrawBufferFn(GLenum mode) override; -void glDrawBuffersARBFn(GLsizei n, const GLenum* bufs) override; -void glDrawElementsFn(GLenum mode, - GLsizei count, - GLenum type, - const void* indices) override; -void glDrawElementsInstancedANGLEFn(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei primcount) override; -void glDrawRangeElementsFn(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices) override; -void glEGLImageTargetRenderbufferStorageOESFn(GLenum target, - GLeglImageOES image) override; -void glEGLImageTargetTexture2DOESFn(GLenum target, - GLeglImageOES image) override; -void glEnableFn(GLenum cap) override; -void glEnableVertexAttribArrayFn(GLuint index) override; -void glEndQueryFn(GLenum target) override; -void glEndTransformFeedbackFn(void) override; -GLsync glFenceSyncFn(GLenum condition, GLbitfield flags) override; -void glFinishFn(void) override; -void glFinishFenceAPPLEFn(GLuint fence) override; -void glFinishFenceNVFn(GLuint fence) override; -void glFlushFn(void) override; -void glFlushMappedBufferRangeFn(GLenum target, - GLintptr offset, - GLsizeiptr length) override; -void glFramebufferRenderbufferEXTFn(GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer) override; -void glFramebufferTexture2DEXTFn(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level) override; -void glFramebufferTexture2DMultisampleEXTFn(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples) override; -void glFramebufferTexture2DMultisampleIMGFn(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples) override; -void glFramebufferTextureLayerFn(GLenum target, - GLenum attachment, - GLuint texture, - GLint level, - GLint layer) override; -void glFrontFaceFn(GLenum mode) override; -void glGenBuffersARBFn(GLsizei n, GLuint* buffers) override; -void glGenerateMipmapEXTFn(GLenum target) override; -void glGenFencesAPPLEFn(GLsizei n, GLuint* fences) override; -void glGenFencesNVFn(GLsizei n, GLuint* fences) override; -void glGenFramebuffersEXTFn(GLsizei n, GLuint* framebuffers) override; -void glGenQueriesFn(GLsizei n, GLuint* ids) override; -void glGenRenderbuffersEXTFn(GLsizei n, GLuint* renderbuffers) override; -void glGenSamplersFn(GLsizei n, GLuint* samplers) override; -void glGenTexturesFn(GLsizei n, GLuint* textures) override; -void glGenTransformFeedbacksFn(GLsizei n, GLuint* ids) override; -void glGenVertexArraysOESFn(GLsizei n, GLuint* arrays) override; -void glGetActiveAttribFn(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - char* name) override; -void glGetActiveUniformFn(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - char* name) override; -void glGetActiveUniformBlockivFn(GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint* params) override; -void glGetActiveUniformBlockNameFn(GLuint program, - GLuint uniformBlockIndex, - GLsizei bufSize, - GLsizei* length, - char* uniformBlockName) override; -void glGetActiveUniformsivFn(GLuint program, - GLsizei uniformCount, - const GLuint* uniformIndices, - GLenum pname, - GLint* params) override; -void glGetAttachedShadersFn(GLuint program, - GLsizei maxcount, - GLsizei* count, - GLuint* shaders) override; -GLint glGetAttribLocationFn(GLuint program, const char* name) override; -void glGetBooleanvFn(GLenum pname, GLboolean* params) override; -void glGetBufferParameterivFn(GLenum target, - GLenum pname, - GLint* params) override; -GLuint glGetDebugMessageLogKHRFn(GLuint count, - GLsizei bufSize, - GLenum* sources, - GLenum* types, - GLuint* ids, - GLenum* severities, - GLsizei* lengths, - GLchar* messageLog) override; -GLenum glGetErrorFn(void) override; -void glGetFenceivNVFn(GLuint fence, GLenum pname, GLint* params) override; -void glGetFloatvFn(GLenum pname, GLfloat* params) override; -GLint glGetFragDataLocationFn(GLuint program, const char* name) override; -void glGetFramebufferAttachmentParameterivEXTFn(GLenum target, - GLenum attachment, - GLenum pname, - GLint* params) override; -GLenum glGetGraphicsResetStatusARBFn(void) override; -void glGetInteger64i_vFn(GLenum target, GLuint index, GLint64* data) override; -void glGetInteger64vFn(GLenum pname, GLint64* params) override; -void glGetIntegeri_vFn(GLenum target, GLuint index, GLint* data) override; -void glGetIntegervFn(GLenum pname, GLint* params) override; -void glGetInternalformativFn(GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLint* params) override; -void glGetProgramBinaryFn(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - GLvoid* binary) override; -void glGetProgramInfoLogFn(GLuint program, - GLsizei bufsize, - GLsizei* length, - char* infolog) override; -void glGetProgramivFn(GLuint program, GLenum pname, GLint* params) override; -GLint glGetProgramResourceLocationFn(GLuint program, - GLenum programInterface, - const char* name) override; -void glGetQueryivFn(GLenum target, GLenum pname, GLint* params) override; -void glGetQueryObjecti64vFn(GLuint id, GLenum pname, GLint64* params) override; -void glGetQueryObjectivFn(GLuint id, GLenum pname, GLint* params) override; -void glGetQueryObjectui64vFn(GLuint id, - GLenum pname, - GLuint64* params) override; -void glGetQueryObjectuivFn(GLuint id, GLenum pname, GLuint* params) override; -void glGetRenderbufferParameterivEXTFn(GLenum target, - GLenum pname, - GLint* params) override; -void glGetSamplerParameterfvFn(GLuint sampler, - GLenum pname, - GLfloat* params) override; -void glGetSamplerParameterivFn(GLuint sampler, - GLenum pname, - GLint* params) override; -void glGetShaderInfoLogFn(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* infolog) override; -void glGetShaderivFn(GLuint shader, GLenum pname, GLint* params) override; -void glGetShaderPrecisionFormatFn(GLenum shadertype, - GLenum precisiontype, - GLint* range, - GLint* precision) override; -void glGetShaderSourceFn(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* source) override; -const GLubyte* glGetStringFn(GLenum name) override; -const GLubyte* glGetStringiFn(GLenum name, GLuint index) override; -void glGetSyncivFn(GLsync sync, - GLenum pname, - GLsizei bufSize, - GLsizei* length, - GLint* values) override; -void glGetTexLevelParameterfvFn(GLenum target, - GLint level, - GLenum pname, - GLfloat* params) override; -void glGetTexLevelParameterivFn(GLenum target, - GLint level, - GLenum pname, - GLint* params) override; -void glGetTexParameterfvFn(GLenum target, - GLenum pname, - GLfloat* params) override; -void glGetTexParameterivFn(GLenum target, GLenum pname, GLint* params) override; -void glGetTransformFeedbackVaryingFn(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLsizei* size, - GLenum* type, - char* name) override; -void glGetTranslatedShaderSourceANGLEFn(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* source) override; -GLuint glGetUniformBlockIndexFn(GLuint program, - const char* uniformBlockName) override; -void glGetUniformfvFn(GLuint program, GLint location, GLfloat* params) override; -void glGetUniformIndicesFn(GLuint program, - GLsizei uniformCount, - const char* const* uniformNames, - GLuint* uniformIndices) override; -void glGetUniformivFn(GLuint program, GLint location, GLint* params) override; -GLint glGetUniformLocationFn(GLuint program, const char* name) override; -void glGetVertexAttribfvFn(GLuint index, - GLenum pname, - GLfloat* params) override; -void glGetVertexAttribivFn(GLuint index, GLenum pname, GLint* params) override; -void glGetVertexAttribPointervFn(GLuint index, - GLenum pname, - void** pointer) override; -void glHintFn(GLenum target, GLenum mode) override; -void glInsertEventMarkerEXTFn(GLsizei length, const char* marker) override; -void glInvalidateFramebufferFn(GLenum target, - GLsizei numAttachments, - const GLenum* attachments) override; -void glInvalidateSubFramebufferFn(GLenum target, - GLsizei numAttachments, - const GLenum* attachments, - GLint x, - GLint y, - GLint width, - GLint height) override; -GLboolean glIsBufferFn(GLuint buffer) override; -GLboolean glIsEnabledFn(GLenum cap) override; -GLboolean glIsFenceAPPLEFn(GLuint fence) override; -GLboolean glIsFenceNVFn(GLuint fence) override; -GLboolean glIsFramebufferEXTFn(GLuint framebuffer) override; -GLboolean glIsProgramFn(GLuint program) override; -GLboolean glIsQueryFn(GLuint query) override; -GLboolean glIsRenderbufferEXTFn(GLuint renderbuffer) override; -GLboolean glIsSamplerFn(GLuint sampler) override; -GLboolean glIsShaderFn(GLuint shader) override; -GLboolean glIsSyncFn(GLsync sync) override; -GLboolean glIsTextureFn(GLuint texture) override; -GLboolean glIsTransformFeedbackFn(GLuint id) override; -GLboolean glIsVertexArrayOESFn(GLuint array) override; -void glLineWidthFn(GLfloat width) override; -void glLinkProgramFn(GLuint program) override; -void* glMapBufferFn(GLenum target, GLenum access) override; -void* glMapBufferRangeFn(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access) override; -void glMatrixLoadfEXTFn(GLenum matrixMode, const GLfloat* m) override; -void glMatrixLoadIdentityEXTFn(GLenum matrixMode) override; -void glObjectLabelKHRFn(GLenum identifier, - GLuint name, - GLsizei length, - const GLchar* label) override; -void glPauseTransformFeedbackFn(void) override; -void glPixelStoreiFn(GLenum pname, GLint param) override; -void glPointParameteriFn(GLenum pname, GLint param) override; -void glPolygonOffsetFn(GLfloat factor, GLfloat units) override; -void glPopDebugGroupKHRFn(void) override; -void glPopGroupMarkerEXTFn(void) override; -void glProgramBinaryFn(GLuint program, - GLenum binaryFormat, - const GLvoid* binary, - GLsizei length) override; -void glProgramParameteriFn(GLuint program, GLenum pname, GLint value) override; -void glPushDebugGroupKHRFn(GLenum source, - GLuint id, - GLsizei length, - const GLchar* message) override; -void glPushGroupMarkerEXTFn(GLsizei length, const char* marker) override; -void glQueryCounterFn(GLuint id, GLenum target) override; -void glReadBufferFn(GLenum src) override; -void glReadPixelsFn(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - void* pixels) override; -void glReleaseShaderCompilerFn(void) override; -void glRenderbufferStorageEXTFn(GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height) override; -void glRenderbufferStorageMultisampleFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) override; -void glRenderbufferStorageMultisampleANGLEFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) override; -void glRenderbufferStorageMultisampleAPPLEFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) override; -void glRenderbufferStorageMultisampleEXTFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) override; -void glRenderbufferStorageMultisampleIMGFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) override; -void glResolveMultisampleFramebufferAPPLEFn(void) override; -void glResumeTransformFeedbackFn(void) override; -void glSampleCoverageFn(GLclampf value, GLboolean invert) override; -void glSamplerParameterfFn(GLuint sampler, - GLenum pname, - GLfloat param) override; -void glSamplerParameterfvFn(GLuint sampler, - GLenum pname, - const GLfloat* params) override; -void glSamplerParameteriFn(GLuint sampler, GLenum pname, GLint param) override; -void glSamplerParameterivFn(GLuint sampler, - GLenum pname, - const GLint* params) override; -void glScissorFn(GLint x, GLint y, GLsizei width, GLsizei height) override; -void glSetFenceAPPLEFn(GLuint fence) override; -void glSetFenceNVFn(GLuint fence, GLenum condition) override; -void glShaderBinaryFn(GLsizei n, - const GLuint* shaders, - GLenum binaryformat, - const void* binary, - GLsizei length) override; -void glShaderSourceFn(GLuint shader, - GLsizei count, - const char* const* str, - const GLint* length) override; -void glStencilFuncFn(GLenum func, GLint ref, GLuint mask) override; -void glStencilFuncSeparateFn(GLenum face, - GLenum func, - GLint ref, - GLuint mask) override; -void glStencilMaskFn(GLuint mask) override; -void glStencilMaskSeparateFn(GLenum face, GLuint mask) override; -void glStencilOpFn(GLenum fail, GLenum zfail, GLenum zpass) override; -void glStencilOpSeparateFn(GLenum face, - GLenum fail, - GLenum zfail, - GLenum zpass) override; -GLboolean glTestFenceAPPLEFn(GLuint fence) override; -GLboolean glTestFenceNVFn(GLuint fence) override; -void glTexImage2DFn(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const void* pixels) override; -void glTexImage3DFn(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - const void* pixels) override; -void glTexParameterfFn(GLenum target, GLenum pname, GLfloat param) override; -void glTexParameterfvFn(GLenum target, - GLenum pname, - const GLfloat* params) override; -void glTexParameteriFn(GLenum target, GLenum pname, GLint param) override; -void glTexParameterivFn(GLenum target, - GLenum pname, - const GLint* params) override; -void glTexStorage2DEXTFn(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height) override; -void glTexStorage3DFn(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth) override; -void glTexSubImage2DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const void* pixels) override; -void glTextureBarrierNVFn(void) override; -void glTransformFeedbackVaryingsFn(GLuint program, - GLsizei count, - const char* const* varyings, - GLenum bufferMode) override; -void glUniform1fFn(GLint location, GLfloat x) override; -void glUniform1fvFn(GLint location, GLsizei count, const GLfloat* v) override; -void glUniform1iFn(GLint location, GLint x) override; -void glUniform1ivFn(GLint location, GLsizei count, const GLint* v) override; -void glUniform1uiFn(GLint location, GLuint v0) override; -void glUniform1uivFn(GLint location, GLsizei count, const GLuint* v) override; -void glUniform2fFn(GLint location, GLfloat x, GLfloat y) override; -void glUniform2fvFn(GLint location, GLsizei count, const GLfloat* v) override; -void glUniform2iFn(GLint location, GLint x, GLint y) override; -void glUniform2ivFn(GLint location, GLsizei count, const GLint* v) override; -void glUniform2uiFn(GLint location, GLuint v0, GLuint v1) override; -void glUniform2uivFn(GLint location, GLsizei count, const GLuint* v) override; -void glUniform3fFn(GLint location, GLfloat x, GLfloat y, GLfloat z) override; -void glUniform3fvFn(GLint location, GLsizei count, const GLfloat* v) override; -void glUniform3iFn(GLint location, GLint x, GLint y, GLint z) override; -void glUniform3ivFn(GLint location, GLsizei count, const GLint* v) override; -void glUniform3uiFn(GLint location, GLuint v0, GLuint v1, GLuint v2) override; -void glUniform3uivFn(GLint location, GLsizei count, const GLuint* v) override; -void glUniform4fFn(GLint location, - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w) override; -void glUniform4fvFn(GLint location, GLsizei count, const GLfloat* v) override; -void glUniform4iFn(GLint location, GLint x, GLint y, GLint z, GLint w) override; -void glUniform4ivFn(GLint location, GLsizei count, const GLint* v) override; -void glUniform4uiFn(GLint location, - GLuint v0, - GLuint v1, - GLuint v2, - GLuint v3) override; -void glUniform4uivFn(GLint location, GLsizei count, const GLuint* v) override; -void glUniformBlockBindingFn(GLuint program, - GLuint uniformBlockIndex, - GLuint uniformBlockBinding) override; -void glUniformMatrix2fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) override; -void glUniformMatrix2x3fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) override; -void glUniformMatrix2x4fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) override; -void glUniformMatrix3fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) override; -void glUniformMatrix3x2fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) override; -void glUniformMatrix3x4fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) override; -void glUniformMatrix4fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) override; -void glUniformMatrix4x2fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) override; -void glUniformMatrix4x3fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) override; -GLboolean glUnmapBufferFn(GLenum target) override; -void glUseProgramFn(GLuint program) override; -void glValidateProgramFn(GLuint program) override; -void glVertexAttrib1fFn(GLuint indx, GLfloat x) override; -void glVertexAttrib1fvFn(GLuint indx, const GLfloat* values) override; -void glVertexAttrib2fFn(GLuint indx, GLfloat x, GLfloat y) override; -void glVertexAttrib2fvFn(GLuint indx, const GLfloat* values) override; -void glVertexAttrib3fFn(GLuint indx, GLfloat x, GLfloat y, GLfloat z) override; -void glVertexAttrib3fvFn(GLuint indx, const GLfloat* values) override; -void glVertexAttrib4fFn(GLuint indx, - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w) override; -void glVertexAttrib4fvFn(GLuint indx, const GLfloat* values) override; -void glVertexAttribDivisorANGLEFn(GLuint index, GLuint divisor) override; -void glVertexAttribI4iFn(GLuint indx, - GLint x, - GLint y, - GLint z, - GLint w) override; -void glVertexAttribI4ivFn(GLuint indx, const GLint* values) override; -void glVertexAttribI4uiFn(GLuint indx, - GLuint x, - GLuint y, - GLuint z, - GLuint w) override; -void glVertexAttribI4uivFn(GLuint indx, const GLuint* values) override; -void glVertexAttribIPointerFn(GLuint indx, - GLint size, - GLenum type, - GLsizei stride, - const void* ptr) override; -void glVertexAttribPointerFn(GLuint indx, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const void* ptr) override; -void glViewportFn(GLint x, GLint y, GLsizei width, GLsizei height) override; -GLenum glWaitSyncFn(GLsync sync, GLbitfield flags, GLuint64 timeout) override; diff --git a/ui/gl/gl_bindings_api_autogen_osmesa.h b/ui/gl/gl_bindings_api_autogen_osmesa.h deleted file mode 100644 index c061275c0..000000000 --- a/ui/gl/gl_bindings_api_autogen_osmesa.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 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 is auto-generated from -// ui/gl/generate_bindings.py -// It's formatted by clang-format using chromium coding style: -// clang-format -i -style=chromium filename -// DO NOT EDIT! - -void OSMesaColorClampFn(GLboolean enable) override; -OSMesaContext OSMesaCreateContextFn(GLenum format, - OSMesaContext sharelist) override; -OSMesaContext OSMesaCreateContextExtFn(GLenum format, - GLint depthBits, - GLint stencilBits, - GLint accumBits, - OSMesaContext sharelist) override; -void OSMesaDestroyContextFn(OSMesaContext ctx) override; -GLboolean OSMesaGetColorBufferFn(OSMesaContext c, - GLint* width, - GLint* height, - GLint* format, - void** buffer) override; -OSMesaContext OSMesaGetCurrentContextFn(void) override; -GLboolean OSMesaGetDepthBufferFn(OSMesaContext c, - GLint* width, - GLint* height, - GLint* bytesPerValue, - void** buffer) override; -void OSMesaGetIntegervFn(GLint pname, GLint* value) override; -OSMESAproc OSMesaGetProcAddressFn(const char* funcName) override; -GLboolean OSMesaMakeCurrentFn(OSMesaContext ctx, - void* buffer, - GLenum type, - GLsizei width, - GLsizei height) override; -void OSMesaPixelStoreFn(GLint pname, GLint value) override; diff --git a/ui/gl/gl_bindings_autogen_egl.cc b/ui/gl/gl_bindings_autogen_egl.cc deleted file mode 100644 index 26f7a71c8..000000000 --- a/ui/gl/gl_bindings_autogen_egl.cc +++ /dev/null @@ -1,1497 +0,0 @@ -// Copyright 2014 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 is auto-generated from -// ui/gl/generate_bindings.py -// It's formatted by clang-format using chromium coding style: -// clang-format -i -style=chromium filename -// DO NOT EDIT! - -#include - -#include "base/trace_event/trace_event.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_egl_api_implementation.h" -#include "ui/gl/gl_enums.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_version_info.h" - -namespace gfx { - -static bool g_debugBindingsInitialized; -DriverEGL g_driver_egl; - -void DriverEGL::InitializeStaticBindings() { - fn.eglBindAPIFn = - reinterpret_cast(GetGLProcAddress("eglBindAPI")); - fn.eglBindTexImageFn = reinterpret_cast( - GetGLProcAddress("eglBindTexImage")); - fn.eglChooseConfigFn = reinterpret_cast( - GetGLProcAddress("eglChooseConfig")); - fn.eglClientWaitSyncKHRFn = 0; - fn.eglCopyBuffersFn = - reinterpret_cast(GetGLProcAddress("eglCopyBuffers")); - fn.eglCreateContextFn = reinterpret_cast( - GetGLProcAddress("eglCreateContext")); - fn.eglCreateImageKHRFn = 0; - fn.eglCreatePbufferFromClientBufferFn = - reinterpret_cast( - GetGLProcAddress("eglCreatePbufferFromClientBuffer")); - fn.eglCreatePbufferSurfaceFn = reinterpret_cast( - GetGLProcAddress("eglCreatePbufferSurface")); - fn.eglCreatePixmapSurfaceFn = reinterpret_cast( - GetGLProcAddress("eglCreatePixmapSurface")); - fn.eglCreateSyncKHRFn = 0; - fn.eglCreateWindowSurfaceFn = reinterpret_cast( - GetGLProcAddress("eglCreateWindowSurface")); - fn.eglDestroyContextFn = reinterpret_cast( - GetGLProcAddress("eglDestroyContext")); - fn.eglDestroyImageKHRFn = 0; - fn.eglDestroySurfaceFn = reinterpret_cast( - GetGLProcAddress("eglDestroySurface")); - fn.eglDestroySyncKHRFn = 0; - fn.eglGetConfigAttribFn = reinterpret_cast( - GetGLProcAddress("eglGetConfigAttrib")); - fn.eglGetConfigsFn = - reinterpret_cast(GetGLProcAddress("eglGetConfigs")); - fn.eglGetCurrentContextFn = reinterpret_cast( - GetGLProcAddress("eglGetCurrentContext")); - fn.eglGetCurrentDisplayFn = reinterpret_cast( - GetGLProcAddress("eglGetCurrentDisplay")); - fn.eglGetCurrentSurfaceFn = reinterpret_cast( - GetGLProcAddress("eglGetCurrentSurface")); - fn.eglGetDisplayFn = - reinterpret_cast(GetGLProcAddress("eglGetDisplay")); - fn.eglGetErrorFn = - reinterpret_cast(GetGLProcAddress("eglGetError")); - fn.eglGetPlatformDisplayEXTFn = 0; - fn.eglGetProcAddressFn = reinterpret_cast( - GetGLProcAddress("eglGetProcAddress")); - fn.eglGetSyncAttribKHRFn = 0; - fn.eglGetSyncValuesCHROMIUMFn = 0; - fn.eglInitializeFn = - reinterpret_cast(GetGLProcAddress("eglInitialize")); - fn.eglMakeCurrentFn = - reinterpret_cast(GetGLProcAddress("eglMakeCurrent")); - fn.eglPostSubBufferNVFn = 0; - fn.eglQueryAPIFn = - reinterpret_cast(GetGLProcAddress("eglQueryAPI")); - fn.eglQueryContextFn = reinterpret_cast( - GetGLProcAddress("eglQueryContext")); - fn.eglQueryStringFn = - reinterpret_cast(GetGLProcAddress("eglQueryString")); - fn.eglQuerySurfaceFn = reinterpret_cast( - GetGLProcAddress("eglQuerySurface")); - fn.eglQuerySurfacePointerANGLEFn = 0; - fn.eglReleaseTexImageFn = reinterpret_cast( - GetGLProcAddress("eglReleaseTexImage")); - fn.eglReleaseThreadFn = reinterpret_cast( - GetGLProcAddress("eglReleaseThread")); - fn.eglSurfaceAttribFn = reinterpret_cast( - GetGLProcAddress("eglSurfaceAttrib")); - fn.eglSwapBuffersFn = - reinterpret_cast(GetGLProcAddress("eglSwapBuffers")); - fn.eglSwapIntervalFn = reinterpret_cast( - GetGLProcAddress("eglSwapInterval")); - fn.eglTerminateFn = - reinterpret_cast(GetGLProcAddress("eglTerminate")); - fn.eglWaitClientFn = - reinterpret_cast(GetGLProcAddress("eglWaitClient")); - fn.eglWaitGLFn = - reinterpret_cast(GetGLProcAddress("eglWaitGL")); - fn.eglWaitNativeFn = - reinterpret_cast(GetGLProcAddress("eglWaitNative")); - fn.eglWaitSyncKHRFn = 0; - std::string extensions(GetPlatformExtensions()); - extensions += " "; - ALLOW_UNUSED_LOCAL(extensions); - - ext.b_EGL_ANGLE_d3d_share_handle_client_buffer = - extensions.find("EGL_ANGLE_d3d_share_handle_client_buffer ") != - std::string::npos; - ext.b_EGL_ANGLE_platform_angle = - extensions.find("EGL_ANGLE_platform_angle ") != std::string::npos; - ext.b_EGL_ANGLE_query_surface_pointer = - extensions.find("EGL_ANGLE_query_surface_pointer ") != std::string::npos; - ext.b_EGL_ANGLE_surface_d3d_texture_2d_share_handle = - extensions.find("EGL_ANGLE_surface_d3d_texture_2d_share_handle ") != - std::string::npos; - ext.b_EGL_CHROMIUM_sync_control = - extensions.find("EGL_CHROMIUM_sync_control ") != std::string::npos; - ext.b_EGL_KHR_fence_sync = - extensions.find("EGL_KHR_fence_sync ") != std::string::npos; - ext.b_EGL_KHR_gl_texture_2D_image = - extensions.find("EGL_KHR_gl_texture_2D_image ") != std::string::npos; - ext.b_EGL_KHR_image = extensions.find("EGL_KHR_image ") != std::string::npos; - ext.b_EGL_KHR_image_base = - extensions.find("EGL_KHR_image_base ") != std::string::npos; - ext.b_EGL_KHR_reusable_sync = - extensions.find("EGL_KHR_reusable_sync ") != std::string::npos; - ext.b_EGL_KHR_wait_sync = - extensions.find("EGL_KHR_wait_sync ") != std::string::npos; - ext.b_EGL_NV_post_sub_buffer = - extensions.find("EGL_NV_post_sub_buffer ") != std::string::npos; - - debug_fn.eglClientWaitSyncKHRFn = 0; - if (ext.b_EGL_KHR_fence_sync || ext.b_EGL_KHR_reusable_sync) { - fn.eglClientWaitSyncKHRFn = reinterpret_cast( - GetGLProcAddress("eglClientWaitSyncKHR")); - DCHECK(fn.eglClientWaitSyncKHRFn); - } - - debug_fn.eglCreateImageKHRFn = 0; - if (ext.b_EGL_KHR_image || ext.b_EGL_KHR_image_base || - ext.b_EGL_KHR_gl_texture_2D_image) { - fn.eglCreateImageKHRFn = reinterpret_cast( - GetGLProcAddress("eglCreateImageKHR")); - DCHECK(fn.eglCreateImageKHRFn); - } - - debug_fn.eglCreateSyncKHRFn = 0; - if (ext.b_EGL_KHR_fence_sync || ext.b_EGL_KHR_reusable_sync) { - fn.eglCreateSyncKHRFn = reinterpret_cast( - GetGLProcAddress("eglCreateSyncKHR")); - DCHECK(fn.eglCreateSyncKHRFn); - } - - debug_fn.eglDestroyImageKHRFn = 0; - if (ext.b_EGL_KHR_image || ext.b_EGL_KHR_image_base) { - fn.eglDestroyImageKHRFn = reinterpret_cast( - GetGLProcAddress("eglDestroyImageKHR")); - DCHECK(fn.eglDestroyImageKHRFn); - } - - debug_fn.eglDestroySyncKHRFn = 0; - if (ext.b_EGL_KHR_fence_sync || ext.b_EGL_KHR_reusable_sync) { - fn.eglDestroySyncKHRFn = reinterpret_cast( - GetGLProcAddress("eglDestroySyncKHR")); - DCHECK(fn.eglDestroySyncKHRFn); - } - - debug_fn.eglGetPlatformDisplayEXTFn = 0; - if (ext.b_EGL_ANGLE_platform_angle) { - fn.eglGetPlatformDisplayEXTFn = - reinterpret_cast( - GetGLProcAddress("eglGetPlatformDisplayEXT")); - DCHECK(fn.eglGetPlatformDisplayEXTFn); - } - - debug_fn.eglGetSyncAttribKHRFn = 0; - if (ext.b_EGL_KHR_fence_sync || ext.b_EGL_KHR_reusable_sync) { - fn.eglGetSyncAttribKHRFn = reinterpret_cast( - GetGLProcAddress("eglGetSyncAttribKHR")); - DCHECK(fn.eglGetSyncAttribKHRFn); - } - - debug_fn.eglGetSyncValuesCHROMIUMFn = 0; - if (ext.b_EGL_CHROMIUM_sync_control) { - fn.eglGetSyncValuesCHROMIUMFn = - reinterpret_cast( - GetGLProcAddress("eglGetSyncValuesCHROMIUM")); - DCHECK(fn.eglGetSyncValuesCHROMIUMFn); - } - - debug_fn.eglPostSubBufferNVFn = 0; - if (ext.b_EGL_NV_post_sub_buffer) { - fn.eglPostSubBufferNVFn = reinterpret_cast( - GetGLProcAddress("eglPostSubBufferNV")); - DCHECK(fn.eglPostSubBufferNVFn); - } - - debug_fn.eglQuerySurfacePointerANGLEFn = 0; - if (ext.b_EGL_ANGLE_query_surface_pointer) { - fn.eglQuerySurfacePointerANGLEFn = - reinterpret_cast( - GetGLProcAddress("eglQuerySurfacePointerANGLE")); - DCHECK(fn.eglQuerySurfacePointerANGLEFn); - } - - debug_fn.eglWaitSyncKHRFn = 0; - if (ext.b_EGL_KHR_wait_sync) { - fn.eglWaitSyncKHRFn = reinterpret_cast( - GetGLProcAddress("eglWaitSyncKHR")); - DCHECK(fn.eglWaitSyncKHRFn); - } - - if (g_debugBindingsInitialized) - InitializeDebugBindings(); -} - -extern "C" { - -static EGLBoolean GL_BINDING_CALL Debug_eglBindAPI(EGLenum api) { - GL_SERVICE_LOG("eglBindAPI" - << "(" << api << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglBindAPIFn(api); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglBindTexImage(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer) { - GL_SERVICE_LOG("eglBindTexImage" - << "(" << dpy << ", " << surface << ", " << buffer << ")"); - EGLBoolean result = - g_driver_egl.debug_fn.eglBindTexImageFn(dpy, surface, buffer); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL -Debug_eglChooseConfig(EGLDisplay dpy, - const EGLint* attrib_list, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config) { - GL_SERVICE_LOG("eglChooseConfig" - << "(" << dpy << ", " << static_cast(attrib_list) - << ", " << static_cast(configs) << ", " - << config_size << ", " << static_cast(num_config) - << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglChooseConfigFn( - dpy, attrib_list, configs, config_size, num_config); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLint GL_BINDING_CALL Debug_eglClientWaitSyncKHR(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint flags, - EGLTimeKHR timeout) { - GL_SERVICE_LOG("eglClientWaitSyncKHR" - << "(" << dpy << ", " << sync << ", " << flags << ", " - << timeout << ")"); - EGLint result = - g_driver_egl.debug_fn.eglClientWaitSyncKHRFn(dpy, sync, flags, timeout); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL -Debug_eglCopyBuffers(EGLDisplay dpy, - EGLSurface surface, - EGLNativePixmapType target) { - GL_SERVICE_LOG("eglCopyBuffers" - << "(" << dpy << ", " << surface << ", " << target << ")"); - EGLBoolean result = - g_driver_egl.debug_fn.eglCopyBuffersFn(dpy, surface, target); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLContext GL_BINDING_CALL -Debug_eglCreateContext(EGLDisplay dpy, - EGLConfig config, - EGLContext share_context, - const EGLint* attrib_list) { - GL_SERVICE_LOG("eglCreateContext" - << "(" << dpy << ", " << config << ", " << share_context - << ", " << static_cast(attrib_list) << ")"); - EGLContext result = g_driver_egl.debug_fn.eglCreateContextFn( - dpy, config, share_context, attrib_list); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLImageKHR GL_BINDING_CALL -Debug_eglCreateImageKHR(EGLDisplay dpy, - EGLContext ctx, - EGLenum target, - EGLClientBuffer buffer, - const EGLint* attrib_list) { - GL_SERVICE_LOG("eglCreateImageKHR" - << "(" << dpy << ", " << ctx << ", " << target << ", " - << buffer << ", " << static_cast(attrib_list) - << ")"); - EGLImageKHR result = g_driver_egl.debug_fn.eglCreateImageKHRFn( - dpy, ctx, target, buffer, attrib_list); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLSurface GL_BINDING_CALL -Debug_eglCreatePbufferFromClientBuffer(EGLDisplay dpy, - EGLenum buftype, - void* buffer, - EGLConfig config, - const EGLint* attrib_list) { - GL_SERVICE_LOG("eglCreatePbufferFromClientBuffer" - << "(" << dpy << ", " << buftype << ", " - << static_cast(buffer) << ", " << config << ", " - << static_cast(attrib_list) << ")"); - EGLSurface result = g_driver_egl.debug_fn.eglCreatePbufferFromClientBufferFn( - dpy, buftype, buffer, config, attrib_list); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLSurface GL_BINDING_CALL -Debug_eglCreatePbufferSurface(EGLDisplay dpy, - EGLConfig config, - const EGLint* attrib_list) { - GL_SERVICE_LOG("eglCreatePbufferSurface" - << "(" << dpy << ", " << config << ", " - << static_cast(attrib_list) << ")"); - EGLSurface result = - g_driver_egl.debug_fn.eglCreatePbufferSurfaceFn(dpy, config, attrib_list); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLSurface GL_BINDING_CALL -Debug_eglCreatePixmapSurface(EGLDisplay dpy, - EGLConfig config, - EGLNativePixmapType pixmap, - const EGLint* attrib_list) { - GL_SERVICE_LOG("eglCreatePixmapSurface" - << "(" << dpy << ", " << config << ", " << pixmap << ", " - << static_cast(attrib_list) << ")"); - EGLSurface result = g_driver_egl.debug_fn.eglCreatePixmapSurfaceFn( - dpy, config, pixmap, attrib_list); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLSyncKHR GL_BINDING_CALL -Debug_eglCreateSyncKHR(EGLDisplay dpy, - EGLenum type, - const EGLint* attrib_list) { - GL_SERVICE_LOG("eglCreateSyncKHR" - << "(" << dpy << ", " << type << ", " - << static_cast(attrib_list) << ")"); - EGLSyncKHR result = - g_driver_egl.debug_fn.eglCreateSyncKHRFn(dpy, type, attrib_list); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLSurface GL_BINDING_CALL -Debug_eglCreateWindowSurface(EGLDisplay dpy, - EGLConfig config, - EGLNativeWindowType win, - const EGLint* attrib_list) { - GL_SERVICE_LOG("eglCreateWindowSurface" - << "(" << dpy << ", " << config << ", " << win << ", " - << static_cast(attrib_list) << ")"); - EGLSurface result = g_driver_egl.debug_fn.eglCreateWindowSurfaceFn( - dpy, config, win, attrib_list); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglDestroyContext(EGLDisplay dpy, - EGLContext ctx) { - GL_SERVICE_LOG("eglDestroyContext" - << "(" << dpy << ", " << ctx << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglDestroyContextFn(dpy, ctx); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglDestroyImageKHR(EGLDisplay dpy, - EGLImageKHR image) { - GL_SERVICE_LOG("eglDestroyImageKHR" - << "(" << dpy << ", " << image << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglDestroyImageKHRFn(dpy, image); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglDestroySurface(EGLDisplay dpy, - EGLSurface surface) { - GL_SERVICE_LOG("eglDestroySurface" - << "(" << dpy << ", " << surface << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglDestroySurfaceFn(dpy, surface); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglDestroySyncKHR(EGLDisplay dpy, - EGLSyncKHR sync) { - GL_SERVICE_LOG("eglDestroySyncKHR" - << "(" << dpy << ", " << sync << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglDestroySyncKHRFn(dpy, sync); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglGetConfigAttrib(EGLDisplay dpy, - EGLConfig config, - EGLint attribute, - EGLint* value) { - GL_SERVICE_LOG("eglGetConfigAttrib" - << "(" << dpy << ", " << config << ", " << attribute << ", " - << static_cast(value) << ")"); - EGLBoolean result = - g_driver_egl.debug_fn.eglGetConfigAttribFn(dpy, config, attribute, value); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglGetConfigs(EGLDisplay dpy, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config) { - GL_SERVICE_LOG("eglGetConfigs" - << "(" << dpy << ", " << static_cast(configs) - << ", " << config_size << ", " - << static_cast(num_config) << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglGetConfigsFn( - dpy, configs, config_size, num_config); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLContext GL_BINDING_CALL Debug_eglGetCurrentContext(void) { - GL_SERVICE_LOG("eglGetCurrentContext" - << "(" - << ")"); - EGLContext result = g_driver_egl.debug_fn.eglGetCurrentContextFn(); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLDisplay GL_BINDING_CALL Debug_eglGetCurrentDisplay(void) { - GL_SERVICE_LOG("eglGetCurrentDisplay" - << "(" - << ")"); - EGLDisplay result = g_driver_egl.debug_fn.eglGetCurrentDisplayFn(); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLSurface GL_BINDING_CALL Debug_eglGetCurrentSurface(EGLint readdraw) { - GL_SERVICE_LOG("eglGetCurrentSurface" - << "(" << readdraw << ")"); - EGLSurface result = g_driver_egl.debug_fn.eglGetCurrentSurfaceFn(readdraw); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLDisplay GL_BINDING_CALL -Debug_eglGetDisplay(EGLNativeDisplayType display_id) { - GL_SERVICE_LOG("eglGetDisplay" - << "(" << display_id << ")"); - EGLDisplay result = g_driver_egl.debug_fn.eglGetDisplayFn(display_id); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLint GL_BINDING_CALL Debug_eglGetError(void) { - GL_SERVICE_LOG("eglGetError" - << "(" - << ")"); - EGLint result = g_driver_egl.debug_fn.eglGetErrorFn(); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLDisplay GL_BINDING_CALL -Debug_eglGetPlatformDisplayEXT(EGLenum platform, - void* native_display, - const EGLint* attrib_list) { - GL_SERVICE_LOG("eglGetPlatformDisplayEXT" - << "(" << platform << ", " - << static_cast(native_display) << ", " - << static_cast(attrib_list) << ")"); - EGLDisplay result = g_driver_egl.debug_fn.eglGetPlatformDisplayEXTFn( - platform, native_display, attrib_list); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static __eglMustCastToProperFunctionPointerType GL_BINDING_CALL -Debug_eglGetProcAddress(const char* procname) { - GL_SERVICE_LOG("eglGetProcAddress" - << "(" << procname << ")"); - __eglMustCastToProperFunctionPointerType result = - g_driver_egl.debug_fn.eglGetProcAddressFn(procname); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglGetSyncAttribKHR(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint attribute, - EGLint* value) { - GL_SERVICE_LOG("eglGetSyncAttribKHR" - << "(" << dpy << ", " << sync << ", " << attribute << ", " - << static_cast(value) << ")"); - EGLBoolean result = - g_driver_egl.debug_fn.eglGetSyncAttribKHRFn(dpy, sync, attribute, value); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL -Debug_eglGetSyncValuesCHROMIUM(EGLDisplay dpy, - EGLSurface surface, - EGLuint64CHROMIUM* ust, - EGLuint64CHROMIUM* msc, - EGLuint64CHROMIUM* sbc) { - GL_SERVICE_LOG("eglGetSyncValuesCHROMIUM" - << "(" << dpy << ", " << surface << ", " - << static_cast(ust) << ", " - << static_cast(msc) << ", " - << static_cast(sbc) << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglGetSyncValuesCHROMIUMFn( - dpy, surface, ust, msc, sbc); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglInitialize(EGLDisplay dpy, - EGLint* major, - EGLint* minor) { - GL_SERVICE_LOG("eglInitialize" - << "(" << dpy << ", " << static_cast(major) - << ", " << static_cast(minor) << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglInitializeFn(dpy, major, minor); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglMakeCurrent(EGLDisplay dpy, - EGLSurface draw, - EGLSurface read, - EGLContext ctx) { - GL_SERVICE_LOG("eglMakeCurrent" - << "(" << dpy << ", " << draw << ", " << read << ", " << ctx - << ")"); - EGLBoolean result = - g_driver_egl.debug_fn.eglMakeCurrentFn(dpy, draw, read, ctx); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglPostSubBufferNV(EGLDisplay dpy, - EGLSurface surface, - EGLint x, - EGLint y, - EGLint width, - EGLint height) { - GL_SERVICE_LOG("eglPostSubBufferNV" - << "(" << dpy << ", " << surface << ", " << x << ", " << y - << ", " << width << ", " << height << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglPostSubBufferNVFn( - dpy, surface, x, y, width, height); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLenum GL_BINDING_CALL Debug_eglQueryAPI(void) { - GL_SERVICE_LOG("eglQueryAPI" - << "(" - << ")"); - EGLenum result = g_driver_egl.debug_fn.eglQueryAPIFn(); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglQueryContext(EGLDisplay dpy, - EGLContext ctx, - EGLint attribute, - EGLint* value) { - GL_SERVICE_LOG("eglQueryContext" - << "(" << dpy << ", " << ctx << ", " << attribute << ", " - << static_cast(value) << ")"); - EGLBoolean result = - g_driver_egl.debug_fn.eglQueryContextFn(dpy, ctx, attribute, value); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static const char* GL_BINDING_CALL Debug_eglQueryString(EGLDisplay dpy, - EGLint name) { - GL_SERVICE_LOG("eglQueryString" - << "(" << dpy << ", " << name << ")"); - const char* result = g_driver_egl.debug_fn.eglQueryStringFn(dpy, name); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglQuerySurface(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint* value) { - GL_SERVICE_LOG("eglQuerySurface" - << "(" << dpy << ", " << surface << ", " << attribute << ", " - << static_cast(value) << ")"); - EGLBoolean result = - g_driver_egl.debug_fn.eglQuerySurfaceFn(dpy, surface, attribute, value); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL -Debug_eglQuerySurfacePointerANGLE(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - void** value) { - GL_SERVICE_LOG("eglQuerySurfacePointerANGLE" - << "(" << dpy << ", " << surface << ", " << attribute << ", " - << value << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglQuerySurfacePointerANGLEFn( - dpy, surface, attribute, value); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglReleaseTexImage(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer) { - GL_SERVICE_LOG("eglReleaseTexImage" - << "(" << dpy << ", " << surface << ", " << buffer << ")"); - EGLBoolean result = - g_driver_egl.debug_fn.eglReleaseTexImageFn(dpy, surface, buffer); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglReleaseThread(void) { - GL_SERVICE_LOG("eglReleaseThread" - << "(" - << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglReleaseThreadFn(); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglSurfaceAttrib(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint value) { - GL_SERVICE_LOG("eglSurfaceAttrib" - << "(" << dpy << ", " << surface << ", " << attribute << ", " - << value << ")"); - EGLBoolean result = - g_driver_egl.debug_fn.eglSurfaceAttribFn(dpy, surface, attribute, value); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglSwapBuffers(EGLDisplay dpy, - EGLSurface surface) { - GL_SERVICE_LOG("eglSwapBuffers" - << "(" << dpy << ", " << surface << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglSwapBuffersFn(dpy, surface); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglSwapInterval(EGLDisplay dpy, - EGLint interval) { - GL_SERVICE_LOG("eglSwapInterval" - << "(" << dpy << ", " << interval << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglSwapIntervalFn(dpy, interval); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglTerminate(EGLDisplay dpy) { - GL_SERVICE_LOG("eglTerminate" - << "(" << dpy << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglTerminateFn(dpy); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglWaitClient(void) { - GL_SERVICE_LOG("eglWaitClient" - << "(" - << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglWaitClientFn(); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglWaitGL(void) { - GL_SERVICE_LOG("eglWaitGL" - << "(" - << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglWaitGLFn(); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLBoolean GL_BINDING_CALL Debug_eglWaitNative(EGLint engine) { - GL_SERVICE_LOG("eglWaitNative" - << "(" << engine << ")"); - EGLBoolean result = g_driver_egl.debug_fn.eglWaitNativeFn(engine); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static EGLint GL_BINDING_CALL Debug_eglWaitSyncKHR(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint flags) { - GL_SERVICE_LOG("eglWaitSyncKHR" - << "(" << dpy << ", " << sync << ", " << flags << ")"); - EGLint result = g_driver_egl.debug_fn.eglWaitSyncKHRFn(dpy, sync, flags); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} -} // extern "C" - -void DriverEGL::InitializeDebugBindings() { - if (!debug_fn.eglBindAPIFn) { - debug_fn.eglBindAPIFn = fn.eglBindAPIFn; - fn.eglBindAPIFn = Debug_eglBindAPI; - } - if (!debug_fn.eglBindTexImageFn) { - debug_fn.eglBindTexImageFn = fn.eglBindTexImageFn; - fn.eglBindTexImageFn = Debug_eglBindTexImage; - } - if (!debug_fn.eglChooseConfigFn) { - debug_fn.eglChooseConfigFn = fn.eglChooseConfigFn; - fn.eglChooseConfigFn = Debug_eglChooseConfig; - } - if (!debug_fn.eglClientWaitSyncKHRFn) { - debug_fn.eglClientWaitSyncKHRFn = fn.eglClientWaitSyncKHRFn; - fn.eglClientWaitSyncKHRFn = Debug_eglClientWaitSyncKHR; - } - if (!debug_fn.eglCopyBuffersFn) { - debug_fn.eglCopyBuffersFn = fn.eglCopyBuffersFn; - fn.eglCopyBuffersFn = Debug_eglCopyBuffers; - } - if (!debug_fn.eglCreateContextFn) { - debug_fn.eglCreateContextFn = fn.eglCreateContextFn; - fn.eglCreateContextFn = Debug_eglCreateContext; - } - if (!debug_fn.eglCreateImageKHRFn) { - debug_fn.eglCreateImageKHRFn = fn.eglCreateImageKHRFn; - fn.eglCreateImageKHRFn = Debug_eglCreateImageKHR; - } - if (!debug_fn.eglCreatePbufferFromClientBufferFn) { - debug_fn.eglCreatePbufferFromClientBufferFn = - fn.eglCreatePbufferFromClientBufferFn; - fn.eglCreatePbufferFromClientBufferFn = - Debug_eglCreatePbufferFromClientBuffer; - } - if (!debug_fn.eglCreatePbufferSurfaceFn) { - debug_fn.eglCreatePbufferSurfaceFn = fn.eglCreatePbufferSurfaceFn; - fn.eglCreatePbufferSurfaceFn = Debug_eglCreatePbufferSurface; - } - if (!debug_fn.eglCreatePixmapSurfaceFn) { - debug_fn.eglCreatePixmapSurfaceFn = fn.eglCreatePixmapSurfaceFn; - fn.eglCreatePixmapSurfaceFn = Debug_eglCreatePixmapSurface; - } - if (!debug_fn.eglCreateSyncKHRFn) { - debug_fn.eglCreateSyncKHRFn = fn.eglCreateSyncKHRFn; - fn.eglCreateSyncKHRFn = Debug_eglCreateSyncKHR; - } - if (!debug_fn.eglCreateWindowSurfaceFn) { - debug_fn.eglCreateWindowSurfaceFn = fn.eglCreateWindowSurfaceFn; - fn.eglCreateWindowSurfaceFn = Debug_eglCreateWindowSurface; - } - if (!debug_fn.eglDestroyContextFn) { - debug_fn.eglDestroyContextFn = fn.eglDestroyContextFn; - fn.eglDestroyContextFn = Debug_eglDestroyContext; - } - if (!debug_fn.eglDestroyImageKHRFn) { - debug_fn.eglDestroyImageKHRFn = fn.eglDestroyImageKHRFn; - fn.eglDestroyImageKHRFn = Debug_eglDestroyImageKHR; - } - if (!debug_fn.eglDestroySurfaceFn) { - debug_fn.eglDestroySurfaceFn = fn.eglDestroySurfaceFn; - fn.eglDestroySurfaceFn = Debug_eglDestroySurface; - } - if (!debug_fn.eglDestroySyncKHRFn) { - debug_fn.eglDestroySyncKHRFn = fn.eglDestroySyncKHRFn; - fn.eglDestroySyncKHRFn = Debug_eglDestroySyncKHR; - } - if (!debug_fn.eglGetConfigAttribFn) { - debug_fn.eglGetConfigAttribFn = fn.eglGetConfigAttribFn; - fn.eglGetConfigAttribFn = Debug_eglGetConfigAttrib; - } - if (!debug_fn.eglGetConfigsFn) { - debug_fn.eglGetConfigsFn = fn.eglGetConfigsFn; - fn.eglGetConfigsFn = Debug_eglGetConfigs; - } - if (!debug_fn.eglGetCurrentContextFn) { - debug_fn.eglGetCurrentContextFn = fn.eglGetCurrentContextFn; - fn.eglGetCurrentContextFn = Debug_eglGetCurrentContext; - } - if (!debug_fn.eglGetCurrentDisplayFn) { - debug_fn.eglGetCurrentDisplayFn = fn.eglGetCurrentDisplayFn; - fn.eglGetCurrentDisplayFn = Debug_eglGetCurrentDisplay; - } - if (!debug_fn.eglGetCurrentSurfaceFn) { - debug_fn.eglGetCurrentSurfaceFn = fn.eglGetCurrentSurfaceFn; - fn.eglGetCurrentSurfaceFn = Debug_eglGetCurrentSurface; - } - if (!debug_fn.eglGetDisplayFn) { - debug_fn.eglGetDisplayFn = fn.eglGetDisplayFn; - fn.eglGetDisplayFn = Debug_eglGetDisplay; - } - if (!debug_fn.eglGetErrorFn) { - debug_fn.eglGetErrorFn = fn.eglGetErrorFn; - fn.eglGetErrorFn = Debug_eglGetError; - } - if (!debug_fn.eglGetPlatformDisplayEXTFn) { - debug_fn.eglGetPlatformDisplayEXTFn = fn.eglGetPlatformDisplayEXTFn; - fn.eglGetPlatformDisplayEXTFn = Debug_eglGetPlatformDisplayEXT; - } - if (!debug_fn.eglGetProcAddressFn) { - debug_fn.eglGetProcAddressFn = fn.eglGetProcAddressFn; - fn.eglGetProcAddressFn = Debug_eglGetProcAddress; - } - if (!debug_fn.eglGetSyncAttribKHRFn) { - debug_fn.eglGetSyncAttribKHRFn = fn.eglGetSyncAttribKHRFn; - fn.eglGetSyncAttribKHRFn = Debug_eglGetSyncAttribKHR; - } - if (!debug_fn.eglGetSyncValuesCHROMIUMFn) { - debug_fn.eglGetSyncValuesCHROMIUMFn = fn.eglGetSyncValuesCHROMIUMFn; - fn.eglGetSyncValuesCHROMIUMFn = Debug_eglGetSyncValuesCHROMIUM; - } - if (!debug_fn.eglInitializeFn) { - debug_fn.eglInitializeFn = fn.eglInitializeFn; - fn.eglInitializeFn = Debug_eglInitialize; - } - if (!debug_fn.eglMakeCurrentFn) { - debug_fn.eglMakeCurrentFn = fn.eglMakeCurrentFn; - fn.eglMakeCurrentFn = Debug_eglMakeCurrent; - } - if (!debug_fn.eglPostSubBufferNVFn) { - debug_fn.eglPostSubBufferNVFn = fn.eglPostSubBufferNVFn; - fn.eglPostSubBufferNVFn = Debug_eglPostSubBufferNV; - } - if (!debug_fn.eglQueryAPIFn) { - debug_fn.eglQueryAPIFn = fn.eglQueryAPIFn; - fn.eglQueryAPIFn = Debug_eglQueryAPI; - } - if (!debug_fn.eglQueryContextFn) { - debug_fn.eglQueryContextFn = fn.eglQueryContextFn; - fn.eglQueryContextFn = Debug_eglQueryContext; - } - if (!debug_fn.eglQueryStringFn) { - debug_fn.eglQueryStringFn = fn.eglQueryStringFn; - fn.eglQueryStringFn = Debug_eglQueryString; - } - if (!debug_fn.eglQuerySurfaceFn) { - debug_fn.eglQuerySurfaceFn = fn.eglQuerySurfaceFn; - fn.eglQuerySurfaceFn = Debug_eglQuerySurface; - } - if (!debug_fn.eglQuerySurfacePointerANGLEFn) { - debug_fn.eglQuerySurfacePointerANGLEFn = fn.eglQuerySurfacePointerANGLEFn; - fn.eglQuerySurfacePointerANGLEFn = Debug_eglQuerySurfacePointerANGLE; - } - if (!debug_fn.eglReleaseTexImageFn) { - debug_fn.eglReleaseTexImageFn = fn.eglReleaseTexImageFn; - fn.eglReleaseTexImageFn = Debug_eglReleaseTexImage; - } - if (!debug_fn.eglReleaseThreadFn) { - debug_fn.eglReleaseThreadFn = fn.eglReleaseThreadFn; - fn.eglReleaseThreadFn = Debug_eglReleaseThread; - } - if (!debug_fn.eglSurfaceAttribFn) { - debug_fn.eglSurfaceAttribFn = fn.eglSurfaceAttribFn; - fn.eglSurfaceAttribFn = Debug_eglSurfaceAttrib; - } - if (!debug_fn.eglSwapBuffersFn) { - debug_fn.eglSwapBuffersFn = fn.eglSwapBuffersFn; - fn.eglSwapBuffersFn = Debug_eglSwapBuffers; - } - if (!debug_fn.eglSwapIntervalFn) { - debug_fn.eglSwapIntervalFn = fn.eglSwapIntervalFn; - fn.eglSwapIntervalFn = Debug_eglSwapInterval; - } - if (!debug_fn.eglTerminateFn) { - debug_fn.eglTerminateFn = fn.eglTerminateFn; - fn.eglTerminateFn = Debug_eglTerminate; - } - if (!debug_fn.eglWaitClientFn) { - debug_fn.eglWaitClientFn = fn.eglWaitClientFn; - fn.eglWaitClientFn = Debug_eglWaitClient; - } - if (!debug_fn.eglWaitGLFn) { - debug_fn.eglWaitGLFn = fn.eglWaitGLFn; - fn.eglWaitGLFn = Debug_eglWaitGL; - } - if (!debug_fn.eglWaitNativeFn) { - debug_fn.eglWaitNativeFn = fn.eglWaitNativeFn; - fn.eglWaitNativeFn = Debug_eglWaitNative; - } - if (!debug_fn.eglWaitSyncKHRFn) { - debug_fn.eglWaitSyncKHRFn = fn.eglWaitSyncKHRFn; - fn.eglWaitSyncKHRFn = Debug_eglWaitSyncKHR; - } - g_debugBindingsInitialized = true; -} - -void DriverEGL::ClearBindings() { - memset(this, 0, sizeof(*this)); -} - -EGLBoolean EGLApiBase::eglBindAPIFn(EGLenum api) { - return driver_->fn.eglBindAPIFn(api); -} - -EGLBoolean EGLApiBase::eglBindTexImageFn(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer) { - return driver_->fn.eglBindTexImageFn(dpy, surface, buffer); -} - -EGLBoolean EGLApiBase::eglChooseConfigFn(EGLDisplay dpy, - const EGLint* attrib_list, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config) { - return driver_->fn.eglChooseConfigFn(dpy, attrib_list, configs, config_size, - num_config); -} - -EGLint EGLApiBase::eglClientWaitSyncKHRFn(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint flags, - EGLTimeKHR timeout) { - return driver_->fn.eglClientWaitSyncKHRFn(dpy, sync, flags, timeout); -} - -EGLBoolean EGLApiBase::eglCopyBuffersFn(EGLDisplay dpy, - EGLSurface surface, - EGLNativePixmapType target) { - return driver_->fn.eglCopyBuffersFn(dpy, surface, target); -} - -EGLContext EGLApiBase::eglCreateContextFn(EGLDisplay dpy, - EGLConfig config, - EGLContext share_context, - const EGLint* attrib_list) { - return driver_->fn.eglCreateContextFn(dpy, config, share_context, - attrib_list); -} - -EGLImageKHR EGLApiBase::eglCreateImageKHRFn(EGLDisplay dpy, - EGLContext ctx, - EGLenum target, - EGLClientBuffer buffer, - const EGLint* attrib_list) { - return driver_->fn.eglCreateImageKHRFn(dpy, ctx, target, buffer, attrib_list); -} - -EGLSurface EGLApiBase::eglCreatePbufferFromClientBufferFn( - EGLDisplay dpy, - EGLenum buftype, - void* buffer, - EGLConfig config, - const EGLint* attrib_list) { - return driver_->fn.eglCreatePbufferFromClientBufferFn(dpy, buftype, buffer, - config, attrib_list); -} - -EGLSurface EGLApiBase::eglCreatePbufferSurfaceFn(EGLDisplay dpy, - EGLConfig config, - const EGLint* attrib_list) { - return driver_->fn.eglCreatePbufferSurfaceFn(dpy, config, attrib_list); -} - -EGLSurface EGLApiBase::eglCreatePixmapSurfaceFn(EGLDisplay dpy, - EGLConfig config, - EGLNativePixmapType pixmap, - const EGLint* attrib_list) { - return driver_->fn.eglCreatePixmapSurfaceFn(dpy, config, pixmap, attrib_list); -} - -EGLSyncKHR EGLApiBase::eglCreateSyncKHRFn(EGLDisplay dpy, - EGLenum type, - const EGLint* attrib_list) { - return driver_->fn.eglCreateSyncKHRFn(dpy, type, attrib_list); -} - -EGLSurface EGLApiBase::eglCreateWindowSurfaceFn(EGLDisplay dpy, - EGLConfig config, - EGLNativeWindowType win, - const EGLint* attrib_list) { - return driver_->fn.eglCreateWindowSurfaceFn(dpy, config, win, attrib_list); -} - -EGLBoolean EGLApiBase::eglDestroyContextFn(EGLDisplay dpy, EGLContext ctx) { - return driver_->fn.eglDestroyContextFn(dpy, ctx); -} - -EGLBoolean EGLApiBase::eglDestroyImageKHRFn(EGLDisplay dpy, EGLImageKHR image) { - return driver_->fn.eglDestroyImageKHRFn(dpy, image); -} - -EGLBoolean EGLApiBase::eglDestroySurfaceFn(EGLDisplay dpy, EGLSurface surface) { - return driver_->fn.eglDestroySurfaceFn(dpy, surface); -} - -EGLBoolean EGLApiBase::eglDestroySyncKHRFn(EGLDisplay dpy, EGLSyncKHR sync) { - return driver_->fn.eglDestroySyncKHRFn(dpy, sync); -} - -EGLBoolean EGLApiBase::eglGetConfigAttribFn(EGLDisplay dpy, - EGLConfig config, - EGLint attribute, - EGLint* value) { - return driver_->fn.eglGetConfigAttribFn(dpy, config, attribute, value); -} - -EGLBoolean EGLApiBase::eglGetConfigsFn(EGLDisplay dpy, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config) { - return driver_->fn.eglGetConfigsFn(dpy, configs, config_size, num_config); -} - -EGLContext EGLApiBase::eglGetCurrentContextFn(void) { - return driver_->fn.eglGetCurrentContextFn(); -} - -EGLDisplay EGLApiBase::eglGetCurrentDisplayFn(void) { - return driver_->fn.eglGetCurrentDisplayFn(); -} - -EGLSurface EGLApiBase::eglGetCurrentSurfaceFn(EGLint readdraw) { - return driver_->fn.eglGetCurrentSurfaceFn(readdraw); -} - -EGLDisplay EGLApiBase::eglGetDisplayFn(EGLNativeDisplayType display_id) { - return driver_->fn.eglGetDisplayFn(display_id); -} - -EGLint EGLApiBase::eglGetErrorFn(void) { - return driver_->fn.eglGetErrorFn(); -} - -EGLDisplay EGLApiBase::eglGetPlatformDisplayEXTFn(EGLenum platform, - void* native_display, - const EGLint* attrib_list) { - return driver_->fn.eglGetPlatformDisplayEXTFn(platform, native_display, - attrib_list); -} - -__eglMustCastToProperFunctionPointerType EGLApiBase::eglGetProcAddressFn( - const char* procname) { - return driver_->fn.eglGetProcAddressFn(procname); -} - -EGLBoolean EGLApiBase::eglGetSyncAttribKHRFn(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint attribute, - EGLint* value) { - return driver_->fn.eglGetSyncAttribKHRFn(dpy, sync, attribute, value); -} - -EGLBoolean EGLApiBase::eglGetSyncValuesCHROMIUMFn(EGLDisplay dpy, - EGLSurface surface, - EGLuint64CHROMIUM* ust, - EGLuint64CHROMIUM* msc, - EGLuint64CHROMIUM* sbc) { - return driver_->fn.eglGetSyncValuesCHROMIUMFn(dpy, surface, ust, msc, sbc); -} - -EGLBoolean EGLApiBase::eglInitializeFn(EGLDisplay dpy, - EGLint* major, - EGLint* minor) { - return driver_->fn.eglInitializeFn(dpy, major, minor); -} - -EGLBoolean EGLApiBase::eglMakeCurrentFn(EGLDisplay dpy, - EGLSurface draw, - EGLSurface read, - EGLContext ctx) { - return driver_->fn.eglMakeCurrentFn(dpy, draw, read, ctx); -} - -EGLBoolean EGLApiBase::eglPostSubBufferNVFn(EGLDisplay dpy, - EGLSurface surface, - EGLint x, - EGLint y, - EGLint width, - EGLint height) { - return driver_->fn.eglPostSubBufferNVFn(dpy, surface, x, y, width, height); -} - -EGLenum EGLApiBase::eglQueryAPIFn(void) { - return driver_->fn.eglQueryAPIFn(); -} - -EGLBoolean EGLApiBase::eglQueryContextFn(EGLDisplay dpy, - EGLContext ctx, - EGLint attribute, - EGLint* value) { - return driver_->fn.eglQueryContextFn(dpy, ctx, attribute, value); -} - -const char* EGLApiBase::eglQueryStringFn(EGLDisplay dpy, EGLint name) { - return driver_->fn.eglQueryStringFn(dpy, name); -} - -EGLBoolean EGLApiBase::eglQuerySurfaceFn(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint* value) { - return driver_->fn.eglQuerySurfaceFn(dpy, surface, attribute, value); -} - -EGLBoolean EGLApiBase::eglQuerySurfacePointerANGLEFn(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - void** value) { - return driver_->fn.eglQuerySurfacePointerANGLEFn(dpy, surface, attribute, - value); -} - -EGLBoolean EGLApiBase::eglReleaseTexImageFn(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer) { - return driver_->fn.eglReleaseTexImageFn(dpy, surface, buffer); -} - -EGLBoolean EGLApiBase::eglReleaseThreadFn(void) { - return driver_->fn.eglReleaseThreadFn(); -} - -EGLBoolean EGLApiBase::eglSurfaceAttribFn(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint value) { - return driver_->fn.eglSurfaceAttribFn(dpy, surface, attribute, value); -} - -EGLBoolean EGLApiBase::eglSwapBuffersFn(EGLDisplay dpy, EGLSurface surface) { - return driver_->fn.eglSwapBuffersFn(dpy, surface); -} - -EGLBoolean EGLApiBase::eglSwapIntervalFn(EGLDisplay dpy, EGLint interval) { - return driver_->fn.eglSwapIntervalFn(dpy, interval); -} - -EGLBoolean EGLApiBase::eglTerminateFn(EGLDisplay dpy) { - return driver_->fn.eglTerminateFn(dpy); -} - -EGLBoolean EGLApiBase::eglWaitClientFn(void) { - return driver_->fn.eglWaitClientFn(); -} - -EGLBoolean EGLApiBase::eglWaitGLFn(void) { - return driver_->fn.eglWaitGLFn(); -} - -EGLBoolean EGLApiBase::eglWaitNativeFn(EGLint engine) { - return driver_->fn.eglWaitNativeFn(engine); -} - -EGLint EGLApiBase::eglWaitSyncKHRFn(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint flags) { - return driver_->fn.eglWaitSyncKHRFn(dpy, sync, flags); -} - -EGLBoolean TraceEGLApi::eglBindAPIFn(EGLenum api) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglBindAPI") - return egl_api_->eglBindAPIFn(api); -} - -EGLBoolean TraceEGLApi::eglBindTexImageFn(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglBindTexImage") - return egl_api_->eglBindTexImageFn(dpy, surface, buffer); -} - -EGLBoolean TraceEGLApi::eglChooseConfigFn(EGLDisplay dpy, - const EGLint* attrib_list, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglChooseConfig") - return egl_api_->eglChooseConfigFn(dpy, attrib_list, configs, config_size, - num_config); -} - -EGLint TraceEGLApi::eglClientWaitSyncKHRFn(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint flags, - EGLTimeKHR timeout) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglClientWaitSyncKHR") - return egl_api_->eglClientWaitSyncKHRFn(dpy, sync, flags, timeout); -} - -EGLBoolean TraceEGLApi::eglCopyBuffersFn(EGLDisplay dpy, - EGLSurface surface, - EGLNativePixmapType target) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglCopyBuffers") - return egl_api_->eglCopyBuffersFn(dpy, surface, target); -} - -EGLContext TraceEGLApi::eglCreateContextFn(EGLDisplay dpy, - EGLConfig config, - EGLContext share_context, - const EGLint* attrib_list) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglCreateContext") - return egl_api_->eglCreateContextFn(dpy, config, share_context, attrib_list); -} - -EGLImageKHR TraceEGLApi::eglCreateImageKHRFn(EGLDisplay dpy, - EGLContext ctx, - EGLenum target, - EGLClientBuffer buffer, - const EGLint* attrib_list) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglCreateImageKHR") - return egl_api_->eglCreateImageKHRFn(dpy, ctx, target, buffer, attrib_list); -} - -EGLSurface TraceEGLApi::eglCreatePbufferFromClientBufferFn( - EGLDisplay dpy, - EGLenum buftype, - void* buffer, - EGLConfig config, - const EGLint* attrib_list) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", - "TraceGLAPI::eglCreatePbufferFromClientBuffer") - return egl_api_->eglCreatePbufferFromClientBufferFn(dpy, buftype, buffer, - config, attrib_list); -} - -EGLSurface TraceEGLApi::eglCreatePbufferSurfaceFn(EGLDisplay dpy, - EGLConfig config, - const EGLint* attrib_list) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglCreatePbufferSurface") - return egl_api_->eglCreatePbufferSurfaceFn(dpy, config, attrib_list); -} - -EGLSurface TraceEGLApi::eglCreatePixmapSurfaceFn(EGLDisplay dpy, - EGLConfig config, - EGLNativePixmapType pixmap, - const EGLint* attrib_list) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglCreatePixmapSurface") - return egl_api_->eglCreatePixmapSurfaceFn(dpy, config, pixmap, attrib_list); -} - -EGLSyncKHR TraceEGLApi::eglCreateSyncKHRFn(EGLDisplay dpy, - EGLenum type, - const EGLint* attrib_list) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglCreateSyncKHR") - return egl_api_->eglCreateSyncKHRFn(dpy, type, attrib_list); -} - -EGLSurface TraceEGLApi::eglCreateWindowSurfaceFn(EGLDisplay dpy, - EGLConfig config, - EGLNativeWindowType win, - const EGLint* attrib_list) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglCreateWindowSurface") - return egl_api_->eglCreateWindowSurfaceFn(dpy, config, win, attrib_list); -} - -EGLBoolean TraceEGLApi::eglDestroyContextFn(EGLDisplay dpy, EGLContext ctx) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglDestroyContext") - return egl_api_->eglDestroyContextFn(dpy, ctx); -} - -EGLBoolean TraceEGLApi::eglDestroyImageKHRFn(EGLDisplay dpy, - EGLImageKHR image) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglDestroyImageKHR") - return egl_api_->eglDestroyImageKHRFn(dpy, image); -} - -EGLBoolean TraceEGLApi::eglDestroySurfaceFn(EGLDisplay dpy, - EGLSurface surface) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglDestroySurface") - return egl_api_->eglDestroySurfaceFn(dpy, surface); -} - -EGLBoolean TraceEGLApi::eglDestroySyncKHRFn(EGLDisplay dpy, EGLSyncKHR sync) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglDestroySyncKHR") - return egl_api_->eglDestroySyncKHRFn(dpy, sync); -} - -EGLBoolean TraceEGLApi::eglGetConfigAttribFn(EGLDisplay dpy, - EGLConfig config, - EGLint attribute, - EGLint* value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglGetConfigAttrib") - return egl_api_->eglGetConfigAttribFn(dpy, config, attribute, value); -} - -EGLBoolean TraceEGLApi::eglGetConfigsFn(EGLDisplay dpy, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglGetConfigs") - return egl_api_->eglGetConfigsFn(dpy, configs, config_size, num_config); -} - -EGLContext TraceEGLApi::eglGetCurrentContextFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglGetCurrentContext") - return egl_api_->eglGetCurrentContextFn(); -} - -EGLDisplay TraceEGLApi::eglGetCurrentDisplayFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglGetCurrentDisplay") - return egl_api_->eglGetCurrentDisplayFn(); -} - -EGLSurface TraceEGLApi::eglGetCurrentSurfaceFn(EGLint readdraw) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglGetCurrentSurface") - return egl_api_->eglGetCurrentSurfaceFn(readdraw); -} - -EGLDisplay TraceEGLApi::eglGetDisplayFn(EGLNativeDisplayType display_id) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglGetDisplay") - return egl_api_->eglGetDisplayFn(display_id); -} - -EGLint TraceEGLApi::eglGetErrorFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglGetError") - return egl_api_->eglGetErrorFn(); -} - -EGLDisplay TraceEGLApi::eglGetPlatformDisplayEXTFn(EGLenum platform, - void* native_display, - const EGLint* attrib_list) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglGetPlatformDisplayEXT") - return egl_api_->eglGetPlatformDisplayEXTFn(platform, native_display, - attrib_list); -} - -__eglMustCastToProperFunctionPointerType TraceEGLApi::eglGetProcAddressFn( - const char* procname) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglGetProcAddress") - return egl_api_->eglGetProcAddressFn(procname); -} - -EGLBoolean TraceEGLApi::eglGetSyncAttribKHRFn(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint attribute, - EGLint* value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglGetSyncAttribKHR") - return egl_api_->eglGetSyncAttribKHRFn(dpy, sync, attribute, value); -} - -EGLBoolean TraceEGLApi::eglGetSyncValuesCHROMIUMFn(EGLDisplay dpy, - EGLSurface surface, - EGLuint64CHROMIUM* ust, - EGLuint64CHROMIUM* msc, - EGLuint64CHROMIUM* sbc) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglGetSyncValuesCHROMIUM") - return egl_api_->eglGetSyncValuesCHROMIUMFn(dpy, surface, ust, msc, sbc); -} - -EGLBoolean TraceEGLApi::eglInitializeFn(EGLDisplay dpy, - EGLint* major, - EGLint* minor) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglInitialize") - return egl_api_->eglInitializeFn(dpy, major, minor); -} - -EGLBoolean TraceEGLApi::eglMakeCurrentFn(EGLDisplay dpy, - EGLSurface draw, - EGLSurface read, - EGLContext ctx) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglMakeCurrent") - return egl_api_->eglMakeCurrentFn(dpy, draw, read, ctx); -} - -EGLBoolean TraceEGLApi::eglPostSubBufferNVFn(EGLDisplay dpy, - EGLSurface surface, - EGLint x, - EGLint y, - EGLint width, - EGLint height) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglPostSubBufferNV") - return egl_api_->eglPostSubBufferNVFn(dpy, surface, x, y, width, height); -} - -EGLenum TraceEGLApi::eglQueryAPIFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglQueryAPI") - return egl_api_->eglQueryAPIFn(); -} - -EGLBoolean TraceEGLApi::eglQueryContextFn(EGLDisplay dpy, - EGLContext ctx, - EGLint attribute, - EGLint* value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglQueryContext") - return egl_api_->eglQueryContextFn(dpy, ctx, attribute, value); -} - -const char* TraceEGLApi::eglQueryStringFn(EGLDisplay dpy, EGLint name) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglQueryString") - return egl_api_->eglQueryStringFn(dpy, name); -} - -EGLBoolean TraceEGLApi::eglQuerySurfaceFn(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint* value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglQuerySurface") - return egl_api_->eglQuerySurfaceFn(dpy, surface, attribute, value); -} - -EGLBoolean TraceEGLApi::eglQuerySurfacePointerANGLEFn(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - void** value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", - "TraceGLAPI::eglQuerySurfacePointerANGLE") - return egl_api_->eglQuerySurfacePointerANGLEFn(dpy, surface, attribute, - value); -} - -EGLBoolean TraceEGLApi::eglReleaseTexImageFn(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglReleaseTexImage") - return egl_api_->eglReleaseTexImageFn(dpy, surface, buffer); -} - -EGLBoolean TraceEGLApi::eglReleaseThreadFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglReleaseThread") - return egl_api_->eglReleaseThreadFn(); -} - -EGLBoolean TraceEGLApi::eglSurfaceAttribFn(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglSurfaceAttrib") - return egl_api_->eglSurfaceAttribFn(dpy, surface, attribute, value); -} - -EGLBoolean TraceEGLApi::eglSwapBuffersFn(EGLDisplay dpy, EGLSurface surface) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglSwapBuffers") - return egl_api_->eglSwapBuffersFn(dpy, surface); -} - -EGLBoolean TraceEGLApi::eglSwapIntervalFn(EGLDisplay dpy, EGLint interval) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglSwapInterval") - return egl_api_->eglSwapIntervalFn(dpy, interval); -} - -EGLBoolean TraceEGLApi::eglTerminateFn(EGLDisplay dpy) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglTerminate") - return egl_api_->eglTerminateFn(dpy); -} - -EGLBoolean TraceEGLApi::eglWaitClientFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglWaitClient") - return egl_api_->eglWaitClientFn(); -} - -EGLBoolean TraceEGLApi::eglWaitGLFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglWaitGL") - return egl_api_->eglWaitGLFn(); -} - -EGLBoolean TraceEGLApi::eglWaitNativeFn(EGLint engine) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglWaitNative") - return egl_api_->eglWaitNativeFn(engine); -} - -EGLint TraceEGLApi::eglWaitSyncKHRFn(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint flags) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::eglWaitSyncKHR") - return egl_api_->eglWaitSyncKHRFn(dpy, sync, flags); -} - -} // namespace gfx diff --git a/ui/gl/gl_bindings_autogen_egl.h b/ui/gl/gl_bindings_autogen_egl.h deleted file mode 100644 index f184b6a22..000000000 --- a/ui/gl/gl_bindings_autogen_egl.h +++ /dev/null @@ -1,409 +0,0 @@ -// Copyright 2014 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 is auto-generated from -// ui/gl/generate_bindings.py -// It's formatted by clang-format using chromium coding style: -// clang-format -i -style=chromium filename -// DO NOT EDIT! - -#ifndef UI_GFX_GL_GL_BINDINGS_AUTOGEN_EGL_H_ -#define UI_GFX_GL_GL_BINDINGS_AUTOGEN_EGL_H_ - -namespace gfx { - -class GLContext; - -typedef EGLBoolean(GL_BINDING_CALL* eglBindAPIProc)(EGLenum api); -typedef EGLBoolean(GL_BINDING_CALL* eglBindTexImageProc)(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer); -typedef EGLBoolean(GL_BINDING_CALL* eglChooseConfigProc)( - EGLDisplay dpy, - const EGLint* attrib_list, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config); -typedef EGLint(GL_BINDING_CALL* eglClientWaitSyncKHRProc)(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint flags, - EGLTimeKHR timeout); -typedef EGLBoolean(GL_BINDING_CALL* eglCopyBuffersProc)( - EGLDisplay dpy, - EGLSurface surface, - EGLNativePixmapType target); -typedef EGLContext(GL_BINDING_CALL* eglCreateContextProc)( - EGLDisplay dpy, - EGLConfig config, - EGLContext share_context, - const EGLint* attrib_list); -typedef EGLImageKHR(GL_BINDING_CALL* eglCreateImageKHRProc)( - EGLDisplay dpy, - EGLContext ctx, - EGLenum target, - EGLClientBuffer buffer, - const EGLint* attrib_list); -typedef EGLSurface(GL_BINDING_CALL* eglCreatePbufferFromClientBufferProc)( - EGLDisplay dpy, - EGLenum buftype, - void* buffer, - EGLConfig config, - const EGLint* attrib_list); -typedef EGLSurface(GL_BINDING_CALL* eglCreatePbufferSurfaceProc)( - EGLDisplay dpy, - EGLConfig config, - const EGLint* attrib_list); -typedef EGLSurface(GL_BINDING_CALL* eglCreatePixmapSurfaceProc)( - EGLDisplay dpy, - EGLConfig config, - EGLNativePixmapType pixmap, - const EGLint* attrib_list); -typedef EGLSyncKHR(GL_BINDING_CALL* eglCreateSyncKHRProc)( - EGLDisplay dpy, - EGLenum type, - const EGLint* attrib_list); -typedef EGLSurface(GL_BINDING_CALL* eglCreateWindowSurfaceProc)( - EGLDisplay dpy, - EGLConfig config, - EGLNativeWindowType win, - const EGLint* attrib_list); -typedef EGLBoolean(GL_BINDING_CALL* eglDestroyContextProc)(EGLDisplay dpy, - EGLContext ctx); -typedef EGLBoolean(GL_BINDING_CALL* eglDestroyImageKHRProc)(EGLDisplay dpy, - EGLImageKHR image); -typedef EGLBoolean(GL_BINDING_CALL* eglDestroySurfaceProc)(EGLDisplay dpy, - EGLSurface surface); -typedef EGLBoolean(GL_BINDING_CALL* eglDestroySyncKHRProc)(EGLDisplay dpy, - EGLSyncKHR sync); -typedef EGLBoolean(GL_BINDING_CALL* eglGetConfigAttribProc)(EGLDisplay dpy, - EGLConfig config, - EGLint attribute, - EGLint* value); -typedef EGLBoolean(GL_BINDING_CALL* eglGetConfigsProc)(EGLDisplay dpy, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config); -typedef EGLContext(GL_BINDING_CALL* eglGetCurrentContextProc)(void); -typedef EGLDisplay(GL_BINDING_CALL* eglGetCurrentDisplayProc)(void); -typedef EGLSurface(GL_BINDING_CALL* eglGetCurrentSurfaceProc)(EGLint readdraw); -typedef EGLDisplay(GL_BINDING_CALL* eglGetDisplayProc)( - EGLNativeDisplayType display_id); -typedef EGLint(GL_BINDING_CALL* eglGetErrorProc)(void); -typedef EGLDisplay(GL_BINDING_CALL* eglGetPlatformDisplayEXTProc)( - EGLenum platform, - void* native_display, - const EGLint* attrib_list); -typedef __eglMustCastToProperFunctionPointerType( - GL_BINDING_CALL* eglGetProcAddressProc)(const char* procname); -typedef EGLBoolean(GL_BINDING_CALL* eglGetSyncAttribKHRProc)(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint attribute, - EGLint* value); -typedef EGLBoolean(GL_BINDING_CALL* eglGetSyncValuesCHROMIUMProc)( - EGLDisplay dpy, - EGLSurface surface, - EGLuint64CHROMIUM* ust, - EGLuint64CHROMIUM* msc, - EGLuint64CHROMIUM* sbc); -typedef EGLBoolean(GL_BINDING_CALL* eglInitializeProc)(EGLDisplay dpy, - EGLint* major, - EGLint* minor); -typedef EGLBoolean(GL_BINDING_CALL* eglMakeCurrentProc)(EGLDisplay dpy, - EGLSurface draw, - EGLSurface read, - EGLContext ctx); -typedef EGLBoolean(GL_BINDING_CALL* eglPostSubBufferNVProc)(EGLDisplay dpy, - EGLSurface surface, - EGLint x, - EGLint y, - EGLint width, - EGLint height); -typedef EGLenum(GL_BINDING_CALL* eglQueryAPIProc)(void); -typedef EGLBoolean(GL_BINDING_CALL* eglQueryContextProc)(EGLDisplay dpy, - EGLContext ctx, - EGLint attribute, - EGLint* value); -typedef const char*(GL_BINDING_CALL* eglQueryStringProc)(EGLDisplay dpy, - EGLint name); -typedef EGLBoolean(GL_BINDING_CALL* eglQuerySurfaceProc)(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint* value); -typedef EGLBoolean(GL_BINDING_CALL* eglQuerySurfacePointerANGLEProc)( - EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - void** value); -typedef EGLBoolean(GL_BINDING_CALL* eglReleaseTexImageProc)(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer); -typedef EGLBoolean(GL_BINDING_CALL* eglReleaseThreadProc)(void); -typedef EGLBoolean(GL_BINDING_CALL* eglSurfaceAttribProc)(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint value); -typedef EGLBoolean(GL_BINDING_CALL* eglSwapBuffersProc)(EGLDisplay dpy, - EGLSurface surface); -typedef EGLBoolean(GL_BINDING_CALL* eglSwapIntervalProc)(EGLDisplay dpy, - EGLint interval); -typedef EGLBoolean(GL_BINDING_CALL* eglTerminateProc)(EGLDisplay dpy); -typedef EGLBoolean(GL_BINDING_CALL* eglWaitClientProc)(void); -typedef EGLBoolean(GL_BINDING_CALL* eglWaitGLProc)(void); -typedef EGLBoolean(GL_BINDING_CALL* eglWaitNativeProc)(EGLint engine); -typedef EGLint(GL_BINDING_CALL* eglWaitSyncKHRProc)(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint flags); - -struct ExtensionsEGL { - bool b_EGL_ANGLE_d3d_share_handle_client_buffer; - bool b_EGL_ANGLE_platform_angle; - bool b_EGL_ANGLE_query_surface_pointer; - bool b_EGL_ANGLE_surface_d3d_texture_2d_share_handle; - bool b_EGL_CHROMIUM_sync_control; - bool b_EGL_KHR_fence_sync; - bool b_EGL_KHR_gl_texture_2D_image; - bool b_EGL_KHR_image; - bool b_EGL_KHR_image_base; - bool b_EGL_KHR_reusable_sync; - bool b_EGL_KHR_wait_sync; - bool b_EGL_NV_post_sub_buffer; -}; - -struct ProcsEGL { - eglBindAPIProc eglBindAPIFn; - eglBindTexImageProc eglBindTexImageFn; - eglChooseConfigProc eglChooseConfigFn; - eglClientWaitSyncKHRProc eglClientWaitSyncKHRFn; - eglCopyBuffersProc eglCopyBuffersFn; - eglCreateContextProc eglCreateContextFn; - eglCreateImageKHRProc eglCreateImageKHRFn; - eglCreatePbufferFromClientBufferProc eglCreatePbufferFromClientBufferFn; - eglCreatePbufferSurfaceProc eglCreatePbufferSurfaceFn; - eglCreatePixmapSurfaceProc eglCreatePixmapSurfaceFn; - eglCreateSyncKHRProc eglCreateSyncKHRFn; - eglCreateWindowSurfaceProc eglCreateWindowSurfaceFn; - eglDestroyContextProc eglDestroyContextFn; - eglDestroyImageKHRProc eglDestroyImageKHRFn; - eglDestroySurfaceProc eglDestroySurfaceFn; - eglDestroySyncKHRProc eglDestroySyncKHRFn; - eglGetConfigAttribProc eglGetConfigAttribFn; - eglGetConfigsProc eglGetConfigsFn; - eglGetCurrentContextProc eglGetCurrentContextFn; - eglGetCurrentDisplayProc eglGetCurrentDisplayFn; - eglGetCurrentSurfaceProc eglGetCurrentSurfaceFn; - eglGetDisplayProc eglGetDisplayFn; - eglGetErrorProc eglGetErrorFn; - eglGetPlatformDisplayEXTProc eglGetPlatformDisplayEXTFn; - eglGetProcAddressProc eglGetProcAddressFn; - eglGetSyncAttribKHRProc eglGetSyncAttribKHRFn; - eglGetSyncValuesCHROMIUMProc eglGetSyncValuesCHROMIUMFn; - eglInitializeProc eglInitializeFn; - eglMakeCurrentProc eglMakeCurrentFn; - eglPostSubBufferNVProc eglPostSubBufferNVFn; - eglQueryAPIProc eglQueryAPIFn; - eglQueryContextProc eglQueryContextFn; - eglQueryStringProc eglQueryStringFn; - eglQuerySurfaceProc eglQuerySurfaceFn; - eglQuerySurfacePointerANGLEProc eglQuerySurfacePointerANGLEFn; - eglReleaseTexImageProc eglReleaseTexImageFn; - eglReleaseThreadProc eglReleaseThreadFn; - eglSurfaceAttribProc eglSurfaceAttribFn; - eglSwapBuffersProc eglSwapBuffersFn; - eglSwapIntervalProc eglSwapIntervalFn; - eglTerminateProc eglTerminateFn; - eglWaitClientProc eglWaitClientFn; - eglWaitGLProc eglWaitGLFn; - eglWaitNativeProc eglWaitNativeFn; - eglWaitSyncKHRProc eglWaitSyncKHRFn; -}; - -class GL_EXPORT EGLApi { - public: - EGLApi(); - virtual ~EGLApi(); - - virtual EGLBoolean eglBindAPIFn(EGLenum api) = 0; - virtual EGLBoolean eglBindTexImageFn(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer) = 0; - virtual EGLBoolean eglChooseConfigFn(EGLDisplay dpy, - const EGLint* attrib_list, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config) = 0; - virtual EGLint eglClientWaitSyncKHRFn(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint flags, - EGLTimeKHR timeout) = 0; - virtual EGLBoolean eglCopyBuffersFn(EGLDisplay dpy, - EGLSurface surface, - EGLNativePixmapType target) = 0; - virtual EGLContext eglCreateContextFn(EGLDisplay dpy, - EGLConfig config, - EGLContext share_context, - const EGLint* attrib_list) = 0; - virtual EGLImageKHR eglCreateImageKHRFn(EGLDisplay dpy, - EGLContext ctx, - EGLenum target, - EGLClientBuffer buffer, - const EGLint* attrib_list) = 0; - virtual EGLSurface eglCreatePbufferFromClientBufferFn( - EGLDisplay dpy, - EGLenum buftype, - void* buffer, - EGLConfig config, - const EGLint* attrib_list) = 0; - virtual EGLSurface eglCreatePbufferSurfaceFn(EGLDisplay dpy, - EGLConfig config, - const EGLint* attrib_list) = 0; - virtual EGLSurface eglCreatePixmapSurfaceFn(EGLDisplay dpy, - EGLConfig config, - EGLNativePixmapType pixmap, - const EGLint* attrib_list) = 0; - virtual EGLSyncKHR eglCreateSyncKHRFn(EGLDisplay dpy, - EGLenum type, - const EGLint* attrib_list) = 0; - virtual EGLSurface eglCreateWindowSurfaceFn(EGLDisplay dpy, - EGLConfig config, - EGLNativeWindowType win, - const EGLint* attrib_list) = 0; - virtual EGLBoolean eglDestroyContextFn(EGLDisplay dpy, EGLContext ctx) = 0; - virtual EGLBoolean eglDestroyImageKHRFn(EGLDisplay dpy, - EGLImageKHR image) = 0; - virtual EGLBoolean eglDestroySurfaceFn(EGLDisplay dpy, - EGLSurface surface) = 0; - virtual EGLBoolean eglDestroySyncKHRFn(EGLDisplay dpy, EGLSyncKHR sync) = 0; - virtual EGLBoolean eglGetConfigAttribFn(EGLDisplay dpy, - EGLConfig config, - EGLint attribute, - EGLint* value) = 0; - virtual EGLBoolean eglGetConfigsFn(EGLDisplay dpy, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config) = 0; - virtual EGLContext eglGetCurrentContextFn(void) = 0; - virtual EGLDisplay eglGetCurrentDisplayFn(void) = 0; - virtual EGLSurface eglGetCurrentSurfaceFn(EGLint readdraw) = 0; - virtual EGLDisplay eglGetDisplayFn(EGLNativeDisplayType display_id) = 0; - virtual EGLint eglGetErrorFn(void) = 0; - virtual EGLDisplay eglGetPlatformDisplayEXTFn(EGLenum platform, - void* native_display, - const EGLint* attrib_list) = 0; - virtual __eglMustCastToProperFunctionPointerType eglGetProcAddressFn( - const char* procname) = 0; - virtual EGLBoolean eglGetSyncAttribKHRFn(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint attribute, - EGLint* value) = 0; - virtual EGLBoolean eglGetSyncValuesCHROMIUMFn(EGLDisplay dpy, - EGLSurface surface, - EGLuint64CHROMIUM* ust, - EGLuint64CHROMIUM* msc, - EGLuint64CHROMIUM* sbc) = 0; - virtual EGLBoolean eglInitializeFn(EGLDisplay dpy, - EGLint* major, - EGLint* minor) = 0; - virtual EGLBoolean eglMakeCurrentFn(EGLDisplay dpy, - EGLSurface draw, - EGLSurface read, - EGLContext ctx) = 0; - virtual EGLBoolean eglPostSubBufferNVFn(EGLDisplay dpy, - EGLSurface surface, - EGLint x, - EGLint y, - EGLint width, - EGLint height) = 0; - virtual EGLenum eglQueryAPIFn(void) = 0; - virtual EGLBoolean eglQueryContextFn(EGLDisplay dpy, - EGLContext ctx, - EGLint attribute, - EGLint* value) = 0; - virtual const char* eglQueryStringFn(EGLDisplay dpy, EGLint name) = 0; - virtual EGLBoolean eglQuerySurfaceFn(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint* value) = 0; - virtual EGLBoolean eglQuerySurfacePointerANGLEFn(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - void** value) = 0; - virtual EGLBoolean eglReleaseTexImageFn(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer) = 0; - virtual EGLBoolean eglReleaseThreadFn(void) = 0; - virtual EGLBoolean eglSurfaceAttribFn(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint value) = 0; - virtual EGLBoolean eglSwapBuffersFn(EGLDisplay dpy, EGLSurface surface) = 0; - virtual EGLBoolean eglSwapIntervalFn(EGLDisplay dpy, EGLint interval) = 0; - virtual EGLBoolean eglTerminateFn(EGLDisplay dpy) = 0; - virtual EGLBoolean eglWaitClientFn(void) = 0; - virtual EGLBoolean eglWaitGLFn(void) = 0; - virtual EGLBoolean eglWaitNativeFn(EGLint engine) = 0; - virtual EGLint eglWaitSyncKHRFn(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint flags) = 0; -}; - -} // namespace gfx - -#define eglBindAPI ::gfx::g_current_egl_context->eglBindAPIFn -#define eglBindTexImage ::gfx::g_current_egl_context->eglBindTexImageFn -#define eglChooseConfig ::gfx::g_current_egl_context->eglChooseConfigFn -#define eglClientWaitSyncKHR \ - ::gfx::g_current_egl_context->eglClientWaitSyncKHRFn -#define eglCopyBuffers ::gfx::g_current_egl_context->eglCopyBuffersFn -#define eglCreateContext ::gfx::g_current_egl_context->eglCreateContextFn -#define eglCreateImageKHR ::gfx::g_current_egl_context->eglCreateImageKHRFn -#define eglCreatePbufferFromClientBuffer \ - ::gfx::g_current_egl_context->eglCreatePbufferFromClientBufferFn -#define eglCreatePbufferSurface \ - ::gfx::g_current_egl_context->eglCreatePbufferSurfaceFn -#define eglCreatePixmapSurface \ - ::gfx::g_current_egl_context->eglCreatePixmapSurfaceFn -#define eglCreateSyncKHR ::gfx::g_current_egl_context->eglCreateSyncKHRFn -#define eglCreateWindowSurface \ - ::gfx::g_current_egl_context->eglCreateWindowSurfaceFn -#define eglDestroyContext ::gfx::g_current_egl_context->eglDestroyContextFn -#define eglDestroyImageKHR ::gfx::g_current_egl_context->eglDestroyImageKHRFn -#define eglDestroySurface ::gfx::g_current_egl_context->eglDestroySurfaceFn -#define eglDestroySyncKHR ::gfx::g_current_egl_context->eglDestroySyncKHRFn -#define eglGetConfigAttrib ::gfx::g_current_egl_context->eglGetConfigAttribFn -#define eglGetConfigs ::gfx::g_current_egl_context->eglGetConfigsFn -#define eglGetCurrentContext \ - ::gfx::g_current_egl_context->eglGetCurrentContextFn -#define eglGetCurrentDisplay \ - ::gfx::g_current_egl_context->eglGetCurrentDisplayFn -#define eglGetCurrentSurface \ - ::gfx::g_current_egl_context->eglGetCurrentSurfaceFn -#define eglGetDisplay ::gfx::g_current_egl_context->eglGetDisplayFn -#define eglGetError ::gfx::g_current_egl_context->eglGetErrorFn -#define eglGetPlatformDisplayEXT \ - ::gfx::g_current_egl_context->eglGetPlatformDisplayEXTFn -#define eglGetProcAddress ::gfx::g_current_egl_context->eglGetProcAddressFn -#define eglGetSyncAttribKHR ::gfx::g_current_egl_context->eglGetSyncAttribKHRFn -#define eglGetSyncValuesCHROMIUM \ - ::gfx::g_current_egl_context->eglGetSyncValuesCHROMIUMFn -#define eglInitialize ::gfx::g_current_egl_context->eglInitializeFn -#define eglMakeCurrent ::gfx::g_current_egl_context->eglMakeCurrentFn -#define eglPostSubBufferNV ::gfx::g_current_egl_context->eglPostSubBufferNVFn -#define eglQueryAPI ::gfx::g_current_egl_context->eglQueryAPIFn -#define eglQueryContext ::gfx::g_current_egl_context->eglQueryContextFn -#define eglQueryString ::gfx::g_current_egl_context->eglQueryStringFn -#define eglQuerySurface ::gfx::g_current_egl_context->eglQuerySurfaceFn -#define eglQuerySurfacePointerANGLE \ - ::gfx::g_current_egl_context->eglQuerySurfacePointerANGLEFn -#define eglReleaseTexImage ::gfx::g_current_egl_context->eglReleaseTexImageFn -#define eglReleaseThread ::gfx::g_current_egl_context->eglReleaseThreadFn -#define eglSurfaceAttrib ::gfx::g_current_egl_context->eglSurfaceAttribFn -#define eglSwapBuffers ::gfx::g_current_egl_context->eglSwapBuffersFn -#define eglSwapInterval ::gfx::g_current_egl_context->eglSwapIntervalFn -#define eglTerminate ::gfx::g_current_egl_context->eglTerminateFn -#define eglWaitClient ::gfx::g_current_egl_context->eglWaitClientFn -#define eglWaitGL ::gfx::g_current_egl_context->eglWaitGLFn -#define eglWaitNative ::gfx::g_current_egl_context->eglWaitNativeFn -#define eglWaitSyncKHR ::gfx::g_current_egl_context->eglWaitSyncKHRFn - -#endif // UI_GFX_GL_GL_BINDINGS_AUTOGEN_EGL_H_ diff --git a/ui/gl/gl_bindings_autogen_gl.cc b/ui/gl/gl_bindings_autogen_gl.cc deleted file mode 100644 index 8581779d2..000000000 --- a/ui/gl/gl_bindings_autogen_gl.cc +++ /dev/null @@ -1,12194 +0,0 @@ -// Copyright 2014 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 is auto-generated from -// ui/gl/generate_bindings.py -// It's formatted by clang-format using chromium coding style: -// clang-format -i -style=chromium filename -// DO NOT EDIT! - -#include - -#include "base/trace_event/trace_event.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_enums.h" -#include "ui/gl/gl_gl_api_implementation.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_version_info.h" - -namespace gfx { - -static bool g_debugBindingsInitialized; -DriverGL g_driver_gl; - -void DriverGL::InitializeStaticBindings() { - fn.glActiveTextureFn = reinterpret_cast( - GetGLProcAddress("glActiveTexture")); - fn.glAttachShaderFn = - reinterpret_cast(GetGLProcAddress("glAttachShader")); - fn.glBeginQueryFn = 0; - fn.glBeginTransformFeedbackFn = 0; - fn.glBindAttribLocationFn = reinterpret_cast( - GetGLProcAddress("glBindAttribLocation")); - fn.glBindBufferFn = - reinterpret_cast(GetGLProcAddress("glBindBuffer")); - fn.glBindBufferBaseFn = 0; - fn.glBindBufferRangeFn = 0; - fn.glBindFragDataLocationFn = 0; - fn.glBindFragDataLocationIndexedFn = 0; - fn.glBindFramebufferEXTFn = 0; - fn.glBindRenderbufferEXTFn = 0; - fn.glBindSamplerFn = 0; - fn.glBindTextureFn = - reinterpret_cast(GetGLProcAddress("glBindTexture")); - fn.glBindTransformFeedbackFn = 0; - fn.glBindVertexArrayOESFn = 0; - fn.glBlendBarrierKHRFn = 0; - fn.glBlendColorFn = - reinterpret_cast(GetGLProcAddress("glBlendColor")); - fn.glBlendEquationFn = reinterpret_cast( - GetGLProcAddress("glBlendEquation")); - fn.glBlendEquationSeparateFn = reinterpret_cast( - GetGLProcAddress("glBlendEquationSeparate")); - fn.glBlendFuncFn = - reinterpret_cast(GetGLProcAddress("glBlendFunc")); - fn.glBlendFuncSeparateFn = reinterpret_cast( - GetGLProcAddress("glBlendFuncSeparate")); - fn.glBlitFramebufferFn = 0; - fn.glBlitFramebufferANGLEFn = 0; - fn.glBlitFramebufferEXTFn = 0; - fn.glBufferDataFn = - reinterpret_cast(GetGLProcAddress("glBufferData")); - fn.glBufferSubDataFn = reinterpret_cast( - GetGLProcAddress("glBufferSubData")); - fn.glCheckFramebufferStatusEXTFn = 0; - fn.glClearFn = reinterpret_cast(GetGLProcAddress("glClear")); - fn.glClearBufferfiFn = 0; - fn.glClearBufferfvFn = 0; - fn.glClearBufferivFn = 0; - fn.glClearBufferuivFn = 0; - fn.glClearColorFn = - reinterpret_cast(GetGLProcAddress("glClearColor")); - fn.glClearDepthFn = - reinterpret_cast(GetGLProcAddress("glClearDepth")); - fn.glClearDepthfFn = 0; - fn.glClearStencilFn = - reinterpret_cast(GetGLProcAddress("glClearStencil")); - fn.glClientWaitSyncFn = 0; - fn.glColorMaskFn = - reinterpret_cast(GetGLProcAddress("glColorMask")); - fn.glCompileShaderFn = reinterpret_cast( - GetGLProcAddress("glCompileShader")); - fn.glCompressedTexImage2DFn = reinterpret_cast( - GetGLProcAddress("glCompressedTexImage2D")); - fn.glCompressedTexImage3DFn = 0; - fn.glCompressedTexSubImage2DFn = - reinterpret_cast( - GetGLProcAddress("glCompressedTexSubImage2D")); - fn.glCopyBufferSubDataFn = 0; - fn.glCopyTexImage2DFn = reinterpret_cast( - GetGLProcAddress("glCopyTexImage2D")); - fn.glCopyTexSubImage2DFn = reinterpret_cast( - GetGLProcAddress("glCopyTexSubImage2D")); - fn.glCopyTexSubImage3DFn = 0; - fn.glCreateProgramFn = reinterpret_cast( - GetGLProcAddress("glCreateProgram")); - fn.glCreateShaderFn = - reinterpret_cast(GetGLProcAddress("glCreateShader")); - fn.glCullFaceFn = - reinterpret_cast(GetGLProcAddress("glCullFace")); - fn.glDebugMessageCallbackKHRFn = 0; - fn.glDebugMessageControlKHRFn = 0; - fn.glDebugMessageInsertKHRFn = 0; - fn.glDeleteBuffersARBFn = reinterpret_cast( - GetGLProcAddress("glDeleteBuffers")); - fn.glDeleteFencesAPPLEFn = 0; - fn.glDeleteFencesNVFn = 0; - fn.glDeleteFramebuffersEXTFn = 0; - fn.glDeleteProgramFn = reinterpret_cast( - GetGLProcAddress("glDeleteProgram")); - fn.glDeleteQueriesFn = 0; - fn.glDeleteRenderbuffersEXTFn = 0; - fn.glDeleteSamplersFn = 0; - fn.glDeleteShaderFn = - reinterpret_cast(GetGLProcAddress("glDeleteShader")); - fn.glDeleteSyncFn = 0; - fn.glDeleteTexturesFn = reinterpret_cast( - GetGLProcAddress("glDeleteTextures")); - fn.glDeleteTransformFeedbacksFn = 0; - fn.glDeleteVertexArraysOESFn = 0; - fn.glDepthFuncFn = - reinterpret_cast(GetGLProcAddress("glDepthFunc")); - fn.glDepthMaskFn = - reinterpret_cast(GetGLProcAddress("glDepthMask")); - fn.glDepthRangeFn = - reinterpret_cast(GetGLProcAddress("glDepthRange")); - fn.glDepthRangefFn = 0; - fn.glDetachShaderFn = - reinterpret_cast(GetGLProcAddress("glDetachShader")); - fn.glDisableFn = - reinterpret_cast(GetGLProcAddress("glDisable")); - fn.glDisableVertexAttribArrayFn = - reinterpret_cast( - GetGLProcAddress("glDisableVertexAttribArray")); - fn.glDiscardFramebufferEXTFn = 0; - fn.glDrawArraysFn = - reinterpret_cast(GetGLProcAddress("glDrawArrays")); - fn.glDrawArraysInstancedANGLEFn = 0; - fn.glDrawBufferFn = 0; - fn.glDrawBuffersARBFn = 0; - fn.glDrawElementsFn = - reinterpret_cast(GetGLProcAddress("glDrawElements")); - fn.glDrawElementsInstancedANGLEFn = 0; - fn.glDrawRangeElementsFn = 0; - fn.glEGLImageTargetRenderbufferStorageOESFn = 0; - fn.glEGLImageTargetTexture2DOESFn = 0; - fn.glEnableFn = reinterpret_cast(GetGLProcAddress("glEnable")); - fn.glEnableVertexAttribArrayFn = - reinterpret_cast( - GetGLProcAddress("glEnableVertexAttribArray")); - fn.glEndQueryFn = 0; - fn.glEndTransformFeedbackFn = 0; - fn.glFenceSyncFn = 0; - fn.glFinishFn = reinterpret_cast(GetGLProcAddress("glFinish")); - fn.glFinishFenceAPPLEFn = 0; - fn.glFinishFenceNVFn = 0; - fn.glFlushFn = reinterpret_cast(GetGLProcAddress("glFlush")); - fn.glFlushMappedBufferRangeFn = 0; - fn.glFramebufferRenderbufferEXTFn = 0; - fn.glFramebufferTexture2DEXTFn = 0; - fn.glFramebufferTexture2DMultisampleEXTFn = 0; - fn.glFramebufferTexture2DMultisampleIMGFn = 0; - fn.glFramebufferTextureLayerFn = 0; - fn.glFrontFaceFn = - reinterpret_cast(GetGLProcAddress("glFrontFace")); - fn.glGenBuffersARBFn = - reinterpret_cast(GetGLProcAddress("glGenBuffers")); - fn.glGenerateMipmapEXTFn = 0; - fn.glGenFencesAPPLEFn = 0; - fn.glGenFencesNVFn = 0; - fn.glGenFramebuffersEXTFn = 0; - fn.glGenQueriesFn = 0; - fn.glGenRenderbuffersEXTFn = 0; - fn.glGenSamplersFn = 0; - fn.glGenTexturesFn = - reinterpret_cast(GetGLProcAddress("glGenTextures")); - fn.glGenTransformFeedbacksFn = 0; - fn.glGenVertexArraysOESFn = 0; - fn.glGetActiveAttribFn = reinterpret_cast( - GetGLProcAddress("glGetActiveAttrib")); - fn.glGetActiveUniformFn = reinterpret_cast( - GetGLProcAddress("glGetActiveUniform")); - fn.glGetActiveUniformBlockivFn = 0; - fn.glGetActiveUniformBlockNameFn = 0; - fn.glGetActiveUniformsivFn = 0; - fn.glGetAttachedShadersFn = reinterpret_cast( - GetGLProcAddress("glGetAttachedShaders")); - fn.glGetAttribLocationFn = reinterpret_cast( - GetGLProcAddress("glGetAttribLocation")); - fn.glGetBooleanvFn = - reinterpret_cast(GetGLProcAddress("glGetBooleanv")); - fn.glGetBufferParameterivFn = reinterpret_cast( - GetGLProcAddress("glGetBufferParameteriv")); - fn.glGetDebugMessageLogKHRFn = 0; - fn.glGetErrorFn = - reinterpret_cast(GetGLProcAddress("glGetError")); - fn.glGetFenceivNVFn = 0; - fn.glGetFloatvFn = - reinterpret_cast(GetGLProcAddress("glGetFloatv")); - fn.glGetFragDataLocationFn = 0; - fn.glGetFramebufferAttachmentParameterivEXTFn = 0; - fn.glGetGraphicsResetStatusARBFn = 0; - fn.glGetInteger64i_vFn = 0; - fn.glGetInteger64vFn = 0; - fn.glGetIntegeri_vFn = 0; - fn.glGetIntegervFn = - reinterpret_cast(GetGLProcAddress("glGetIntegerv")); - fn.glGetInternalformativFn = 0; - fn.glGetProgramBinaryFn = 0; - fn.glGetProgramInfoLogFn = reinterpret_cast( - GetGLProcAddress("glGetProgramInfoLog")); - fn.glGetProgramivFn = - reinterpret_cast(GetGLProcAddress("glGetProgramiv")); - fn.glGetProgramResourceLocationFn = 0; - fn.glGetQueryivFn = 0; - fn.glGetQueryObjecti64vFn = 0; - fn.glGetQueryObjectivFn = 0; - fn.glGetQueryObjectui64vFn = 0; - fn.glGetQueryObjectuivFn = 0; - fn.glGetRenderbufferParameterivEXTFn = 0; - fn.glGetSamplerParameterfvFn = 0; - fn.glGetSamplerParameterivFn = 0; - fn.glGetShaderInfoLogFn = reinterpret_cast( - GetGLProcAddress("glGetShaderInfoLog")); - fn.glGetShaderivFn = - reinterpret_cast(GetGLProcAddress("glGetShaderiv")); - fn.glGetShaderPrecisionFormatFn = 0; - fn.glGetShaderSourceFn = reinterpret_cast( - GetGLProcAddress("glGetShaderSource")); - fn.glGetStringFn = - reinterpret_cast(GetGLProcAddress("glGetString")); - fn.glGetStringiFn = 0; - fn.glGetSyncivFn = 0; - fn.glGetTexLevelParameterfvFn = 0; - fn.glGetTexLevelParameterivFn = 0; - fn.glGetTexParameterfvFn = reinterpret_cast( - GetGLProcAddress("glGetTexParameterfv")); - fn.glGetTexParameterivFn = reinterpret_cast( - GetGLProcAddress("glGetTexParameteriv")); - fn.glGetTransformFeedbackVaryingFn = 0; - fn.glGetTranslatedShaderSourceANGLEFn = 0; - fn.glGetUniformBlockIndexFn = 0; - fn.glGetUniformfvFn = - reinterpret_cast(GetGLProcAddress("glGetUniformfv")); - fn.glGetUniformIndicesFn = 0; - fn.glGetUniformivFn = - reinterpret_cast(GetGLProcAddress("glGetUniformiv")); - fn.glGetUniformLocationFn = reinterpret_cast( - GetGLProcAddress("glGetUniformLocation")); - fn.glGetVertexAttribfvFn = reinterpret_cast( - GetGLProcAddress("glGetVertexAttribfv")); - fn.glGetVertexAttribivFn = reinterpret_cast( - GetGLProcAddress("glGetVertexAttribiv")); - fn.glGetVertexAttribPointervFn = - reinterpret_cast( - GetGLProcAddress("glGetVertexAttribPointerv")); - fn.glHintFn = reinterpret_cast(GetGLProcAddress("glHint")); - fn.glInsertEventMarkerEXTFn = 0; - fn.glInvalidateFramebufferFn = 0; - fn.glInvalidateSubFramebufferFn = 0; - fn.glIsBufferFn = - reinterpret_cast(GetGLProcAddress("glIsBuffer")); - fn.glIsEnabledFn = - reinterpret_cast(GetGLProcAddress("glIsEnabled")); - fn.glIsFenceAPPLEFn = 0; - fn.glIsFenceNVFn = 0; - fn.glIsFramebufferEXTFn = 0; - fn.glIsProgramFn = - reinterpret_cast(GetGLProcAddress("glIsProgram")); - fn.glIsQueryFn = 0; - fn.glIsRenderbufferEXTFn = 0; - fn.glIsSamplerFn = 0; - fn.glIsShaderFn = - reinterpret_cast(GetGLProcAddress("glIsShader")); - fn.glIsSyncFn = 0; - fn.glIsTextureFn = - reinterpret_cast(GetGLProcAddress("glIsTexture")); - fn.glIsTransformFeedbackFn = 0; - fn.glIsVertexArrayOESFn = 0; - fn.glLineWidthFn = - reinterpret_cast(GetGLProcAddress("glLineWidth")); - fn.glLinkProgramFn = - reinterpret_cast(GetGLProcAddress("glLinkProgram")); - fn.glMapBufferFn = 0; - fn.glMapBufferRangeFn = 0; - fn.glMatrixLoadfEXTFn = 0; - fn.glMatrixLoadIdentityEXTFn = 0; - fn.glObjectLabelKHRFn = 0; - fn.glPauseTransformFeedbackFn = 0; - fn.glPixelStoreiFn = - reinterpret_cast(GetGLProcAddress("glPixelStorei")); - fn.glPointParameteriFn = 0; - fn.glPolygonOffsetFn = reinterpret_cast( - GetGLProcAddress("glPolygonOffset")); - fn.glPopDebugGroupKHRFn = 0; - fn.glPopGroupMarkerEXTFn = 0; - fn.glProgramBinaryFn = 0; - fn.glProgramParameteriFn = 0; - fn.glPushDebugGroupKHRFn = 0; - fn.glPushGroupMarkerEXTFn = 0; - fn.glQueryCounterFn = 0; - fn.glReadBufferFn = 0; - fn.glReadPixelsFn = - reinterpret_cast(GetGLProcAddress("glReadPixels")); - fn.glReleaseShaderCompilerFn = 0; - fn.glRenderbufferStorageEXTFn = 0; - fn.glRenderbufferStorageMultisampleFn = 0; - fn.glRenderbufferStorageMultisampleANGLEFn = 0; - fn.glRenderbufferStorageMultisampleAPPLEFn = 0; - fn.glRenderbufferStorageMultisampleEXTFn = 0; - fn.glRenderbufferStorageMultisampleIMGFn = 0; - fn.glResolveMultisampleFramebufferAPPLEFn = 0; - fn.glResumeTransformFeedbackFn = 0; - fn.glSampleCoverageFn = reinterpret_cast( - GetGLProcAddress("glSampleCoverage")); - fn.glSamplerParameterfFn = 0; - fn.glSamplerParameterfvFn = 0; - fn.glSamplerParameteriFn = 0; - fn.glSamplerParameterivFn = 0; - fn.glScissorFn = - reinterpret_cast(GetGLProcAddress("glScissor")); - fn.glSetFenceAPPLEFn = 0; - fn.glSetFenceNVFn = 0; - fn.glShaderBinaryFn = 0; - fn.glShaderSourceFn = - reinterpret_cast(GetGLProcAddress("glShaderSource")); - fn.glStencilFuncFn = - reinterpret_cast(GetGLProcAddress("glStencilFunc")); - fn.glStencilFuncSeparateFn = reinterpret_cast( - GetGLProcAddress("glStencilFuncSeparate")); - fn.glStencilMaskFn = - reinterpret_cast(GetGLProcAddress("glStencilMask")); - fn.glStencilMaskSeparateFn = reinterpret_cast( - GetGLProcAddress("glStencilMaskSeparate")); - fn.glStencilOpFn = - reinterpret_cast(GetGLProcAddress("glStencilOp")); - fn.glStencilOpSeparateFn = reinterpret_cast( - GetGLProcAddress("glStencilOpSeparate")); - fn.glTestFenceAPPLEFn = 0; - fn.glTestFenceNVFn = 0; - fn.glTexImage2DFn = - reinterpret_cast(GetGLProcAddress("glTexImage2D")); - fn.glTexImage3DFn = 0; - fn.glTexParameterfFn = reinterpret_cast( - GetGLProcAddress("glTexParameterf")); - fn.glTexParameterfvFn = reinterpret_cast( - GetGLProcAddress("glTexParameterfv")); - fn.glTexParameteriFn = reinterpret_cast( - GetGLProcAddress("glTexParameteri")); - fn.glTexParameterivFn = reinterpret_cast( - GetGLProcAddress("glTexParameteriv")); - fn.glTexStorage2DEXTFn = 0; - fn.glTexStorage3DFn = 0; - fn.glTexSubImage2DFn = reinterpret_cast( - GetGLProcAddress("glTexSubImage2D")); - fn.glTextureBarrierNVFn = 0; - fn.glTransformFeedbackVaryingsFn = 0; - fn.glUniform1fFn = - reinterpret_cast(GetGLProcAddress("glUniform1f")); - fn.glUniform1fvFn = - reinterpret_cast(GetGLProcAddress("glUniform1fv")); - fn.glUniform1iFn = - reinterpret_cast(GetGLProcAddress("glUniform1i")); - fn.glUniform1ivFn = - reinterpret_cast(GetGLProcAddress("glUniform1iv")); - fn.glUniform1uiFn = 0; - fn.glUniform1uivFn = 0; - fn.glUniform2fFn = - reinterpret_cast(GetGLProcAddress("glUniform2f")); - fn.glUniform2fvFn = - reinterpret_cast(GetGLProcAddress("glUniform2fv")); - fn.glUniform2iFn = - reinterpret_cast(GetGLProcAddress("glUniform2i")); - fn.glUniform2ivFn = - reinterpret_cast(GetGLProcAddress("glUniform2iv")); - fn.glUniform2uiFn = 0; - fn.glUniform2uivFn = 0; - fn.glUniform3fFn = - reinterpret_cast(GetGLProcAddress("glUniform3f")); - fn.glUniform3fvFn = - reinterpret_cast(GetGLProcAddress("glUniform3fv")); - fn.glUniform3iFn = - reinterpret_cast(GetGLProcAddress("glUniform3i")); - fn.glUniform3ivFn = - reinterpret_cast(GetGLProcAddress("glUniform3iv")); - fn.glUniform3uiFn = 0; - fn.glUniform3uivFn = 0; - fn.glUniform4fFn = - reinterpret_cast(GetGLProcAddress("glUniform4f")); - fn.glUniform4fvFn = - reinterpret_cast(GetGLProcAddress("glUniform4fv")); - fn.glUniform4iFn = - reinterpret_cast(GetGLProcAddress("glUniform4i")); - fn.glUniform4ivFn = - reinterpret_cast(GetGLProcAddress("glUniform4iv")); - fn.glUniform4uiFn = 0; - fn.glUniform4uivFn = 0; - fn.glUniformBlockBindingFn = 0; - fn.glUniformMatrix2fvFn = reinterpret_cast( - GetGLProcAddress("glUniformMatrix2fv")); - fn.glUniformMatrix2x3fvFn = 0; - fn.glUniformMatrix2x4fvFn = 0; - fn.glUniformMatrix3fvFn = reinterpret_cast( - GetGLProcAddress("glUniformMatrix3fv")); - fn.glUniformMatrix3x2fvFn = 0; - fn.glUniformMatrix3x4fvFn = 0; - fn.glUniformMatrix4fvFn = reinterpret_cast( - GetGLProcAddress("glUniformMatrix4fv")); - fn.glUniformMatrix4x2fvFn = 0; - fn.glUniformMatrix4x3fvFn = 0; - fn.glUnmapBufferFn = 0; - fn.glUseProgramFn = - reinterpret_cast(GetGLProcAddress("glUseProgram")); - fn.glValidateProgramFn = reinterpret_cast( - GetGLProcAddress("glValidateProgram")); - fn.glVertexAttrib1fFn = reinterpret_cast( - GetGLProcAddress("glVertexAttrib1f")); - fn.glVertexAttrib1fvFn = reinterpret_cast( - GetGLProcAddress("glVertexAttrib1fv")); - fn.glVertexAttrib2fFn = reinterpret_cast( - GetGLProcAddress("glVertexAttrib2f")); - fn.glVertexAttrib2fvFn = reinterpret_cast( - GetGLProcAddress("glVertexAttrib2fv")); - fn.glVertexAttrib3fFn = reinterpret_cast( - GetGLProcAddress("glVertexAttrib3f")); - fn.glVertexAttrib3fvFn = reinterpret_cast( - GetGLProcAddress("glVertexAttrib3fv")); - fn.glVertexAttrib4fFn = reinterpret_cast( - GetGLProcAddress("glVertexAttrib4f")); - fn.glVertexAttrib4fvFn = reinterpret_cast( - GetGLProcAddress("glVertexAttrib4fv")); - fn.glVertexAttribDivisorANGLEFn = 0; - fn.glVertexAttribI4iFn = 0; - fn.glVertexAttribI4ivFn = 0; - fn.glVertexAttribI4uiFn = 0; - fn.glVertexAttribI4uivFn = 0; - fn.glVertexAttribIPointerFn = 0; - fn.glVertexAttribPointerFn = reinterpret_cast( - GetGLProcAddress("glVertexAttribPointer")); - fn.glViewportFn = - reinterpret_cast(GetGLProcAddress("glViewport")); - fn.glWaitSyncFn = 0; -} - -void DriverGL::InitializeDynamicBindings(GLContext* context) { - DCHECK(context && context->IsCurrent(NULL)); - const GLVersionInfo* ver = context->GetVersionInfo(); - ALLOW_UNUSED_LOCAL(ver); - std::string extensions = context->GetExtensions() + " "; - ALLOW_UNUSED_LOCAL(extensions); - - ext.b_GL_ANGLE_framebuffer_blit = - extensions.find("GL_ANGLE_framebuffer_blit ") != std::string::npos; - ext.b_GL_ANGLE_framebuffer_multisample = - extensions.find("GL_ANGLE_framebuffer_multisample ") != std::string::npos; - ext.b_GL_ANGLE_instanced_arrays = - extensions.find("GL_ANGLE_instanced_arrays ") != std::string::npos; - ext.b_GL_ANGLE_translated_shader_source = - extensions.find("GL_ANGLE_translated_shader_source ") != - std::string::npos; - ext.b_GL_APPLE_fence = - extensions.find("GL_APPLE_fence ") != std::string::npos; - ext.b_GL_APPLE_framebuffer_multisample = - extensions.find("GL_APPLE_framebuffer_multisample ") != std::string::npos; - ext.b_GL_APPLE_vertex_array_object = - extensions.find("GL_APPLE_vertex_array_object ") != std::string::npos; - ext.b_GL_ARB_draw_buffers = - extensions.find("GL_ARB_draw_buffers ") != std::string::npos; - ext.b_GL_ARB_draw_instanced = - extensions.find("GL_ARB_draw_instanced ") != std::string::npos; - ext.b_GL_ARB_get_program_binary = - extensions.find("GL_ARB_get_program_binary ") != std::string::npos; - ext.b_GL_ARB_instanced_arrays = - extensions.find("GL_ARB_instanced_arrays ") != std::string::npos; - ext.b_GL_ARB_map_buffer_range = - extensions.find("GL_ARB_map_buffer_range ") != std::string::npos; - ext.b_GL_ARB_occlusion_query = - extensions.find("GL_ARB_occlusion_query ") != std::string::npos; - ext.b_GL_ARB_robustness = - extensions.find("GL_ARB_robustness ") != std::string::npos; - ext.b_GL_ARB_sync = extensions.find("GL_ARB_sync ") != std::string::npos; - ext.b_GL_ARB_texture_storage = - extensions.find("GL_ARB_texture_storage ") != std::string::npos; - ext.b_GL_ARB_timer_query = - extensions.find("GL_ARB_timer_query ") != std::string::npos; - ext.b_GL_ARB_vertex_array_object = - extensions.find("GL_ARB_vertex_array_object ") != std::string::npos; - ext.b_GL_CHROMIUM_gles_depth_binding_hack = - extensions.find("GL_CHROMIUM_gles_depth_binding_hack ") != - std::string::npos; - ext.b_GL_EXT_debug_marker = - extensions.find("GL_EXT_debug_marker ") != std::string::npos; - ext.b_GL_EXT_direct_state_access = - extensions.find("GL_EXT_direct_state_access ") != std::string::npos; - ext.b_GL_EXT_discard_framebuffer = - extensions.find("GL_EXT_discard_framebuffer ") != std::string::npos; - ext.b_GL_EXT_disjoint_timer_query = - extensions.find("GL_EXT_disjoint_timer_query ") != std::string::npos; - ext.b_GL_EXT_draw_buffers = - extensions.find("GL_EXT_draw_buffers ") != std::string::npos; - ext.b_GL_EXT_framebuffer_blit = - extensions.find("GL_EXT_framebuffer_blit ") != std::string::npos; - ext.b_GL_EXT_framebuffer_multisample = - extensions.find("GL_EXT_framebuffer_multisample ") != std::string::npos; - ext.b_GL_EXT_framebuffer_object = - extensions.find("GL_EXT_framebuffer_object ") != std::string::npos; - ext.b_GL_EXT_map_buffer_range = - extensions.find("GL_EXT_map_buffer_range ") != std::string::npos; - ext.b_GL_EXT_multisampled_render_to_texture = - extensions.find("GL_EXT_multisampled_render_to_texture ") != - std::string::npos; - ext.b_GL_EXT_occlusion_query_boolean = - extensions.find("GL_EXT_occlusion_query_boolean ") != std::string::npos; - ext.b_GL_EXT_robustness = - extensions.find("GL_EXT_robustness ") != std::string::npos; - ext.b_GL_EXT_texture_storage = - extensions.find("GL_EXT_texture_storage ") != std::string::npos; - ext.b_GL_EXT_timer_query = - extensions.find("GL_EXT_timer_query ") != std::string::npos; - ext.b_GL_IMG_multisampled_render_to_texture = - extensions.find("GL_IMG_multisampled_render_to_texture ") != - std::string::npos; - ext.b_GL_KHR_blend_equation_advanced = - extensions.find("GL_KHR_blend_equation_advanced ") != std::string::npos; - ext.b_GL_KHR_debug = extensions.find("GL_KHR_debug ") != std::string::npos; - ext.b_GL_KHR_robustness = - extensions.find("GL_KHR_robustness ") != std::string::npos; - ext.b_GL_NV_blend_equation_advanced = - extensions.find("GL_NV_blend_equation_advanced ") != std::string::npos; - ext.b_GL_NV_fence = extensions.find("GL_NV_fence ") != std::string::npos; - ext.b_GL_NV_path_rendering = - extensions.find("GL_NV_path_rendering ") != std::string::npos; - ext.b_GL_NV_texture_barrier = - extensions.find("GL_NV_texture_barrier ") != std::string::npos; - ext.b_GL_OES_EGL_image = - extensions.find("GL_OES_EGL_image ") != std::string::npos; - ext.b_GL_OES_get_program_binary = - extensions.find("GL_OES_get_program_binary ") != std::string::npos; - ext.b_GL_OES_mapbuffer = - extensions.find("GL_OES_mapbuffer ") != std::string::npos; - ext.b_GL_OES_vertex_array_object = - extensions.find("GL_OES_vertex_array_object ") != std::string::npos; - - debug_fn.glBeginQueryFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glBeginQueryFn = - reinterpret_cast(GetGLProcAddress("glBeginQuery")); - DCHECK(fn.glBeginQueryFn); - } else if (ext.b_GL_ARB_occlusion_query) { - fn.glBeginQueryFn = - reinterpret_cast(GetGLProcAddress("glBeginQueryARB")); - DCHECK(fn.glBeginQueryFn); - } else if (ext.b_GL_EXT_disjoint_timer_query || - ext.b_GL_EXT_occlusion_query_boolean) { - fn.glBeginQueryFn = - reinterpret_cast(GetGLProcAddress("glBeginQueryEXT")); - DCHECK(fn.glBeginQueryFn); - } - - debug_fn.glBeginTransformFeedbackFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glBeginTransformFeedbackFn = - reinterpret_cast( - GetGLProcAddress("glBeginTransformFeedback")); - DCHECK(fn.glBeginTransformFeedbackFn); - } - - debug_fn.glBindBufferBaseFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glBindBufferBaseFn = reinterpret_cast( - GetGLProcAddress("glBindBufferBase")); - DCHECK(fn.glBindBufferBaseFn); - } - - debug_fn.glBindBufferRangeFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glBindBufferRangeFn = reinterpret_cast( - GetGLProcAddress("glBindBufferRange")); - DCHECK(fn.glBindBufferRangeFn); - } - - debug_fn.glBindFragDataLocationFn = 0; - if (ver->IsAtLeastGL(3u, 0u)) { - fn.glBindFragDataLocationFn = reinterpret_cast( - GetGLProcAddress("glBindFragDataLocation")); - DCHECK(fn.glBindFragDataLocationFn); - } - - debug_fn.glBindFragDataLocationIndexedFn = 0; - if (ver->IsAtLeastGL(3u, 3u)) { - fn.glBindFragDataLocationIndexedFn = - reinterpret_cast( - GetGLProcAddress("glBindFragDataLocationIndexed")); - DCHECK(fn.glBindFragDataLocationIndexedFn); - } - - debug_fn.glBindFramebufferEXTFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->is_es) { - fn.glBindFramebufferEXTFn = reinterpret_cast( - GetGLProcAddress("glBindFramebuffer")); - DCHECK(fn.glBindFramebufferEXTFn); - } else if (ext.b_GL_EXT_framebuffer_object) { - fn.glBindFramebufferEXTFn = reinterpret_cast( - GetGLProcAddress("glBindFramebufferEXT")); - DCHECK(fn.glBindFramebufferEXTFn); - } - - debug_fn.glBindRenderbufferEXTFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->is_es) { - fn.glBindRenderbufferEXTFn = reinterpret_cast( - GetGLProcAddress("glBindRenderbuffer")); - DCHECK(fn.glBindRenderbufferEXTFn); - } else if (ext.b_GL_EXT_framebuffer_object) { - fn.glBindRenderbufferEXTFn = reinterpret_cast( - GetGLProcAddress("glBindRenderbufferEXT")); - DCHECK(fn.glBindRenderbufferEXTFn); - } - - debug_fn.glBindSamplerFn = 0; - if (ver->IsAtLeastGL(3u, 3u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glBindSamplerFn = - reinterpret_cast(GetGLProcAddress("glBindSampler")); - DCHECK(fn.glBindSamplerFn); - } - - debug_fn.glBindTransformFeedbackFn = 0; - if (ver->IsAtLeastGLES(3u, 0u) || ver->IsAtLeastGL(4u, 0u)) { - fn.glBindTransformFeedbackFn = - reinterpret_cast( - GetGLProcAddress("glBindTransformFeedback")); - DCHECK(fn.glBindTransformFeedbackFn); - } - - debug_fn.glBindVertexArrayOESFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u) || - ext.b_GL_ARB_vertex_array_object) { - fn.glBindVertexArrayOESFn = reinterpret_cast( - GetGLProcAddress("glBindVertexArray")); - DCHECK(fn.glBindVertexArrayOESFn); - } else if (ext.b_GL_OES_vertex_array_object) { - fn.glBindVertexArrayOESFn = reinterpret_cast( - GetGLProcAddress("glBindVertexArrayOES")); - DCHECK(fn.glBindVertexArrayOESFn); - } else if (ext.b_GL_APPLE_vertex_array_object) { - fn.glBindVertexArrayOESFn = reinterpret_cast( - GetGLProcAddress("glBindVertexArrayAPPLE")); - DCHECK(fn.glBindVertexArrayOESFn); - } - - debug_fn.glBlendBarrierKHRFn = 0; - if (ext.b_GL_NV_blend_equation_advanced) { - fn.glBlendBarrierKHRFn = reinterpret_cast( - GetGLProcAddress("glBlendBarrierNV")); - DCHECK(fn.glBlendBarrierKHRFn); - } else if (ext.b_GL_KHR_blend_equation_advanced) { - fn.glBlendBarrierKHRFn = reinterpret_cast( - GetGLProcAddress("glBlendBarrierKHR")); - DCHECK(fn.glBlendBarrierKHRFn); - } - - debug_fn.glBlitFramebufferFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glBlitFramebufferFn = reinterpret_cast( - GetGLProcAddress("glBlitFramebuffer")); - DCHECK(fn.glBlitFramebufferFn); - } - - debug_fn.glBlitFramebufferANGLEFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glBlitFramebufferANGLEFn = reinterpret_cast( - GetGLProcAddress("glBlitFramebuffer")); - DCHECK(fn.glBlitFramebufferANGLEFn); - } else if (ext.b_GL_ANGLE_framebuffer_blit) { - fn.glBlitFramebufferANGLEFn = reinterpret_cast( - GetGLProcAddress("glBlitFramebufferANGLE")); - DCHECK(fn.glBlitFramebufferANGLEFn); - } - - debug_fn.glBlitFramebufferEXTFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glBlitFramebufferEXTFn = reinterpret_cast( - GetGLProcAddress("glBlitFramebuffer")); - DCHECK(fn.glBlitFramebufferEXTFn); - } else if (ext.b_GL_EXT_framebuffer_blit) { - fn.glBlitFramebufferEXTFn = reinterpret_cast( - GetGLProcAddress("glBlitFramebufferEXT")); - DCHECK(fn.glBlitFramebufferEXTFn); - } - - debug_fn.glCheckFramebufferStatusEXTFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->is_es) { - fn.glCheckFramebufferStatusEXTFn = - reinterpret_cast( - GetGLProcAddress("glCheckFramebufferStatus")); - DCHECK(fn.glCheckFramebufferStatusEXTFn); - } else if (ext.b_GL_EXT_framebuffer_object) { - fn.glCheckFramebufferStatusEXTFn = - reinterpret_cast( - GetGLProcAddress("glCheckFramebufferStatusEXT")); - DCHECK(fn.glCheckFramebufferStatusEXTFn); - } - - debug_fn.glClearBufferfiFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glClearBufferfiFn = reinterpret_cast( - GetGLProcAddress("glClearBufferfi")); - DCHECK(fn.glClearBufferfiFn); - } - - debug_fn.glClearBufferfvFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glClearBufferfvFn = reinterpret_cast( - GetGLProcAddress("glClearBufferfv")); - DCHECK(fn.glClearBufferfvFn); - } - - debug_fn.glClearBufferivFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glClearBufferivFn = reinterpret_cast( - GetGLProcAddress("glClearBufferiv")); - DCHECK(fn.glClearBufferivFn); - } - - debug_fn.glClearBufferuivFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glClearBufferuivFn = reinterpret_cast( - GetGLProcAddress("glClearBufferuiv")); - DCHECK(fn.glClearBufferuivFn); - } - - debug_fn.glClearDepthfFn = 0; - if (ver->IsAtLeastGL(4u, 1u) || ver->is_es) { - fn.glClearDepthfFn = - reinterpret_cast(GetGLProcAddress("glClearDepthf")); - DCHECK(fn.glClearDepthfFn); - } - - debug_fn.glClientWaitSyncFn = 0; - if (ver->IsAtLeastGL(3u, 2u) || ver->IsAtLeastGLES(3u, 0u) || - ext.b_GL_ARB_sync) { - fn.glClientWaitSyncFn = reinterpret_cast( - GetGLProcAddress("glClientWaitSync")); - DCHECK(fn.glClientWaitSyncFn); - } - - debug_fn.glCompressedTexImage3DFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glCompressedTexImage3DFn = reinterpret_cast( - GetGLProcAddress("glCompressedTexImage3D")); - DCHECK(fn.glCompressedTexImage3DFn); - } - - debug_fn.glCopyBufferSubDataFn = 0; - if (ver->IsAtLeastGLES(3u, 0u) || ver->IsAtLeastGL(3u, 1u)) { - fn.glCopyBufferSubDataFn = reinterpret_cast( - GetGLProcAddress("glCopyBufferSubData")); - DCHECK(fn.glCopyBufferSubDataFn); - } - - debug_fn.glCopyTexSubImage3DFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glCopyTexSubImage3DFn = reinterpret_cast( - GetGLProcAddress("glCopyTexSubImage3D")); - DCHECK(fn.glCopyTexSubImage3DFn); - } - - debug_fn.glDebugMessageCallbackKHRFn = 0; - if (ext.b_GL_KHR_debug) { - fn.glDebugMessageCallbackKHRFn = - reinterpret_cast( - GetGLProcAddress("glDebugMessageCallbackKHR")); - DCHECK(fn.glDebugMessageCallbackKHRFn); - } - - debug_fn.glDebugMessageControlKHRFn = 0; - if (ext.b_GL_KHR_debug) { - fn.glDebugMessageControlKHRFn = - reinterpret_cast( - GetGLProcAddress("glDebugMessageControlKHR")); - DCHECK(fn.glDebugMessageControlKHRFn); - } - - debug_fn.glDebugMessageInsertKHRFn = 0; - if (ext.b_GL_KHR_debug) { - fn.glDebugMessageInsertKHRFn = - reinterpret_cast( - GetGLProcAddress("glDebugMessageInsertKHR")); - DCHECK(fn.glDebugMessageInsertKHRFn); - } - - debug_fn.glDeleteFencesAPPLEFn = 0; - if (ext.b_GL_APPLE_fence) { - fn.glDeleteFencesAPPLEFn = reinterpret_cast( - GetGLProcAddress("glDeleteFencesAPPLE")); - DCHECK(fn.glDeleteFencesAPPLEFn); - } - - debug_fn.glDeleteFencesNVFn = 0; - if (ext.b_GL_NV_fence) { - fn.glDeleteFencesNVFn = reinterpret_cast( - GetGLProcAddress("glDeleteFencesNV")); - DCHECK(fn.glDeleteFencesNVFn); - } - - debug_fn.glDeleteFramebuffersEXTFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->is_es) { - fn.glDeleteFramebuffersEXTFn = - reinterpret_cast( - GetGLProcAddress("glDeleteFramebuffers")); - DCHECK(fn.glDeleteFramebuffersEXTFn); - } else if (ext.b_GL_EXT_framebuffer_object) { - fn.glDeleteFramebuffersEXTFn = - reinterpret_cast( - GetGLProcAddress("glDeleteFramebuffersEXT")); - DCHECK(fn.glDeleteFramebuffersEXTFn); - } - - debug_fn.glDeleteQueriesFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glDeleteQueriesFn = reinterpret_cast( - GetGLProcAddress("glDeleteQueries")); - DCHECK(fn.glDeleteQueriesFn); - } else if (ext.b_GL_ARB_occlusion_query) { - fn.glDeleteQueriesFn = reinterpret_cast( - GetGLProcAddress("glDeleteQueriesARB")); - DCHECK(fn.glDeleteQueriesFn); - } else if (ext.b_GL_EXT_disjoint_timer_query || - ext.b_GL_EXT_occlusion_query_boolean) { - fn.glDeleteQueriesFn = reinterpret_cast( - GetGLProcAddress("glDeleteQueriesEXT")); - DCHECK(fn.glDeleteQueriesFn); - } - - debug_fn.glDeleteRenderbuffersEXTFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->is_es) { - fn.glDeleteRenderbuffersEXTFn = - reinterpret_cast( - GetGLProcAddress("glDeleteRenderbuffers")); - DCHECK(fn.glDeleteRenderbuffersEXTFn); - } else if (ext.b_GL_EXT_framebuffer_object) { - fn.glDeleteRenderbuffersEXTFn = - reinterpret_cast( - GetGLProcAddress("glDeleteRenderbuffersEXT")); - DCHECK(fn.glDeleteRenderbuffersEXTFn); - } - - debug_fn.glDeleteSamplersFn = 0; - if (ver->IsAtLeastGL(3u, 3u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glDeleteSamplersFn = reinterpret_cast( - GetGLProcAddress("glDeleteSamplers")); - DCHECK(fn.glDeleteSamplersFn); - } - - debug_fn.glDeleteSyncFn = 0; - if (ver->IsAtLeastGL(3u, 2u) || ver->IsAtLeastGLES(3u, 0u) || - ext.b_GL_ARB_sync) { - fn.glDeleteSyncFn = - reinterpret_cast(GetGLProcAddress("glDeleteSync")); - DCHECK(fn.glDeleteSyncFn); - } - - debug_fn.glDeleteTransformFeedbacksFn = 0; - if (ver->IsAtLeastGLES(3u, 0u) || ver->IsAtLeastGL(4u, 0u)) { - fn.glDeleteTransformFeedbacksFn = - reinterpret_cast( - GetGLProcAddress("glDeleteTransformFeedbacks")); - DCHECK(fn.glDeleteTransformFeedbacksFn); - } - - debug_fn.glDeleteVertexArraysOESFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u) || - ext.b_GL_ARB_vertex_array_object) { - fn.glDeleteVertexArraysOESFn = - reinterpret_cast( - GetGLProcAddress("glDeleteVertexArrays")); - DCHECK(fn.glDeleteVertexArraysOESFn); - } else if (ext.b_GL_OES_vertex_array_object) { - fn.glDeleteVertexArraysOESFn = - reinterpret_cast( - GetGLProcAddress("glDeleteVertexArraysOES")); - DCHECK(fn.glDeleteVertexArraysOESFn); - } else if (ext.b_GL_APPLE_vertex_array_object) { - fn.glDeleteVertexArraysOESFn = - reinterpret_cast( - GetGLProcAddress("glDeleteVertexArraysAPPLE")); - DCHECK(fn.glDeleteVertexArraysOESFn); - } - - debug_fn.glDepthRangefFn = 0; - if (ver->IsAtLeastGL(4u, 1u) || ver->is_es) { - fn.glDepthRangefFn = - reinterpret_cast(GetGLProcAddress("glDepthRangef")); - DCHECK(fn.glDepthRangefFn); - } - - debug_fn.glDiscardFramebufferEXTFn = 0; - if (ext.b_GL_EXT_discard_framebuffer) { - fn.glDiscardFramebufferEXTFn = - reinterpret_cast( - GetGLProcAddress("glDiscardFramebufferEXT")); - DCHECK(fn.glDiscardFramebufferEXTFn); - } - - debug_fn.glDrawArraysInstancedANGLEFn = 0; - if (ver->IsAtLeastGLES(3u, 0u) || ver->IsAtLeastGL(3u, 1u)) { - fn.glDrawArraysInstancedANGLEFn = - reinterpret_cast( - GetGLProcAddress("glDrawArraysInstanced")); - DCHECK(fn.glDrawArraysInstancedANGLEFn); - } else if (ext.b_GL_ARB_draw_instanced) { - fn.glDrawArraysInstancedANGLEFn = - reinterpret_cast( - GetGLProcAddress("glDrawArraysInstancedARB")); - DCHECK(fn.glDrawArraysInstancedANGLEFn); - } else if (ext.b_GL_ANGLE_instanced_arrays) { - fn.glDrawArraysInstancedANGLEFn = - reinterpret_cast( - GetGLProcAddress("glDrawArraysInstancedANGLE")); - DCHECK(fn.glDrawArraysInstancedANGLEFn); - } - - debug_fn.glDrawBufferFn = 0; - if (!ver->is_es) { - fn.glDrawBufferFn = - reinterpret_cast(GetGLProcAddress("glDrawBuffer")); - DCHECK(fn.glDrawBufferFn); - } - - debug_fn.glDrawBuffersARBFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glDrawBuffersARBFn = reinterpret_cast( - GetGLProcAddress("glDrawBuffers")); - DCHECK(fn.glDrawBuffersARBFn); - } else if (ext.b_GL_ARB_draw_buffers) { - fn.glDrawBuffersARBFn = reinterpret_cast( - GetGLProcAddress("glDrawBuffersARB")); - DCHECK(fn.glDrawBuffersARBFn); - } else if (ext.b_GL_EXT_draw_buffers) { - fn.glDrawBuffersARBFn = reinterpret_cast( - GetGLProcAddress("glDrawBuffersEXT")); - DCHECK(fn.glDrawBuffersARBFn); - } - - debug_fn.glDrawElementsInstancedANGLEFn = 0; - if (ver->IsAtLeastGLES(3u, 0u) || ver->IsAtLeastGL(3u, 1u)) { - fn.glDrawElementsInstancedANGLEFn = - reinterpret_cast( - GetGLProcAddress("glDrawElementsInstanced")); - DCHECK(fn.glDrawElementsInstancedANGLEFn); - } else if (ext.b_GL_ARB_draw_instanced) { - fn.glDrawElementsInstancedANGLEFn = - reinterpret_cast( - GetGLProcAddress("glDrawElementsInstancedARB")); - DCHECK(fn.glDrawElementsInstancedANGLEFn); - } else if (ext.b_GL_ANGLE_instanced_arrays) { - fn.glDrawElementsInstancedANGLEFn = - reinterpret_cast( - GetGLProcAddress("glDrawElementsInstancedANGLE")); - DCHECK(fn.glDrawElementsInstancedANGLEFn); - } - - debug_fn.glDrawRangeElementsFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glDrawRangeElementsFn = reinterpret_cast( - GetGLProcAddress("glDrawRangeElements")); - DCHECK(fn.glDrawRangeElementsFn); - } - - debug_fn.glEGLImageTargetRenderbufferStorageOESFn = 0; - if (ext.b_GL_OES_EGL_image) { - fn.glEGLImageTargetRenderbufferStorageOESFn = - reinterpret_cast( - GetGLProcAddress("glEGLImageTargetRenderbufferStorageOES")); - DCHECK(fn.glEGLImageTargetRenderbufferStorageOESFn); - } - - debug_fn.glEGLImageTargetTexture2DOESFn = 0; - if (ext.b_GL_OES_EGL_image) { - fn.glEGLImageTargetTexture2DOESFn = - reinterpret_cast( - GetGLProcAddress("glEGLImageTargetTexture2DOES")); - DCHECK(fn.glEGLImageTargetTexture2DOESFn); - } - - debug_fn.glEndQueryFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glEndQueryFn = - reinterpret_cast(GetGLProcAddress("glEndQuery")); - DCHECK(fn.glEndQueryFn); - } else if (ext.b_GL_ARB_occlusion_query) { - fn.glEndQueryFn = - reinterpret_cast(GetGLProcAddress("glEndQueryARB")); - DCHECK(fn.glEndQueryFn); - } else if (ext.b_GL_EXT_disjoint_timer_query || - ext.b_GL_EXT_occlusion_query_boolean) { - fn.glEndQueryFn = - reinterpret_cast(GetGLProcAddress("glEndQueryEXT")); - DCHECK(fn.glEndQueryFn); - } - - debug_fn.glEndTransformFeedbackFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glEndTransformFeedbackFn = reinterpret_cast( - GetGLProcAddress("glEndTransformFeedback")); - DCHECK(fn.glEndTransformFeedbackFn); - } - - debug_fn.glFenceSyncFn = 0; - if (ver->IsAtLeastGL(3u, 2u) || ver->IsAtLeastGLES(3u, 0u) || - ext.b_GL_ARB_sync) { - fn.glFenceSyncFn = - reinterpret_cast(GetGLProcAddress("glFenceSync")); - DCHECK(fn.glFenceSyncFn); - } - - debug_fn.glFinishFenceAPPLEFn = 0; - if (ext.b_GL_APPLE_fence) { - fn.glFinishFenceAPPLEFn = reinterpret_cast( - GetGLProcAddress("glFinishFenceAPPLE")); - DCHECK(fn.glFinishFenceAPPLEFn); - } - - debug_fn.glFinishFenceNVFn = 0; - if (ext.b_GL_NV_fence) { - fn.glFinishFenceNVFn = reinterpret_cast( - GetGLProcAddress("glFinishFenceNV")); - DCHECK(fn.glFinishFenceNVFn); - } - - debug_fn.glFlushMappedBufferRangeFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glFlushMappedBufferRangeFn = - reinterpret_cast( - GetGLProcAddress("glFlushMappedBufferRange")); - DCHECK(fn.glFlushMappedBufferRangeFn); - } - - debug_fn.glFramebufferRenderbufferEXTFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->is_es) { - fn.glFramebufferRenderbufferEXTFn = - reinterpret_cast( - GetGLProcAddress("glFramebufferRenderbuffer")); - DCHECK(fn.glFramebufferRenderbufferEXTFn); - } else if (ext.b_GL_EXT_framebuffer_object) { - fn.glFramebufferRenderbufferEXTFn = - reinterpret_cast( - GetGLProcAddress("glFramebufferRenderbufferEXT")); - DCHECK(fn.glFramebufferRenderbufferEXTFn); - } - - debug_fn.glFramebufferTexture2DEXTFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->is_es) { - fn.glFramebufferTexture2DEXTFn = - reinterpret_cast( - GetGLProcAddress("glFramebufferTexture2D")); - DCHECK(fn.glFramebufferTexture2DEXTFn); - } else if (ext.b_GL_EXT_framebuffer_object) { - fn.glFramebufferTexture2DEXTFn = - reinterpret_cast( - GetGLProcAddress("glFramebufferTexture2DEXT")); - DCHECK(fn.glFramebufferTexture2DEXTFn); - } - - debug_fn.glFramebufferTexture2DMultisampleEXTFn = 0; - if (ext.b_GL_EXT_multisampled_render_to_texture) { - fn.glFramebufferTexture2DMultisampleEXTFn = - reinterpret_cast( - GetGLProcAddress("glFramebufferTexture2DMultisampleEXT")); - DCHECK(fn.glFramebufferTexture2DMultisampleEXTFn); - } - - debug_fn.glFramebufferTexture2DMultisampleIMGFn = 0; - if (ext.b_GL_IMG_multisampled_render_to_texture) { - fn.glFramebufferTexture2DMultisampleIMGFn = - reinterpret_cast( - GetGLProcAddress("glFramebufferTexture2DMultisampleIMG")); - DCHECK(fn.glFramebufferTexture2DMultisampleIMGFn); - } - - debug_fn.glFramebufferTextureLayerFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glFramebufferTextureLayerFn = - reinterpret_cast( - GetGLProcAddress("glFramebufferTextureLayer")); - DCHECK(fn.glFramebufferTextureLayerFn); - } - - debug_fn.glGenerateMipmapEXTFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->is_es) { - fn.glGenerateMipmapEXTFn = reinterpret_cast( - GetGLProcAddress("glGenerateMipmap")); - DCHECK(fn.glGenerateMipmapEXTFn); - } else if (ext.b_GL_EXT_framebuffer_object) { - fn.glGenerateMipmapEXTFn = reinterpret_cast( - GetGLProcAddress("glGenerateMipmapEXT")); - DCHECK(fn.glGenerateMipmapEXTFn); - } - - debug_fn.glGenFencesAPPLEFn = 0; - if (ext.b_GL_APPLE_fence) { - fn.glGenFencesAPPLEFn = reinterpret_cast( - GetGLProcAddress("glGenFencesAPPLE")); - DCHECK(fn.glGenFencesAPPLEFn); - } - - debug_fn.glGenFencesNVFn = 0; - if (ext.b_GL_NV_fence) { - fn.glGenFencesNVFn = - reinterpret_cast(GetGLProcAddress("glGenFencesNV")); - DCHECK(fn.glGenFencesNVFn); - } - - debug_fn.glGenFramebuffersEXTFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->is_es) { - fn.glGenFramebuffersEXTFn = reinterpret_cast( - GetGLProcAddress("glGenFramebuffers")); - DCHECK(fn.glGenFramebuffersEXTFn); - } else if (ext.b_GL_EXT_framebuffer_object) { - fn.glGenFramebuffersEXTFn = reinterpret_cast( - GetGLProcAddress("glGenFramebuffersEXT")); - DCHECK(fn.glGenFramebuffersEXTFn); - } - - debug_fn.glGenQueriesFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glGenQueriesFn = - reinterpret_cast(GetGLProcAddress("glGenQueries")); - DCHECK(fn.glGenQueriesFn); - } else if (ext.b_GL_ARB_occlusion_query) { - fn.glGenQueriesFn = - reinterpret_cast(GetGLProcAddress("glGenQueriesARB")); - DCHECK(fn.glGenQueriesFn); - } else if (ext.b_GL_EXT_disjoint_timer_query || - ext.b_GL_EXT_occlusion_query_boolean) { - fn.glGenQueriesFn = - reinterpret_cast(GetGLProcAddress("glGenQueriesEXT")); - DCHECK(fn.glGenQueriesFn); - } - - debug_fn.glGenRenderbuffersEXTFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->is_es) { - fn.glGenRenderbuffersEXTFn = reinterpret_cast( - GetGLProcAddress("glGenRenderbuffers")); - DCHECK(fn.glGenRenderbuffersEXTFn); - } else if (ext.b_GL_EXT_framebuffer_object) { - fn.glGenRenderbuffersEXTFn = reinterpret_cast( - GetGLProcAddress("glGenRenderbuffersEXT")); - DCHECK(fn.glGenRenderbuffersEXTFn); - } - - debug_fn.glGenSamplersFn = 0; - if (ver->IsAtLeastGL(3u, 3u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glGenSamplersFn = - reinterpret_cast(GetGLProcAddress("glGenSamplers")); - DCHECK(fn.glGenSamplersFn); - } - - debug_fn.glGenTransformFeedbacksFn = 0; - if (ver->IsAtLeastGLES(3u, 0u) || ver->IsAtLeastGL(4u, 0u)) { - fn.glGenTransformFeedbacksFn = - reinterpret_cast( - GetGLProcAddress("glGenTransformFeedbacks")); - DCHECK(fn.glGenTransformFeedbacksFn); - } - - debug_fn.glGenVertexArraysOESFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u) || - ext.b_GL_ARB_vertex_array_object) { - fn.glGenVertexArraysOESFn = reinterpret_cast( - GetGLProcAddress("glGenVertexArrays")); - DCHECK(fn.glGenVertexArraysOESFn); - } else if (ext.b_GL_OES_vertex_array_object) { - fn.glGenVertexArraysOESFn = reinterpret_cast( - GetGLProcAddress("glGenVertexArraysOES")); - DCHECK(fn.glGenVertexArraysOESFn); - } else if (ext.b_GL_APPLE_vertex_array_object) { - fn.glGenVertexArraysOESFn = reinterpret_cast( - GetGLProcAddress("glGenVertexArraysAPPLE")); - DCHECK(fn.glGenVertexArraysOESFn); - } - - debug_fn.glGetActiveUniformBlockivFn = 0; - if (ver->IsAtLeastGLES(3u, 0u) || ver->IsAtLeastGL(3u, 1u)) { - fn.glGetActiveUniformBlockivFn = - reinterpret_cast( - GetGLProcAddress("glGetActiveUniformBlockiv")); - DCHECK(fn.glGetActiveUniformBlockivFn); - } - - debug_fn.glGetActiveUniformBlockNameFn = 0; - if (ver->IsAtLeastGLES(3u, 0u) || ver->IsAtLeastGL(3u, 1u)) { - fn.glGetActiveUniformBlockNameFn = - reinterpret_cast( - GetGLProcAddress("glGetActiveUniformBlockName")); - DCHECK(fn.glGetActiveUniformBlockNameFn); - } - - debug_fn.glGetActiveUniformsivFn = 0; - if (ver->IsAtLeastGLES(3u, 0u) || ver->IsAtLeastGL(3u, 1u)) { - fn.glGetActiveUniformsivFn = reinterpret_cast( - GetGLProcAddress("glGetActiveUniformsiv")); - DCHECK(fn.glGetActiveUniformsivFn); - } - - debug_fn.glGetDebugMessageLogKHRFn = 0; - if (ext.b_GL_KHR_debug) { - fn.glGetDebugMessageLogKHRFn = - reinterpret_cast( - GetGLProcAddress("glGetDebugMessageLogKHR")); - DCHECK(fn.glGetDebugMessageLogKHRFn); - } - - debug_fn.glGetFenceivNVFn = 0; - if (ext.b_GL_NV_fence) { - fn.glGetFenceivNVFn = reinterpret_cast( - GetGLProcAddress("glGetFenceivNV")); - DCHECK(fn.glGetFenceivNVFn); - } - - debug_fn.glGetFragDataLocationFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glGetFragDataLocationFn = reinterpret_cast( - GetGLProcAddress("glGetFragDataLocation")); - DCHECK(fn.glGetFragDataLocationFn); - } - - debug_fn.glGetFramebufferAttachmentParameterivEXTFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->is_es) { - fn.glGetFramebufferAttachmentParameterivEXTFn = - reinterpret_cast( - GetGLProcAddress("glGetFramebufferAttachmentParameteriv")); - DCHECK(fn.glGetFramebufferAttachmentParameterivEXTFn); - } else if (ext.b_GL_EXT_framebuffer_object) { - fn.glGetFramebufferAttachmentParameterivEXTFn = - reinterpret_cast( - GetGLProcAddress("glGetFramebufferAttachmentParameterivEXT")); - DCHECK(fn.glGetFramebufferAttachmentParameterivEXTFn); - } - - debug_fn.glGetGraphicsResetStatusARBFn = 0; - if (ver->IsAtLeastGL(4u, 5u)) { - fn.glGetGraphicsResetStatusARBFn = - reinterpret_cast( - GetGLProcAddress("glGetGraphicsResetStatus")); - DCHECK(fn.glGetGraphicsResetStatusARBFn); - } else if (ext.b_GL_ARB_robustness) { - fn.glGetGraphicsResetStatusARBFn = - reinterpret_cast( - GetGLProcAddress("glGetGraphicsResetStatusARB")); - DCHECK(fn.glGetGraphicsResetStatusARBFn); - } else if (ext.b_GL_KHR_robustness) { - fn.glGetGraphicsResetStatusARBFn = - reinterpret_cast( - GetGLProcAddress("glGetGraphicsResetStatusKHR")); - DCHECK(fn.glGetGraphicsResetStatusARBFn); - } else if (ext.b_GL_EXT_robustness) { - fn.glGetGraphicsResetStatusARBFn = - reinterpret_cast( - GetGLProcAddress("glGetGraphicsResetStatusEXT")); - DCHECK(fn.glGetGraphicsResetStatusARBFn); - } - - debug_fn.glGetInteger64i_vFn = 0; - if (ver->IsAtLeastGL(3u, 2u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glGetInteger64i_vFn = reinterpret_cast( - GetGLProcAddress("glGetInteger64i_v")); - DCHECK(fn.glGetInteger64i_vFn); - } - - debug_fn.glGetInteger64vFn = 0; - if (ver->IsAtLeastGL(3u, 2u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glGetInteger64vFn = reinterpret_cast( - GetGLProcAddress("glGetInteger64v")); - DCHECK(fn.glGetInteger64vFn); - } - - debug_fn.glGetIntegeri_vFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glGetIntegeri_vFn = reinterpret_cast( - GetGLProcAddress("glGetIntegeri_v")); - DCHECK(fn.glGetIntegeri_vFn); - } - - debug_fn.glGetInternalformativFn = 0; - if (ver->IsAtLeastGL(4u, 2u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glGetInternalformativFn = reinterpret_cast( - GetGLProcAddress("glGetInternalformativ")); - DCHECK(fn.glGetInternalformativFn); - } - - debug_fn.glGetProgramBinaryFn = 0; - if (ver->IsAtLeastGL(4u, 1u) || ver->IsAtLeastGLES(3u, 0u) || - ext.b_GL_ARB_get_program_binary) { - fn.glGetProgramBinaryFn = reinterpret_cast( - GetGLProcAddress("glGetProgramBinary")); - DCHECK(fn.glGetProgramBinaryFn); - } else if (ext.b_GL_OES_get_program_binary) { - fn.glGetProgramBinaryFn = reinterpret_cast( - GetGLProcAddress("glGetProgramBinaryOES")); - DCHECK(fn.glGetProgramBinaryFn); - } - - debug_fn.glGetProgramResourceLocationFn = 0; - if (ver->IsAtLeastGL(4u, 3u) || ver->IsAtLeastGLES(3u, 1u)) { - fn.glGetProgramResourceLocationFn = - reinterpret_cast( - GetGLProcAddress("glGetProgramResourceLocation")); - DCHECK(fn.glGetProgramResourceLocationFn); - } - - debug_fn.glGetQueryivFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glGetQueryivFn = - reinterpret_cast(GetGLProcAddress("glGetQueryiv")); - DCHECK(fn.glGetQueryivFn); - } else if (ext.b_GL_ARB_occlusion_query) { - fn.glGetQueryivFn = - reinterpret_cast(GetGLProcAddress("glGetQueryivARB")); - DCHECK(fn.glGetQueryivFn); - } else if (ext.b_GL_EXT_disjoint_timer_query || - ext.b_GL_EXT_occlusion_query_boolean) { - fn.glGetQueryivFn = - reinterpret_cast(GetGLProcAddress("glGetQueryivEXT")); - DCHECK(fn.glGetQueryivFn); - } - - debug_fn.glGetQueryObjecti64vFn = 0; - if (ver->IsAtLeastGL(3u, 3u) || ext.b_GL_ARB_timer_query) { - fn.glGetQueryObjecti64vFn = reinterpret_cast( - GetGLProcAddress("glGetQueryObjecti64v")); - DCHECK(fn.glGetQueryObjecti64vFn); - } else if (ext.b_GL_EXT_timer_query || ext.b_GL_EXT_disjoint_timer_query) { - fn.glGetQueryObjecti64vFn = reinterpret_cast( - GetGLProcAddress("glGetQueryObjecti64vEXT")); - DCHECK(fn.glGetQueryObjecti64vFn); - } - - debug_fn.glGetQueryObjectivFn = 0; - if (!ver->is_es) { - fn.glGetQueryObjectivFn = reinterpret_cast( - GetGLProcAddress("glGetQueryObjectiv")); - DCHECK(fn.glGetQueryObjectivFn); - } else if (ext.b_GL_ARB_occlusion_query) { - fn.glGetQueryObjectivFn = reinterpret_cast( - GetGLProcAddress("glGetQueryObjectivARB")); - DCHECK(fn.glGetQueryObjectivFn); - } else if (ext.b_GL_EXT_disjoint_timer_query) { - fn.glGetQueryObjectivFn = reinterpret_cast( - GetGLProcAddress("glGetQueryObjectivEXT")); - DCHECK(fn.glGetQueryObjectivFn); - } - - debug_fn.glGetQueryObjectui64vFn = 0; - if (ver->IsAtLeastGL(3u, 3u) || ext.b_GL_ARB_timer_query) { - fn.glGetQueryObjectui64vFn = reinterpret_cast( - GetGLProcAddress("glGetQueryObjectui64v")); - DCHECK(fn.glGetQueryObjectui64vFn); - } else if (ext.b_GL_EXT_timer_query || ext.b_GL_EXT_disjoint_timer_query) { - fn.glGetQueryObjectui64vFn = reinterpret_cast( - GetGLProcAddress("glGetQueryObjectui64vEXT")); - DCHECK(fn.glGetQueryObjectui64vFn); - } - - debug_fn.glGetQueryObjectuivFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glGetQueryObjectuivFn = reinterpret_cast( - GetGLProcAddress("glGetQueryObjectuiv")); - DCHECK(fn.glGetQueryObjectuivFn); - } else if (ext.b_GL_ARB_occlusion_query) { - fn.glGetQueryObjectuivFn = reinterpret_cast( - GetGLProcAddress("glGetQueryObjectuivARB")); - DCHECK(fn.glGetQueryObjectuivFn); - } else if (ext.b_GL_EXT_disjoint_timer_query || - ext.b_GL_EXT_occlusion_query_boolean) { - fn.glGetQueryObjectuivFn = reinterpret_cast( - GetGLProcAddress("glGetQueryObjectuivEXT")); - DCHECK(fn.glGetQueryObjectuivFn); - } - - debug_fn.glGetRenderbufferParameterivEXTFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->is_es) { - fn.glGetRenderbufferParameterivEXTFn = - reinterpret_cast( - GetGLProcAddress("glGetRenderbufferParameteriv")); - DCHECK(fn.glGetRenderbufferParameterivEXTFn); - } else if (ext.b_GL_EXT_framebuffer_object) { - fn.glGetRenderbufferParameterivEXTFn = - reinterpret_cast( - GetGLProcAddress("glGetRenderbufferParameterivEXT")); - DCHECK(fn.glGetRenderbufferParameterivEXTFn); - } - - debug_fn.glGetSamplerParameterfvFn = 0; - if (ver->IsAtLeastGL(3u, 3u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glGetSamplerParameterfvFn = - reinterpret_cast( - GetGLProcAddress("glGetSamplerParameterfv")); - DCHECK(fn.glGetSamplerParameterfvFn); - } - - debug_fn.glGetSamplerParameterivFn = 0; - if (ver->IsAtLeastGL(3u, 3u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glGetSamplerParameterivFn = - reinterpret_cast( - GetGLProcAddress("glGetSamplerParameteriv")); - DCHECK(fn.glGetSamplerParameterivFn); - } - - debug_fn.glGetShaderPrecisionFormatFn = 0; - if (ver->IsAtLeastGL(4u, 1u) || ver->is_es) { - fn.glGetShaderPrecisionFormatFn = - reinterpret_cast( - GetGLProcAddress("glGetShaderPrecisionFormat")); - DCHECK(fn.glGetShaderPrecisionFormatFn); - } - - debug_fn.glGetStringiFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glGetStringiFn = - reinterpret_cast(GetGLProcAddress("glGetStringi")); - DCHECK(fn.glGetStringiFn); - } - - debug_fn.glGetSyncivFn = 0; - if (ver->IsAtLeastGL(3u, 2u) || ver->IsAtLeastGLES(3u, 0u) || - ext.b_GL_ARB_sync) { - fn.glGetSyncivFn = - reinterpret_cast(GetGLProcAddress("glGetSynciv")); - DCHECK(fn.glGetSyncivFn); - } - - debug_fn.glGetTexLevelParameterfvFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 1u)) { - fn.glGetTexLevelParameterfvFn = - reinterpret_cast( - GetGLProcAddress("glGetTexLevelParameterfv")); - DCHECK(fn.glGetTexLevelParameterfvFn); - } - - debug_fn.glGetTexLevelParameterivFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 1u)) { - fn.glGetTexLevelParameterivFn = - reinterpret_cast( - GetGLProcAddress("glGetTexLevelParameteriv")); - DCHECK(fn.glGetTexLevelParameterivFn); - } - - debug_fn.glGetTransformFeedbackVaryingFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glGetTransformFeedbackVaryingFn = - reinterpret_cast( - GetGLProcAddress("glGetTransformFeedbackVarying")); - DCHECK(fn.glGetTransformFeedbackVaryingFn); - } - - debug_fn.glGetTranslatedShaderSourceANGLEFn = 0; - if (ext.b_GL_ANGLE_translated_shader_source) { - fn.glGetTranslatedShaderSourceANGLEFn = - reinterpret_cast( - GetGLProcAddress("glGetTranslatedShaderSourceANGLE")); - DCHECK(fn.glGetTranslatedShaderSourceANGLEFn); - } - - debug_fn.glGetUniformBlockIndexFn = 0; - if (ver->IsAtLeastGLES(3u, 0u) || ver->IsAtLeastGL(3u, 1u)) { - fn.glGetUniformBlockIndexFn = reinterpret_cast( - GetGLProcAddress("glGetUniformBlockIndex")); - DCHECK(fn.glGetUniformBlockIndexFn); - } - - debug_fn.glGetUniformIndicesFn = 0; - if (ver->IsAtLeastGLES(3u, 0u) || ver->IsAtLeastGL(3u, 1u)) { - fn.glGetUniformIndicesFn = reinterpret_cast( - GetGLProcAddress("glGetUniformIndices")); - DCHECK(fn.glGetUniformIndicesFn); - } - - debug_fn.glInsertEventMarkerEXTFn = 0; - if (ext.b_GL_EXT_debug_marker) { - fn.glInsertEventMarkerEXTFn = reinterpret_cast( - GetGLProcAddress("glInsertEventMarkerEXT")); - DCHECK(fn.glInsertEventMarkerEXTFn); - } - - debug_fn.glInvalidateFramebufferFn = 0; - if (ver->IsAtLeastGL(4u, 3u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glInvalidateFramebufferFn = - reinterpret_cast( - GetGLProcAddress("glInvalidateFramebuffer")); - DCHECK(fn.glInvalidateFramebufferFn); - } - - debug_fn.glInvalidateSubFramebufferFn = 0; - if (ver->IsAtLeastGL(4u, 3u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glInvalidateSubFramebufferFn = - reinterpret_cast( - GetGLProcAddress("glInvalidateSubFramebuffer")); - DCHECK(fn.glInvalidateSubFramebufferFn); - } - - debug_fn.glIsFenceAPPLEFn = 0; - if (ext.b_GL_APPLE_fence) { - fn.glIsFenceAPPLEFn = reinterpret_cast( - GetGLProcAddress("glIsFenceAPPLE")); - DCHECK(fn.glIsFenceAPPLEFn); - } - - debug_fn.glIsFenceNVFn = 0; - if (ext.b_GL_NV_fence) { - fn.glIsFenceNVFn = - reinterpret_cast(GetGLProcAddress("glIsFenceNV")); - DCHECK(fn.glIsFenceNVFn); - } - - debug_fn.glIsFramebufferEXTFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->is_es) { - fn.glIsFramebufferEXTFn = reinterpret_cast( - GetGLProcAddress("glIsFramebuffer")); - DCHECK(fn.glIsFramebufferEXTFn); - } else if (ext.b_GL_EXT_framebuffer_object) { - fn.glIsFramebufferEXTFn = reinterpret_cast( - GetGLProcAddress("glIsFramebufferEXT")); - DCHECK(fn.glIsFramebufferEXTFn); - } - - debug_fn.glIsQueryFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glIsQueryFn = - reinterpret_cast(GetGLProcAddress("glIsQuery")); - DCHECK(fn.glIsQueryFn); - } else if (ext.b_GL_ARB_occlusion_query) { - fn.glIsQueryFn = - reinterpret_cast(GetGLProcAddress("glIsQueryARB")); - DCHECK(fn.glIsQueryFn); - } else if (ext.b_GL_EXT_disjoint_timer_query || - ext.b_GL_EXT_occlusion_query_boolean) { - fn.glIsQueryFn = - reinterpret_cast(GetGLProcAddress("glIsQueryEXT")); - DCHECK(fn.glIsQueryFn); - } - - debug_fn.glIsRenderbufferEXTFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->is_es) { - fn.glIsRenderbufferEXTFn = reinterpret_cast( - GetGLProcAddress("glIsRenderbuffer")); - DCHECK(fn.glIsRenderbufferEXTFn); - } else if (ext.b_GL_EXT_framebuffer_object) { - fn.glIsRenderbufferEXTFn = reinterpret_cast( - GetGLProcAddress("glIsRenderbufferEXT")); - DCHECK(fn.glIsRenderbufferEXTFn); - } - - debug_fn.glIsSamplerFn = 0; - if (ver->IsAtLeastGL(3u, 3u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glIsSamplerFn = - reinterpret_cast(GetGLProcAddress("glIsSampler")); - DCHECK(fn.glIsSamplerFn); - } - - debug_fn.glIsSyncFn = 0; - if (ver->IsAtLeastGL(3u, 2u) || ver->IsAtLeastGLES(3u, 0u) || - ext.b_GL_ARB_sync) { - fn.glIsSyncFn = - reinterpret_cast(GetGLProcAddress("glIsSync")); - DCHECK(fn.glIsSyncFn); - } - - debug_fn.glIsTransformFeedbackFn = 0; - if (ver->IsAtLeastGLES(3u, 0u) || ver->IsAtLeastGL(4u, 0u)) { - fn.glIsTransformFeedbackFn = reinterpret_cast( - GetGLProcAddress("glIsTransformFeedback")); - DCHECK(fn.glIsTransformFeedbackFn); - } - - debug_fn.glIsVertexArrayOESFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u) || - ext.b_GL_ARB_vertex_array_object) { - fn.glIsVertexArrayOESFn = reinterpret_cast( - GetGLProcAddress("glIsVertexArray")); - DCHECK(fn.glIsVertexArrayOESFn); - } else if (ext.b_GL_OES_vertex_array_object) { - fn.glIsVertexArrayOESFn = reinterpret_cast( - GetGLProcAddress("glIsVertexArrayOES")); - DCHECK(fn.glIsVertexArrayOESFn); - } else if (ext.b_GL_APPLE_vertex_array_object) { - fn.glIsVertexArrayOESFn = reinterpret_cast( - GetGLProcAddress("glIsVertexArrayAPPLE")); - DCHECK(fn.glIsVertexArrayOESFn); - } - - debug_fn.glMapBufferFn = 0; - if (!ver->is_es) { - fn.glMapBufferFn = - reinterpret_cast(GetGLProcAddress("glMapBuffer")); - DCHECK(fn.glMapBufferFn); - } else if (ext.b_GL_OES_mapbuffer) { - fn.glMapBufferFn = - reinterpret_cast(GetGLProcAddress("glMapBufferOES")); - DCHECK(fn.glMapBufferFn); - } - - debug_fn.glMapBufferRangeFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u) || - ext.b_GL_ARB_map_buffer_range) { - fn.glMapBufferRangeFn = reinterpret_cast( - GetGLProcAddress("glMapBufferRange")); - DCHECK(fn.glMapBufferRangeFn); - } else if (ext.b_GL_EXT_map_buffer_range) { - fn.glMapBufferRangeFn = reinterpret_cast( - GetGLProcAddress("glMapBufferRangeEXT")); - DCHECK(fn.glMapBufferRangeFn); - } - - debug_fn.glMatrixLoadfEXTFn = 0; - if (ext.b_GL_EXT_direct_state_access || ext.b_GL_NV_path_rendering) { - fn.glMatrixLoadfEXTFn = reinterpret_cast( - GetGLProcAddress("glMatrixLoadfEXT")); - DCHECK(fn.glMatrixLoadfEXTFn); - } - - debug_fn.glMatrixLoadIdentityEXTFn = 0; - if (ext.b_GL_EXT_direct_state_access || ext.b_GL_NV_path_rendering) { - fn.glMatrixLoadIdentityEXTFn = - reinterpret_cast( - GetGLProcAddress("glMatrixLoadIdentityEXT")); - DCHECK(fn.glMatrixLoadIdentityEXTFn); - } - - debug_fn.glObjectLabelKHRFn = 0; - if (ext.b_GL_KHR_debug) { - fn.glObjectLabelKHRFn = reinterpret_cast( - GetGLProcAddress("glObjectLabelKHR")); - DCHECK(fn.glObjectLabelKHRFn); - } - - debug_fn.glPauseTransformFeedbackFn = 0; - if (ver->IsAtLeastGLES(3u, 0u) || ver->IsAtLeastGL(4u, 0u)) { - fn.glPauseTransformFeedbackFn = - reinterpret_cast( - GetGLProcAddress("glPauseTransformFeedback")); - DCHECK(fn.glPauseTransformFeedbackFn); - } - - debug_fn.glPointParameteriFn = 0; - if (!ver->is_es) { - fn.glPointParameteriFn = reinterpret_cast( - GetGLProcAddress("glPointParameteri")); - DCHECK(fn.glPointParameteriFn); - } - - debug_fn.glPopDebugGroupKHRFn = 0; - if (ext.b_GL_KHR_debug) { - fn.glPopDebugGroupKHRFn = reinterpret_cast( - GetGLProcAddress("glPopDebugGroupKHR")); - DCHECK(fn.glPopDebugGroupKHRFn); - } - - debug_fn.glPopGroupMarkerEXTFn = 0; - if (ext.b_GL_EXT_debug_marker) { - fn.glPopGroupMarkerEXTFn = reinterpret_cast( - GetGLProcAddress("glPopGroupMarkerEXT")); - DCHECK(fn.glPopGroupMarkerEXTFn); - } - - debug_fn.glProgramBinaryFn = 0; - if (ver->IsAtLeastGL(4u, 1u) || ver->IsAtLeastGLES(3u, 0u) || - ext.b_GL_ARB_get_program_binary) { - fn.glProgramBinaryFn = reinterpret_cast( - GetGLProcAddress("glProgramBinary")); - DCHECK(fn.glProgramBinaryFn); - } else if (ext.b_GL_OES_get_program_binary) { - fn.glProgramBinaryFn = reinterpret_cast( - GetGLProcAddress("glProgramBinaryOES")); - DCHECK(fn.glProgramBinaryFn); - } - - debug_fn.glProgramParameteriFn = 0; - if (ver->IsAtLeastGL(4u, 1u) || ver->IsAtLeastGLES(3u, 0u) || - ext.b_GL_ARB_get_program_binary) { - fn.glProgramParameteriFn = reinterpret_cast( - GetGLProcAddress("glProgramParameteri")); - DCHECK(fn.glProgramParameteriFn); - } - - debug_fn.glPushDebugGroupKHRFn = 0; - if (ext.b_GL_KHR_debug) { - fn.glPushDebugGroupKHRFn = reinterpret_cast( - GetGLProcAddress("glPushDebugGroupKHR")); - DCHECK(fn.glPushDebugGroupKHRFn); - } - - debug_fn.glPushGroupMarkerEXTFn = 0; - if (ext.b_GL_EXT_debug_marker) { - fn.glPushGroupMarkerEXTFn = reinterpret_cast( - GetGLProcAddress("glPushGroupMarkerEXT")); - DCHECK(fn.glPushGroupMarkerEXTFn); - } - - debug_fn.glQueryCounterFn = 0; - if (ver->IsAtLeastGL(3u, 3u) || ext.b_GL_ARB_timer_query) { - fn.glQueryCounterFn = reinterpret_cast( - GetGLProcAddress("glQueryCounter")); - DCHECK(fn.glQueryCounterFn); - } else if (ext.b_GL_EXT_disjoint_timer_query) { - fn.glQueryCounterFn = reinterpret_cast( - GetGLProcAddress("glQueryCounterEXT")); - DCHECK(fn.glQueryCounterFn); - } - - debug_fn.glReadBufferFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glReadBufferFn = - reinterpret_cast(GetGLProcAddress("glReadBuffer")); - DCHECK(fn.glReadBufferFn); - } - - debug_fn.glReleaseShaderCompilerFn = 0; - if (ver->IsAtLeastGL(4u, 1u) || ver->is_es) { - fn.glReleaseShaderCompilerFn = - reinterpret_cast( - GetGLProcAddress("glReleaseShaderCompiler")); - DCHECK(fn.glReleaseShaderCompilerFn); - } - - debug_fn.glRenderbufferStorageEXTFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->is_es) { - fn.glRenderbufferStorageEXTFn = - reinterpret_cast( - GetGLProcAddress("glRenderbufferStorage")); - DCHECK(fn.glRenderbufferStorageEXTFn); - } else if (ext.b_GL_EXT_framebuffer_object) { - fn.glRenderbufferStorageEXTFn = - reinterpret_cast( - GetGLProcAddress("glRenderbufferStorageEXT")); - DCHECK(fn.glRenderbufferStorageEXTFn); - } - - debug_fn.glRenderbufferStorageMultisampleFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glRenderbufferStorageMultisampleFn = - reinterpret_cast( - GetGLProcAddress("glRenderbufferStorageMultisample")); - DCHECK(fn.glRenderbufferStorageMultisampleFn); - } - - debug_fn.glRenderbufferStorageMultisampleANGLEFn = 0; - if (ext.b_GL_ANGLE_framebuffer_multisample) { - fn.glRenderbufferStorageMultisampleANGLEFn = - reinterpret_cast( - GetGLProcAddress("glRenderbufferStorageMultisampleANGLE")); - DCHECK(fn.glRenderbufferStorageMultisampleANGLEFn); - } - - debug_fn.glRenderbufferStorageMultisampleAPPLEFn = 0; - if (ext.b_GL_APPLE_framebuffer_multisample) { - fn.glRenderbufferStorageMultisampleAPPLEFn = - reinterpret_cast( - GetGLProcAddress("glRenderbufferStorageMultisampleAPPLE")); - DCHECK(fn.glRenderbufferStorageMultisampleAPPLEFn); - } - - debug_fn.glRenderbufferStorageMultisampleEXTFn = 0; - if (ext.b_GL_EXT_multisampled_render_to_texture || - ext.b_GL_EXT_framebuffer_multisample) { - fn.glRenderbufferStorageMultisampleEXTFn = - reinterpret_cast( - GetGLProcAddress("glRenderbufferStorageMultisampleEXT")); - DCHECK(fn.glRenderbufferStorageMultisampleEXTFn); - } - - debug_fn.glRenderbufferStorageMultisampleIMGFn = 0; - if (ext.b_GL_IMG_multisampled_render_to_texture) { - fn.glRenderbufferStorageMultisampleIMGFn = - reinterpret_cast( - GetGLProcAddress("glRenderbufferStorageMultisampleIMG")); - DCHECK(fn.glRenderbufferStorageMultisampleIMGFn); - } - - debug_fn.glResolveMultisampleFramebufferAPPLEFn = 0; - if (ext.b_GL_APPLE_framebuffer_multisample) { - fn.glResolveMultisampleFramebufferAPPLEFn = - reinterpret_cast( - GetGLProcAddress("glResolveMultisampleFramebufferAPPLE")); - DCHECK(fn.glResolveMultisampleFramebufferAPPLEFn); - } - - debug_fn.glResumeTransformFeedbackFn = 0; - if (ver->IsAtLeastGLES(3u, 0u) || ver->IsAtLeastGL(4u, 0u)) { - fn.glResumeTransformFeedbackFn = - reinterpret_cast( - GetGLProcAddress("glResumeTransformFeedback")); - DCHECK(fn.glResumeTransformFeedbackFn); - } - - debug_fn.glSamplerParameterfFn = 0; - if (ver->IsAtLeastGL(3u, 3u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glSamplerParameterfFn = reinterpret_cast( - GetGLProcAddress("glSamplerParameterf")); - DCHECK(fn.glSamplerParameterfFn); - } - - debug_fn.glSamplerParameterfvFn = 0; - if (ver->IsAtLeastGL(3u, 3u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glSamplerParameterfvFn = reinterpret_cast( - GetGLProcAddress("glSamplerParameterfv")); - DCHECK(fn.glSamplerParameterfvFn); - } - - debug_fn.glSamplerParameteriFn = 0; - if (ver->IsAtLeastGL(3u, 3u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glSamplerParameteriFn = reinterpret_cast( - GetGLProcAddress("glSamplerParameteri")); - DCHECK(fn.glSamplerParameteriFn); - } - - debug_fn.glSamplerParameterivFn = 0; - if (ver->IsAtLeastGL(3u, 3u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glSamplerParameterivFn = reinterpret_cast( - GetGLProcAddress("glSamplerParameteriv")); - DCHECK(fn.glSamplerParameterivFn); - } - - debug_fn.glSetFenceAPPLEFn = 0; - if (ext.b_GL_APPLE_fence) { - fn.glSetFenceAPPLEFn = reinterpret_cast( - GetGLProcAddress("glSetFenceAPPLE")); - DCHECK(fn.glSetFenceAPPLEFn); - } - - debug_fn.glSetFenceNVFn = 0; - if (ext.b_GL_NV_fence) { - fn.glSetFenceNVFn = - reinterpret_cast(GetGLProcAddress("glSetFenceNV")); - DCHECK(fn.glSetFenceNVFn); - } - - debug_fn.glShaderBinaryFn = 0; - if (ver->IsAtLeastGL(4u, 1u) || ver->is_es) { - fn.glShaderBinaryFn = reinterpret_cast( - GetGLProcAddress("glShaderBinary")); - DCHECK(fn.glShaderBinaryFn); - } - - debug_fn.glTestFenceAPPLEFn = 0; - if (ext.b_GL_APPLE_fence) { - fn.glTestFenceAPPLEFn = reinterpret_cast( - GetGLProcAddress("glTestFenceAPPLE")); - DCHECK(fn.glTestFenceAPPLEFn); - } - - debug_fn.glTestFenceNVFn = 0; - if (ext.b_GL_NV_fence) { - fn.glTestFenceNVFn = - reinterpret_cast(GetGLProcAddress("glTestFenceNV")); - DCHECK(fn.glTestFenceNVFn); - } - - debug_fn.glTexImage3DFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glTexImage3DFn = - reinterpret_cast(GetGLProcAddress("glTexImage3D")); - DCHECK(fn.glTexImage3DFn); - } - - debug_fn.glTexStorage2DEXTFn = 0; - if (ver->IsAtLeastGL(4u, 2u) || ver->IsAtLeastGLES(3u, 0u) || - ext.b_GL_ARB_texture_storage) { - fn.glTexStorage2DEXTFn = reinterpret_cast( - GetGLProcAddress("glTexStorage2D")); - DCHECK(fn.glTexStorage2DEXTFn); - } else if (ext.b_GL_EXT_texture_storage) { - fn.glTexStorage2DEXTFn = reinterpret_cast( - GetGLProcAddress("glTexStorage2DEXT")); - DCHECK(fn.glTexStorage2DEXTFn); - } - - debug_fn.glTexStorage3DFn = 0; - if (ver->IsAtLeastGL(4u, 2u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glTexStorage3DFn = reinterpret_cast( - GetGLProcAddress("glTexStorage3D")); - DCHECK(fn.glTexStorage3DFn); - } - - debug_fn.glTextureBarrierNVFn = 0; - if (ext.b_GL_NV_texture_barrier) { - fn.glTextureBarrierNVFn = reinterpret_cast( - GetGLProcAddress("glTextureBarrierNV")); - DCHECK(fn.glTextureBarrierNVFn); - } - - debug_fn.glTransformFeedbackVaryingsFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glTransformFeedbackVaryingsFn = - reinterpret_cast( - GetGLProcAddress("glTransformFeedbackVaryings")); - DCHECK(fn.glTransformFeedbackVaryingsFn); - } - - debug_fn.glUniform1uiFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glUniform1uiFn = - reinterpret_cast(GetGLProcAddress("glUniform1ui")); - DCHECK(fn.glUniform1uiFn); - } - - debug_fn.glUniform1uivFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glUniform1uivFn = - reinterpret_cast(GetGLProcAddress("glUniform1uiv")); - DCHECK(fn.glUniform1uivFn); - } - - debug_fn.glUniform2uiFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glUniform2uiFn = - reinterpret_cast(GetGLProcAddress("glUniform2ui")); - DCHECK(fn.glUniform2uiFn); - } - - debug_fn.glUniform2uivFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glUniform2uivFn = - reinterpret_cast(GetGLProcAddress("glUniform2uiv")); - DCHECK(fn.glUniform2uivFn); - } - - debug_fn.glUniform3uiFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glUniform3uiFn = - reinterpret_cast(GetGLProcAddress("glUniform3ui")); - DCHECK(fn.glUniform3uiFn); - } - - debug_fn.glUniform3uivFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glUniform3uivFn = - reinterpret_cast(GetGLProcAddress("glUniform3uiv")); - DCHECK(fn.glUniform3uivFn); - } - - debug_fn.glUniform4uiFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glUniform4uiFn = - reinterpret_cast(GetGLProcAddress("glUniform4ui")); - DCHECK(fn.glUniform4uiFn); - } - - debug_fn.glUniform4uivFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glUniform4uivFn = - reinterpret_cast(GetGLProcAddress("glUniform4uiv")); - DCHECK(fn.glUniform4uivFn); - } - - debug_fn.glUniformBlockBindingFn = 0; - if (ver->IsAtLeastGLES(3u, 0u) || ver->IsAtLeastGL(3u, 1u)) { - fn.glUniformBlockBindingFn = reinterpret_cast( - GetGLProcAddress("glUniformBlockBinding")); - DCHECK(fn.glUniformBlockBindingFn); - } - - debug_fn.glUniformMatrix2x3fvFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glUniformMatrix2x3fvFn = reinterpret_cast( - GetGLProcAddress("glUniformMatrix2x3fv")); - DCHECK(fn.glUniformMatrix2x3fvFn); - } - - debug_fn.glUniformMatrix2x4fvFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glUniformMatrix2x4fvFn = reinterpret_cast( - GetGLProcAddress("glUniformMatrix2x4fv")); - DCHECK(fn.glUniformMatrix2x4fvFn); - } - - debug_fn.glUniformMatrix3x2fvFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glUniformMatrix3x2fvFn = reinterpret_cast( - GetGLProcAddress("glUniformMatrix3x2fv")); - DCHECK(fn.glUniformMatrix3x2fvFn); - } - - debug_fn.glUniformMatrix3x4fvFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glUniformMatrix3x4fvFn = reinterpret_cast( - GetGLProcAddress("glUniformMatrix3x4fv")); - DCHECK(fn.glUniformMatrix3x4fvFn); - } - - debug_fn.glUniformMatrix4x2fvFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glUniformMatrix4x2fvFn = reinterpret_cast( - GetGLProcAddress("glUniformMatrix4x2fv")); - DCHECK(fn.glUniformMatrix4x2fvFn); - } - - debug_fn.glUniformMatrix4x3fvFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glUniformMatrix4x3fvFn = reinterpret_cast( - GetGLProcAddress("glUniformMatrix4x3fv")); - DCHECK(fn.glUniformMatrix4x3fvFn); - } - - debug_fn.glUnmapBufferFn = 0; - if (!ver->is_es || ver->IsAtLeastGLES(3u, 0u)) { - fn.glUnmapBufferFn = - reinterpret_cast(GetGLProcAddress("glUnmapBuffer")); - DCHECK(fn.glUnmapBufferFn); - } else if (ext.b_GL_OES_mapbuffer) { - fn.glUnmapBufferFn = reinterpret_cast( - GetGLProcAddress("glUnmapBufferOES")); - DCHECK(fn.glUnmapBufferFn); - } - - debug_fn.glVertexAttribDivisorANGLEFn = 0; - if (ver->IsAtLeastGL(3u, 3u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glVertexAttribDivisorANGLEFn = - reinterpret_cast( - GetGLProcAddress("glVertexAttribDivisor")); - DCHECK(fn.glVertexAttribDivisorANGLEFn); - } else if (ext.b_GL_ARB_instanced_arrays) { - fn.glVertexAttribDivisorANGLEFn = - reinterpret_cast( - GetGLProcAddress("glVertexAttribDivisorARB")); - DCHECK(fn.glVertexAttribDivisorANGLEFn); - } else if (ext.b_GL_ANGLE_instanced_arrays) { - fn.glVertexAttribDivisorANGLEFn = - reinterpret_cast( - GetGLProcAddress("glVertexAttribDivisorANGLE")); - DCHECK(fn.glVertexAttribDivisorANGLEFn); - } - - debug_fn.glVertexAttribI4iFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glVertexAttribI4iFn = reinterpret_cast( - GetGLProcAddress("glVertexAttribI4i")); - DCHECK(fn.glVertexAttribI4iFn); - } - - debug_fn.glVertexAttribI4ivFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glVertexAttribI4ivFn = reinterpret_cast( - GetGLProcAddress("glVertexAttribI4iv")); - DCHECK(fn.glVertexAttribI4ivFn); - } - - debug_fn.glVertexAttribI4uiFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glVertexAttribI4uiFn = reinterpret_cast( - GetGLProcAddress("glVertexAttribI4ui")); - DCHECK(fn.glVertexAttribI4uiFn); - } - - debug_fn.glVertexAttribI4uivFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glVertexAttribI4uivFn = reinterpret_cast( - GetGLProcAddress("glVertexAttribI4uiv")); - DCHECK(fn.glVertexAttribI4uivFn); - } - - debug_fn.glVertexAttribIPointerFn = 0; - if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { - fn.glVertexAttribIPointerFn = reinterpret_cast( - GetGLProcAddress("glVertexAttribIPointer")); - DCHECK(fn.glVertexAttribIPointerFn); - } - - debug_fn.glWaitSyncFn = 0; - if (ver->IsAtLeastGL(3u, 2u) || ver->IsAtLeastGLES(3u, 0u) || - ext.b_GL_ARB_sync) { - fn.glWaitSyncFn = - reinterpret_cast(GetGLProcAddress("glWaitSync")); - DCHECK(fn.glWaitSyncFn); - } - - if (g_debugBindingsInitialized) - InitializeDebugBindings(); -} - -extern "C" { - -static void GL_BINDING_CALL Debug_glActiveTexture(GLenum texture) { - GL_SERVICE_LOG("glActiveTexture" - << "(" << GLEnums::GetStringEnum(texture) << ")"); - g_driver_gl.debug_fn.glActiveTextureFn(texture); -} - -static void GL_BINDING_CALL Debug_glAttachShader(GLuint program, - GLuint shader) { - GL_SERVICE_LOG("glAttachShader" - << "(" << program << ", " << shader << ")"); - g_driver_gl.debug_fn.glAttachShaderFn(program, shader); -} - -static void GL_BINDING_CALL Debug_glBeginQuery(GLenum target, GLuint id) { - GL_SERVICE_LOG("glBeginQuery" - << "(" << GLEnums::GetStringEnum(target) << ", " << id << ")"); - g_driver_gl.debug_fn.glBeginQueryFn(target, id); -} - -static void GL_BINDING_CALL -Debug_glBeginTransformFeedback(GLenum primitiveMode) { - GL_SERVICE_LOG("glBeginTransformFeedback" - << "(" << GLEnums::GetStringEnum(primitiveMode) << ")"); - g_driver_gl.debug_fn.glBeginTransformFeedbackFn(primitiveMode); -} - -static void GL_BINDING_CALL Debug_glBindAttribLocation(GLuint program, - GLuint index, - const char* name) { - GL_SERVICE_LOG("glBindAttribLocation" - << "(" << program << ", " << index << ", " << name << ")"); - g_driver_gl.debug_fn.glBindAttribLocationFn(program, index, name); -} - -static void GL_BINDING_CALL Debug_glBindBuffer(GLenum target, GLuint buffer) { - GL_SERVICE_LOG("glBindBuffer" - << "(" << GLEnums::GetStringEnum(target) << ", " << buffer - << ")"); - g_driver_gl.debug_fn.glBindBufferFn(target, buffer); -} - -static void GL_BINDING_CALL Debug_glBindBufferBase(GLenum target, - GLuint index, - GLuint buffer) { - GL_SERVICE_LOG("glBindBufferBase" - << "(" << GLEnums::GetStringEnum(target) << ", " << index - << ", " << buffer << ")"); - g_driver_gl.debug_fn.glBindBufferBaseFn(target, index, buffer); -} - -static void GL_BINDING_CALL Debug_glBindBufferRange(GLenum target, - GLuint index, - GLuint buffer, - GLintptr offset, - GLsizeiptr size) { - GL_SERVICE_LOG("glBindBufferRange" - << "(" << GLEnums::GetStringEnum(target) << ", " << index - << ", " << buffer << ", " << offset << ", " << size << ")"); - g_driver_gl.debug_fn.glBindBufferRangeFn(target, index, buffer, offset, size); -} - -static void GL_BINDING_CALL Debug_glBindFragDataLocation(GLuint program, - GLuint colorNumber, - const char* name) { - GL_SERVICE_LOG("glBindFragDataLocation" - << "(" << program << ", " << colorNumber << ", " << name - << ")"); - g_driver_gl.debug_fn.glBindFragDataLocationFn(program, colorNumber, name); -} - -static void GL_BINDING_CALL -Debug_glBindFragDataLocationIndexed(GLuint program, - GLuint colorNumber, - GLuint index, - const char* name) { - GL_SERVICE_LOG("glBindFragDataLocationIndexed" - << "(" << program << ", " << colorNumber << ", " << index - << ", " << name << ")"); - g_driver_gl.debug_fn.glBindFragDataLocationIndexedFn(program, colorNumber, - index, name); -} - -static void GL_BINDING_CALL Debug_glBindFramebufferEXT(GLenum target, - GLuint framebuffer) { - GL_SERVICE_LOG("glBindFramebufferEXT" - << "(" << GLEnums::GetStringEnum(target) << ", " << framebuffer - << ")"); - g_driver_gl.debug_fn.glBindFramebufferEXTFn(target, framebuffer); -} - -static void GL_BINDING_CALL Debug_glBindRenderbufferEXT(GLenum target, - GLuint renderbuffer) { - GL_SERVICE_LOG("glBindRenderbufferEXT" - << "(" << GLEnums::GetStringEnum(target) << ", " - << renderbuffer << ")"); - g_driver_gl.debug_fn.glBindRenderbufferEXTFn(target, renderbuffer); -} - -static void GL_BINDING_CALL Debug_glBindSampler(GLuint unit, GLuint sampler) { - GL_SERVICE_LOG("glBindSampler" - << "(" << unit << ", " << sampler << ")"); - g_driver_gl.debug_fn.glBindSamplerFn(unit, sampler); -} - -static void GL_BINDING_CALL Debug_glBindTexture(GLenum target, GLuint texture) { - GL_SERVICE_LOG("glBindTexture" - << "(" << GLEnums::GetStringEnum(target) << ", " << texture - << ")"); - g_driver_gl.debug_fn.glBindTextureFn(target, texture); -} - -static void GL_BINDING_CALL Debug_glBindTransformFeedback(GLenum target, - GLuint id) { - GL_SERVICE_LOG("glBindTransformFeedback" - << "(" << GLEnums::GetStringEnum(target) << ", " << id << ")"); - g_driver_gl.debug_fn.glBindTransformFeedbackFn(target, id); -} - -static void GL_BINDING_CALL Debug_glBindVertexArrayOES(GLuint array) { - GL_SERVICE_LOG("glBindVertexArrayOES" - << "(" << array << ")"); - g_driver_gl.debug_fn.glBindVertexArrayOESFn(array); -} - -static void GL_BINDING_CALL Debug_glBlendBarrierKHR(void) { - GL_SERVICE_LOG("glBlendBarrierKHR" - << "(" - << ")"); - g_driver_gl.debug_fn.glBlendBarrierKHRFn(); -} - -static void GL_BINDING_CALL Debug_glBlendColor(GLclampf red, - GLclampf green, - GLclampf blue, - GLclampf alpha) { - GL_SERVICE_LOG("glBlendColor" - << "(" << red << ", " << green << ", " << blue << ", " << alpha - << ")"); - g_driver_gl.debug_fn.glBlendColorFn(red, green, blue, alpha); -} - -static void GL_BINDING_CALL Debug_glBlendEquation(GLenum mode) { - GL_SERVICE_LOG("glBlendEquation" - << "(" << GLEnums::GetStringEnum(mode) << ")"); - g_driver_gl.debug_fn.glBlendEquationFn(mode); -} - -static void GL_BINDING_CALL Debug_glBlendEquationSeparate(GLenum modeRGB, - GLenum modeAlpha) { - GL_SERVICE_LOG("glBlendEquationSeparate" - << "(" << GLEnums::GetStringEnum(modeRGB) << ", " - << GLEnums::GetStringEnum(modeAlpha) << ")"); - g_driver_gl.debug_fn.glBlendEquationSeparateFn(modeRGB, modeAlpha); -} - -static void GL_BINDING_CALL Debug_glBlendFunc(GLenum sfactor, GLenum dfactor) { - GL_SERVICE_LOG("glBlendFunc" - << "(" << GLEnums::GetStringEnum(sfactor) << ", " - << GLEnums::GetStringEnum(dfactor) << ")"); - g_driver_gl.debug_fn.glBlendFuncFn(sfactor, dfactor); -} - -static void GL_BINDING_CALL Debug_glBlendFuncSeparate(GLenum srcRGB, - GLenum dstRGB, - GLenum srcAlpha, - GLenum dstAlpha) { - GL_SERVICE_LOG("glBlendFuncSeparate" - << "(" << GLEnums::GetStringEnum(srcRGB) << ", " - << GLEnums::GetStringEnum(dstRGB) << ", " - << GLEnums::GetStringEnum(srcAlpha) << ", " - << GLEnums::GetStringEnum(dstAlpha) << ")"); - g_driver_gl.debug_fn.glBlendFuncSeparateFn(srcRGB, dstRGB, srcAlpha, - dstAlpha); -} - -static void GL_BINDING_CALL Debug_glBlitFramebuffer(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) { - GL_SERVICE_LOG("glBlitFramebuffer" - << "(" << srcX0 << ", " << srcY0 << ", " << srcX1 << ", " - << srcY1 << ", " << dstX0 << ", " << dstY0 << ", " << dstX1 - << ", " << dstY1 << ", " << mask << ", " - << GLEnums::GetStringEnum(filter) << ")"); - g_driver_gl.debug_fn.glBlitFramebufferFn(srcX0, srcY0, srcX1, srcY1, dstX0, - dstY0, dstX1, dstY1, mask, filter); -} - -static void GL_BINDING_CALL Debug_glBlitFramebufferANGLE(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) { - GL_SERVICE_LOG("glBlitFramebufferANGLE" - << "(" << srcX0 << ", " << srcY0 << ", " << srcX1 << ", " - << srcY1 << ", " << dstX0 << ", " << dstY0 << ", " << dstX1 - << ", " << dstY1 << ", " << mask << ", " - << GLEnums::GetStringEnum(filter) << ")"); - g_driver_gl.debug_fn.glBlitFramebufferANGLEFn( - srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); -} - -static void GL_BINDING_CALL Debug_glBlitFramebufferEXT(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) { - GL_SERVICE_LOG("glBlitFramebufferEXT" - << "(" << srcX0 << ", " << srcY0 << ", " << srcX1 << ", " - << srcY1 << ", " << dstX0 << ", " << dstY0 << ", " << dstX1 - << ", " << dstY1 << ", " << mask << ", " - << GLEnums::GetStringEnum(filter) << ")"); - g_driver_gl.debug_fn.glBlitFramebufferEXTFn( - srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); -} - -static void GL_BINDING_CALL Debug_glBufferData(GLenum target, - GLsizeiptr size, - const void* data, - GLenum usage) { - GL_SERVICE_LOG("glBufferData" - << "(" << GLEnums::GetStringEnum(target) << ", " << size - << ", " << static_cast(data) << ", " - << GLEnums::GetStringEnum(usage) << ")"); - g_driver_gl.debug_fn.glBufferDataFn(target, size, data, usage); -} - -static void GL_BINDING_CALL Debug_glBufferSubData(GLenum target, - GLintptr offset, - GLsizeiptr size, - const void* data) { - GL_SERVICE_LOG("glBufferSubData" - << "(" << GLEnums::GetStringEnum(target) << ", " << offset - << ", " << size << ", " << static_cast(data) - << ")"); - g_driver_gl.debug_fn.glBufferSubDataFn(target, offset, size, data); -} - -static GLenum GL_BINDING_CALL Debug_glCheckFramebufferStatusEXT(GLenum target) { - GL_SERVICE_LOG("glCheckFramebufferStatusEXT" - << "(" << GLEnums::GetStringEnum(target) << ")"); - GLenum result = g_driver_gl.debug_fn.glCheckFramebufferStatusEXTFn(target); - - GL_SERVICE_LOG("GL_RESULT: " << GLEnums::GetStringEnum(result)); - - return result; -} - -static void GL_BINDING_CALL Debug_glClear(GLbitfield mask) { - GL_SERVICE_LOG("glClear" - << "(" << mask << ")"); - g_driver_gl.debug_fn.glClearFn(mask); -} - -static void GL_BINDING_CALL Debug_glClearBufferfi(GLenum buffer, - GLint drawbuffer, - const GLfloat depth, - GLint stencil) { - GL_SERVICE_LOG("glClearBufferfi" - << "(" << GLEnums::GetStringEnum(buffer) << ", " << drawbuffer - << ", " << depth << ", " << stencil << ")"); - g_driver_gl.debug_fn.glClearBufferfiFn(buffer, drawbuffer, depth, stencil); -} - -static void GL_BINDING_CALL Debug_glClearBufferfv(GLenum buffer, - GLint drawbuffer, - const GLfloat* value) { - GL_SERVICE_LOG("glClearBufferfv" - << "(" << GLEnums::GetStringEnum(buffer) << ", " << drawbuffer - << ", " << static_cast(value) << ")"); - g_driver_gl.debug_fn.glClearBufferfvFn(buffer, drawbuffer, value); -} - -static void GL_BINDING_CALL Debug_glClearBufferiv(GLenum buffer, - GLint drawbuffer, - const GLint* value) { - GL_SERVICE_LOG("glClearBufferiv" - << "(" << GLEnums::GetStringEnum(buffer) << ", " << drawbuffer - << ", " << static_cast(value) << ")"); - g_driver_gl.debug_fn.glClearBufferivFn(buffer, drawbuffer, value); -} - -static void GL_BINDING_CALL Debug_glClearBufferuiv(GLenum buffer, - GLint drawbuffer, - const GLuint* value) { - GL_SERVICE_LOG("glClearBufferuiv" - << "(" << GLEnums::GetStringEnum(buffer) << ", " << drawbuffer - << ", " << static_cast(value) << ")"); - g_driver_gl.debug_fn.glClearBufferuivFn(buffer, drawbuffer, value); -} - -static void GL_BINDING_CALL Debug_glClearColor(GLclampf red, - GLclampf green, - GLclampf blue, - GLclampf alpha) { - GL_SERVICE_LOG("glClearColor" - << "(" << red << ", " << green << ", " << blue << ", " << alpha - << ")"); - g_driver_gl.debug_fn.glClearColorFn(red, green, blue, alpha); -} - -static void GL_BINDING_CALL Debug_glClearDepth(GLclampd depth) { - GL_SERVICE_LOG("glClearDepth" - << "(" << depth << ")"); - g_driver_gl.debug_fn.glClearDepthFn(depth); -} - -static void GL_BINDING_CALL Debug_glClearDepthf(GLclampf depth) { - GL_SERVICE_LOG("glClearDepthf" - << "(" << depth << ")"); - g_driver_gl.debug_fn.glClearDepthfFn(depth); -} - -static void GL_BINDING_CALL Debug_glClearStencil(GLint s) { - GL_SERVICE_LOG("glClearStencil" - << "(" << s << ")"); - g_driver_gl.debug_fn.glClearStencilFn(s); -} - -static GLenum GL_BINDING_CALL Debug_glClientWaitSync(GLsync sync, - GLbitfield flags, - GLuint64 timeout) { - GL_SERVICE_LOG("glClientWaitSync" - << "(" << sync << ", " << flags << ", " << timeout << ")"); - GLenum result = g_driver_gl.debug_fn.glClientWaitSyncFn(sync, flags, timeout); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void GL_BINDING_CALL Debug_glColorMask(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha) { - GL_SERVICE_LOG("glColorMask" - << "(" << GLEnums::GetStringBool(red) << ", " - << GLEnums::GetStringBool(green) << ", " - << GLEnums::GetStringBool(blue) << ", " - << GLEnums::GetStringBool(alpha) << ")"); - g_driver_gl.debug_fn.glColorMaskFn(red, green, blue, alpha); -} - -static void GL_BINDING_CALL Debug_glCompileShader(GLuint shader) { - GL_SERVICE_LOG("glCompileShader" - << "(" << shader << ")"); - g_driver_gl.debug_fn.glCompileShaderFn(shader); -} - -static void GL_BINDING_CALL Debug_glCompressedTexImage2D(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const void* data) { - GL_SERVICE_LOG("glCompressedTexImage2D" - << "(" << GLEnums::GetStringEnum(target) << ", " << level - << ", " << GLEnums::GetStringEnum(internalformat) << ", " - << width << ", " << height << ", " << border << ", " - << imageSize << ", " << static_cast(data) << ")"); - g_driver_gl.debug_fn.glCompressedTexImage2DFn( - target, level, internalformat, width, height, border, imageSize, data); -} - -static void GL_BINDING_CALL Debug_glCompressedTexImage3D(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLsizei imageSize, - const void* data) { - GL_SERVICE_LOG("glCompressedTexImage3D" - << "(" << GLEnums::GetStringEnum(target) << ", " << level - << ", " << GLEnums::GetStringEnum(internalformat) << ", " - << width << ", " << height << ", " << depth << ", " << border - << ", " << imageSize << ", " << static_cast(data) - << ")"); - g_driver_gl.debug_fn.glCompressedTexImage3DFn(target, level, internalformat, - width, height, depth, border, - imageSize, data); -} - -static void GL_BINDING_CALL Debug_glCompressedTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const void* data) { - GL_SERVICE_LOG("glCompressedTexSubImage2D" - << "(" << GLEnums::GetStringEnum(target) << ", " << level - << ", " << xoffset << ", " << yoffset << ", " << width << ", " - << height << ", " << GLEnums::GetStringEnum(format) << ", " - << imageSize << ", " << static_cast(data) << ")"); - g_driver_gl.debug_fn.glCompressedTexSubImage2DFn( - target, level, xoffset, yoffset, width, height, format, imageSize, data); -} - -static void GL_BINDING_CALL Debug_glCopyBufferSubData(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size) { - GL_SERVICE_LOG("glCopyBufferSubData" - << "(" << GLEnums::GetStringEnum(readTarget) << ", " - << GLEnums::GetStringEnum(writeTarget) << ", " << readOffset - << ", " << writeOffset << ", " << size << ")"); - g_driver_gl.debug_fn.glCopyBufferSubDataFn(readTarget, writeTarget, - readOffset, writeOffset, size); -} - -static void GL_BINDING_CALL Debug_glCopyTexImage2D(GLenum target, - GLint level, - GLenum internalformat, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLint border) { - GL_SERVICE_LOG("glCopyTexImage2D" - << "(" << GLEnums::GetStringEnum(target) << ", " << level - << ", " << GLEnums::GetStringEnum(internalformat) << ", " << x - << ", " << y << ", " << width << ", " << height << ", " - << border << ")"); - g_driver_gl.debug_fn.glCopyTexImage2DFn(target, level, internalformat, x, y, - width, height, border); -} - -static void GL_BINDING_CALL Debug_glCopyTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height) { - GL_SERVICE_LOG("glCopyTexSubImage2D" - << "(" << GLEnums::GetStringEnum(target) << ", " << level - << ", " << xoffset << ", " << yoffset << ", " << x << ", " << y - << ", " << width << ", " << height << ")"); - g_driver_gl.debug_fn.glCopyTexSubImage2DFn(target, level, xoffset, yoffset, x, - y, width, height); -} - -static void GL_BINDING_CALL Debug_glCopyTexSubImage3D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height) { - GL_SERVICE_LOG("glCopyTexSubImage3D" - << "(" << GLEnums::GetStringEnum(target) << ", " << level - << ", " << xoffset << ", " << yoffset << ", " << zoffset - << ", " << x << ", " << y << ", " << width << ", " << height - << ")"); - g_driver_gl.debug_fn.glCopyTexSubImage3DFn(target, level, xoffset, yoffset, - zoffset, x, y, width, height); -} - -static GLuint GL_BINDING_CALL Debug_glCreateProgram(void) { - GL_SERVICE_LOG("glCreateProgram" - << "(" - << ")"); - GLuint result = g_driver_gl.debug_fn.glCreateProgramFn(); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLuint GL_BINDING_CALL Debug_glCreateShader(GLenum type) { - GL_SERVICE_LOG("glCreateShader" - << "(" << GLEnums::GetStringEnum(type) << ")"); - GLuint result = g_driver_gl.debug_fn.glCreateShaderFn(type); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void GL_BINDING_CALL Debug_glCullFace(GLenum mode) { - GL_SERVICE_LOG("glCullFace" - << "(" << GLEnums::GetStringEnum(mode) << ")"); - g_driver_gl.debug_fn.glCullFaceFn(mode); -} - -static void GL_BINDING_CALL -Debug_glDebugMessageCallbackKHR(GLDEBUGPROCKHR callback, - const void* userparam) { - GL_SERVICE_LOG("glDebugMessageCallbackKHR" - << "(" << callback << ", " - << static_cast(userparam) << ")"); - g_driver_gl.debug_fn.glDebugMessageCallbackKHRFn(callback, userparam); -} - -static void GL_BINDING_CALL Debug_glDebugMessageControlKHR(GLenum source, - GLenum type, - GLenum severity, - GLsizei count, - const GLuint* ids, - GLboolean enabled) { - GL_SERVICE_LOG("glDebugMessageControlKHR" - << "(" << GLEnums::GetStringEnum(source) << ", " - << GLEnums::GetStringEnum(type) << ", " - << GLEnums::GetStringEnum(severity) << ", " << count << ", " - << static_cast(ids) << ", " - << GLEnums::GetStringBool(enabled) << ")"); - g_driver_gl.debug_fn.glDebugMessageControlKHRFn(source, type, severity, count, - ids, enabled); -} - -static void GL_BINDING_CALL Debug_glDebugMessageInsertKHR(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar* buf) { - GL_SERVICE_LOG("glDebugMessageInsertKHR" - << "(" << GLEnums::GetStringEnum(source) << ", " - << GLEnums::GetStringEnum(type) << ", " << id << ", " - << GLEnums::GetStringEnum(severity) << ", " << length << ", " - << static_cast(buf) << ")"); - g_driver_gl.debug_fn.glDebugMessageInsertKHRFn(source, type, id, severity, - length, buf); -} - -static void GL_BINDING_CALL Debug_glDeleteBuffersARB(GLsizei n, - const GLuint* buffers) { - GL_SERVICE_LOG("glDeleteBuffersARB" - << "(" << n << ", " << static_cast(buffers) - << ")"); - g_driver_gl.debug_fn.glDeleteBuffersARBFn(n, buffers); -} - -static void GL_BINDING_CALL Debug_glDeleteFencesAPPLE(GLsizei n, - const GLuint* fences) { - GL_SERVICE_LOG("glDeleteFencesAPPLE" - << "(" << n << ", " << static_cast(fences) - << ")"); - g_driver_gl.debug_fn.glDeleteFencesAPPLEFn(n, fences); -} - -static void GL_BINDING_CALL Debug_glDeleteFencesNV(GLsizei n, - const GLuint* fences) { - GL_SERVICE_LOG("glDeleteFencesNV" - << "(" << n << ", " << static_cast(fences) - << ")"); - g_driver_gl.debug_fn.glDeleteFencesNVFn(n, fences); -} - -static void GL_BINDING_CALL -Debug_glDeleteFramebuffersEXT(GLsizei n, const GLuint* framebuffers) { - GL_SERVICE_LOG("glDeleteFramebuffersEXT" - << "(" << n << ", " << static_cast(framebuffers) - << ")"); - g_driver_gl.debug_fn.glDeleteFramebuffersEXTFn(n, framebuffers); -} - -static void GL_BINDING_CALL Debug_glDeleteProgram(GLuint program) { - GL_SERVICE_LOG("glDeleteProgram" - << "(" << program << ")"); - g_driver_gl.debug_fn.glDeleteProgramFn(program); -} - -static void GL_BINDING_CALL Debug_glDeleteQueries(GLsizei n, - const GLuint* ids) { - GL_SERVICE_LOG("glDeleteQueries" - << "(" << n << ", " << static_cast(ids) << ")"); - g_driver_gl.debug_fn.glDeleteQueriesFn(n, ids); -} - -static void GL_BINDING_CALL -Debug_glDeleteRenderbuffersEXT(GLsizei n, const GLuint* renderbuffers) { - GL_SERVICE_LOG("glDeleteRenderbuffersEXT" - << "(" << n << ", " << static_cast(renderbuffers) - << ")"); - g_driver_gl.debug_fn.glDeleteRenderbuffersEXTFn(n, renderbuffers); -} - -static void GL_BINDING_CALL Debug_glDeleteSamplers(GLsizei n, - const GLuint* samplers) { - GL_SERVICE_LOG("glDeleteSamplers" - << "(" << n << ", " << static_cast(samplers) - << ")"); - g_driver_gl.debug_fn.glDeleteSamplersFn(n, samplers); -} - -static void GL_BINDING_CALL Debug_glDeleteShader(GLuint shader) { - GL_SERVICE_LOG("glDeleteShader" - << "(" << shader << ")"); - g_driver_gl.debug_fn.glDeleteShaderFn(shader); -} - -static void GL_BINDING_CALL Debug_glDeleteSync(GLsync sync) { - GL_SERVICE_LOG("glDeleteSync" - << "(" << sync << ")"); - g_driver_gl.debug_fn.glDeleteSyncFn(sync); -} - -static void GL_BINDING_CALL Debug_glDeleteTextures(GLsizei n, - const GLuint* textures) { - GL_SERVICE_LOG("glDeleteTextures" - << "(" << n << ", " << static_cast(textures) - << ")"); - g_driver_gl.debug_fn.glDeleteTexturesFn(n, textures); -} - -static void GL_BINDING_CALL -Debug_glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) { - GL_SERVICE_LOG("glDeleteTransformFeedbacks" - << "(" << n << ", " << static_cast(ids) << ")"); - g_driver_gl.debug_fn.glDeleteTransformFeedbacksFn(n, ids); -} - -static void GL_BINDING_CALL -Debug_glDeleteVertexArraysOES(GLsizei n, const GLuint* arrays) { - GL_SERVICE_LOG("glDeleteVertexArraysOES" - << "(" << n << ", " << static_cast(arrays) - << ")"); - g_driver_gl.debug_fn.glDeleteVertexArraysOESFn(n, arrays); -} - -static void GL_BINDING_CALL Debug_glDepthFunc(GLenum func) { - GL_SERVICE_LOG("glDepthFunc" - << "(" << GLEnums::GetStringEnum(func) << ")"); - g_driver_gl.debug_fn.glDepthFuncFn(func); -} - -static void GL_BINDING_CALL Debug_glDepthMask(GLboolean flag) { - GL_SERVICE_LOG("glDepthMask" - << "(" << GLEnums::GetStringBool(flag) << ")"); - g_driver_gl.debug_fn.glDepthMaskFn(flag); -} - -static void GL_BINDING_CALL Debug_glDepthRange(GLclampd zNear, GLclampd zFar) { - GL_SERVICE_LOG("glDepthRange" - << "(" << zNear << ", " << zFar << ")"); - g_driver_gl.debug_fn.glDepthRangeFn(zNear, zFar); -} - -static void GL_BINDING_CALL Debug_glDepthRangef(GLclampf zNear, GLclampf zFar) { - GL_SERVICE_LOG("glDepthRangef" - << "(" << zNear << ", " << zFar << ")"); - g_driver_gl.debug_fn.glDepthRangefFn(zNear, zFar); -} - -static void GL_BINDING_CALL Debug_glDetachShader(GLuint program, - GLuint shader) { - GL_SERVICE_LOG("glDetachShader" - << "(" << program << ", " << shader << ")"); - g_driver_gl.debug_fn.glDetachShaderFn(program, shader); -} - -static void GL_BINDING_CALL Debug_glDisable(GLenum cap) { - GL_SERVICE_LOG("glDisable" - << "(" << GLEnums::GetStringEnum(cap) << ")"); - g_driver_gl.debug_fn.glDisableFn(cap); -} - -static void GL_BINDING_CALL Debug_glDisableVertexAttribArray(GLuint index) { - GL_SERVICE_LOG("glDisableVertexAttribArray" - << "(" << index << ")"); - g_driver_gl.debug_fn.glDisableVertexAttribArrayFn(index); -} - -static void GL_BINDING_CALL -Debug_glDiscardFramebufferEXT(GLenum target, - GLsizei numAttachments, - const GLenum* attachments) { - GL_SERVICE_LOG("glDiscardFramebufferEXT" - << "(" << GLEnums::GetStringEnum(target) << ", " - << numAttachments << ", " - << static_cast(attachments) << ")"); - g_driver_gl.debug_fn.glDiscardFramebufferEXTFn(target, numAttachments, - attachments); -} - -static void GL_BINDING_CALL Debug_glDrawArrays(GLenum mode, - GLint first, - GLsizei count) { - GL_SERVICE_LOG("glDrawArrays" - << "(" << GLEnums::GetStringEnum(mode) << ", " << first << ", " - << count << ")"); - g_driver_gl.debug_fn.glDrawArraysFn(mode, first, count); -} - -static void GL_BINDING_CALL -Debug_glDrawArraysInstancedANGLE(GLenum mode, - GLint first, - GLsizei count, - GLsizei primcount) { - GL_SERVICE_LOG("glDrawArraysInstancedANGLE" - << "(" << GLEnums::GetStringEnum(mode) << ", " << first << ", " - << count << ", " << primcount << ")"); - g_driver_gl.debug_fn.glDrawArraysInstancedANGLEFn(mode, first, count, - primcount); -} - -static void GL_BINDING_CALL Debug_glDrawBuffer(GLenum mode) { - GL_SERVICE_LOG("glDrawBuffer" - << "(" << GLEnums::GetStringEnum(mode) << ")"); - g_driver_gl.debug_fn.glDrawBufferFn(mode); -} - -static void GL_BINDING_CALL Debug_glDrawBuffersARB(GLsizei n, - const GLenum* bufs) { - GL_SERVICE_LOG("glDrawBuffersARB" - << "(" << n << ", " << static_cast(bufs) << ")"); - g_driver_gl.debug_fn.glDrawBuffersARBFn(n, bufs); -} - -static void GL_BINDING_CALL Debug_glDrawElements(GLenum mode, - GLsizei count, - GLenum type, - const void* indices) { - GL_SERVICE_LOG("glDrawElements" - << "(" << GLEnums::GetStringEnum(mode) << ", " << count << ", " - << GLEnums::GetStringEnum(type) << ", " - << static_cast(indices) << ")"); - g_driver_gl.debug_fn.glDrawElementsFn(mode, count, type, indices); -} - -static void GL_BINDING_CALL -Debug_glDrawElementsInstancedANGLE(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei primcount) { - GL_SERVICE_LOG("glDrawElementsInstancedANGLE" - << "(" << GLEnums::GetStringEnum(mode) << ", " << count << ", " - << GLEnums::GetStringEnum(type) << ", " - << static_cast(indices) << ", " << primcount - << ")"); - g_driver_gl.debug_fn.glDrawElementsInstancedANGLEFn(mode, count, type, - indices, primcount); -} - -static void GL_BINDING_CALL Debug_glDrawRangeElements(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices) { - GL_SERVICE_LOG("glDrawRangeElements" - << "(" << GLEnums::GetStringEnum(mode) << ", " << start << ", " - << end << ", " << count << ", " << GLEnums::GetStringEnum(type) - << ", " << static_cast(indices) << ")"); - g_driver_gl.debug_fn.glDrawRangeElementsFn(mode, start, end, count, type, - indices); -} - -static void GL_BINDING_CALL -Debug_glEGLImageTargetRenderbufferStorageOES(GLenum target, - GLeglImageOES image) { - GL_SERVICE_LOG("glEGLImageTargetRenderbufferStorageOES" - << "(" << GLEnums::GetStringEnum(target) << ", " << image - << ")"); - g_driver_gl.debug_fn.glEGLImageTargetRenderbufferStorageOESFn(target, image); -} - -static void GL_BINDING_CALL -Debug_glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) { - GL_SERVICE_LOG("glEGLImageTargetTexture2DOES" - << "(" << GLEnums::GetStringEnum(target) << ", " << image - << ")"); - g_driver_gl.debug_fn.glEGLImageTargetTexture2DOESFn(target, image); -} - -static void GL_BINDING_CALL Debug_glEnable(GLenum cap) { - GL_SERVICE_LOG("glEnable" - << "(" << GLEnums::GetStringEnum(cap) << ")"); - g_driver_gl.debug_fn.glEnableFn(cap); -} - -static void GL_BINDING_CALL Debug_glEnableVertexAttribArray(GLuint index) { - GL_SERVICE_LOG("glEnableVertexAttribArray" - << "(" << index << ")"); - g_driver_gl.debug_fn.glEnableVertexAttribArrayFn(index); -} - -static void GL_BINDING_CALL Debug_glEndQuery(GLenum target) { - GL_SERVICE_LOG("glEndQuery" - << "(" << GLEnums::GetStringEnum(target) << ")"); - g_driver_gl.debug_fn.glEndQueryFn(target); -} - -static void GL_BINDING_CALL Debug_glEndTransformFeedback(void) { - GL_SERVICE_LOG("glEndTransformFeedback" - << "(" - << ")"); - g_driver_gl.debug_fn.glEndTransformFeedbackFn(); -} - -static GLsync GL_BINDING_CALL Debug_glFenceSync(GLenum condition, - GLbitfield flags) { - GL_SERVICE_LOG("glFenceSync" - << "(" << GLEnums::GetStringEnum(condition) << ", " << flags - << ")"); - GLsync result = g_driver_gl.debug_fn.glFenceSyncFn(condition, flags); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void GL_BINDING_CALL Debug_glFinish(void) { - GL_SERVICE_LOG("glFinish" - << "(" - << ")"); - g_driver_gl.debug_fn.glFinishFn(); -} - -static void GL_BINDING_CALL Debug_glFinishFenceAPPLE(GLuint fence) { - GL_SERVICE_LOG("glFinishFenceAPPLE" - << "(" << fence << ")"); - g_driver_gl.debug_fn.glFinishFenceAPPLEFn(fence); -} - -static void GL_BINDING_CALL Debug_glFinishFenceNV(GLuint fence) { - GL_SERVICE_LOG("glFinishFenceNV" - << "(" << fence << ")"); - g_driver_gl.debug_fn.glFinishFenceNVFn(fence); -} - -static void GL_BINDING_CALL Debug_glFlush(void) { - GL_SERVICE_LOG("glFlush" - << "(" - << ")"); - g_driver_gl.debug_fn.glFlushFn(); -} - -static void GL_BINDING_CALL Debug_glFlushMappedBufferRange(GLenum target, - GLintptr offset, - GLsizeiptr length) { - GL_SERVICE_LOG("glFlushMappedBufferRange" - << "(" << GLEnums::GetStringEnum(target) << ", " << offset - << ", " << length << ")"); - g_driver_gl.debug_fn.glFlushMappedBufferRangeFn(target, offset, length); -} - -static void GL_BINDING_CALL -Debug_glFramebufferRenderbufferEXT(GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer) { - GL_SERVICE_LOG("glFramebufferRenderbufferEXT" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(attachment) << ", " - << GLEnums::GetStringEnum(renderbuffertarget) << ", " - << renderbuffer << ")"); - g_driver_gl.debug_fn.glFramebufferRenderbufferEXTFn( - target, attachment, renderbuffertarget, renderbuffer); -} - -static void GL_BINDING_CALL Debug_glFramebufferTexture2DEXT(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level) { - GL_SERVICE_LOG("glFramebufferTexture2DEXT" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(attachment) << ", " - << GLEnums::GetStringEnum(textarget) << ", " << texture << ", " - << level << ")"); - g_driver_gl.debug_fn.glFramebufferTexture2DEXTFn(target, attachment, - textarget, texture, level); -} - -static void GL_BINDING_CALL -Debug_glFramebufferTexture2DMultisampleEXT(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples) { - GL_SERVICE_LOG("glFramebufferTexture2DMultisampleEXT" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(attachment) << ", " - << GLEnums::GetStringEnum(textarget) << ", " << texture << ", " - << level << ", " << samples << ")"); - g_driver_gl.debug_fn.glFramebufferTexture2DMultisampleEXTFn( - target, attachment, textarget, texture, level, samples); -} - -static void GL_BINDING_CALL -Debug_glFramebufferTexture2DMultisampleIMG(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples) { - GL_SERVICE_LOG("glFramebufferTexture2DMultisampleIMG" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(attachment) << ", " - << GLEnums::GetStringEnum(textarget) << ", " << texture << ", " - << level << ", " << samples << ")"); - g_driver_gl.debug_fn.glFramebufferTexture2DMultisampleIMGFn( - target, attachment, textarget, texture, level, samples); -} - -static void GL_BINDING_CALL Debug_glFramebufferTextureLayer(GLenum target, - GLenum attachment, - GLuint texture, - GLint level, - GLint layer) { - GL_SERVICE_LOG("glFramebufferTextureLayer" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(attachment) << ", " << texture - << ", " << level << ", " << layer << ")"); - g_driver_gl.debug_fn.glFramebufferTextureLayerFn(target, attachment, texture, - level, layer); -} - -static void GL_BINDING_CALL Debug_glFrontFace(GLenum mode) { - GL_SERVICE_LOG("glFrontFace" - << "(" << GLEnums::GetStringEnum(mode) << ")"); - g_driver_gl.debug_fn.glFrontFaceFn(mode); -} - -static void GL_BINDING_CALL Debug_glGenBuffersARB(GLsizei n, GLuint* buffers) { - GL_SERVICE_LOG("glGenBuffersARB" - << "(" << n << ", " << static_cast(buffers) - << ")"); - g_driver_gl.debug_fn.glGenBuffersARBFn(n, buffers); -} - -static void GL_BINDING_CALL Debug_glGenerateMipmapEXT(GLenum target) { - GL_SERVICE_LOG("glGenerateMipmapEXT" - << "(" << GLEnums::GetStringEnum(target) << ")"); - g_driver_gl.debug_fn.glGenerateMipmapEXTFn(target); -} - -static void GL_BINDING_CALL Debug_glGenFencesAPPLE(GLsizei n, GLuint* fences) { - GL_SERVICE_LOG("glGenFencesAPPLE" - << "(" << n << ", " << static_cast(fences) - << ")"); - g_driver_gl.debug_fn.glGenFencesAPPLEFn(n, fences); -} - -static void GL_BINDING_CALL Debug_glGenFencesNV(GLsizei n, GLuint* fences) { - GL_SERVICE_LOG("glGenFencesNV" - << "(" << n << ", " << static_cast(fences) - << ")"); - g_driver_gl.debug_fn.glGenFencesNVFn(n, fences); -} - -static void GL_BINDING_CALL Debug_glGenFramebuffersEXT(GLsizei n, - GLuint* framebuffers) { - GL_SERVICE_LOG("glGenFramebuffersEXT" - << "(" << n << ", " << static_cast(framebuffers) - << ")"); - g_driver_gl.debug_fn.glGenFramebuffersEXTFn(n, framebuffers); -} - -static void GL_BINDING_CALL Debug_glGenQueries(GLsizei n, GLuint* ids) { - GL_SERVICE_LOG("glGenQueries" - << "(" << n << ", " << static_cast(ids) << ")"); - g_driver_gl.debug_fn.glGenQueriesFn(n, ids); -} - -static void GL_BINDING_CALL Debug_glGenRenderbuffersEXT(GLsizei n, - GLuint* renderbuffers) { - GL_SERVICE_LOG("glGenRenderbuffersEXT" - << "(" << n << ", " << static_cast(renderbuffers) - << ")"); - g_driver_gl.debug_fn.glGenRenderbuffersEXTFn(n, renderbuffers); -} - -static void GL_BINDING_CALL Debug_glGenSamplers(GLsizei n, GLuint* samplers) { - GL_SERVICE_LOG("glGenSamplers" - << "(" << n << ", " << static_cast(samplers) - << ")"); - g_driver_gl.debug_fn.glGenSamplersFn(n, samplers); -} - -static void GL_BINDING_CALL Debug_glGenTextures(GLsizei n, GLuint* textures) { - GL_SERVICE_LOG("glGenTextures" - << "(" << n << ", " << static_cast(textures) - << ")"); - g_driver_gl.debug_fn.glGenTexturesFn(n, textures); -} - -static void GL_BINDING_CALL Debug_glGenTransformFeedbacks(GLsizei n, - GLuint* ids) { - GL_SERVICE_LOG("glGenTransformFeedbacks" - << "(" << n << ", " << static_cast(ids) << ")"); - g_driver_gl.debug_fn.glGenTransformFeedbacksFn(n, ids); -} - -static void GL_BINDING_CALL Debug_glGenVertexArraysOES(GLsizei n, - GLuint* arrays) { - GL_SERVICE_LOG("glGenVertexArraysOES" - << "(" << n << ", " << static_cast(arrays) - << ")"); - g_driver_gl.debug_fn.glGenVertexArraysOESFn(n, arrays); -} - -static void GL_BINDING_CALL Debug_glGetActiveAttrib(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - char* name) { - GL_SERVICE_LOG("glGetActiveAttrib" - << "(" << program << ", " << index << ", " << bufsize << ", " - << static_cast(length) << ", " - << static_cast(size) << ", " - << static_cast(type) << ", " - << static_cast(name) << ")"); - g_driver_gl.debug_fn.glGetActiveAttribFn(program, index, bufsize, length, - size, type, name); -} - -static void GL_BINDING_CALL Debug_glGetActiveUniform(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - char* name) { - GL_SERVICE_LOG("glGetActiveUniform" - << "(" << program << ", " << index << ", " << bufsize << ", " - << static_cast(length) << ", " - << static_cast(size) << ", " - << static_cast(type) << ", " - << static_cast(name) << ")"); - g_driver_gl.debug_fn.glGetActiveUniformFn(program, index, bufsize, length, - size, type, name); -} - -static void GL_BINDING_CALL -Debug_glGetActiveUniformBlockiv(GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint* params) { - GL_SERVICE_LOG("glGetActiveUniformBlockiv" - << "(" << program << ", " << uniformBlockIndex << ", " - << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetActiveUniformBlockivFn(program, uniformBlockIndex, - pname, params); -} - -static void GL_BINDING_CALL -Debug_glGetActiveUniformBlockName(GLuint program, - GLuint uniformBlockIndex, - GLsizei bufSize, - GLsizei* length, - char* uniformBlockName) { - GL_SERVICE_LOG("glGetActiveUniformBlockName" - << "(" << program << ", " << uniformBlockIndex << ", " - << bufSize << ", " << static_cast(length) << ", " - << static_cast(uniformBlockName) << ")"); - g_driver_gl.debug_fn.glGetActiveUniformBlockNameFn( - program, uniformBlockIndex, bufSize, length, uniformBlockName); -} - -static void GL_BINDING_CALL -Debug_glGetActiveUniformsiv(GLuint program, - GLsizei uniformCount, - const GLuint* uniformIndices, - GLenum pname, - GLint* params) { - GL_SERVICE_LOG("glGetActiveUniformsiv" - << "(" << program << ", " << uniformCount << ", " - << static_cast(uniformIndices) << ", " - << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetActiveUniformsivFn(program, uniformCount, - uniformIndices, pname, params); -} - -static void GL_BINDING_CALL Debug_glGetAttachedShaders(GLuint program, - GLsizei maxcount, - GLsizei* count, - GLuint* shaders) { - GL_SERVICE_LOG("glGetAttachedShaders" - << "(" << program << ", " << maxcount << ", " - << static_cast(count) << ", " - << static_cast(shaders) << ")"); - g_driver_gl.debug_fn.glGetAttachedShadersFn(program, maxcount, count, - shaders); -} - -static GLint GL_BINDING_CALL Debug_glGetAttribLocation(GLuint program, - const char* name) { - GL_SERVICE_LOG("glGetAttribLocation" - << "(" << program << ", " << name << ")"); - GLint result = g_driver_gl.debug_fn.glGetAttribLocationFn(program, name); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void GL_BINDING_CALL Debug_glGetBooleanv(GLenum pname, - GLboolean* params) { - GL_SERVICE_LOG("glGetBooleanv" - << "(" << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetBooleanvFn(pname, params); -} - -static void GL_BINDING_CALL Debug_glGetBufferParameteriv(GLenum target, - GLenum pname, - GLint* params) { - GL_SERVICE_LOG("glGetBufferParameteriv" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetBufferParameterivFn(target, pname, params); -} - -static GLuint GL_BINDING_CALL -Debug_glGetDebugMessageLogKHR(GLuint count, - GLsizei bufSize, - GLenum* sources, - GLenum* types, - GLuint* ids, - GLenum* severities, - GLsizei* lengths, - GLchar* messageLog) { - GL_SERVICE_LOG("glGetDebugMessageLogKHR" - << "(" << count << ", " << bufSize << ", " - << static_cast(sources) << ", " - << static_cast(types) << ", " - << static_cast(ids) << ", " - << static_cast(severities) << ", " - << static_cast(lengths) << ", " - << static_cast(messageLog) << ")"); - GLuint result = g_driver_gl.debug_fn.glGetDebugMessageLogKHRFn( - count, bufSize, sources, types, ids, severities, lengths, messageLog); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLenum GL_BINDING_CALL Debug_glGetError(void) { - GL_SERVICE_LOG("glGetError" - << "(" - << ")"); - GLenum result = g_driver_gl.debug_fn.glGetErrorFn(); - - GL_SERVICE_LOG("GL_RESULT: " << GLEnums::GetStringError(result)); - - return result; -} - -static void GL_BINDING_CALL Debug_glGetFenceivNV(GLuint fence, - GLenum pname, - GLint* params) { - GL_SERVICE_LOG("glGetFenceivNV" - << "(" << fence << ", " << GLEnums::GetStringEnum(pname) - << ", " << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetFenceivNVFn(fence, pname, params); -} - -static void GL_BINDING_CALL Debug_glGetFloatv(GLenum pname, GLfloat* params) { - GL_SERVICE_LOG("glGetFloatv" - << "(" << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetFloatvFn(pname, params); -} - -static GLint GL_BINDING_CALL Debug_glGetFragDataLocation(GLuint program, - const char* name) { - GL_SERVICE_LOG("glGetFragDataLocation" - << "(" << program << ", " << name << ")"); - GLint result = g_driver_gl.debug_fn.glGetFragDataLocationFn(program, name); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void GL_BINDING_CALL -Debug_glGetFramebufferAttachmentParameterivEXT(GLenum target, - GLenum attachment, - GLenum pname, - GLint* params) { - GL_SERVICE_LOG("glGetFramebufferAttachmentParameterivEXT" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(attachment) << ", " - << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetFramebufferAttachmentParameterivEXTFn( - target, attachment, pname, params); -} - -static GLenum GL_BINDING_CALL Debug_glGetGraphicsResetStatusARB(void) { - GL_SERVICE_LOG("glGetGraphicsResetStatusARB" - << "(" - << ")"); - GLenum result = g_driver_gl.debug_fn.glGetGraphicsResetStatusARBFn(); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void GL_BINDING_CALL Debug_glGetInteger64i_v(GLenum target, - GLuint index, - GLint64* data) { - GL_SERVICE_LOG("glGetInteger64i_v" - << "(" << GLEnums::GetStringEnum(target) << ", " << index - << ", " << static_cast(data) << ")"); - g_driver_gl.debug_fn.glGetInteger64i_vFn(target, index, data); -} - -static void GL_BINDING_CALL Debug_glGetInteger64v(GLenum pname, - GLint64* params) { - GL_SERVICE_LOG("glGetInteger64v" - << "(" << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetInteger64vFn(pname, params); -} - -static void GL_BINDING_CALL Debug_glGetIntegeri_v(GLenum target, - GLuint index, - GLint* data) { - GL_SERVICE_LOG("glGetIntegeri_v" - << "(" << GLEnums::GetStringEnum(target) << ", " << index - << ", " << static_cast(data) << ")"); - g_driver_gl.debug_fn.glGetIntegeri_vFn(target, index, data); -} - -static void GL_BINDING_CALL Debug_glGetIntegerv(GLenum pname, GLint* params) { - GL_SERVICE_LOG("glGetIntegerv" - << "(" << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetIntegervFn(pname, params); -} - -static void GL_BINDING_CALL Debug_glGetInternalformativ(GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLint* params) { - GL_SERVICE_LOG("glGetInternalformativ" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(internalformat) << ", " - << GLEnums::GetStringEnum(pname) << ", " << bufSize << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetInternalformativFn(target, internalformat, pname, - bufSize, params); -} - -static void GL_BINDING_CALL Debug_glGetProgramBinary(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - GLvoid* binary) { - GL_SERVICE_LOG("glGetProgramBinary" - << "(" << program << ", " << bufSize << ", " - << static_cast(length) << ", " - << static_cast(binaryFormat) << ", " - << static_cast(binary) << ")"); - g_driver_gl.debug_fn.glGetProgramBinaryFn(program, bufSize, length, - binaryFormat, binary); -} - -static void GL_BINDING_CALL Debug_glGetProgramInfoLog(GLuint program, - GLsizei bufsize, - GLsizei* length, - char* infolog) { - GL_SERVICE_LOG("glGetProgramInfoLog" - << "(" << program << ", " << bufsize << ", " - << static_cast(length) << ", " - << static_cast(infolog) << ")"); - g_driver_gl.debug_fn.glGetProgramInfoLogFn(program, bufsize, length, infolog); -} - -static void GL_BINDING_CALL Debug_glGetProgramiv(GLuint program, - GLenum pname, - GLint* params) { - GL_SERVICE_LOG("glGetProgramiv" - << "(" << program << ", " << GLEnums::GetStringEnum(pname) - << ", " << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetProgramivFn(program, pname, params); -} - -static GLint GL_BINDING_CALL -Debug_glGetProgramResourceLocation(GLuint program, - GLenum programInterface, - const char* name) { - GL_SERVICE_LOG("glGetProgramResourceLocation" - << "(" << program << ", " - << GLEnums::GetStringEnum(programInterface) << ", " << name - << ")"); - GLint result = g_driver_gl.debug_fn.glGetProgramResourceLocationFn( - program, programInterface, name); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void GL_BINDING_CALL Debug_glGetQueryiv(GLenum target, - GLenum pname, - GLint* params) { - GL_SERVICE_LOG("glGetQueryiv" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetQueryivFn(target, pname, params); -} - -static void GL_BINDING_CALL Debug_glGetQueryObjecti64v(GLuint id, - GLenum pname, - GLint64* params) { - GL_SERVICE_LOG("glGetQueryObjecti64v" - << "(" << id << ", " << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetQueryObjecti64vFn(id, pname, params); -} - -static void GL_BINDING_CALL Debug_glGetQueryObjectiv(GLuint id, - GLenum pname, - GLint* params) { - GL_SERVICE_LOG("glGetQueryObjectiv" - << "(" << id << ", " << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetQueryObjectivFn(id, pname, params); -} - -static void GL_BINDING_CALL Debug_glGetQueryObjectui64v(GLuint id, - GLenum pname, - GLuint64* params) { - GL_SERVICE_LOG("glGetQueryObjectui64v" - << "(" << id << ", " << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetQueryObjectui64vFn(id, pname, params); -} - -static void GL_BINDING_CALL Debug_glGetQueryObjectuiv(GLuint id, - GLenum pname, - GLuint* params) { - GL_SERVICE_LOG("glGetQueryObjectuiv" - << "(" << id << ", " << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetQueryObjectuivFn(id, pname, params); -} - -static void GL_BINDING_CALL -Debug_glGetRenderbufferParameterivEXT(GLenum target, - GLenum pname, - GLint* params) { - GL_SERVICE_LOG("glGetRenderbufferParameterivEXT" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetRenderbufferParameterivEXTFn(target, pname, params); -} - -static void GL_BINDING_CALL Debug_glGetSamplerParameterfv(GLuint sampler, - GLenum pname, - GLfloat* params) { - GL_SERVICE_LOG("glGetSamplerParameterfv" - << "(" << sampler << ", " << GLEnums::GetStringEnum(pname) - << ", " << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetSamplerParameterfvFn(sampler, pname, params); -} - -static void GL_BINDING_CALL Debug_glGetSamplerParameteriv(GLuint sampler, - GLenum pname, - GLint* params) { - GL_SERVICE_LOG("glGetSamplerParameteriv" - << "(" << sampler << ", " << GLEnums::GetStringEnum(pname) - << ", " << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetSamplerParameterivFn(sampler, pname, params); -} - -static void GL_BINDING_CALL Debug_glGetShaderInfoLog(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* infolog) { - GL_SERVICE_LOG("glGetShaderInfoLog" - << "(" << shader << ", " << bufsize << ", " - << static_cast(length) << ", " - << static_cast(infolog) << ")"); - g_driver_gl.debug_fn.glGetShaderInfoLogFn(shader, bufsize, length, infolog); -} - -static void GL_BINDING_CALL Debug_glGetShaderiv(GLuint shader, - GLenum pname, - GLint* params) { - GL_SERVICE_LOG("glGetShaderiv" - << "(" << shader << ", " << GLEnums::GetStringEnum(pname) - << ", " << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetShaderivFn(shader, pname, params); -} - -static void GL_BINDING_CALL -Debug_glGetShaderPrecisionFormat(GLenum shadertype, - GLenum precisiontype, - GLint* range, - GLint* precision) { - GL_SERVICE_LOG("glGetShaderPrecisionFormat" - << "(" << GLEnums::GetStringEnum(shadertype) << ", " - << GLEnums::GetStringEnum(precisiontype) << ", " - << static_cast(range) << ", " - << static_cast(precision) << ")"); - g_driver_gl.debug_fn.glGetShaderPrecisionFormatFn(shadertype, precisiontype, - range, precision); -} - -static void GL_BINDING_CALL Debug_glGetShaderSource(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* source) { - GL_SERVICE_LOG("glGetShaderSource" - << "(" << shader << ", " << bufsize << ", " - << static_cast(length) << ", " - << static_cast(source) << ")"); - g_driver_gl.debug_fn.glGetShaderSourceFn(shader, bufsize, length, source); -} - -static const GLubyte* GL_BINDING_CALL Debug_glGetString(GLenum name) { - GL_SERVICE_LOG("glGetString" - << "(" << GLEnums::GetStringEnum(name) << ")"); - const GLubyte* result = g_driver_gl.debug_fn.glGetStringFn(name); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static const GLubyte* GL_BINDING_CALL Debug_glGetStringi(GLenum name, - GLuint index) { - GL_SERVICE_LOG("glGetStringi" - << "(" << GLEnums::GetStringEnum(name) << ", " << index - << ")"); - const GLubyte* result = g_driver_gl.debug_fn.glGetStringiFn(name, index); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void GL_BINDING_CALL Debug_glGetSynciv(GLsync sync, - GLenum pname, - GLsizei bufSize, - GLsizei* length, - GLint* values) { - GL_SERVICE_LOG("glGetSynciv" - << "(" << sync << ", " << GLEnums::GetStringEnum(pname) << ", " - << bufSize << ", " << static_cast(length) << ", " - << static_cast(values) << ")"); - g_driver_gl.debug_fn.glGetSyncivFn(sync, pname, bufSize, length, values); -} - -static void GL_BINDING_CALL Debug_glGetTexLevelParameterfv(GLenum target, - GLint level, - GLenum pname, - GLfloat* params) { - GL_SERVICE_LOG("glGetTexLevelParameterfv" - << "(" << GLEnums::GetStringEnum(target) << ", " << level - << ", " << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetTexLevelParameterfvFn(target, level, pname, params); -} - -static void GL_BINDING_CALL Debug_glGetTexLevelParameteriv(GLenum target, - GLint level, - GLenum pname, - GLint* params) { - GL_SERVICE_LOG("glGetTexLevelParameteriv" - << "(" << GLEnums::GetStringEnum(target) << ", " << level - << ", " << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetTexLevelParameterivFn(target, level, pname, params); -} - -static void GL_BINDING_CALL Debug_glGetTexParameterfv(GLenum target, - GLenum pname, - GLfloat* params) { - GL_SERVICE_LOG("glGetTexParameterfv" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetTexParameterfvFn(target, pname, params); -} - -static void GL_BINDING_CALL Debug_glGetTexParameteriv(GLenum target, - GLenum pname, - GLint* params) { - GL_SERVICE_LOG("glGetTexParameteriv" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetTexParameterivFn(target, pname, params); -} - -static void GL_BINDING_CALL Debug_glGetTransformFeedbackVarying(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLsizei* size, - GLenum* type, - char* name) { - GL_SERVICE_LOG("glGetTransformFeedbackVarying" - << "(" << program << ", " << index << ", " << bufSize << ", " - << static_cast(length) << ", " - << static_cast(size) << ", " - << static_cast(type) << ", " - << static_cast(name) << ")"); - g_driver_gl.debug_fn.glGetTransformFeedbackVaryingFn( - program, index, bufSize, length, size, type, name); -} - -static void GL_BINDING_CALL -Debug_glGetTranslatedShaderSourceANGLE(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* source) { - GL_SERVICE_LOG("glGetTranslatedShaderSourceANGLE" - << "(" << shader << ", " << bufsize << ", " - << static_cast(length) << ", " - << static_cast(source) << ")"); - g_driver_gl.debug_fn.glGetTranslatedShaderSourceANGLEFn(shader, bufsize, - length, source); -} - -static GLuint GL_BINDING_CALL -Debug_glGetUniformBlockIndex(GLuint program, const char* uniformBlockName) { - GL_SERVICE_LOG("glGetUniformBlockIndex" - << "(" << program << ", " << uniformBlockName << ")"); - GLuint result = - g_driver_gl.debug_fn.glGetUniformBlockIndexFn(program, uniformBlockName); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void GL_BINDING_CALL Debug_glGetUniformfv(GLuint program, - GLint location, - GLfloat* params) { - GL_SERVICE_LOG("glGetUniformfv" - << "(" << program << ", " << location << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetUniformfvFn(program, location, params); -} - -static void GL_BINDING_CALL -Debug_glGetUniformIndices(GLuint program, - GLsizei uniformCount, - const char* const* uniformNames, - GLuint* uniformIndices) { - GL_SERVICE_LOG("glGetUniformIndices" - << "(" << program << ", " << uniformCount << ", " - << static_cast(uniformNames) << ", " - << static_cast(uniformIndices) << ")"); - g_driver_gl.debug_fn.glGetUniformIndicesFn(program, uniformCount, - uniformNames, uniformIndices); -} - -static void GL_BINDING_CALL Debug_glGetUniformiv(GLuint program, - GLint location, - GLint* params) { - GL_SERVICE_LOG("glGetUniformiv" - << "(" << program << ", " << location << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetUniformivFn(program, location, params); -} - -static GLint GL_BINDING_CALL Debug_glGetUniformLocation(GLuint program, - const char* name) { - GL_SERVICE_LOG("glGetUniformLocation" - << "(" << program << ", " << name << ")"); - GLint result = g_driver_gl.debug_fn.glGetUniformLocationFn(program, name); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void GL_BINDING_CALL Debug_glGetVertexAttribfv(GLuint index, - GLenum pname, - GLfloat* params) { - GL_SERVICE_LOG("glGetVertexAttribfv" - << "(" << index << ", " << GLEnums::GetStringEnum(pname) - << ", " << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetVertexAttribfvFn(index, pname, params); -} - -static void GL_BINDING_CALL Debug_glGetVertexAttribiv(GLuint index, - GLenum pname, - GLint* params) { - GL_SERVICE_LOG("glGetVertexAttribiv" - << "(" << index << ", " << GLEnums::GetStringEnum(pname) - << ", " << static_cast(params) << ")"); - g_driver_gl.debug_fn.glGetVertexAttribivFn(index, pname, params); -} - -static void GL_BINDING_CALL Debug_glGetVertexAttribPointerv(GLuint index, - GLenum pname, - void** pointer) { - GL_SERVICE_LOG("glGetVertexAttribPointerv" - << "(" << index << ", " << GLEnums::GetStringEnum(pname) - << ", " << pointer << ")"); - g_driver_gl.debug_fn.glGetVertexAttribPointervFn(index, pname, pointer); -} - -static void GL_BINDING_CALL Debug_glHint(GLenum target, GLenum mode) { - GL_SERVICE_LOG("glHint" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(mode) << ")"); - g_driver_gl.debug_fn.glHintFn(target, mode); -} - -static void GL_BINDING_CALL Debug_glInsertEventMarkerEXT(GLsizei length, - const char* marker) { - GL_SERVICE_LOG("glInsertEventMarkerEXT" - << "(" << length << ", " << marker << ")"); - g_driver_gl.debug_fn.glInsertEventMarkerEXTFn(length, marker); -} - -static void GL_BINDING_CALL -Debug_glInvalidateFramebuffer(GLenum target, - GLsizei numAttachments, - const GLenum* attachments) { - GL_SERVICE_LOG("glInvalidateFramebuffer" - << "(" << GLEnums::GetStringEnum(target) << ", " - << numAttachments << ", " - << static_cast(attachments) << ")"); - g_driver_gl.debug_fn.glInvalidateFramebufferFn(target, numAttachments, - attachments); -} - -static void GL_BINDING_CALL -Debug_glInvalidateSubFramebuffer(GLenum target, - GLsizei numAttachments, - const GLenum* attachments, - GLint x, - GLint y, - GLint width, - GLint height) { - GL_SERVICE_LOG("glInvalidateSubFramebuffer" - << "(" << GLEnums::GetStringEnum(target) << ", " - << numAttachments << ", " - << static_cast(attachments) << ", " << x << ", " - << y << ", " << width << ", " << height << ")"); - g_driver_gl.debug_fn.glInvalidateSubFramebufferFn( - target, numAttachments, attachments, x, y, width, height); -} - -static GLboolean GL_BINDING_CALL Debug_glIsBuffer(GLuint buffer) { - GL_SERVICE_LOG("glIsBuffer" - << "(" << buffer << ")"); - GLboolean result = g_driver_gl.debug_fn.glIsBufferFn(buffer); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLboolean GL_BINDING_CALL Debug_glIsEnabled(GLenum cap) { - GL_SERVICE_LOG("glIsEnabled" - << "(" << GLEnums::GetStringEnum(cap) << ")"); - GLboolean result = g_driver_gl.debug_fn.glIsEnabledFn(cap); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLboolean GL_BINDING_CALL Debug_glIsFenceAPPLE(GLuint fence) { - GL_SERVICE_LOG("glIsFenceAPPLE" - << "(" << fence << ")"); - GLboolean result = g_driver_gl.debug_fn.glIsFenceAPPLEFn(fence); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLboolean GL_BINDING_CALL Debug_glIsFenceNV(GLuint fence) { - GL_SERVICE_LOG("glIsFenceNV" - << "(" << fence << ")"); - GLboolean result = g_driver_gl.debug_fn.glIsFenceNVFn(fence); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLboolean GL_BINDING_CALL Debug_glIsFramebufferEXT(GLuint framebuffer) { - GL_SERVICE_LOG("glIsFramebufferEXT" - << "(" << framebuffer << ")"); - GLboolean result = g_driver_gl.debug_fn.glIsFramebufferEXTFn(framebuffer); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLboolean GL_BINDING_CALL Debug_glIsProgram(GLuint program) { - GL_SERVICE_LOG("glIsProgram" - << "(" << program << ")"); - GLboolean result = g_driver_gl.debug_fn.glIsProgramFn(program); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLboolean GL_BINDING_CALL Debug_glIsQuery(GLuint query) { - GL_SERVICE_LOG("glIsQuery" - << "(" << query << ")"); - GLboolean result = g_driver_gl.debug_fn.glIsQueryFn(query); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLboolean GL_BINDING_CALL -Debug_glIsRenderbufferEXT(GLuint renderbuffer) { - GL_SERVICE_LOG("glIsRenderbufferEXT" - << "(" << renderbuffer << ")"); - GLboolean result = g_driver_gl.debug_fn.glIsRenderbufferEXTFn(renderbuffer); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLboolean GL_BINDING_CALL Debug_glIsSampler(GLuint sampler) { - GL_SERVICE_LOG("glIsSampler" - << "(" << sampler << ")"); - GLboolean result = g_driver_gl.debug_fn.glIsSamplerFn(sampler); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLboolean GL_BINDING_CALL Debug_glIsShader(GLuint shader) { - GL_SERVICE_LOG("glIsShader" - << "(" << shader << ")"); - GLboolean result = g_driver_gl.debug_fn.glIsShaderFn(shader); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLboolean GL_BINDING_CALL Debug_glIsSync(GLsync sync) { - GL_SERVICE_LOG("glIsSync" - << "(" << sync << ")"); - GLboolean result = g_driver_gl.debug_fn.glIsSyncFn(sync); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLboolean GL_BINDING_CALL Debug_glIsTexture(GLuint texture) { - GL_SERVICE_LOG("glIsTexture" - << "(" << texture << ")"); - GLboolean result = g_driver_gl.debug_fn.glIsTextureFn(texture); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLboolean GL_BINDING_CALL Debug_glIsTransformFeedback(GLuint id) { - GL_SERVICE_LOG("glIsTransformFeedback" - << "(" << id << ")"); - GLboolean result = g_driver_gl.debug_fn.glIsTransformFeedbackFn(id); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLboolean GL_BINDING_CALL Debug_glIsVertexArrayOES(GLuint array) { - GL_SERVICE_LOG("glIsVertexArrayOES" - << "(" << array << ")"); - GLboolean result = g_driver_gl.debug_fn.glIsVertexArrayOESFn(array); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void GL_BINDING_CALL Debug_glLineWidth(GLfloat width) { - GL_SERVICE_LOG("glLineWidth" - << "(" << width << ")"); - g_driver_gl.debug_fn.glLineWidthFn(width); -} - -static void GL_BINDING_CALL Debug_glLinkProgram(GLuint program) { - GL_SERVICE_LOG("glLinkProgram" - << "(" << program << ")"); - g_driver_gl.debug_fn.glLinkProgramFn(program); -} - -static void* GL_BINDING_CALL Debug_glMapBuffer(GLenum target, GLenum access) { - GL_SERVICE_LOG("glMapBuffer" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(access) << ")"); - void* result = g_driver_gl.debug_fn.glMapBufferFn(target, access); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void* GL_BINDING_CALL Debug_glMapBufferRange(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access) { - GL_SERVICE_LOG("glMapBufferRange" - << "(" << GLEnums::GetStringEnum(target) << ", " << offset - << ", " << length << ", " << access << ")"); - void* result = - g_driver_gl.debug_fn.glMapBufferRangeFn(target, offset, length, access); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void GL_BINDING_CALL Debug_glMatrixLoadfEXT(GLenum matrixMode, - const GLfloat* m) { - GL_SERVICE_LOG("glMatrixLoadfEXT" - << "(" << GLEnums::GetStringEnum(matrixMode) << ", " - << static_cast(m) << ")"); - g_driver_gl.debug_fn.glMatrixLoadfEXTFn(matrixMode, m); -} - -static void GL_BINDING_CALL Debug_glMatrixLoadIdentityEXT(GLenum matrixMode) { - GL_SERVICE_LOG("glMatrixLoadIdentityEXT" - << "(" << GLEnums::GetStringEnum(matrixMode) << ")"); - g_driver_gl.debug_fn.glMatrixLoadIdentityEXTFn(matrixMode); -} - -static void GL_BINDING_CALL Debug_glObjectLabelKHR(GLenum identifier, - GLuint name, - GLsizei length, - const GLchar* label) { - GL_SERVICE_LOG("glObjectLabelKHR" - << "(" << GLEnums::GetStringEnum(identifier) << ", " << name - << ", " << length << ", " << static_cast(label) - << ")"); - g_driver_gl.debug_fn.glObjectLabelKHRFn(identifier, name, length, label); -} - -static void GL_BINDING_CALL Debug_glPauseTransformFeedback(void) { - GL_SERVICE_LOG("glPauseTransformFeedback" - << "(" - << ")"); - g_driver_gl.debug_fn.glPauseTransformFeedbackFn(); -} - -static void GL_BINDING_CALL Debug_glPixelStorei(GLenum pname, GLint param) { - GL_SERVICE_LOG("glPixelStorei" - << "(" << GLEnums::GetStringEnum(pname) << ", " << param - << ")"); - g_driver_gl.debug_fn.glPixelStoreiFn(pname, param); -} - -static void GL_BINDING_CALL Debug_glPointParameteri(GLenum pname, GLint param) { - GL_SERVICE_LOG("glPointParameteri" - << "(" << GLEnums::GetStringEnum(pname) << ", " << param - << ")"); - g_driver_gl.debug_fn.glPointParameteriFn(pname, param); -} - -static void GL_BINDING_CALL Debug_glPolygonOffset(GLfloat factor, - GLfloat units) { - GL_SERVICE_LOG("glPolygonOffset" - << "(" << factor << ", " << units << ")"); - g_driver_gl.debug_fn.glPolygonOffsetFn(factor, units); -} - -static void GL_BINDING_CALL Debug_glPopDebugGroupKHR(void) { - GL_SERVICE_LOG("glPopDebugGroupKHR" - << "(" - << ")"); - g_driver_gl.debug_fn.glPopDebugGroupKHRFn(); -} - -static void GL_BINDING_CALL Debug_glPopGroupMarkerEXT(void) { - GL_SERVICE_LOG("glPopGroupMarkerEXT" - << "(" - << ")"); - g_driver_gl.debug_fn.glPopGroupMarkerEXTFn(); -} - -static void GL_BINDING_CALL Debug_glProgramBinary(GLuint program, - GLenum binaryFormat, - const GLvoid* binary, - GLsizei length) { - GL_SERVICE_LOG("glProgramBinary" - << "(" << program << ", " - << GLEnums::GetStringEnum(binaryFormat) << ", " - << static_cast(binary) << ", " << length << ")"); - g_driver_gl.debug_fn.glProgramBinaryFn(program, binaryFormat, binary, length); -} - -static void GL_BINDING_CALL Debug_glProgramParameteri(GLuint program, - GLenum pname, - GLint value) { - GL_SERVICE_LOG("glProgramParameteri" - << "(" << program << ", " << GLEnums::GetStringEnum(pname) - << ", " << value << ")"); - g_driver_gl.debug_fn.glProgramParameteriFn(program, pname, value); -} - -static void GL_BINDING_CALL Debug_glPushDebugGroupKHR(GLenum source, - GLuint id, - GLsizei length, - const GLchar* message) { - GL_SERVICE_LOG("glPushDebugGroupKHR" - << "(" << GLEnums::GetStringEnum(source) << ", " << id << ", " - << length << ", " << static_cast(message) << ")"); - g_driver_gl.debug_fn.glPushDebugGroupKHRFn(source, id, length, message); -} - -static void GL_BINDING_CALL Debug_glPushGroupMarkerEXT(GLsizei length, - const char* marker) { - GL_SERVICE_LOG("glPushGroupMarkerEXT" - << "(" << length << ", " << marker << ")"); - g_driver_gl.debug_fn.glPushGroupMarkerEXTFn(length, marker); -} - -static void GL_BINDING_CALL Debug_glQueryCounter(GLuint id, GLenum target) { - GL_SERVICE_LOG("glQueryCounter" - << "(" << id << ", " << GLEnums::GetStringEnum(target) << ")"); - g_driver_gl.debug_fn.glQueryCounterFn(id, target); -} - -static void GL_BINDING_CALL Debug_glReadBuffer(GLenum src) { - GL_SERVICE_LOG("glReadBuffer" - << "(" << GLEnums::GetStringEnum(src) << ")"); - g_driver_gl.debug_fn.glReadBufferFn(src); -} - -static void GL_BINDING_CALL Debug_glReadPixels(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - void* pixels) { - GL_SERVICE_LOG("glReadPixels" - << "(" << x << ", " << y << ", " << width << ", " << height - << ", " << GLEnums::GetStringEnum(format) << ", " - << GLEnums::GetStringEnum(type) << ", " - << static_cast(pixels) << ")"); - g_driver_gl.debug_fn.glReadPixelsFn(x, y, width, height, format, type, - pixels); -} - -static void GL_BINDING_CALL Debug_glReleaseShaderCompiler(void) { - GL_SERVICE_LOG("glReleaseShaderCompiler" - << "(" - << ")"); - g_driver_gl.debug_fn.glReleaseShaderCompilerFn(); -} - -static void GL_BINDING_CALL -Debug_glRenderbufferStorageEXT(GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height) { - GL_SERVICE_LOG("glRenderbufferStorageEXT" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(internalformat) << ", " << width - << ", " << height << ")"); - g_driver_gl.debug_fn.glRenderbufferStorageEXTFn(target, internalformat, width, - height); -} - -static void GL_BINDING_CALL -Debug_glRenderbufferStorageMultisample(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - GL_SERVICE_LOG("glRenderbufferStorageMultisample" - << "(" << GLEnums::GetStringEnum(target) << ", " << samples - << ", " << GLEnums::GetStringEnum(internalformat) << ", " - << width << ", " << height << ")"); - g_driver_gl.debug_fn.glRenderbufferStorageMultisampleFn( - target, samples, internalformat, width, height); -} - -static void GL_BINDING_CALL -Debug_glRenderbufferStorageMultisampleANGLE(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - GL_SERVICE_LOG("glRenderbufferStorageMultisampleANGLE" - << "(" << GLEnums::GetStringEnum(target) << ", " << samples - << ", " << GLEnums::GetStringEnum(internalformat) << ", " - << width << ", " << height << ")"); - g_driver_gl.debug_fn.glRenderbufferStorageMultisampleANGLEFn( - target, samples, internalformat, width, height); -} - -static void GL_BINDING_CALL -Debug_glRenderbufferStorageMultisampleAPPLE(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - GL_SERVICE_LOG("glRenderbufferStorageMultisampleAPPLE" - << "(" << GLEnums::GetStringEnum(target) << ", " << samples - << ", " << GLEnums::GetStringEnum(internalformat) << ", " - << width << ", " << height << ")"); - g_driver_gl.debug_fn.glRenderbufferStorageMultisampleAPPLEFn( - target, samples, internalformat, width, height); -} - -static void GL_BINDING_CALL -Debug_glRenderbufferStorageMultisampleEXT(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - GL_SERVICE_LOG("glRenderbufferStorageMultisampleEXT" - << "(" << GLEnums::GetStringEnum(target) << ", " << samples - << ", " << GLEnums::GetStringEnum(internalformat) << ", " - << width << ", " << height << ")"); - g_driver_gl.debug_fn.glRenderbufferStorageMultisampleEXTFn( - target, samples, internalformat, width, height); -} - -static void GL_BINDING_CALL -Debug_glRenderbufferStorageMultisampleIMG(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - GL_SERVICE_LOG("glRenderbufferStorageMultisampleIMG" - << "(" << GLEnums::GetStringEnum(target) << ", " << samples - << ", " << GLEnums::GetStringEnum(internalformat) << ", " - << width << ", " << height << ")"); - g_driver_gl.debug_fn.glRenderbufferStorageMultisampleIMGFn( - target, samples, internalformat, width, height); -} - -static void GL_BINDING_CALL Debug_glResolveMultisampleFramebufferAPPLE(void) { - GL_SERVICE_LOG("glResolveMultisampleFramebufferAPPLE" - << "(" - << ")"); - g_driver_gl.debug_fn.glResolveMultisampleFramebufferAPPLEFn(); -} - -static void GL_BINDING_CALL Debug_glResumeTransformFeedback(void) { - GL_SERVICE_LOG("glResumeTransformFeedback" - << "(" - << ")"); - g_driver_gl.debug_fn.glResumeTransformFeedbackFn(); -} - -static void GL_BINDING_CALL Debug_glSampleCoverage(GLclampf value, - GLboolean invert) { - GL_SERVICE_LOG("glSampleCoverage" - << "(" << value << ", " << GLEnums::GetStringBool(invert) - << ")"); - g_driver_gl.debug_fn.glSampleCoverageFn(value, invert); -} - -static void GL_BINDING_CALL Debug_glSamplerParameterf(GLuint sampler, - GLenum pname, - GLfloat param) { - GL_SERVICE_LOG("glSamplerParameterf" - << "(" << sampler << ", " << GLEnums::GetStringEnum(pname) - << ", " << param << ")"); - g_driver_gl.debug_fn.glSamplerParameterfFn(sampler, pname, param); -} - -static void GL_BINDING_CALL Debug_glSamplerParameterfv(GLuint sampler, - GLenum pname, - const GLfloat* params) { - GL_SERVICE_LOG("glSamplerParameterfv" - << "(" << sampler << ", " << GLEnums::GetStringEnum(pname) - << ", " << static_cast(params) << ")"); - g_driver_gl.debug_fn.glSamplerParameterfvFn(sampler, pname, params); -} - -static void GL_BINDING_CALL Debug_glSamplerParameteri(GLuint sampler, - GLenum pname, - GLint param) { - GL_SERVICE_LOG("glSamplerParameteri" - << "(" << sampler << ", " << GLEnums::GetStringEnum(pname) - << ", " << param << ")"); - g_driver_gl.debug_fn.glSamplerParameteriFn(sampler, pname, param); -} - -static void GL_BINDING_CALL Debug_glSamplerParameteriv(GLuint sampler, - GLenum pname, - const GLint* params) { - GL_SERVICE_LOG("glSamplerParameteriv" - << "(" << sampler << ", " << GLEnums::GetStringEnum(pname) - << ", " << static_cast(params) << ")"); - g_driver_gl.debug_fn.glSamplerParameterivFn(sampler, pname, params); -} - -static void GL_BINDING_CALL Debug_glScissor(GLint x, - GLint y, - GLsizei width, - GLsizei height) { - GL_SERVICE_LOG("glScissor" - << "(" << x << ", " << y << ", " << width << ", " << height - << ")"); - g_driver_gl.debug_fn.glScissorFn(x, y, width, height); -} - -static void GL_BINDING_CALL Debug_glSetFenceAPPLE(GLuint fence) { - GL_SERVICE_LOG("glSetFenceAPPLE" - << "(" << fence << ")"); - g_driver_gl.debug_fn.glSetFenceAPPLEFn(fence); -} - -static void GL_BINDING_CALL Debug_glSetFenceNV(GLuint fence, GLenum condition) { - GL_SERVICE_LOG("glSetFenceNV" - << "(" << fence << ", " << GLEnums::GetStringEnum(condition) - << ")"); - g_driver_gl.debug_fn.glSetFenceNVFn(fence, condition); -} - -static void GL_BINDING_CALL Debug_glShaderBinary(GLsizei n, - const GLuint* shaders, - GLenum binaryformat, - const void* binary, - GLsizei length) { - GL_SERVICE_LOG("glShaderBinary" - << "(" << n << ", " << static_cast(shaders) - << ", " << GLEnums::GetStringEnum(binaryformat) << ", " - << static_cast(binary) << ", " << length << ")"); - g_driver_gl.debug_fn.glShaderBinaryFn(n, shaders, binaryformat, binary, - length); -} - -static void GL_BINDING_CALL Debug_glShaderSource(GLuint shader, - GLsizei count, - const char* const* str, - const GLint* length) { - GL_SERVICE_LOG("glShaderSource" - << "(" << shader << ", " << count << ", " - << static_cast(str) << ", " - << static_cast(length) << ")"); - g_driver_gl.debug_fn.glShaderSourceFn(shader, count, str, length); - - GL_SERVICE_LOG_CODE_BLOCK({ - for (GLsizei ii = 0; ii < count; ++ii) { - if (str[ii]) { - if (length && length[ii] >= 0) { - std::string source(str[ii], length[ii]); - GL_SERVICE_LOG(" " << ii << ": ---\n" << source << "\n---"); - } else { - GL_SERVICE_LOG(" " << ii << ": ---\n" << str[ii] << "\n---"); - } - } else { - GL_SERVICE_LOG(" " << ii << ": NULL"); - } - } - }); -} - -static void GL_BINDING_CALL Debug_glStencilFunc(GLenum func, - GLint ref, - GLuint mask) { - GL_SERVICE_LOG("glStencilFunc" - << "(" << GLEnums::GetStringEnum(func) << ", " << ref << ", " - << mask << ")"); - g_driver_gl.debug_fn.glStencilFuncFn(func, ref, mask); -} - -static void GL_BINDING_CALL Debug_glStencilFuncSeparate(GLenum face, - GLenum func, - GLint ref, - GLuint mask) { - GL_SERVICE_LOG("glStencilFuncSeparate" - << "(" << GLEnums::GetStringEnum(face) << ", " - << GLEnums::GetStringEnum(func) << ", " << ref << ", " << mask - << ")"); - g_driver_gl.debug_fn.glStencilFuncSeparateFn(face, func, ref, mask); -} - -static void GL_BINDING_CALL Debug_glStencilMask(GLuint mask) { - GL_SERVICE_LOG("glStencilMask" - << "(" << mask << ")"); - g_driver_gl.debug_fn.glStencilMaskFn(mask); -} - -static void GL_BINDING_CALL Debug_glStencilMaskSeparate(GLenum face, - GLuint mask) { - GL_SERVICE_LOG("glStencilMaskSeparate" - << "(" << GLEnums::GetStringEnum(face) << ", " << mask << ")"); - g_driver_gl.debug_fn.glStencilMaskSeparateFn(face, mask); -} - -static void GL_BINDING_CALL Debug_glStencilOp(GLenum fail, - GLenum zfail, - GLenum zpass) { - GL_SERVICE_LOG("glStencilOp" - << "(" << GLEnums::GetStringEnum(fail) << ", " - << GLEnums::GetStringEnum(zfail) << ", " - << GLEnums::GetStringEnum(zpass) << ")"); - g_driver_gl.debug_fn.glStencilOpFn(fail, zfail, zpass); -} - -static void GL_BINDING_CALL Debug_glStencilOpSeparate(GLenum face, - GLenum fail, - GLenum zfail, - GLenum zpass) { - GL_SERVICE_LOG("glStencilOpSeparate" - << "(" << GLEnums::GetStringEnum(face) << ", " - << GLEnums::GetStringEnum(fail) << ", " - << GLEnums::GetStringEnum(zfail) << ", " - << GLEnums::GetStringEnum(zpass) << ")"); - g_driver_gl.debug_fn.glStencilOpSeparateFn(face, fail, zfail, zpass); -} - -static GLboolean GL_BINDING_CALL Debug_glTestFenceAPPLE(GLuint fence) { - GL_SERVICE_LOG("glTestFenceAPPLE" - << "(" << fence << ")"); - GLboolean result = g_driver_gl.debug_fn.glTestFenceAPPLEFn(fence); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLboolean GL_BINDING_CALL Debug_glTestFenceNV(GLuint fence) { - GL_SERVICE_LOG("glTestFenceNV" - << "(" << fence << ")"); - GLboolean result = g_driver_gl.debug_fn.glTestFenceNVFn(fence); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void GL_BINDING_CALL Debug_glTexImage2D(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const void* pixels) { - GL_SERVICE_LOG("glTexImage2D" - << "(" << GLEnums::GetStringEnum(target) << ", " << level - << ", " << internalformat << ", " << width << ", " << height - << ", " << border << ", " << GLEnums::GetStringEnum(format) - << ", " << GLEnums::GetStringEnum(type) << ", " - << static_cast(pixels) << ")"); - g_driver_gl.debug_fn.glTexImage2DFn(target, level, internalformat, width, - height, border, format, type, pixels); -} - -static void GL_BINDING_CALL Debug_glTexImage3D(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - const void* pixels) { - GL_SERVICE_LOG("glTexImage3D" - << "(" << GLEnums::GetStringEnum(target) << ", " << level - << ", " << internalformat << ", " << width << ", " << height - << ", " << depth << ", " << border << ", " - << GLEnums::GetStringEnum(format) << ", " - << GLEnums::GetStringEnum(type) << ", " - << static_cast(pixels) << ")"); - g_driver_gl.debug_fn.glTexImage3DFn(target, level, internalformat, width, - height, depth, border, format, type, - pixels); -} - -static void GL_BINDING_CALL Debug_glTexParameterf(GLenum target, - GLenum pname, - GLfloat param) { - GL_SERVICE_LOG("glTexParameterf" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(pname) << ", " << param << ")"); - g_driver_gl.debug_fn.glTexParameterfFn(target, pname, param); -} - -static void GL_BINDING_CALL Debug_glTexParameterfv(GLenum target, - GLenum pname, - const GLfloat* params) { - GL_SERVICE_LOG("glTexParameterfv" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glTexParameterfvFn(target, pname, params); -} - -static void GL_BINDING_CALL Debug_glTexParameteri(GLenum target, - GLenum pname, - GLint param) { - GL_SERVICE_LOG("glTexParameteri" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(pname) << ", " << param << ")"); - g_driver_gl.debug_fn.glTexParameteriFn(target, pname, param); -} - -static void GL_BINDING_CALL Debug_glTexParameteriv(GLenum target, - GLenum pname, - const GLint* params) { - GL_SERVICE_LOG("glTexParameteriv" - << "(" << GLEnums::GetStringEnum(target) << ", " - << GLEnums::GetStringEnum(pname) << ", " - << static_cast(params) << ")"); - g_driver_gl.debug_fn.glTexParameterivFn(target, pname, params); -} - -static void GL_BINDING_CALL Debug_glTexStorage2DEXT(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height) { - GL_SERVICE_LOG("glTexStorage2DEXT" - << "(" << GLEnums::GetStringEnum(target) << ", " << levels - << ", " << GLEnums::GetStringEnum(internalformat) << ", " - << width << ", " << height << ")"); - g_driver_gl.debug_fn.glTexStorage2DEXTFn(target, levels, internalformat, - width, height); -} - -static void GL_BINDING_CALL Debug_glTexStorage3D(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth) { - GL_SERVICE_LOG("glTexStorage3D" - << "(" << GLEnums::GetStringEnum(target) << ", " << levels - << ", " << GLEnums::GetStringEnum(internalformat) << ", " - << width << ", " << height << ", " << depth << ")"); - g_driver_gl.debug_fn.glTexStorage3DFn(target, levels, internalformat, width, - height, depth); -} - -static void GL_BINDING_CALL Debug_glTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const void* pixels) { - GL_SERVICE_LOG("glTexSubImage2D" - << "(" << GLEnums::GetStringEnum(target) << ", " << level - << ", " << xoffset << ", " << yoffset << ", " << width << ", " - << height << ", " << GLEnums::GetStringEnum(format) << ", " - << GLEnums::GetStringEnum(type) << ", " - << static_cast(pixels) << ")"); - g_driver_gl.debug_fn.glTexSubImage2DFn(target, level, xoffset, yoffset, width, - height, format, type, pixels); -} - -static void GL_BINDING_CALL Debug_glTextureBarrierNV(void) { - GL_SERVICE_LOG("glTextureBarrierNV" - << "(" - << ")"); - g_driver_gl.debug_fn.glTextureBarrierNVFn(); -} - -static void GL_BINDING_CALL -Debug_glTransformFeedbackVaryings(GLuint program, - GLsizei count, - const char* const* varyings, - GLenum bufferMode) { - GL_SERVICE_LOG("glTransformFeedbackVaryings" - << "(" << program << ", " << count << ", " - << static_cast(varyings) << ", " - << GLEnums::GetStringEnum(bufferMode) << ")"); - g_driver_gl.debug_fn.glTransformFeedbackVaryingsFn(program, count, varyings, - bufferMode); -} - -static void GL_BINDING_CALL Debug_glUniform1f(GLint location, GLfloat x) { - GL_SERVICE_LOG("glUniform1f" - << "(" << location << ", " << x << ")"); - g_driver_gl.debug_fn.glUniform1fFn(location, x); -} - -static void GL_BINDING_CALL Debug_glUniform1fv(GLint location, - GLsizei count, - const GLfloat* v) { - GL_SERVICE_LOG("glUniform1fv" - << "(" << location << ", " << count << ", " - << static_cast(v) << ")"); - g_driver_gl.debug_fn.glUniform1fvFn(location, count, v); -} - -static void GL_BINDING_CALL Debug_glUniform1i(GLint location, GLint x) { - GL_SERVICE_LOG("glUniform1i" - << "(" << location << ", " << x << ")"); - g_driver_gl.debug_fn.glUniform1iFn(location, x); -} - -static void GL_BINDING_CALL Debug_glUniform1iv(GLint location, - GLsizei count, - const GLint* v) { - GL_SERVICE_LOG("glUniform1iv" - << "(" << location << ", " << count << ", " - << static_cast(v) << ")"); - g_driver_gl.debug_fn.glUniform1ivFn(location, count, v); -} - -static void GL_BINDING_CALL Debug_glUniform1ui(GLint location, GLuint v0) { - GL_SERVICE_LOG("glUniform1ui" - << "(" << location << ", " << v0 << ")"); - g_driver_gl.debug_fn.glUniform1uiFn(location, v0); -} - -static void GL_BINDING_CALL Debug_glUniform1uiv(GLint location, - GLsizei count, - const GLuint* v) { - GL_SERVICE_LOG("glUniform1uiv" - << "(" << location << ", " << count << ", " - << static_cast(v) << ")"); - g_driver_gl.debug_fn.glUniform1uivFn(location, count, v); -} - -static void GL_BINDING_CALL Debug_glUniform2f(GLint location, - GLfloat x, - GLfloat y) { - GL_SERVICE_LOG("glUniform2f" - << "(" << location << ", " << x << ", " << y << ")"); - g_driver_gl.debug_fn.glUniform2fFn(location, x, y); -} - -static void GL_BINDING_CALL Debug_glUniform2fv(GLint location, - GLsizei count, - const GLfloat* v) { - GL_SERVICE_LOG("glUniform2fv" - << "(" << location << ", " << count << ", " - << static_cast(v) << ")"); - g_driver_gl.debug_fn.glUniform2fvFn(location, count, v); -} - -static void GL_BINDING_CALL Debug_glUniform2i(GLint location, - GLint x, - GLint y) { - GL_SERVICE_LOG("glUniform2i" - << "(" << location << ", " << x << ", " << y << ")"); - g_driver_gl.debug_fn.glUniform2iFn(location, x, y); -} - -static void GL_BINDING_CALL Debug_glUniform2iv(GLint location, - GLsizei count, - const GLint* v) { - GL_SERVICE_LOG("glUniform2iv" - << "(" << location << ", " << count << ", " - << static_cast(v) << ")"); - g_driver_gl.debug_fn.glUniform2ivFn(location, count, v); -} - -static void GL_BINDING_CALL Debug_glUniform2ui(GLint location, - GLuint v0, - GLuint v1) { - GL_SERVICE_LOG("glUniform2ui" - << "(" << location << ", " << v0 << ", " << v1 << ")"); - g_driver_gl.debug_fn.glUniform2uiFn(location, v0, v1); -} - -static void GL_BINDING_CALL Debug_glUniform2uiv(GLint location, - GLsizei count, - const GLuint* v) { - GL_SERVICE_LOG("glUniform2uiv" - << "(" << location << ", " << count << ", " - << static_cast(v) << ")"); - g_driver_gl.debug_fn.glUniform2uivFn(location, count, v); -} - -static void GL_BINDING_CALL Debug_glUniform3f(GLint location, - GLfloat x, - GLfloat y, - GLfloat z) { - GL_SERVICE_LOG("glUniform3f" - << "(" << location << ", " << x << ", " << y << ", " << z - << ")"); - g_driver_gl.debug_fn.glUniform3fFn(location, x, y, z); -} - -static void GL_BINDING_CALL Debug_glUniform3fv(GLint location, - GLsizei count, - const GLfloat* v) { - GL_SERVICE_LOG("glUniform3fv" - << "(" << location << ", " << count << ", " - << static_cast(v) << ")"); - g_driver_gl.debug_fn.glUniform3fvFn(location, count, v); -} - -static void GL_BINDING_CALL Debug_glUniform3i(GLint location, - GLint x, - GLint y, - GLint z) { - GL_SERVICE_LOG("glUniform3i" - << "(" << location << ", " << x << ", " << y << ", " << z - << ")"); - g_driver_gl.debug_fn.glUniform3iFn(location, x, y, z); -} - -static void GL_BINDING_CALL Debug_glUniform3iv(GLint location, - GLsizei count, - const GLint* v) { - GL_SERVICE_LOG("glUniform3iv" - << "(" << location << ", " << count << ", " - << static_cast(v) << ")"); - g_driver_gl.debug_fn.glUniform3ivFn(location, count, v); -} - -static void GL_BINDING_CALL Debug_glUniform3ui(GLint location, - GLuint v0, - GLuint v1, - GLuint v2) { - GL_SERVICE_LOG("glUniform3ui" - << "(" << location << ", " << v0 << ", " << v1 << ", " << v2 - << ")"); - g_driver_gl.debug_fn.glUniform3uiFn(location, v0, v1, v2); -} - -static void GL_BINDING_CALL Debug_glUniform3uiv(GLint location, - GLsizei count, - const GLuint* v) { - GL_SERVICE_LOG("glUniform3uiv" - << "(" << location << ", " << count << ", " - << static_cast(v) << ")"); - g_driver_gl.debug_fn.glUniform3uivFn(location, count, v); -} - -static void GL_BINDING_CALL -Debug_glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { - GL_SERVICE_LOG("glUniform4f" - << "(" << location << ", " << x << ", " << y << ", " << z - << ", " << w << ")"); - g_driver_gl.debug_fn.glUniform4fFn(location, x, y, z, w); -} - -static void GL_BINDING_CALL Debug_glUniform4fv(GLint location, - GLsizei count, - const GLfloat* v) { - GL_SERVICE_LOG("glUniform4fv" - << "(" << location << ", " << count << ", " - << static_cast(v) << ")"); - g_driver_gl.debug_fn.glUniform4fvFn(location, count, v); -} - -static void GL_BINDING_CALL -Debug_glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) { - GL_SERVICE_LOG("glUniform4i" - << "(" << location << ", " << x << ", " << y << ", " << z - << ", " << w << ")"); - g_driver_gl.debug_fn.glUniform4iFn(location, x, y, z, w); -} - -static void GL_BINDING_CALL Debug_glUniform4iv(GLint location, - GLsizei count, - const GLint* v) { - GL_SERVICE_LOG("glUniform4iv" - << "(" << location << ", " << count << ", " - << static_cast(v) << ")"); - g_driver_gl.debug_fn.glUniform4ivFn(location, count, v); -} - -static void GL_BINDING_CALL -Debug_glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) { - GL_SERVICE_LOG("glUniform4ui" - << "(" << location << ", " << v0 << ", " << v1 << ", " << v2 - << ", " << v3 << ")"); - g_driver_gl.debug_fn.glUniform4uiFn(location, v0, v1, v2, v3); -} - -static void GL_BINDING_CALL Debug_glUniform4uiv(GLint location, - GLsizei count, - const GLuint* v) { - GL_SERVICE_LOG("glUniform4uiv" - << "(" << location << ", " << count << ", " - << static_cast(v) << ")"); - g_driver_gl.debug_fn.glUniform4uivFn(location, count, v); -} - -static void GL_BINDING_CALL -Debug_glUniformBlockBinding(GLuint program, - GLuint uniformBlockIndex, - GLuint uniformBlockBinding) { - GL_SERVICE_LOG("glUniformBlockBinding" - << "(" << program << ", " << uniformBlockIndex << ", " - << uniformBlockBinding << ")"); - g_driver_gl.debug_fn.glUniformBlockBindingFn(program, uniformBlockIndex, - uniformBlockBinding); -} - -static void GL_BINDING_CALL Debug_glUniformMatrix2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - GL_SERVICE_LOG("glUniformMatrix2fv" - << "(" << location << ", " << count << ", " - << GLEnums::GetStringBool(transpose) << ", " - << static_cast(value) << ")"); - g_driver_gl.debug_fn.glUniformMatrix2fvFn(location, count, transpose, value); -} - -static void GL_BINDING_CALL Debug_glUniformMatrix2x3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - GL_SERVICE_LOG("glUniformMatrix2x3fv" - << "(" << location << ", " << count << ", " - << GLEnums::GetStringBool(transpose) << ", " - << static_cast(value) << ")"); - g_driver_gl.debug_fn.glUniformMatrix2x3fvFn(location, count, transpose, - value); -} - -static void GL_BINDING_CALL Debug_glUniformMatrix2x4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - GL_SERVICE_LOG("glUniformMatrix2x4fv" - << "(" << location << ", " << count << ", " - << GLEnums::GetStringBool(transpose) << ", " - << static_cast(value) << ")"); - g_driver_gl.debug_fn.glUniformMatrix2x4fvFn(location, count, transpose, - value); -} - -static void GL_BINDING_CALL Debug_glUniformMatrix3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - GL_SERVICE_LOG("glUniformMatrix3fv" - << "(" << location << ", " << count << ", " - << GLEnums::GetStringBool(transpose) << ", " - << static_cast(value) << ")"); - g_driver_gl.debug_fn.glUniformMatrix3fvFn(location, count, transpose, value); -} - -static void GL_BINDING_CALL Debug_glUniformMatrix3x2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - GL_SERVICE_LOG("glUniformMatrix3x2fv" - << "(" << location << ", " << count << ", " - << GLEnums::GetStringBool(transpose) << ", " - << static_cast(value) << ")"); - g_driver_gl.debug_fn.glUniformMatrix3x2fvFn(location, count, transpose, - value); -} - -static void GL_BINDING_CALL Debug_glUniformMatrix3x4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - GL_SERVICE_LOG("glUniformMatrix3x4fv" - << "(" << location << ", " << count << ", " - << GLEnums::GetStringBool(transpose) << ", " - << static_cast(value) << ")"); - g_driver_gl.debug_fn.glUniformMatrix3x4fvFn(location, count, transpose, - value); -} - -static void GL_BINDING_CALL Debug_glUniformMatrix4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - GL_SERVICE_LOG("glUniformMatrix4fv" - << "(" << location << ", " << count << ", " - << GLEnums::GetStringBool(transpose) << ", " - << static_cast(value) << ")"); - g_driver_gl.debug_fn.glUniformMatrix4fvFn(location, count, transpose, value); -} - -static void GL_BINDING_CALL Debug_glUniformMatrix4x2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - GL_SERVICE_LOG("glUniformMatrix4x2fv" - << "(" << location << ", " << count << ", " - << GLEnums::GetStringBool(transpose) << ", " - << static_cast(value) << ")"); - g_driver_gl.debug_fn.glUniformMatrix4x2fvFn(location, count, transpose, - value); -} - -static void GL_BINDING_CALL Debug_glUniformMatrix4x3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - GL_SERVICE_LOG("glUniformMatrix4x3fv" - << "(" << location << ", " << count << ", " - << GLEnums::GetStringBool(transpose) << ", " - << static_cast(value) << ")"); - g_driver_gl.debug_fn.glUniformMatrix4x3fvFn(location, count, transpose, - value); -} - -static GLboolean GL_BINDING_CALL Debug_glUnmapBuffer(GLenum target) { - GL_SERVICE_LOG("glUnmapBuffer" - << "(" << GLEnums::GetStringEnum(target) << ")"); - GLboolean result = g_driver_gl.debug_fn.glUnmapBufferFn(target); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void GL_BINDING_CALL Debug_glUseProgram(GLuint program) { - GL_SERVICE_LOG("glUseProgram" - << "(" << program << ")"); - g_driver_gl.debug_fn.glUseProgramFn(program); -} - -static void GL_BINDING_CALL Debug_glValidateProgram(GLuint program) { - GL_SERVICE_LOG("glValidateProgram" - << "(" << program << ")"); - g_driver_gl.debug_fn.glValidateProgramFn(program); -} - -static void GL_BINDING_CALL Debug_glVertexAttrib1f(GLuint indx, GLfloat x) { - GL_SERVICE_LOG("glVertexAttrib1f" - << "(" << indx << ", " << x << ")"); - g_driver_gl.debug_fn.glVertexAttrib1fFn(indx, x); -} - -static void GL_BINDING_CALL Debug_glVertexAttrib1fv(GLuint indx, - const GLfloat* values) { - GL_SERVICE_LOG("glVertexAttrib1fv" - << "(" << indx << ", " << static_cast(values) - << ")"); - g_driver_gl.debug_fn.glVertexAttrib1fvFn(indx, values); -} - -static void GL_BINDING_CALL Debug_glVertexAttrib2f(GLuint indx, - GLfloat x, - GLfloat y) { - GL_SERVICE_LOG("glVertexAttrib2f" - << "(" << indx << ", " << x << ", " << y << ")"); - g_driver_gl.debug_fn.glVertexAttrib2fFn(indx, x, y); -} - -static void GL_BINDING_CALL Debug_glVertexAttrib2fv(GLuint indx, - const GLfloat* values) { - GL_SERVICE_LOG("glVertexAttrib2fv" - << "(" << indx << ", " << static_cast(values) - << ")"); - g_driver_gl.debug_fn.glVertexAttrib2fvFn(indx, values); -} - -static void GL_BINDING_CALL Debug_glVertexAttrib3f(GLuint indx, - GLfloat x, - GLfloat y, - GLfloat z) { - GL_SERVICE_LOG("glVertexAttrib3f" - << "(" << indx << ", " << x << ", " << y << ", " << z << ")"); - g_driver_gl.debug_fn.glVertexAttrib3fFn(indx, x, y, z); -} - -static void GL_BINDING_CALL Debug_glVertexAttrib3fv(GLuint indx, - const GLfloat* values) { - GL_SERVICE_LOG("glVertexAttrib3fv" - << "(" << indx << ", " << static_cast(values) - << ")"); - g_driver_gl.debug_fn.glVertexAttrib3fvFn(indx, values); -} - -static void GL_BINDING_CALL Debug_glVertexAttrib4f(GLuint indx, - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w) { - GL_SERVICE_LOG("glVertexAttrib4f" - << "(" << indx << ", " << x << ", " << y << ", " << z << ", " - << w << ")"); - g_driver_gl.debug_fn.glVertexAttrib4fFn(indx, x, y, z, w); -} - -static void GL_BINDING_CALL Debug_glVertexAttrib4fv(GLuint indx, - const GLfloat* values) { - GL_SERVICE_LOG("glVertexAttrib4fv" - << "(" << indx << ", " << static_cast(values) - << ")"); - g_driver_gl.debug_fn.glVertexAttrib4fvFn(indx, values); -} - -static void GL_BINDING_CALL Debug_glVertexAttribDivisorANGLE(GLuint index, - GLuint divisor) { - GL_SERVICE_LOG("glVertexAttribDivisorANGLE" - << "(" << index << ", " << divisor << ")"); - g_driver_gl.debug_fn.glVertexAttribDivisorANGLEFn(index, divisor); -} - -static void GL_BINDING_CALL -Debug_glVertexAttribI4i(GLuint indx, GLint x, GLint y, GLint z, GLint w) { - GL_SERVICE_LOG("glVertexAttribI4i" - << "(" << indx << ", " << x << ", " << y << ", " << z << ", " - << w << ")"); - g_driver_gl.debug_fn.glVertexAttribI4iFn(indx, x, y, z, w); -} - -static void GL_BINDING_CALL Debug_glVertexAttribI4iv(GLuint indx, - const GLint* values) { - GL_SERVICE_LOG("glVertexAttribI4iv" - << "(" << indx << ", " << static_cast(values) - << ")"); - g_driver_gl.debug_fn.glVertexAttribI4ivFn(indx, values); -} - -static void GL_BINDING_CALL -Debug_glVertexAttribI4ui(GLuint indx, GLuint x, GLuint y, GLuint z, GLuint w) { - GL_SERVICE_LOG("glVertexAttribI4ui" - << "(" << indx << ", " << x << ", " << y << ", " << z << ", " - << w << ")"); - g_driver_gl.debug_fn.glVertexAttribI4uiFn(indx, x, y, z, w); -} - -static void GL_BINDING_CALL Debug_glVertexAttribI4uiv(GLuint indx, - const GLuint* values) { - GL_SERVICE_LOG("glVertexAttribI4uiv" - << "(" << indx << ", " << static_cast(values) - << ")"); - g_driver_gl.debug_fn.glVertexAttribI4uivFn(indx, values); -} - -static void GL_BINDING_CALL Debug_glVertexAttribIPointer(GLuint indx, - GLint size, - GLenum type, - GLsizei stride, - const void* ptr) { - GL_SERVICE_LOG("glVertexAttribIPointer" - << "(" << indx << ", " << size << ", " - << GLEnums::GetStringEnum(type) << ", " << stride << ", " - << static_cast(ptr) << ")"); - g_driver_gl.debug_fn.glVertexAttribIPointerFn(indx, size, type, stride, ptr); -} - -static void GL_BINDING_CALL Debug_glVertexAttribPointer(GLuint indx, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const void* ptr) { - GL_SERVICE_LOG("glVertexAttribPointer" - << "(" << indx << ", " << size << ", " - << GLEnums::GetStringEnum(type) << ", " - << GLEnums::GetStringBool(normalized) << ", " << stride << ", " - << static_cast(ptr) << ")"); - g_driver_gl.debug_fn.glVertexAttribPointerFn(indx, size, type, normalized, - stride, ptr); -} - -static void GL_BINDING_CALL Debug_glViewport(GLint x, - GLint y, - GLsizei width, - GLsizei height) { - GL_SERVICE_LOG("glViewport" - << "(" << x << ", " << y << ", " << width << ", " << height - << ")"); - g_driver_gl.debug_fn.glViewportFn(x, y, width, height); -} - -static GLenum GL_BINDING_CALL Debug_glWaitSync(GLsync sync, - GLbitfield flags, - GLuint64 timeout) { - GL_SERVICE_LOG("glWaitSync" - << "(" << sync << ", " << flags << ", " << timeout << ")"); - GLenum result = g_driver_gl.debug_fn.glWaitSyncFn(sync, flags, timeout); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} -} // extern "C" - -void DriverGL::InitializeDebugBindings() { - if (!debug_fn.glActiveTextureFn) { - debug_fn.glActiveTextureFn = fn.glActiveTextureFn; - fn.glActiveTextureFn = Debug_glActiveTexture; - } - if (!debug_fn.glAttachShaderFn) { - debug_fn.glAttachShaderFn = fn.glAttachShaderFn; - fn.glAttachShaderFn = Debug_glAttachShader; - } - if (!debug_fn.glBeginQueryFn) { - debug_fn.glBeginQueryFn = fn.glBeginQueryFn; - fn.glBeginQueryFn = Debug_glBeginQuery; - } - if (!debug_fn.glBeginTransformFeedbackFn) { - debug_fn.glBeginTransformFeedbackFn = fn.glBeginTransformFeedbackFn; - fn.glBeginTransformFeedbackFn = Debug_glBeginTransformFeedback; - } - if (!debug_fn.glBindAttribLocationFn) { - debug_fn.glBindAttribLocationFn = fn.glBindAttribLocationFn; - fn.glBindAttribLocationFn = Debug_glBindAttribLocation; - } - if (!debug_fn.glBindBufferFn) { - debug_fn.glBindBufferFn = fn.glBindBufferFn; - fn.glBindBufferFn = Debug_glBindBuffer; - } - if (!debug_fn.glBindBufferBaseFn) { - debug_fn.glBindBufferBaseFn = fn.glBindBufferBaseFn; - fn.glBindBufferBaseFn = Debug_glBindBufferBase; - } - if (!debug_fn.glBindBufferRangeFn) { - debug_fn.glBindBufferRangeFn = fn.glBindBufferRangeFn; - fn.glBindBufferRangeFn = Debug_glBindBufferRange; - } - if (!debug_fn.glBindFragDataLocationFn) { - debug_fn.glBindFragDataLocationFn = fn.glBindFragDataLocationFn; - fn.glBindFragDataLocationFn = Debug_glBindFragDataLocation; - } - if (!debug_fn.glBindFragDataLocationIndexedFn) { - debug_fn.glBindFragDataLocationIndexedFn = - fn.glBindFragDataLocationIndexedFn; - fn.glBindFragDataLocationIndexedFn = Debug_glBindFragDataLocationIndexed; - } - if (!debug_fn.glBindFramebufferEXTFn) { - debug_fn.glBindFramebufferEXTFn = fn.glBindFramebufferEXTFn; - fn.glBindFramebufferEXTFn = Debug_glBindFramebufferEXT; - } - if (!debug_fn.glBindRenderbufferEXTFn) { - debug_fn.glBindRenderbufferEXTFn = fn.glBindRenderbufferEXTFn; - fn.glBindRenderbufferEXTFn = Debug_glBindRenderbufferEXT; - } - if (!debug_fn.glBindSamplerFn) { - debug_fn.glBindSamplerFn = fn.glBindSamplerFn; - fn.glBindSamplerFn = Debug_glBindSampler; - } - if (!debug_fn.glBindTextureFn) { - debug_fn.glBindTextureFn = fn.glBindTextureFn; - fn.glBindTextureFn = Debug_glBindTexture; - } - if (!debug_fn.glBindTransformFeedbackFn) { - debug_fn.glBindTransformFeedbackFn = fn.glBindTransformFeedbackFn; - fn.glBindTransformFeedbackFn = Debug_glBindTransformFeedback; - } - if (!debug_fn.glBindVertexArrayOESFn) { - debug_fn.glBindVertexArrayOESFn = fn.glBindVertexArrayOESFn; - fn.glBindVertexArrayOESFn = Debug_glBindVertexArrayOES; - } - if (!debug_fn.glBlendBarrierKHRFn) { - debug_fn.glBlendBarrierKHRFn = fn.glBlendBarrierKHRFn; - fn.glBlendBarrierKHRFn = Debug_glBlendBarrierKHR; - } - if (!debug_fn.glBlendColorFn) { - debug_fn.glBlendColorFn = fn.glBlendColorFn; - fn.glBlendColorFn = Debug_glBlendColor; - } - if (!debug_fn.glBlendEquationFn) { - debug_fn.glBlendEquationFn = fn.glBlendEquationFn; - fn.glBlendEquationFn = Debug_glBlendEquation; - } - if (!debug_fn.glBlendEquationSeparateFn) { - debug_fn.glBlendEquationSeparateFn = fn.glBlendEquationSeparateFn; - fn.glBlendEquationSeparateFn = Debug_glBlendEquationSeparate; - } - if (!debug_fn.glBlendFuncFn) { - debug_fn.glBlendFuncFn = fn.glBlendFuncFn; - fn.glBlendFuncFn = Debug_glBlendFunc; - } - if (!debug_fn.glBlendFuncSeparateFn) { - debug_fn.glBlendFuncSeparateFn = fn.glBlendFuncSeparateFn; - fn.glBlendFuncSeparateFn = Debug_glBlendFuncSeparate; - } - if (!debug_fn.glBlitFramebufferFn) { - debug_fn.glBlitFramebufferFn = fn.glBlitFramebufferFn; - fn.glBlitFramebufferFn = Debug_glBlitFramebuffer; - } - if (!debug_fn.glBlitFramebufferANGLEFn) { - debug_fn.glBlitFramebufferANGLEFn = fn.glBlitFramebufferANGLEFn; - fn.glBlitFramebufferANGLEFn = Debug_glBlitFramebufferANGLE; - } - if (!debug_fn.glBlitFramebufferEXTFn) { - debug_fn.glBlitFramebufferEXTFn = fn.glBlitFramebufferEXTFn; - fn.glBlitFramebufferEXTFn = Debug_glBlitFramebufferEXT; - } - if (!debug_fn.glBufferDataFn) { - debug_fn.glBufferDataFn = fn.glBufferDataFn; - fn.glBufferDataFn = Debug_glBufferData; - } - if (!debug_fn.glBufferSubDataFn) { - debug_fn.glBufferSubDataFn = fn.glBufferSubDataFn; - fn.glBufferSubDataFn = Debug_glBufferSubData; - } - if (!debug_fn.glCheckFramebufferStatusEXTFn) { - debug_fn.glCheckFramebufferStatusEXTFn = fn.glCheckFramebufferStatusEXTFn; - fn.glCheckFramebufferStatusEXTFn = Debug_glCheckFramebufferStatusEXT; - } - if (!debug_fn.glClearFn) { - debug_fn.glClearFn = fn.glClearFn; - fn.glClearFn = Debug_glClear; - } - if (!debug_fn.glClearBufferfiFn) { - debug_fn.glClearBufferfiFn = fn.glClearBufferfiFn; - fn.glClearBufferfiFn = Debug_glClearBufferfi; - } - if (!debug_fn.glClearBufferfvFn) { - debug_fn.glClearBufferfvFn = fn.glClearBufferfvFn; - fn.glClearBufferfvFn = Debug_glClearBufferfv; - } - if (!debug_fn.glClearBufferivFn) { - debug_fn.glClearBufferivFn = fn.glClearBufferivFn; - fn.glClearBufferivFn = Debug_glClearBufferiv; - } - if (!debug_fn.glClearBufferuivFn) { - debug_fn.glClearBufferuivFn = fn.glClearBufferuivFn; - fn.glClearBufferuivFn = Debug_glClearBufferuiv; - } - if (!debug_fn.glClearColorFn) { - debug_fn.glClearColorFn = fn.glClearColorFn; - fn.glClearColorFn = Debug_glClearColor; - } - if (!debug_fn.glClearDepthFn) { - debug_fn.glClearDepthFn = fn.glClearDepthFn; - fn.glClearDepthFn = Debug_glClearDepth; - } - if (!debug_fn.glClearDepthfFn) { - debug_fn.glClearDepthfFn = fn.glClearDepthfFn; - fn.glClearDepthfFn = Debug_glClearDepthf; - } - if (!debug_fn.glClearStencilFn) { - debug_fn.glClearStencilFn = fn.glClearStencilFn; - fn.glClearStencilFn = Debug_glClearStencil; - } - if (!debug_fn.glClientWaitSyncFn) { - debug_fn.glClientWaitSyncFn = fn.glClientWaitSyncFn; - fn.glClientWaitSyncFn = Debug_glClientWaitSync; - } - if (!debug_fn.glColorMaskFn) { - debug_fn.glColorMaskFn = fn.glColorMaskFn; - fn.glColorMaskFn = Debug_glColorMask; - } - if (!debug_fn.glCompileShaderFn) { - debug_fn.glCompileShaderFn = fn.glCompileShaderFn; - fn.glCompileShaderFn = Debug_glCompileShader; - } - if (!debug_fn.glCompressedTexImage2DFn) { - debug_fn.glCompressedTexImage2DFn = fn.glCompressedTexImage2DFn; - fn.glCompressedTexImage2DFn = Debug_glCompressedTexImage2D; - } - if (!debug_fn.glCompressedTexImage3DFn) { - debug_fn.glCompressedTexImage3DFn = fn.glCompressedTexImage3DFn; - fn.glCompressedTexImage3DFn = Debug_glCompressedTexImage3D; - } - if (!debug_fn.glCompressedTexSubImage2DFn) { - debug_fn.glCompressedTexSubImage2DFn = fn.glCompressedTexSubImage2DFn; - fn.glCompressedTexSubImage2DFn = Debug_glCompressedTexSubImage2D; - } - if (!debug_fn.glCopyBufferSubDataFn) { - debug_fn.glCopyBufferSubDataFn = fn.glCopyBufferSubDataFn; - fn.glCopyBufferSubDataFn = Debug_glCopyBufferSubData; - } - if (!debug_fn.glCopyTexImage2DFn) { - debug_fn.glCopyTexImage2DFn = fn.glCopyTexImage2DFn; - fn.glCopyTexImage2DFn = Debug_glCopyTexImage2D; - } - if (!debug_fn.glCopyTexSubImage2DFn) { - debug_fn.glCopyTexSubImage2DFn = fn.glCopyTexSubImage2DFn; - fn.glCopyTexSubImage2DFn = Debug_glCopyTexSubImage2D; - } - if (!debug_fn.glCopyTexSubImage3DFn) { - debug_fn.glCopyTexSubImage3DFn = fn.glCopyTexSubImage3DFn; - fn.glCopyTexSubImage3DFn = Debug_glCopyTexSubImage3D; - } - if (!debug_fn.glCreateProgramFn) { - debug_fn.glCreateProgramFn = fn.glCreateProgramFn; - fn.glCreateProgramFn = Debug_glCreateProgram; - } - if (!debug_fn.glCreateShaderFn) { - debug_fn.glCreateShaderFn = fn.glCreateShaderFn; - fn.glCreateShaderFn = Debug_glCreateShader; - } - if (!debug_fn.glCullFaceFn) { - debug_fn.glCullFaceFn = fn.glCullFaceFn; - fn.glCullFaceFn = Debug_glCullFace; - } - if (!debug_fn.glDebugMessageCallbackKHRFn) { - debug_fn.glDebugMessageCallbackKHRFn = fn.glDebugMessageCallbackKHRFn; - fn.glDebugMessageCallbackKHRFn = Debug_glDebugMessageCallbackKHR; - } - if (!debug_fn.glDebugMessageControlKHRFn) { - debug_fn.glDebugMessageControlKHRFn = fn.glDebugMessageControlKHRFn; - fn.glDebugMessageControlKHRFn = Debug_glDebugMessageControlKHR; - } - if (!debug_fn.glDebugMessageInsertKHRFn) { - debug_fn.glDebugMessageInsertKHRFn = fn.glDebugMessageInsertKHRFn; - fn.glDebugMessageInsertKHRFn = Debug_glDebugMessageInsertKHR; - } - if (!debug_fn.glDeleteBuffersARBFn) { - debug_fn.glDeleteBuffersARBFn = fn.glDeleteBuffersARBFn; - fn.glDeleteBuffersARBFn = Debug_glDeleteBuffersARB; - } - if (!debug_fn.glDeleteFencesAPPLEFn) { - debug_fn.glDeleteFencesAPPLEFn = fn.glDeleteFencesAPPLEFn; - fn.glDeleteFencesAPPLEFn = Debug_glDeleteFencesAPPLE; - } - if (!debug_fn.glDeleteFencesNVFn) { - debug_fn.glDeleteFencesNVFn = fn.glDeleteFencesNVFn; - fn.glDeleteFencesNVFn = Debug_glDeleteFencesNV; - } - if (!debug_fn.glDeleteFramebuffersEXTFn) { - debug_fn.glDeleteFramebuffersEXTFn = fn.glDeleteFramebuffersEXTFn; - fn.glDeleteFramebuffersEXTFn = Debug_glDeleteFramebuffersEXT; - } - if (!debug_fn.glDeleteProgramFn) { - debug_fn.glDeleteProgramFn = fn.glDeleteProgramFn; - fn.glDeleteProgramFn = Debug_glDeleteProgram; - } - if (!debug_fn.glDeleteQueriesFn) { - debug_fn.glDeleteQueriesFn = fn.glDeleteQueriesFn; - fn.glDeleteQueriesFn = Debug_glDeleteQueries; - } - if (!debug_fn.glDeleteRenderbuffersEXTFn) { - debug_fn.glDeleteRenderbuffersEXTFn = fn.glDeleteRenderbuffersEXTFn; - fn.glDeleteRenderbuffersEXTFn = Debug_glDeleteRenderbuffersEXT; - } - if (!debug_fn.glDeleteSamplersFn) { - debug_fn.glDeleteSamplersFn = fn.glDeleteSamplersFn; - fn.glDeleteSamplersFn = Debug_glDeleteSamplers; - } - if (!debug_fn.glDeleteShaderFn) { - debug_fn.glDeleteShaderFn = fn.glDeleteShaderFn; - fn.glDeleteShaderFn = Debug_glDeleteShader; - } - if (!debug_fn.glDeleteSyncFn) { - debug_fn.glDeleteSyncFn = fn.glDeleteSyncFn; - fn.glDeleteSyncFn = Debug_glDeleteSync; - } - if (!debug_fn.glDeleteTexturesFn) { - debug_fn.glDeleteTexturesFn = fn.glDeleteTexturesFn; - fn.glDeleteTexturesFn = Debug_glDeleteTextures; - } - if (!debug_fn.glDeleteTransformFeedbacksFn) { - debug_fn.glDeleteTransformFeedbacksFn = fn.glDeleteTransformFeedbacksFn; - fn.glDeleteTransformFeedbacksFn = Debug_glDeleteTransformFeedbacks; - } - if (!debug_fn.glDeleteVertexArraysOESFn) { - debug_fn.glDeleteVertexArraysOESFn = fn.glDeleteVertexArraysOESFn; - fn.glDeleteVertexArraysOESFn = Debug_glDeleteVertexArraysOES; - } - if (!debug_fn.glDepthFuncFn) { - debug_fn.glDepthFuncFn = fn.glDepthFuncFn; - fn.glDepthFuncFn = Debug_glDepthFunc; - } - if (!debug_fn.glDepthMaskFn) { - debug_fn.glDepthMaskFn = fn.glDepthMaskFn; - fn.glDepthMaskFn = Debug_glDepthMask; - } - if (!debug_fn.glDepthRangeFn) { - debug_fn.glDepthRangeFn = fn.glDepthRangeFn; - fn.glDepthRangeFn = Debug_glDepthRange; - } - if (!debug_fn.glDepthRangefFn) { - debug_fn.glDepthRangefFn = fn.glDepthRangefFn; - fn.glDepthRangefFn = Debug_glDepthRangef; - } - if (!debug_fn.glDetachShaderFn) { - debug_fn.glDetachShaderFn = fn.glDetachShaderFn; - fn.glDetachShaderFn = Debug_glDetachShader; - } - if (!debug_fn.glDisableFn) { - debug_fn.glDisableFn = fn.glDisableFn; - fn.glDisableFn = Debug_glDisable; - } - if (!debug_fn.glDisableVertexAttribArrayFn) { - debug_fn.glDisableVertexAttribArrayFn = fn.glDisableVertexAttribArrayFn; - fn.glDisableVertexAttribArrayFn = Debug_glDisableVertexAttribArray; - } - if (!debug_fn.glDiscardFramebufferEXTFn) { - debug_fn.glDiscardFramebufferEXTFn = fn.glDiscardFramebufferEXTFn; - fn.glDiscardFramebufferEXTFn = Debug_glDiscardFramebufferEXT; - } - if (!debug_fn.glDrawArraysFn) { - debug_fn.glDrawArraysFn = fn.glDrawArraysFn; - fn.glDrawArraysFn = Debug_glDrawArrays; - } - if (!debug_fn.glDrawArraysInstancedANGLEFn) { - debug_fn.glDrawArraysInstancedANGLEFn = fn.glDrawArraysInstancedANGLEFn; - fn.glDrawArraysInstancedANGLEFn = Debug_glDrawArraysInstancedANGLE; - } - if (!debug_fn.glDrawBufferFn) { - debug_fn.glDrawBufferFn = fn.glDrawBufferFn; - fn.glDrawBufferFn = Debug_glDrawBuffer; - } - if (!debug_fn.glDrawBuffersARBFn) { - debug_fn.glDrawBuffersARBFn = fn.glDrawBuffersARBFn; - fn.glDrawBuffersARBFn = Debug_glDrawBuffersARB; - } - if (!debug_fn.glDrawElementsFn) { - debug_fn.glDrawElementsFn = fn.glDrawElementsFn; - fn.glDrawElementsFn = Debug_glDrawElements; - } - if (!debug_fn.glDrawElementsInstancedANGLEFn) { - debug_fn.glDrawElementsInstancedANGLEFn = fn.glDrawElementsInstancedANGLEFn; - fn.glDrawElementsInstancedANGLEFn = Debug_glDrawElementsInstancedANGLE; - } - if (!debug_fn.glDrawRangeElementsFn) { - debug_fn.glDrawRangeElementsFn = fn.glDrawRangeElementsFn; - fn.glDrawRangeElementsFn = Debug_glDrawRangeElements; - } - if (!debug_fn.glEGLImageTargetRenderbufferStorageOESFn) { - debug_fn.glEGLImageTargetRenderbufferStorageOESFn = - fn.glEGLImageTargetRenderbufferStorageOESFn; - fn.glEGLImageTargetRenderbufferStorageOESFn = - Debug_glEGLImageTargetRenderbufferStorageOES; - } - if (!debug_fn.glEGLImageTargetTexture2DOESFn) { - debug_fn.glEGLImageTargetTexture2DOESFn = fn.glEGLImageTargetTexture2DOESFn; - fn.glEGLImageTargetTexture2DOESFn = Debug_glEGLImageTargetTexture2DOES; - } - if (!debug_fn.glEnableFn) { - debug_fn.glEnableFn = fn.glEnableFn; - fn.glEnableFn = Debug_glEnable; - } - if (!debug_fn.glEnableVertexAttribArrayFn) { - debug_fn.glEnableVertexAttribArrayFn = fn.glEnableVertexAttribArrayFn; - fn.glEnableVertexAttribArrayFn = Debug_glEnableVertexAttribArray; - } - if (!debug_fn.glEndQueryFn) { - debug_fn.glEndQueryFn = fn.glEndQueryFn; - fn.glEndQueryFn = Debug_glEndQuery; - } - if (!debug_fn.glEndTransformFeedbackFn) { - debug_fn.glEndTransformFeedbackFn = fn.glEndTransformFeedbackFn; - fn.glEndTransformFeedbackFn = Debug_glEndTransformFeedback; - } - if (!debug_fn.glFenceSyncFn) { - debug_fn.glFenceSyncFn = fn.glFenceSyncFn; - fn.glFenceSyncFn = Debug_glFenceSync; - } - if (!debug_fn.glFinishFn) { - debug_fn.glFinishFn = fn.glFinishFn; - fn.glFinishFn = Debug_glFinish; - } - if (!debug_fn.glFinishFenceAPPLEFn) { - debug_fn.glFinishFenceAPPLEFn = fn.glFinishFenceAPPLEFn; - fn.glFinishFenceAPPLEFn = Debug_glFinishFenceAPPLE; - } - if (!debug_fn.glFinishFenceNVFn) { - debug_fn.glFinishFenceNVFn = fn.glFinishFenceNVFn; - fn.glFinishFenceNVFn = Debug_glFinishFenceNV; - } - if (!debug_fn.glFlushFn) { - debug_fn.glFlushFn = fn.glFlushFn; - fn.glFlushFn = Debug_glFlush; - } - if (!debug_fn.glFlushMappedBufferRangeFn) { - debug_fn.glFlushMappedBufferRangeFn = fn.glFlushMappedBufferRangeFn; - fn.glFlushMappedBufferRangeFn = Debug_glFlushMappedBufferRange; - } - if (!debug_fn.glFramebufferRenderbufferEXTFn) { - debug_fn.glFramebufferRenderbufferEXTFn = fn.glFramebufferRenderbufferEXTFn; - fn.glFramebufferRenderbufferEXTFn = Debug_glFramebufferRenderbufferEXT; - } - if (!debug_fn.glFramebufferTexture2DEXTFn) { - debug_fn.glFramebufferTexture2DEXTFn = fn.glFramebufferTexture2DEXTFn; - fn.glFramebufferTexture2DEXTFn = Debug_glFramebufferTexture2DEXT; - } - if (!debug_fn.glFramebufferTexture2DMultisampleEXTFn) { - debug_fn.glFramebufferTexture2DMultisampleEXTFn = - fn.glFramebufferTexture2DMultisampleEXTFn; - fn.glFramebufferTexture2DMultisampleEXTFn = - Debug_glFramebufferTexture2DMultisampleEXT; - } - if (!debug_fn.glFramebufferTexture2DMultisampleIMGFn) { - debug_fn.glFramebufferTexture2DMultisampleIMGFn = - fn.glFramebufferTexture2DMultisampleIMGFn; - fn.glFramebufferTexture2DMultisampleIMGFn = - Debug_glFramebufferTexture2DMultisampleIMG; - } - if (!debug_fn.glFramebufferTextureLayerFn) { - debug_fn.glFramebufferTextureLayerFn = fn.glFramebufferTextureLayerFn; - fn.glFramebufferTextureLayerFn = Debug_glFramebufferTextureLayer; - } - if (!debug_fn.glFrontFaceFn) { - debug_fn.glFrontFaceFn = fn.glFrontFaceFn; - fn.glFrontFaceFn = Debug_glFrontFace; - } - if (!debug_fn.glGenBuffersARBFn) { - debug_fn.glGenBuffersARBFn = fn.glGenBuffersARBFn; - fn.glGenBuffersARBFn = Debug_glGenBuffersARB; - } - if (!debug_fn.glGenerateMipmapEXTFn) { - debug_fn.glGenerateMipmapEXTFn = fn.glGenerateMipmapEXTFn; - fn.glGenerateMipmapEXTFn = Debug_glGenerateMipmapEXT; - } - if (!debug_fn.glGenFencesAPPLEFn) { - debug_fn.glGenFencesAPPLEFn = fn.glGenFencesAPPLEFn; - fn.glGenFencesAPPLEFn = Debug_glGenFencesAPPLE; - } - if (!debug_fn.glGenFencesNVFn) { - debug_fn.glGenFencesNVFn = fn.glGenFencesNVFn; - fn.glGenFencesNVFn = Debug_glGenFencesNV; - } - if (!debug_fn.glGenFramebuffersEXTFn) { - debug_fn.glGenFramebuffersEXTFn = fn.glGenFramebuffersEXTFn; - fn.glGenFramebuffersEXTFn = Debug_glGenFramebuffersEXT; - } - if (!debug_fn.glGenQueriesFn) { - debug_fn.glGenQueriesFn = fn.glGenQueriesFn; - fn.glGenQueriesFn = Debug_glGenQueries; - } - if (!debug_fn.glGenRenderbuffersEXTFn) { - debug_fn.glGenRenderbuffersEXTFn = fn.glGenRenderbuffersEXTFn; - fn.glGenRenderbuffersEXTFn = Debug_glGenRenderbuffersEXT; - } - if (!debug_fn.glGenSamplersFn) { - debug_fn.glGenSamplersFn = fn.glGenSamplersFn; - fn.glGenSamplersFn = Debug_glGenSamplers; - } - if (!debug_fn.glGenTexturesFn) { - debug_fn.glGenTexturesFn = fn.glGenTexturesFn; - fn.glGenTexturesFn = Debug_glGenTextures; - } - if (!debug_fn.glGenTransformFeedbacksFn) { - debug_fn.glGenTransformFeedbacksFn = fn.glGenTransformFeedbacksFn; - fn.glGenTransformFeedbacksFn = Debug_glGenTransformFeedbacks; - } - if (!debug_fn.glGenVertexArraysOESFn) { - debug_fn.glGenVertexArraysOESFn = fn.glGenVertexArraysOESFn; - fn.glGenVertexArraysOESFn = Debug_glGenVertexArraysOES; - } - if (!debug_fn.glGetActiveAttribFn) { - debug_fn.glGetActiveAttribFn = fn.glGetActiveAttribFn; - fn.glGetActiveAttribFn = Debug_glGetActiveAttrib; - } - if (!debug_fn.glGetActiveUniformFn) { - debug_fn.glGetActiveUniformFn = fn.glGetActiveUniformFn; - fn.glGetActiveUniformFn = Debug_glGetActiveUniform; - } - if (!debug_fn.glGetActiveUniformBlockivFn) { - debug_fn.glGetActiveUniformBlockivFn = fn.glGetActiveUniformBlockivFn; - fn.glGetActiveUniformBlockivFn = Debug_glGetActiveUniformBlockiv; - } - if (!debug_fn.glGetActiveUniformBlockNameFn) { - debug_fn.glGetActiveUniformBlockNameFn = fn.glGetActiveUniformBlockNameFn; - fn.glGetActiveUniformBlockNameFn = Debug_glGetActiveUniformBlockName; - } - if (!debug_fn.glGetActiveUniformsivFn) { - debug_fn.glGetActiveUniformsivFn = fn.glGetActiveUniformsivFn; - fn.glGetActiveUniformsivFn = Debug_glGetActiveUniformsiv; - } - if (!debug_fn.glGetAttachedShadersFn) { - debug_fn.glGetAttachedShadersFn = fn.glGetAttachedShadersFn; - fn.glGetAttachedShadersFn = Debug_glGetAttachedShaders; - } - if (!debug_fn.glGetAttribLocationFn) { - debug_fn.glGetAttribLocationFn = fn.glGetAttribLocationFn; - fn.glGetAttribLocationFn = Debug_glGetAttribLocation; - } - if (!debug_fn.glGetBooleanvFn) { - debug_fn.glGetBooleanvFn = fn.glGetBooleanvFn; - fn.glGetBooleanvFn = Debug_glGetBooleanv; - } - if (!debug_fn.glGetBufferParameterivFn) { - debug_fn.glGetBufferParameterivFn = fn.glGetBufferParameterivFn; - fn.glGetBufferParameterivFn = Debug_glGetBufferParameteriv; - } - if (!debug_fn.glGetDebugMessageLogKHRFn) { - debug_fn.glGetDebugMessageLogKHRFn = fn.glGetDebugMessageLogKHRFn; - fn.glGetDebugMessageLogKHRFn = Debug_glGetDebugMessageLogKHR; - } - if (!debug_fn.glGetErrorFn) { - debug_fn.glGetErrorFn = fn.glGetErrorFn; - fn.glGetErrorFn = Debug_glGetError; - } - if (!debug_fn.glGetFenceivNVFn) { - debug_fn.glGetFenceivNVFn = fn.glGetFenceivNVFn; - fn.glGetFenceivNVFn = Debug_glGetFenceivNV; - } - if (!debug_fn.glGetFloatvFn) { - debug_fn.glGetFloatvFn = fn.glGetFloatvFn; - fn.glGetFloatvFn = Debug_glGetFloatv; - } - if (!debug_fn.glGetFragDataLocationFn) { - debug_fn.glGetFragDataLocationFn = fn.glGetFragDataLocationFn; - fn.glGetFragDataLocationFn = Debug_glGetFragDataLocation; - } - if (!debug_fn.glGetFramebufferAttachmentParameterivEXTFn) { - debug_fn.glGetFramebufferAttachmentParameterivEXTFn = - fn.glGetFramebufferAttachmentParameterivEXTFn; - fn.glGetFramebufferAttachmentParameterivEXTFn = - Debug_glGetFramebufferAttachmentParameterivEXT; - } - if (!debug_fn.glGetGraphicsResetStatusARBFn) { - debug_fn.glGetGraphicsResetStatusARBFn = fn.glGetGraphicsResetStatusARBFn; - fn.glGetGraphicsResetStatusARBFn = Debug_glGetGraphicsResetStatusARB; - } - if (!debug_fn.glGetInteger64i_vFn) { - debug_fn.glGetInteger64i_vFn = fn.glGetInteger64i_vFn; - fn.glGetInteger64i_vFn = Debug_glGetInteger64i_v; - } - if (!debug_fn.glGetInteger64vFn) { - debug_fn.glGetInteger64vFn = fn.glGetInteger64vFn; - fn.glGetInteger64vFn = Debug_glGetInteger64v; - } - if (!debug_fn.glGetIntegeri_vFn) { - debug_fn.glGetIntegeri_vFn = fn.glGetIntegeri_vFn; - fn.glGetIntegeri_vFn = Debug_glGetIntegeri_v; - } - if (!debug_fn.glGetIntegervFn) { - debug_fn.glGetIntegervFn = fn.glGetIntegervFn; - fn.glGetIntegervFn = Debug_glGetIntegerv; - } - if (!debug_fn.glGetInternalformativFn) { - debug_fn.glGetInternalformativFn = fn.glGetInternalformativFn; - fn.glGetInternalformativFn = Debug_glGetInternalformativ; - } - if (!debug_fn.glGetProgramBinaryFn) { - debug_fn.glGetProgramBinaryFn = fn.glGetProgramBinaryFn; - fn.glGetProgramBinaryFn = Debug_glGetProgramBinary; - } - if (!debug_fn.glGetProgramInfoLogFn) { - debug_fn.glGetProgramInfoLogFn = fn.glGetProgramInfoLogFn; - fn.glGetProgramInfoLogFn = Debug_glGetProgramInfoLog; - } - if (!debug_fn.glGetProgramivFn) { - debug_fn.glGetProgramivFn = fn.glGetProgramivFn; - fn.glGetProgramivFn = Debug_glGetProgramiv; - } - if (!debug_fn.glGetProgramResourceLocationFn) { - debug_fn.glGetProgramResourceLocationFn = fn.glGetProgramResourceLocationFn; - fn.glGetProgramResourceLocationFn = Debug_glGetProgramResourceLocation; - } - if (!debug_fn.glGetQueryivFn) { - debug_fn.glGetQueryivFn = fn.glGetQueryivFn; - fn.glGetQueryivFn = Debug_glGetQueryiv; - } - if (!debug_fn.glGetQueryObjecti64vFn) { - debug_fn.glGetQueryObjecti64vFn = fn.glGetQueryObjecti64vFn; - fn.glGetQueryObjecti64vFn = Debug_glGetQueryObjecti64v; - } - if (!debug_fn.glGetQueryObjectivFn) { - debug_fn.glGetQueryObjectivFn = fn.glGetQueryObjectivFn; - fn.glGetQueryObjectivFn = Debug_glGetQueryObjectiv; - } - if (!debug_fn.glGetQueryObjectui64vFn) { - debug_fn.glGetQueryObjectui64vFn = fn.glGetQueryObjectui64vFn; - fn.glGetQueryObjectui64vFn = Debug_glGetQueryObjectui64v; - } - if (!debug_fn.glGetQueryObjectuivFn) { - debug_fn.glGetQueryObjectuivFn = fn.glGetQueryObjectuivFn; - fn.glGetQueryObjectuivFn = Debug_glGetQueryObjectuiv; - } - if (!debug_fn.glGetRenderbufferParameterivEXTFn) { - debug_fn.glGetRenderbufferParameterivEXTFn = - fn.glGetRenderbufferParameterivEXTFn; - fn.glGetRenderbufferParameterivEXTFn = - Debug_glGetRenderbufferParameterivEXT; - } - if (!debug_fn.glGetSamplerParameterfvFn) { - debug_fn.glGetSamplerParameterfvFn = fn.glGetSamplerParameterfvFn; - fn.glGetSamplerParameterfvFn = Debug_glGetSamplerParameterfv; - } - if (!debug_fn.glGetSamplerParameterivFn) { - debug_fn.glGetSamplerParameterivFn = fn.glGetSamplerParameterivFn; - fn.glGetSamplerParameterivFn = Debug_glGetSamplerParameteriv; - } - if (!debug_fn.glGetShaderInfoLogFn) { - debug_fn.glGetShaderInfoLogFn = fn.glGetShaderInfoLogFn; - fn.glGetShaderInfoLogFn = Debug_glGetShaderInfoLog; - } - if (!debug_fn.glGetShaderivFn) { - debug_fn.glGetShaderivFn = fn.glGetShaderivFn; - fn.glGetShaderivFn = Debug_glGetShaderiv; - } - if (!debug_fn.glGetShaderPrecisionFormatFn) { - debug_fn.glGetShaderPrecisionFormatFn = fn.glGetShaderPrecisionFormatFn; - fn.glGetShaderPrecisionFormatFn = Debug_glGetShaderPrecisionFormat; - } - if (!debug_fn.glGetShaderSourceFn) { - debug_fn.glGetShaderSourceFn = fn.glGetShaderSourceFn; - fn.glGetShaderSourceFn = Debug_glGetShaderSource; - } - if (!debug_fn.glGetStringFn) { - debug_fn.glGetStringFn = fn.glGetStringFn; - fn.glGetStringFn = Debug_glGetString; - } - if (!debug_fn.glGetStringiFn) { - debug_fn.glGetStringiFn = fn.glGetStringiFn; - fn.glGetStringiFn = Debug_glGetStringi; - } - if (!debug_fn.glGetSyncivFn) { - debug_fn.glGetSyncivFn = fn.glGetSyncivFn; - fn.glGetSyncivFn = Debug_glGetSynciv; - } - if (!debug_fn.glGetTexLevelParameterfvFn) { - debug_fn.glGetTexLevelParameterfvFn = fn.glGetTexLevelParameterfvFn; - fn.glGetTexLevelParameterfvFn = Debug_glGetTexLevelParameterfv; - } - if (!debug_fn.glGetTexLevelParameterivFn) { - debug_fn.glGetTexLevelParameterivFn = fn.glGetTexLevelParameterivFn; - fn.glGetTexLevelParameterivFn = Debug_glGetTexLevelParameteriv; - } - if (!debug_fn.glGetTexParameterfvFn) { - debug_fn.glGetTexParameterfvFn = fn.glGetTexParameterfvFn; - fn.glGetTexParameterfvFn = Debug_glGetTexParameterfv; - } - if (!debug_fn.glGetTexParameterivFn) { - debug_fn.glGetTexParameterivFn = fn.glGetTexParameterivFn; - fn.glGetTexParameterivFn = Debug_glGetTexParameteriv; - } - if (!debug_fn.glGetTransformFeedbackVaryingFn) { - debug_fn.glGetTransformFeedbackVaryingFn = - fn.glGetTransformFeedbackVaryingFn; - fn.glGetTransformFeedbackVaryingFn = Debug_glGetTransformFeedbackVarying; - } - if (!debug_fn.glGetTranslatedShaderSourceANGLEFn) { - debug_fn.glGetTranslatedShaderSourceANGLEFn = - fn.glGetTranslatedShaderSourceANGLEFn; - fn.glGetTranslatedShaderSourceANGLEFn = - Debug_glGetTranslatedShaderSourceANGLE; - } - if (!debug_fn.glGetUniformBlockIndexFn) { - debug_fn.glGetUniformBlockIndexFn = fn.glGetUniformBlockIndexFn; - fn.glGetUniformBlockIndexFn = Debug_glGetUniformBlockIndex; - } - if (!debug_fn.glGetUniformfvFn) { - debug_fn.glGetUniformfvFn = fn.glGetUniformfvFn; - fn.glGetUniformfvFn = Debug_glGetUniformfv; - } - if (!debug_fn.glGetUniformIndicesFn) { - debug_fn.glGetUniformIndicesFn = fn.glGetUniformIndicesFn; - fn.glGetUniformIndicesFn = Debug_glGetUniformIndices; - } - if (!debug_fn.glGetUniformivFn) { - debug_fn.glGetUniformivFn = fn.glGetUniformivFn; - fn.glGetUniformivFn = Debug_glGetUniformiv; - } - if (!debug_fn.glGetUniformLocationFn) { - debug_fn.glGetUniformLocationFn = fn.glGetUniformLocationFn; - fn.glGetUniformLocationFn = Debug_glGetUniformLocation; - } - if (!debug_fn.glGetVertexAttribfvFn) { - debug_fn.glGetVertexAttribfvFn = fn.glGetVertexAttribfvFn; - fn.glGetVertexAttribfvFn = Debug_glGetVertexAttribfv; - } - if (!debug_fn.glGetVertexAttribivFn) { - debug_fn.glGetVertexAttribivFn = fn.glGetVertexAttribivFn; - fn.glGetVertexAttribivFn = Debug_glGetVertexAttribiv; - } - if (!debug_fn.glGetVertexAttribPointervFn) { - debug_fn.glGetVertexAttribPointervFn = fn.glGetVertexAttribPointervFn; - fn.glGetVertexAttribPointervFn = Debug_glGetVertexAttribPointerv; - } - if (!debug_fn.glHintFn) { - debug_fn.glHintFn = fn.glHintFn; - fn.glHintFn = Debug_glHint; - } - if (!debug_fn.glInsertEventMarkerEXTFn) { - debug_fn.glInsertEventMarkerEXTFn = fn.glInsertEventMarkerEXTFn; - fn.glInsertEventMarkerEXTFn = Debug_glInsertEventMarkerEXT; - } - if (!debug_fn.glInvalidateFramebufferFn) { - debug_fn.glInvalidateFramebufferFn = fn.glInvalidateFramebufferFn; - fn.glInvalidateFramebufferFn = Debug_glInvalidateFramebuffer; - } - if (!debug_fn.glInvalidateSubFramebufferFn) { - debug_fn.glInvalidateSubFramebufferFn = fn.glInvalidateSubFramebufferFn; - fn.glInvalidateSubFramebufferFn = Debug_glInvalidateSubFramebuffer; - } - if (!debug_fn.glIsBufferFn) { - debug_fn.glIsBufferFn = fn.glIsBufferFn; - fn.glIsBufferFn = Debug_glIsBuffer; - } - if (!debug_fn.glIsEnabledFn) { - debug_fn.glIsEnabledFn = fn.glIsEnabledFn; - fn.glIsEnabledFn = Debug_glIsEnabled; - } - if (!debug_fn.glIsFenceAPPLEFn) { - debug_fn.glIsFenceAPPLEFn = fn.glIsFenceAPPLEFn; - fn.glIsFenceAPPLEFn = Debug_glIsFenceAPPLE; - } - if (!debug_fn.glIsFenceNVFn) { - debug_fn.glIsFenceNVFn = fn.glIsFenceNVFn; - fn.glIsFenceNVFn = Debug_glIsFenceNV; - } - if (!debug_fn.glIsFramebufferEXTFn) { - debug_fn.glIsFramebufferEXTFn = fn.glIsFramebufferEXTFn; - fn.glIsFramebufferEXTFn = Debug_glIsFramebufferEXT; - } - if (!debug_fn.glIsProgramFn) { - debug_fn.glIsProgramFn = fn.glIsProgramFn; - fn.glIsProgramFn = Debug_glIsProgram; - } - if (!debug_fn.glIsQueryFn) { - debug_fn.glIsQueryFn = fn.glIsQueryFn; - fn.glIsQueryFn = Debug_glIsQuery; - } - if (!debug_fn.glIsRenderbufferEXTFn) { - debug_fn.glIsRenderbufferEXTFn = fn.glIsRenderbufferEXTFn; - fn.glIsRenderbufferEXTFn = Debug_glIsRenderbufferEXT; - } - if (!debug_fn.glIsSamplerFn) { - debug_fn.glIsSamplerFn = fn.glIsSamplerFn; - fn.glIsSamplerFn = Debug_glIsSampler; - } - if (!debug_fn.glIsShaderFn) { - debug_fn.glIsShaderFn = fn.glIsShaderFn; - fn.glIsShaderFn = Debug_glIsShader; - } - if (!debug_fn.glIsSyncFn) { - debug_fn.glIsSyncFn = fn.glIsSyncFn; - fn.glIsSyncFn = Debug_glIsSync; - } - if (!debug_fn.glIsTextureFn) { - debug_fn.glIsTextureFn = fn.glIsTextureFn; - fn.glIsTextureFn = Debug_glIsTexture; - } - if (!debug_fn.glIsTransformFeedbackFn) { - debug_fn.glIsTransformFeedbackFn = fn.glIsTransformFeedbackFn; - fn.glIsTransformFeedbackFn = Debug_glIsTransformFeedback; - } - if (!debug_fn.glIsVertexArrayOESFn) { - debug_fn.glIsVertexArrayOESFn = fn.glIsVertexArrayOESFn; - fn.glIsVertexArrayOESFn = Debug_glIsVertexArrayOES; - } - if (!debug_fn.glLineWidthFn) { - debug_fn.glLineWidthFn = fn.glLineWidthFn; - fn.glLineWidthFn = Debug_glLineWidth; - } - if (!debug_fn.glLinkProgramFn) { - debug_fn.glLinkProgramFn = fn.glLinkProgramFn; - fn.glLinkProgramFn = Debug_glLinkProgram; - } - if (!debug_fn.glMapBufferFn) { - debug_fn.glMapBufferFn = fn.glMapBufferFn; - fn.glMapBufferFn = Debug_glMapBuffer; - } - if (!debug_fn.glMapBufferRangeFn) { - debug_fn.glMapBufferRangeFn = fn.glMapBufferRangeFn; - fn.glMapBufferRangeFn = Debug_glMapBufferRange; - } - if (!debug_fn.glMatrixLoadfEXTFn) { - debug_fn.glMatrixLoadfEXTFn = fn.glMatrixLoadfEXTFn; - fn.glMatrixLoadfEXTFn = Debug_glMatrixLoadfEXT; - } - if (!debug_fn.glMatrixLoadIdentityEXTFn) { - debug_fn.glMatrixLoadIdentityEXTFn = fn.glMatrixLoadIdentityEXTFn; - fn.glMatrixLoadIdentityEXTFn = Debug_glMatrixLoadIdentityEXT; - } - if (!debug_fn.glObjectLabelKHRFn) { - debug_fn.glObjectLabelKHRFn = fn.glObjectLabelKHRFn; - fn.glObjectLabelKHRFn = Debug_glObjectLabelKHR; - } - if (!debug_fn.glPauseTransformFeedbackFn) { - debug_fn.glPauseTransformFeedbackFn = fn.glPauseTransformFeedbackFn; - fn.glPauseTransformFeedbackFn = Debug_glPauseTransformFeedback; - } - if (!debug_fn.glPixelStoreiFn) { - debug_fn.glPixelStoreiFn = fn.glPixelStoreiFn; - fn.glPixelStoreiFn = Debug_glPixelStorei; - } - if (!debug_fn.glPointParameteriFn) { - debug_fn.glPointParameteriFn = fn.glPointParameteriFn; - fn.glPointParameteriFn = Debug_glPointParameteri; - } - if (!debug_fn.glPolygonOffsetFn) { - debug_fn.glPolygonOffsetFn = fn.glPolygonOffsetFn; - fn.glPolygonOffsetFn = Debug_glPolygonOffset; - } - if (!debug_fn.glPopDebugGroupKHRFn) { - debug_fn.glPopDebugGroupKHRFn = fn.glPopDebugGroupKHRFn; - fn.glPopDebugGroupKHRFn = Debug_glPopDebugGroupKHR; - } - if (!debug_fn.glPopGroupMarkerEXTFn) { - debug_fn.glPopGroupMarkerEXTFn = fn.glPopGroupMarkerEXTFn; - fn.glPopGroupMarkerEXTFn = Debug_glPopGroupMarkerEXT; - } - if (!debug_fn.glProgramBinaryFn) { - debug_fn.glProgramBinaryFn = fn.glProgramBinaryFn; - fn.glProgramBinaryFn = Debug_glProgramBinary; - } - if (!debug_fn.glProgramParameteriFn) { - debug_fn.glProgramParameteriFn = fn.glProgramParameteriFn; - fn.glProgramParameteriFn = Debug_glProgramParameteri; - } - if (!debug_fn.glPushDebugGroupKHRFn) { - debug_fn.glPushDebugGroupKHRFn = fn.glPushDebugGroupKHRFn; - fn.glPushDebugGroupKHRFn = Debug_glPushDebugGroupKHR; - } - if (!debug_fn.glPushGroupMarkerEXTFn) { - debug_fn.glPushGroupMarkerEXTFn = fn.glPushGroupMarkerEXTFn; - fn.glPushGroupMarkerEXTFn = Debug_glPushGroupMarkerEXT; - } - if (!debug_fn.glQueryCounterFn) { - debug_fn.glQueryCounterFn = fn.glQueryCounterFn; - fn.glQueryCounterFn = Debug_glQueryCounter; - } - if (!debug_fn.glReadBufferFn) { - debug_fn.glReadBufferFn = fn.glReadBufferFn; - fn.glReadBufferFn = Debug_glReadBuffer; - } - if (!debug_fn.glReadPixelsFn) { - debug_fn.glReadPixelsFn = fn.glReadPixelsFn; - fn.glReadPixelsFn = Debug_glReadPixels; - } - if (!debug_fn.glReleaseShaderCompilerFn) { - debug_fn.glReleaseShaderCompilerFn = fn.glReleaseShaderCompilerFn; - fn.glReleaseShaderCompilerFn = Debug_glReleaseShaderCompiler; - } - if (!debug_fn.glRenderbufferStorageEXTFn) { - debug_fn.glRenderbufferStorageEXTFn = fn.glRenderbufferStorageEXTFn; - fn.glRenderbufferStorageEXTFn = Debug_glRenderbufferStorageEXT; - } - if (!debug_fn.glRenderbufferStorageMultisampleFn) { - debug_fn.glRenderbufferStorageMultisampleFn = - fn.glRenderbufferStorageMultisampleFn; - fn.glRenderbufferStorageMultisampleFn = - Debug_glRenderbufferStorageMultisample; - } - if (!debug_fn.glRenderbufferStorageMultisampleANGLEFn) { - debug_fn.glRenderbufferStorageMultisampleANGLEFn = - fn.glRenderbufferStorageMultisampleANGLEFn; - fn.glRenderbufferStorageMultisampleANGLEFn = - Debug_glRenderbufferStorageMultisampleANGLE; - } - if (!debug_fn.glRenderbufferStorageMultisampleAPPLEFn) { - debug_fn.glRenderbufferStorageMultisampleAPPLEFn = - fn.glRenderbufferStorageMultisampleAPPLEFn; - fn.glRenderbufferStorageMultisampleAPPLEFn = - Debug_glRenderbufferStorageMultisampleAPPLE; - } - if (!debug_fn.glRenderbufferStorageMultisampleEXTFn) { - debug_fn.glRenderbufferStorageMultisampleEXTFn = - fn.glRenderbufferStorageMultisampleEXTFn; - fn.glRenderbufferStorageMultisampleEXTFn = - Debug_glRenderbufferStorageMultisampleEXT; - } - if (!debug_fn.glRenderbufferStorageMultisampleIMGFn) { - debug_fn.glRenderbufferStorageMultisampleIMGFn = - fn.glRenderbufferStorageMultisampleIMGFn; - fn.glRenderbufferStorageMultisampleIMGFn = - Debug_glRenderbufferStorageMultisampleIMG; - } - if (!debug_fn.glResolveMultisampleFramebufferAPPLEFn) { - debug_fn.glResolveMultisampleFramebufferAPPLEFn = - fn.glResolveMultisampleFramebufferAPPLEFn; - fn.glResolveMultisampleFramebufferAPPLEFn = - Debug_glResolveMultisampleFramebufferAPPLE; - } - if (!debug_fn.glResumeTransformFeedbackFn) { - debug_fn.glResumeTransformFeedbackFn = fn.glResumeTransformFeedbackFn; - fn.glResumeTransformFeedbackFn = Debug_glResumeTransformFeedback; - } - if (!debug_fn.glSampleCoverageFn) { - debug_fn.glSampleCoverageFn = fn.glSampleCoverageFn; - fn.glSampleCoverageFn = Debug_glSampleCoverage; - } - if (!debug_fn.glSamplerParameterfFn) { - debug_fn.glSamplerParameterfFn = fn.glSamplerParameterfFn; - fn.glSamplerParameterfFn = Debug_glSamplerParameterf; - } - if (!debug_fn.glSamplerParameterfvFn) { - debug_fn.glSamplerParameterfvFn = fn.glSamplerParameterfvFn; - fn.glSamplerParameterfvFn = Debug_glSamplerParameterfv; - } - if (!debug_fn.glSamplerParameteriFn) { - debug_fn.glSamplerParameteriFn = fn.glSamplerParameteriFn; - fn.glSamplerParameteriFn = Debug_glSamplerParameteri; - } - if (!debug_fn.glSamplerParameterivFn) { - debug_fn.glSamplerParameterivFn = fn.glSamplerParameterivFn; - fn.glSamplerParameterivFn = Debug_glSamplerParameteriv; - } - if (!debug_fn.glScissorFn) { - debug_fn.glScissorFn = fn.glScissorFn; - fn.glScissorFn = Debug_glScissor; - } - if (!debug_fn.glSetFenceAPPLEFn) { - debug_fn.glSetFenceAPPLEFn = fn.glSetFenceAPPLEFn; - fn.glSetFenceAPPLEFn = Debug_glSetFenceAPPLE; - } - if (!debug_fn.glSetFenceNVFn) { - debug_fn.glSetFenceNVFn = fn.glSetFenceNVFn; - fn.glSetFenceNVFn = Debug_glSetFenceNV; - } - if (!debug_fn.glShaderBinaryFn) { - debug_fn.glShaderBinaryFn = fn.glShaderBinaryFn; - fn.glShaderBinaryFn = Debug_glShaderBinary; - } - if (!debug_fn.glShaderSourceFn) { - debug_fn.glShaderSourceFn = fn.glShaderSourceFn; - fn.glShaderSourceFn = Debug_glShaderSource; - } - if (!debug_fn.glStencilFuncFn) { - debug_fn.glStencilFuncFn = fn.glStencilFuncFn; - fn.glStencilFuncFn = Debug_glStencilFunc; - } - if (!debug_fn.glStencilFuncSeparateFn) { - debug_fn.glStencilFuncSeparateFn = fn.glStencilFuncSeparateFn; - fn.glStencilFuncSeparateFn = Debug_glStencilFuncSeparate; - } - if (!debug_fn.glStencilMaskFn) { - debug_fn.glStencilMaskFn = fn.glStencilMaskFn; - fn.glStencilMaskFn = Debug_glStencilMask; - } - if (!debug_fn.glStencilMaskSeparateFn) { - debug_fn.glStencilMaskSeparateFn = fn.glStencilMaskSeparateFn; - fn.glStencilMaskSeparateFn = Debug_glStencilMaskSeparate; - } - if (!debug_fn.glStencilOpFn) { - debug_fn.glStencilOpFn = fn.glStencilOpFn; - fn.glStencilOpFn = Debug_glStencilOp; - } - if (!debug_fn.glStencilOpSeparateFn) { - debug_fn.glStencilOpSeparateFn = fn.glStencilOpSeparateFn; - fn.glStencilOpSeparateFn = Debug_glStencilOpSeparate; - } - if (!debug_fn.glTestFenceAPPLEFn) { - debug_fn.glTestFenceAPPLEFn = fn.glTestFenceAPPLEFn; - fn.glTestFenceAPPLEFn = Debug_glTestFenceAPPLE; - } - if (!debug_fn.glTestFenceNVFn) { - debug_fn.glTestFenceNVFn = fn.glTestFenceNVFn; - fn.glTestFenceNVFn = Debug_glTestFenceNV; - } - if (!debug_fn.glTexImage2DFn) { - debug_fn.glTexImage2DFn = fn.glTexImage2DFn; - fn.glTexImage2DFn = Debug_glTexImage2D; - } - if (!debug_fn.glTexImage3DFn) { - debug_fn.glTexImage3DFn = fn.glTexImage3DFn; - fn.glTexImage3DFn = Debug_glTexImage3D; - } - if (!debug_fn.glTexParameterfFn) { - debug_fn.glTexParameterfFn = fn.glTexParameterfFn; - fn.glTexParameterfFn = Debug_glTexParameterf; - } - if (!debug_fn.glTexParameterfvFn) { - debug_fn.glTexParameterfvFn = fn.glTexParameterfvFn; - fn.glTexParameterfvFn = Debug_glTexParameterfv; - } - if (!debug_fn.glTexParameteriFn) { - debug_fn.glTexParameteriFn = fn.glTexParameteriFn; - fn.glTexParameteriFn = Debug_glTexParameteri; - } - if (!debug_fn.glTexParameterivFn) { - debug_fn.glTexParameterivFn = fn.glTexParameterivFn; - fn.glTexParameterivFn = Debug_glTexParameteriv; - } - if (!debug_fn.glTexStorage2DEXTFn) { - debug_fn.glTexStorage2DEXTFn = fn.glTexStorage2DEXTFn; - fn.glTexStorage2DEXTFn = Debug_glTexStorage2DEXT; - } - if (!debug_fn.glTexStorage3DFn) { - debug_fn.glTexStorage3DFn = fn.glTexStorage3DFn; - fn.glTexStorage3DFn = Debug_glTexStorage3D; - } - if (!debug_fn.glTexSubImage2DFn) { - debug_fn.glTexSubImage2DFn = fn.glTexSubImage2DFn; - fn.glTexSubImage2DFn = Debug_glTexSubImage2D; - } - if (!debug_fn.glTextureBarrierNVFn) { - debug_fn.glTextureBarrierNVFn = fn.glTextureBarrierNVFn; - fn.glTextureBarrierNVFn = Debug_glTextureBarrierNV; - } - if (!debug_fn.glTransformFeedbackVaryingsFn) { - debug_fn.glTransformFeedbackVaryingsFn = fn.glTransformFeedbackVaryingsFn; - fn.glTransformFeedbackVaryingsFn = Debug_glTransformFeedbackVaryings; - } - if (!debug_fn.glUniform1fFn) { - debug_fn.glUniform1fFn = fn.glUniform1fFn; - fn.glUniform1fFn = Debug_glUniform1f; - } - if (!debug_fn.glUniform1fvFn) { - debug_fn.glUniform1fvFn = fn.glUniform1fvFn; - fn.glUniform1fvFn = Debug_glUniform1fv; - } - if (!debug_fn.glUniform1iFn) { - debug_fn.glUniform1iFn = fn.glUniform1iFn; - fn.glUniform1iFn = Debug_glUniform1i; - } - if (!debug_fn.glUniform1ivFn) { - debug_fn.glUniform1ivFn = fn.glUniform1ivFn; - fn.glUniform1ivFn = Debug_glUniform1iv; - } - if (!debug_fn.glUniform1uiFn) { - debug_fn.glUniform1uiFn = fn.glUniform1uiFn; - fn.glUniform1uiFn = Debug_glUniform1ui; - } - if (!debug_fn.glUniform1uivFn) { - debug_fn.glUniform1uivFn = fn.glUniform1uivFn; - fn.glUniform1uivFn = Debug_glUniform1uiv; - } - if (!debug_fn.glUniform2fFn) { - debug_fn.glUniform2fFn = fn.glUniform2fFn; - fn.glUniform2fFn = Debug_glUniform2f; - } - if (!debug_fn.glUniform2fvFn) { - debug_fn.glUniform2fvFn = fn.glUniform2fvFn; - fn.glUniform2fvFn = Debug_glUniform2fv; - } - if (!debug_fn.glUniform2iFn) { - debug_fn.glUniform2iFn = fn.glUniform2iFn; - fn.glUniform2iFn = Debug_glUniform2i; - } - if (!debug_fn.glUniform2ivFn) { - debug_fn.glUniform2ivFn = fn.glUniform2ivFn; - fn.glUniform2ivFn = Debug_glUniform2iv; - } - if (!debug_fn.glUniform2uiFn) { - debug_fn.glUniform2uiFn = fn.glUniform2uiFn; - fn.glUniform2uiFn = Debug_glUniform2ui; - } - if (!debug_fn.glUniform2uivFn) { - debug_fn.glUniform2uivFn = fn.glUniform2uivFn; - fn.glUniform2uivFn = Debug_glUniform2uiv; - } - if (!debug_fn.glUniform3fFn) { - debug_fn.glUniform3fFn = fn.glUniform3fFn; - fn.glUniform3fFn = Debug_glUniform3f; - } - if (!debug_fn.glUniform3fvFn) { - debug_fn.glUniform3fvFn = fn.glUniform3fvFn; - fn.glUniform3fvFn = Debug_glUniform3fv; - } - if (!debug_fn.glUniform3iFn) { - debug_fn.glUniform3iFn = fn.glUniform3iFn; - fn.glUniform3iFn = Debug_glUniform3i; - } - if (!debug_fn.glUniform3ivFn) { - debug_fn.glUniform3ivFn = fn.glUniform3ivFn; - fn.glUniform3ivFn = Debug_glUniform3iv; - } - if (!debug_fn.glUniform3uiFn) { - debug_fn.glUniform3uiFn = fn.glUniform3uiFn; - fn.glUniform3uiFn = Debug_glUniform3ui; - } - if (!debug_fn.glUniform3uivFn) { - debug_fn.glUniform3uivFn = fn.glUniform3uivFn; - fn.glUniform3uivFn = Debug_glUniform3uiv; - } - if (!debug_fn.glUniform4fFn) { - debug_fn.glUniform4fFn = fn.glUniform4fFn; - fn.glUniform4fFn = Debug_glUniform4f; - } - if (!debug_fn.glUniform4fvFn) { - debug_fn.glUniform4fvFn = fn.glUniform4fvFn; - fn.glUniform4fvFn = Debug_glUniform4fv; - } - if (!debug_fn.glUniform4iFn) { - debug_fn.glUniform4iFn = fn.glUniform4iFn; - fn.glUniform4iFn = Debug_glUniform4i; - } - if (!debug_fn.glUniform4ivFn) { - debug_fn.glUniform4ivFn = fn.glUniform4ivFn; - fn.glUniform4ivFn = Debug_glUniform4iv; - } - if (!debug_fn.glUniform4uiFn) { - debug_fn.glUniform4uiFn = fn.glUniform4uiFn; - fn.glUniform4uiFn = Debug_glUniform4ui; - } - if (!debug_fn.glUniform4uivFn) { - debug_fn.glUniform4uivFn = fn.glUniform4uivFn; - fn.glUniform4uivFn = Debug_glUniform4uiv; - } - if (!debug_fn.glUniformBlockBindingFn) { - debug_fn.glUniformBlockBindingFn = fn.glUniformBlockBindingFn; - fn.glUniformBlockBindingFn = Debug_glUniformBlockBinding; - } - if (!debug_fn.glUniformMatrix2fvFn) { - debug_fn.glUniformMatrix2fvFn = fn.glUniformMatrix2fvFn; - fn.glUniformMatrix2fvFn = Debug_glUniformMatrix2fv; - } - if (!debug_fn.glUniformMatrix2x3fvFn) { - debug_fn.glUniformMatrix2x3fvFn = fn.glUniformMatrix2x3fvFn; - fn.glUniformMatrix2x3fvFn = Debug_glUniformMatrix2x3fv; - } - if (!debug_fn.glUniformMatrix2x4fvFn) { - debug_fn.glUniformMatrix2x4fvFn = fn.glUniformMatrix2x4fvFn; - fn.glUniformMatrix2x4fvFn = Debug_glUniformMatrix2x4fv; - } - if (!debug_fn.glUniformMatrix3fvFn) { - debug_fn.glUniformMatrix3fvFn = fn.glUniformMatrix3fvFn; - fn.glUniformMatrix3fvFn = Debug_glUniformMatrix3fv; - } - if (!debug_fn.glUniformMatrix3x2fvFn) { - debug_fn.glUniformMatrix3x2fvFn = fn.glUniformMatrix3x2fvFn; - fn.glUniformMatrix3x2fvFn = Debug_glUniformMatrix3x2fv; - } - if (!debug_fn.glUniformMatrix3x4fvFn) { - debug_fn.glUniformMatrix3x4fvFn = fn.glUniformMatrix3x4fvFn; - fn.glUniformMatrix3x4fvFn = Debug_glUniformMatrix3x4fv; - } - if (!debug_fn.glUniformMatrix4fvFn) { - debug_fn.glUniformMatrix4fvFn = fn.glUniformMatrix4fvFn; - fn.glUniformMatrix4fvFn = Debug_glUniformMatrix4fv; - } - if (!debug_fn.glUniformMatrix4x2fvFn) { - debug_fn.glUniformMatrix4x2fvFn = fn.glUniformMatrix4x2fvFn; - fn.glUniformMatrix4x2fvFn = Debug_glUniformMatrix4x2fv; - } - if (!debug_fn.glUniformMatrix4x3fvFn) { - debug_fn.glUniformMatrix4x3fvFn = fn.glUniformMatrix4x3fvFn; - fn.glUniformMatrix4x3fvFn = Debug_glUniformMatrix4x3fv; - } - if (!debug_fn.glUnmapBufferFn) { - debug_fn.glUnmapBufferFn = fn.glUnmapBufferFn; - fn.glUnmapBufferFn = Debug_glUnmapBuffer; - } - if (!debug_fn.glUseProgramFn) { - debug_fn.glUseProgramFn = fn.glUseProgramFn; - fn.glUseProgramFn = Debug_glUseProgram; - } - if (!debug_fn.glValidateProgramFn) { - debug_fn.glValidateProgramFn = fn.glValidateProgramFn; - fn.glValidateProgramFn = Debug_glValidateProgram; - } - if (!debug_fn.glVertexAttrib1fFn) { - debug_fn.glVertexAttrib1fFn = fn.glVertexAttrib1fFn; - fn.glVertexAttrib1fFn = Debug_glVertexAttrib1f; - } - if (!debug_fn.glVertexAttrib1fvFn) { - debug_fn.glVertexAttrib1fvFn = fn.glVertexAttrib1fvFn; - fn.glVertexAttrib1fvFn = Debug_glVertexAttrib1fv; - } - if (!debug_fn.glVertexAttrib2fFn) { - debug_fn.glVertexAttrib2fFn = fn.glVertexAttrib2fFn; - fn.glVertexAttrib2fFn = Debug_glVertexAttrib2f; - } - if (!debug_fn.glVertexAttrib2fvFn) { - debug_fn.glVertexAttrib2fvFn = fn.glVertexAttrib2fvFn; - fn.glVertexAttrib2fvFn = Debug_glVertexAttrib2fv; - } - if (!debug_fn.glVertexAttrib3fFn) { - debug_fn.glVertexAttrib3fFn = fn.glVertexAttrib3fFn; - fn.glVertexAttrib3fFn = Debug_glVertexAttrib3f; - } - if (!debug_fn.glVertexAttrib3fvFn) { - debug_fn.glVertexAttrib3fvFn = fn.glVertexAttrib3fvFn; - fn.glVertexAttrib3fvFn = Debug_glVertexAttrib3fv; - } - if (!debug_fn.glVertexAttrib4fFn) { - debug_fn.glVertexAttrib4fFn = fn.glVertexAttrib4fFn; - fn.glVertexAttrib4fFn = Debug_glVertexAttrib4f; - } - if (!debug_fn.glVertexAttrib4fvFn) { - debug_fn.glVertexAttrib4fvFn = fn.glVertexAttrib4fvFn; - fn.glVertexAttrib4fvFn = Debug_glVertexAttrib4fv; - } - if (!debug_fn.glVertexAttribDivisorANGLEFn) { - debug_fn.glVertexAttribDivisorANGLEFn = fn.glVertexAttribDivisorANGLEFn; - fn.glVertexAttribDivisorANGLEFn = Debug_glVertexAttribDivisorANGLE; - } - if (!debug_fn.glVertexAttribI4iFn) { - debug_fn.glVertexAttribI4iFn = fn.glVertexAttribI4iFn; - fn.glVertexAttribI4iFn = Debug_glVertexAttribI4i; - } - if (!debug_fn.glVertexAttribI4ivFn) { - debug_fn.glVertexAttribI4ivFn = fn.glVertexAttribI4ivFn; - fn.glVertexAttribI4ivFn = Debug_glVertexAttribI4iv; - } - if (!debug_fn.glVertexAttribI4uiFn) { - debug_fn.glVertexAttribI4uiFn = fn.glVertexAttribI4uiFn; - fn.glVertexAttribI4uiFn = Debug_glVertexAttribI4ui; - } - if (!debug_fn.glVertexAttribI4uivFn) { - debug_fn.glVertexAttribI4uivFn = fn.glVertexAttribI4uivFn; - fn.glVertexAttribI4uivFn = Debug_glVertexAttribI4uiv; - } - if (!debug_fn.glVertexAttribIPointerFn) { - debug_fn.glVertexAttribIPointerFn = fn.glVertexAttribIPointerFn; - fn.glVertexAttribIPointerFn = Debug_glVertexAttribIPointer; - } - if (!debug_fn.glVertexAttribPointerFn) { - debug_fn.glVertexAttribPointerFn = fn.glVertexAttribPointerFn; - fn.glVertexAttribPointerFn = Debug_glVertexAttribPointer; - } - if (!debug_fn.glViewportFn) { - debug_fn.glViewportFn = fn.glViewportFn; - fn.glViewportFn = Debug_glViewport; - } - if (!debug_fn.glWaitSyncFn) { - debug_fn.glWaitSyncFn = fn.glWaitSyncFn; - fn.glWaitSyncFn = Debug_glWaitSync; - } - g_debugBindingsInitialized = true; -} - -void DriverGL::ClearBindings() { - memset(this, 0, sizeof(*this)); -} - -void GLApiBase::glActiveTextureFn(GLenum texture) { - driver_->fn.glActiveTextureFn(texture); -} - -void GLApiBase::glAttachShaderFn(GLuint program, GLuint shader) { - driver_->fn.glAttachShaderFn(program, shader); -} - -void GLApiBase::glBeginQueryFn(GLenum target, GLuint id) { - driver_->fn.glBeginQueryFn(target, id); -} - -void GLApiBase::glBeginTransformFeedbackFn(GLenum primitiveMode) { - driver_->fn.glBeginTransformFeedbackFn(primitiveMode); -} - -void GLApiBase::glBindAttribLocationFn(GLuint program, - GLuint index, - const char* name) { - driver_->fn.glBindAttribLocationFn(program, index, name); -} - -void GLApiBase::glBindBufferFn(GLenum target, GLuint buffer) { - driver_->fn.glBindBufferFn(target, buffer); -} - -void GLApiBase::glBindBufferBaseFn(GLenum target, GLuint index, GLuint buffer) { - driver_->fn.glBindBufferBaseFn(target, index, buffer); -} - -void GLApiBase::glBindBufferRangeFn(GLenum target, - GLuint index, - GLuint buffer, - GLintptr offset, - GLsizeiptr size) { - driver_->fn.glBindBufferRangeFn(target, index, buffer, offset, size); -} - -void GLApiBase::glBindFragDataLocationFn(GLuint program, - GLuint colorNumber, - const char* name) { - driver_->fn.glBindFragDataLocationFn(program, colorNumber, name); -} - -void GLApiBase::glBindFragDataLocationIndexedFn(GLuint program, - GLuint colorNumber, - GLuint index, - const char* name) { - driver_->fn.glBindFragDataLocationIndexedFn(program, colorNumber, index, - name); -} - -void GLApiBase::glBindFramebufferEXTFn(GLenum target, GLuint framebuffer) { - driver_->fn.glBindFramebufferEXTFn(target, framebuffer); -} - -void GLApiBase::glBindRenderbufferEXTFn(GLenum target, GLuint renderbuffer) { - driver_->fn.glBindRenderbufferEXTFn(target, renderbuffer); -} - -void GLApiBase::glBindSamplerFn(GLuint unit, GLuint sampler) { - driver_->fn.glBindSamplerFn(unit, sampler); -} - -void GLApiBase::glBindTextureFn(GLenum target, GLuint texture) { - driver_->fn.glBindTextureFn(target, texture); -} - -void GLApiBase::glBindTransformFeedbackFn(GLenum target, GLuint id) { - driver_->fn.glBindTransformFeedbackFn(target, id); -} - -void GLApiBase::glBindVertexArrayOESFn(GLuint array) { - driver_->fn.glBindVertexArrayOESFn(array); -} - -void GLApiBase::glBlendBarrierKHRFn(void) { - driver_->fn.glBlendBarrierKHRFn(); -} - -void GLApiBase::glBlendColorFn(GLclampf red, - GLclampf green, - GLclampf blue, - GLclampf alpha) { - driver_->fn.glBlendColorFn(red, green, blue, alpha); -} - -void GLApiBase::glBlendEquationFn(GLenum mode) { - driver_->fn.glBlendEquationFn(mode); -} - -void GLApiBase::glBlendEquationSeparateFn(GLenum modeRGB, GLenum modeAlpha) { - driver_->fn.glBlendEquationSeparateFn(modeRGB, modeAlpha); -} - -void GLApiBase::glBlendFuncFn(GLenum sfactor, GLenum dfactor) { - driver_->fn.glBlendFuncFn(sfactor, dfactor); -} - -void GLApiBase::glBlendFuncSeparateFn(GLenum srcRGB, - GLenum dstRGB, - GLenum srcAlpha, - GLenum dstAlpha) { - driver_->fn.glBlendFuncSeparateFn(srcRGB, dstRGB, srcAlpha, dstAlpha); -} - -void GLApiBase::glBlitFramebufferFn(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) { - driver_->fn.glBlitFramebufferFn(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, - dstX1, dstY1, mask, filter); -} - -void GLApiBase::glBlitFramebufferANGLEFn(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) { - driver_->fn.glBlitFramebufferANGLEFn(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, - dstX1, dstY1, mask, filter); -} - -void GLApiBase::glBlitFramebufferEXTFn(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) { - driver_->fn.glBlitFramebufferEXTFn(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, - dstX1, dstY1, mask, filter); -} - -void GLApiBase::glBufferDataFn(GLenum target, - GLsizeiptr size, - const void* data, - GLenum usage) { - driver_->fn.glBufferDataFn(target, size, data, usage); -} - -void GLApiBase::glBufferSubDataFn(GLenum target, - GLintptr offset, - GLsizeiptr size, - const void* data) { - driver_->fn.glBufferSubDataFn(target, offset, size, data); -} - -GLenum GLApiBase::glCheckFramebufferStatusEXTFn(GLenum target) { - return driver_->fn.glCheckFramebufferStatusEXTFn(target); -} - -void GLApiBase::glClearFn(GLbitfield mask) { - driver_->fn.glClearFn(mask); -} - -void GLApiBase::glClearBufferfiFn(GLenum buffer, - GLint drawbuffer, - const GLfloat depth, - GLint stencil) { - driver_->fn.glClearBufferfiFn(buffer, drawbuffer, depth, stencil); -} - -void GLApiBase::glClearBufferfvFn(GLenum buffer, - GLint drawbuffer, - const GLfloat* value) { - driver_->fn.glClearBufferfvFn(buffer, drawbuffer, value); -} - -void GLApiBase::glClearBufferivFn(GLenum buffer, - GLint drawbuffer, - const GLint* value) { - driver_->fn.glClearBufferivFn(buffer, drawbuffer, value); -} - -void GLApiBase::glClearBufferuivFn(GLenum buffer, - GLint drawbuffer, - const GLuint* value) { - driver_->fn.glClearBufferuivFn(buffer, drawbuffer, value); -} - -void GLApiBase::glClearColorFn(GLclampf red, - GLclampf green, - GLclampf blue, - GLclampf alpha) { - driver_->fn.glClearColorFn(red, green, blue, alpha); -} - -void GLApiBase::glClearDepthFn(GLclampd depth) { - driver_->fn.glClearDepthFn(depth); -} - -void GLApiBase::glClearDepthfFn(GLclampf depth) { - driver_->fn.glClearDepthfFn(depth); -} - -void GLApiBase::glClearStencilFn(GLint s) { - driver_->fn.glClearStencilFn(s); -} - -GLenum GLApiBase::glClientWaitSyncFn(GLsync sync, - GLbitfield flags, - GLuint64 timeout) { - return driver_->fn.glClientWaitSyncFn(sync, flags, timeout); -} - -void GLApiBase::glColorMaskFn(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha) { - driver_->fn.glColorMaskFn(red, green, blue, alpha); -} - -void GLApiBase::glCompileShaderFn(GLuint shader) { - driver_->fn.glCompileShaderFn(shader); -} - -void GLApiBase::glCompressedTexImage2DFn(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const void* data) { - driver_->fn.glCompressedTexImage2DFn(target, level, internalformat, width, - height, border, imageSize, data); -} - -void GLApiBase::glCompressedTexImage3DFn(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLsizei imageSize, - const void* data) { - driver_->fn.glCompressedTexImage3DFn(target, level, internalformat, width, - height, depth, border, imageSize, data); -} - -void GLApiBase::glCompressedTexSubImage2DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const void* data) { - driver_->fn.glCompressedTexSubImage2DFn( - target, level, xoffset, yoffset, width, height, format, imageSize, data); -} - -void GLApiBase::glCopyBufferSubDataFn(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size) { - driver_->fn.glCopyBufferSubDataFn(readTarget, writeTarget, readOffset, - writeOffset, size); -} - -void GLApiBase::glCopyTexImage2DFn(GLenum target, - GLint level, - GLenum internalformat, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLint border) { - driver_->fn.glCopyTexImage2DFn(target, level, internalformat, x, y, width, - height, border); -} - -void GLApiBase::glCopyTexSubImage2DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height) { - driver_->fn.glCopyTexSubImage2DFn(target, level, xoffset, yoffset, x, y, - width, height); -} - -void GLApiBase::glCopyTexSubImage3DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height) { - driver_->fn.glCopyTexSubImage3DFn(target, level, xoffset, yoffset, zoffset, x, - y, width, height); -} - -GLuint GLApiBase::glCreateProgramFn(void) { - return driver_->fn.glCreateProgramFn(); -} - -GLuint GLApiBase::glCreateShaderFn(GLenum type) { - return driver_->fn.glCreateShaderFn(type); -} - -void GLApiBase::glCullFaceFn(GLenum mode) { - driver_->fn.glCullFaceFn(mode); -} - -void GLApiBase::glDebugMessageCallbackKHRFn(GLDEBUGPROCKHR callback, - const void* userparam) { - driver_->fn.glDebugMessageCallbackKHRFn(callback, userparam); -} - -void GLApiBase::glDebugMessageControlKHRFn(GLenum source, - GLenum type, - GLenum severity, - GLsizei count, - const GLuint* ids, - GLboolean enabled) { - driver_->fn.glDebugMessageControlKHRFn(source, type, severity, count, ids, - enabled); -} - -void GLApiBase::glDebugMessageInsertKHRFn(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar* buf) { - driver_->fn.glDebugMessageInsertKHRFn(source, type, id, severity, length, - buf); -} - -void GLApiBase::glDeleteBuffersARBFn(GLsizei n, const GLuint* buffers) { - driver_->fn.glDeleteBuffersARBFn(n, buffers); -} - -void GLApiBase::glDeleteFencesAPPLEFn(GLsizei n, const GLuint* fences) { - driver_->fn.glDeleteFencesAPPLEFn(n, fences); -} - -void GLApiBase::glDeleteFencesNVFn(GLsizei n, const GLuint* fences) { - driver_->fn.glDeleteFencesNVFn(n, fences); -} - -void GLApiBase::glDeleteFramebuffersEXTFn(GLsizei n, - const GLuint* framebuffers) { - driver_->fn.glDeleteFramebuffersEXTFn(n, framebuffers); -} - -void GLApiBase::glDeleteProgramFn(GLuint program) { - driver_->fn.glDeleteProgramFn(program); -} - -void GLApiBase::glDeleteQueriesFn(GLsizei n, const GLuint* ids) { - driver_->fn.glDeleteQueriesFn(n, ids); -} - -void GLApiBase::glDeleteRenderbuffersEXTFn(GLsizei n, - const GLuint* renderbuffers) { - driver_->fn.glDeleteRenderbuffersEXTFn(n, renderbuffers); -} - -void GLApiBase::glDeleteSamplersFn(GLsizei n, const GLuint* samplers) { - driver_->fn.glDeleteSamplersFn(n, samplers); -} - -void GLApiBase::glDeleteShaderFn(GLuint shader) { - driver_->fn.glDeleteShaderFn(shader); -} - -void GLApiBase::glDeleteSyncFn(GLsync sync) { - driver_->fn.glDeleteSyncFn(sync); -} - -void GLApiBase::glDeleteTexturesFn(GLsizei n, const GLuint* textures) { - driver_->fn.glDeleteTexturesFn(n, textures); -} - -void GLApiBase::glDeleteTransformFeedbacksFn(GLsizei n, const GLuint* ids) { - driver_->fn.glDeleteTransformFeedbacksFn(n, ids); -} - -void GLApiBase::glDeleteVertexArraysOESFn(GLsizei n, const GLuint* arrays) { - driver_->fn.glDeleteVertexArraysOESFn(n, arrays); -} - -void GLApiBase::glDepthFuncFn(GLenum func) { - driver_->fn.glDepthFuncFn(func); -} - -void GLApiBase::glDepthMaskFn(GLboolean flag) { - driver_->fn.glDepthMaskFn(flag); -} - -void GLApiBase::glDepthRangeFn(GLclampd zNear, GLclampd zFar) { - driver_->fn.glDepthRangeFn(zNear, zFar); -} - -void GLApiBase::glDepthRangefFn(GLclampf zNear, GLclampf zFar) { - driver_->fn.glDepthRangefFn(zNear, zFar); -} - -void GLApiBase::glDetachShaderFn(GLuint program, GLuint shader) { - driver_->fn.glDetachShaderFn(program, shader); -} - -void GLApiBase::glDisableFn(GLenum cap) { - driver_->fn.glDisableFn(cap); -} - -void GLApiBase::glDisableVertexAttribArrayFn(GLuint index) { - driver_->fn.glDisableVertexAttribArrayFn(index); -} - -void GLApiBase::glDiscardFramebufferEXTFn(GLenum target, - GLsizei numAttachments, - const GLenum* attachments) { - driver_->fn.glDiscardFramebufferEXTFn(target, numAttachments, attachments); -} - -void GLApiBase::glDrawArraysFn(GLenum mode, GLint first, GLsizei count) { - driver_->fn.glDrawArraysFn(mode, first, count); -} - -void GLApiBase::glDrawArraysInstancedANGLEFn(GLenum mode, - GLint first, - GLsizei count, - GLsizei primcount) { - driver_->fn.glDrawArraysInstancedANGLEFn(mode, first, count, primcount); -} - -void GLApiBase::glDrawBufferFn(GLenum mode) { - driver_->fn.glDrawBufferFn(mode); -} - -void GLApiBase::glDrawBuffersARBFn(GLsizei n, const GLenum* bufs) { - driver_->fn.glDrawBuffersARBFn(n, bufs); -} - -void GLApiBase::glDrawElementsFn(GLenum mode, - GLsizei count, - GLenum type, - const void* indices) { - driver_->fn.glDrawElementsFn(mode, count, type, indices); -} - -void GLApiBase::glDrawElementsInstancedANGLEFn(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei primcount) { - driver_->fn.glDrawElementsInstancedANGLEFn(mode, count, type, indices, - primcount); -} - -void GLApiBase::glDrawRangeElementsFn(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices) { - driver_->fn.glDrawRangeElementsFn(mode, start, end, count, type, indices); -} - -void GLApiBase::glEGLImageTargetRenderbufferStorageOESFn(GLenum target, - GLeglImageOES image) { - driver_->fn.glEGLImageTargetRenderbufferStorageOESFn(target, image); -} - -void GLApiBase::glEGLImageTargetTexture2DOESFn(GLenum target, - GLeglImageOES image) { - driver_->fn.glEGLImageTargetTexture2DOESFn(target, image); -} - -void GLApiBase::glEnableFn(GLenum cap) { - driver_->fn.glEnableFn(cap); -} - -void GLApiBase::glEnableVertexAttribArrayFn(GLuint index) { - driver_->fn.glEnableVertexAttribArrayFn(index); -} - -void GLApiBase::glEndQueryFn(GLenum target) { - driver_->fn.glEndQueryFn(target); -} - -void GLApiBase::glEndTransformFeedbackFn(void) { - driver_->fn.glEndTransformFeedbackFn(); -} - -GLsync GLApiBase::glFenceSyncFn(GLenum condition, GLbitfield flags) { - return driver_->fn.glFenceSyncFn(condition, flags); -} - -void GLApiBase::glFinishFn(void) { - driver_->fn.glFinishFn(); -} - -void GLApiBase::glFinishFenceAPPLEFn(GLuint fence) { - driver_->fn.glFinishFenceAPPLEFn(fence); -} - -void GLApiBase::glFinishFenceNVFn(GLuint fence) { - driver_->fn.glFinishFenceNVFn(fence); -} - -void GLApiBase::glFlushFn(void) { - driver_->fn.glFlushFn(); -} - -void GLApiBase::glFlushMappedBufferRangeFn(GLenum target, - GLintptr offset, - GLsizeiptr length) { - driver_->fn.glFlushMappedBufferRangeFn(target, offset, length); -} - -void GLApiBase::glFramebufferRenderbufferEXTFn(GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer) { - driver_->fn.glFramebufferRenderbufferEXTFn(target, attachment, - renderbuffertarget, renderbuffer); -} - -void GLApiBase::glFramebufferTexture2DEXTFn(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level) { - driver_->fn.glFramebufferTexture2DEXTFn(target, attachment, textarget, - texture, level); -} - -void GLApiBase::glFramebufferTexture2DMultisampleEXTFn(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples) { - driver_->fn.glFramebufferTexture2DMultisampleEXTFn( - target, attachment, textarget, texture, level, samples); -} - -void GLApiBase::glFramebufferTexture2DMultisampleIMGFn(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples) { - driver_->fn.glFramebufferTexture2DMultisampleIMGFn( - target, attachment, textarget, texture, level, samples); -} - -void GLApiBase::glFramebufferTextureLayerFn(GLenum target, - GLenum attachment, - GLuint texture, - GLint level, - GLint layer) { - driver_->fn.glFramebufferTextureLayerFn(target, attachment, texture, level, - layer); -} - -void GLApiBase::glFrontFaceFn(GLenum mode) { - driver_->fn.glFrontFaceFn(mode); -} - -void GLApiBase::glGenBuffersARBFn(GLsizei n, GLuint* buffers) { - driver_->fn.glGenBuffersARBFn(n, buffers); -} - -void GLApiBase::glGenerateMipmapEXTFn(GLenum target) { - driver_->fn.glGenerateMipmapEXTFn(target); -} - -void GLApiBase::glGenFencesAPPLEFn(GLsizei n, GLuint* fences) { - driver_->fn.glGenFencesAPPLEFn(n, fences); -} - -void GLApiBase::glGenFencesNVFn(GLsizei n, GLuint* fences) { - driver_->fn.glGenFencesNVFn(n, fences); -} - -void GLApiBase::glGenFramebuffersEXTFn(GLsizei n, GLuint* framebuffers) { - driver_->fn.glGenFramebuffersEXTFn(n, framebuffers); -} - -void GLApiBase::glGenQueriesFn(GLsizei n, GLuint* ids) { - driver_->fn.glGenQueriesFn(n, ids); -} - -void GLApiBase::glGenRenderbuffersEXTFn(GLsizei n, GLuint* renderbuffers) { - driver_->fn.glGenRenderbuffersEXTFn(n, renderbuffers); -} - -void GLApiBase::glGenSamplersFn(GLsizei n, GLuint* samplers) { - driver_->fn.glGenSamplersFn(n, samplers); -} - -void GLApiBase::glGenTexturesFn(GLsizei n, GLuint* textures) { - driver_->fn.glGenTexturesFn(n, textures); -} - -void GLApiBase::glGenTransformFeedbacksFn(GLsizei n, GLuint* ids) { - driver_->fn.glGenTransformFeedbacksFn(n, ids); -} - -void GLApiBase::glGenVertexArraysOESFn(GLsizei n, GLuint* arrays) { - driver_->fn.glGenVertexArraysOESFn(n, arrays); -} - -void GLApiBase::glGetActiveAttribFn(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - char* name) { - driver_->fn.glGetActiveAttribFn(program, index, bufsize, length, size, type, - name); -} - -void GLApiBase::glGetActiveUniformFn(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - char* name) { - driver_->fn.glGetActiveUniformFn(program, index, bufsize, length, size, type, - name); -} - -void GLApiBase::glGetActiveUniformBlockivFn(GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint* params) { - driver_->fn.glGetActiveUniformBlockivFn(program, uniformBlockIndex, pname, - params); -} - -void GLApiBase::glGetActiveUniformBlockNameFn(GLuint program, - GLuint uniformBlockIndex, - GLsizei bufSize, - GLsizei* length, - char* uniformBlockName) { - driver_->fn.glGetActiveUniformBlockNameFn(program, uniformBlockIndex, bufSize, - length, uniformBlockName); -} - -void GLApiBase::glGetActiveUniformsivFn(GLuint program, - GLsizei uniformCount, - const GLuint* uniformIndices, - GLenum pname, - GLint* params) { - driver_->fn.glGetActiveUniformsivFn(program, uniformCount, uniformIndices, - pname, params); -} - -void GLApiBase::glGetAttachedShadersFn(GLuint program, - GLsizei maxcount, - GLsizei* count, - GLuint* shaders) { - driver_->fn.glGetAttachedShadersFn(program, maxcount, count, shaders); -} - -GLint GLApiBase::glGetAttribLocationFn(GLuint program, const char* name) { - return driver_->fn.glGetAttribLocationFn(program, name); -} - -void GLApiBase::glGetBooleanvFn(GLenum pname, GLboolean* params) { - driver_->fn.glGetBooleanvFn(pname, params); -} - -void GLApiBase::glGetBufferParameterivFn(GLenum target, - GLenum pname, - GLint* params) { - driver_->fn.glGetBufferParameterivFn(target, pname, params); -} - -GLuint GLApiBase::glGetDebugMessageLogKHRFn(GLuint count, - GLsizei bufSize, - GLenum* sources, - GLenum* types, - GLuint* ids, - GLenum* severities, - GLsizei* lengths, - GLchar* messageLog) { - return driver_->fn.glGetDebugMessageLogKHRFn( - count, bufSize, sources, types, ids, severities, lengths, messageLog); -} - -GLenum GLApiBase::glGetErrorFn(void) { - return driver_->fn.glGetErrorFn(); -} - -void GLApiBase::glGetFenceivNVFn(GLuint fence, GLenum pname, GLint* params) { - driver_->fn.glGetFenceivNVFn(fence, pname, params); -} - -void GLApiBase::glGetFloatvFn(GLenum pname, GLfloat* params) { - driver_->fn.glGetFloatvFn(pname, params); -} - -GLint GLApiBase::glGetFragDataLocationFn(GLuint program, const char* name) { - return driver_->fn.glGetFragDataLocationFn(program, name); -} - -void GLApiBase::glGetFramebufferAttachmentParameterivEXTFn(GLenum target, - GLenum attachment, - GLenum pname, - GLint* params) { - driver_->fn.glGetFramebufferAttachmentParameterivEXTFn(target, attachment, - pname, params); -} - -GLenum GLApiBase::glGetGraphicsResetStatusARBFn(void) { - return driver_->fn.glGetGraphicsResetStatusARBFn(); -} - -void GLApiBase::glGetInteger64i_vFn(GLenum target, - GLuint index, - GLint64* data) { - driver_->fn.glGetInteger64i_vFn(target, index, data); -} - -void GLApiBase::glGetInteger64vFn(GLenum pname, GLint64* params) { - driver_->fn.glGetInteger64vFn(pname, params); -} - -void GLApiBase::glGetIntegeri_vFn(GLenum target, GLuint index, GLint* data) { - driver_->fn.glGetIntegeri_vFn(target, index, data); -} - -void GLApiBase::glGetIntegervFn(GLenum pname, GLint* params) { - driver_->fn.glGetIntegervFn(pname, params); -} - -void GLApiBase::glGetInternalformativFn(GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLint* params) { - driver_->fn.glGetInternalformativFn(target, internalformat, pname, bufSize, - params); -} - -void GLApiBase::glGetProgramBinaryFn(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - GLvoid* binary) { - driver_->fn.glGetProgramBinaryFn(program, bufSize, length, binaryFormat, - binary); -} - -void GLApiBase::glGetProgramInfoLogFn(GLuint program, - GLsizei bufsize, - GLsizei* length, - char* infolog) { - driver_->fn.glGetProgramInfoLogFn(program, bufsize, length, infolog); -} - -void GLApiBase::glGetProgramivFn(GLuint program, GLenum pname, GLint* params) { - driver_->fn.glGetProgramivFn(program, pname, params); -} - -GLint GLApiBase::glGetProgramResourceLocationFn(GLuint program, - GLenum programInterface, - const char* name) { - return driver_->fn.glGetProgramResourceLocationFn(program, programInterface, - name); -} - -void GLApiBase::glGetQueryivFn(GLenum target, GLenum pname, GLint* params) { - driver_->fn.glGetQueryivFn(target, pname, params); -} - -void GLApiBase::glGetQueryObjecti64vFn(GLuint id, - GLenum pname, - GLint64* params) { - driver_->fn.glGetQueryObjecti64vFn(id, pname, params); -} - -void GLApiBase::glGetQueryObjectivFn(GLuint id, GLenum pname, GLint* params) { - driver_->fn.glGetQueryObjectivFn(id, pname, params); -} - -void GLApiBase::glGetQueryObjectui64vFn(GLuint id, - GLenum pname, - GLuint64* params) { - driver_->fn.glGetQueryObjectui64vFn(id, pname, params); -} - -void GLApiBase::glGetQueryObjectuivFn(GLuint id, GLenum pname, GLuint* params) { - driver_->fn.glGetQueryObjectuivFn(id, pname, params); -} - -void GLApiBase::glGetRenderbufferParameterivEXTFn(GLenum target, - GLenum pname, - GLint* params) { - driver_->fn.glGetRenderbufferParameterivEXTFn(target, pname, params); -} - -void GLApiBase::glGetSamplerParameterfvFn(GLuint sampler, - GLenum pname, - GLfloat* params) { - driver_->fn.glGetSamplerParameterfvFn(sampler, pname, params); -} - -void GLApiBase::glGetSamplerParameterivFn(GLuint sampler, - GLenum pname, - GLint* params) { - driver_->fn.glGetSamplerParameterivFn(sampler, pname, params); -} - -void GLApiBase::glGetShaderInfoLogFn(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* infolog) { - driver_->fn.glGetShaderInfoLogFn(shader, bufsize, length, infolog); -} - -void GLApiBase::glGetShaderivFn(GLuint shader, GLenum pname, GLint* params) { - driver_->fn.glGetShaderivFn(shader, pname, params); -} - -void GLApiBase::glGetShaderPrecisionFormatFn(GLenum shadertype, - GLenum precisiontype, - GLint* range, - GLint* precision) { - driver_->fn.glGetShaderPrecisionFormatFn(shadertype, precisiontype, range, - precision); -} - -void GLApiBase::glGetShaderSourceFn(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* source) { - driver_->fn.glGetShaderSourceFn(shader, bufsize, length, source); -} - -const GLubyte* GLApiBase::glGetStringFn(GLenum name) { - return driver_->fn.glGetStringFn(name); -} - -const GLubyte* GLApiBase::glGetStringiFn(GLenum name, GLuint index) { - return driver_->fn.glGetStringiFn(name, index); -} - -void GLApiBase::glGetSyncivFn(GLsync sync, - GLenum pname, - GLsizei bufSize, - GLsizei* length, - GLint* values) { - driver_->fn.glGetSyncivFn(sync, pname, bufSize, length, values); -} - -void GLApiBase::glGetTexLevelParameterfvFn(GLenum target, - GLint level, - GLenum pname, - GLfloat* params) { - driver_->fn.glGetTexLevelParameterfvFn(target, level, pname, params); -} - -void GLApiBase::glGetTexLevelParameterivFn(GLenum target, - GLint level, - GLenum pname, - GLint* params) { - driver_->fn.glGetTexLevelParameterivFn(target, level, pname, params); -} - -void GLApiBase::glGetTexParameterfvFn(GLenum target, - GLenum pname, - GLfloat* params) { - driver_->fn.glGetTexParameterfvFn(target, pname, params); -} - -void GLApiBase::glGetTexParameterivFn(GLenum target, - GLenum pname, - GLint* params) { - driver_->fn.glGetTexParameterivFn(target, pname, params); -} - -void GLApiBase::glGetTransformFeedbackVaryingFn(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLsizei* size, - GLenum* type, - char* name) { - driver_->fn.glGetTransformFeedbackVaryingFn(program, index, bufSize, length, - size, type, name); -} - -void GLApiBase::glGetTranslatedShaderSourceANGLEFn(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* source) { - driver_->fn.glGetTranslatedShaderSourceANGLEFn(shader, bufsize, length, - source); -} - -GLuint GLApiBase::glGetUniformBlockIndexFn(GLuint program, - const char* uniformBlockName) { - return driver_->fn.glGetUniformBlockIndexFn(program, uniformBlockName); -} - -void GLApiBase::glGetUniformfvFn(GLuint program, - GLint location, - GLfloat* params) { - driver_->fn.glGetUniformfvFn(program, location, params); -} - -void GLApiBase::glGetUniformIndicesFn(GLuint program, - GLsizei uniformCount, - const char* const* uniformNames, - GLuint* uniformIndices) { - driver_->fn.glGetUniformIndicesFn(program, uniformCount, uniformNames, - uniformIndices); -} - -void GLApiBase::glGetUniformivFn(GLuint program, - GLint location, - GLint* params) { - driver_->fn.glGetUniformivFn(program, location, params); -} - -GLint GLApiBase::glGetUniformLocationFn(GLuint program, const char* name) { - return driver_->fn.glGetUniformLocationFn(program, name); -} - -void GLApiBase::glGetVertexAttribfvFn(GLuint index, - GLenum pname, - GLfloat* params) { - driver_->fn.glGetVertexAttribfvFn(index, pname, params); -} - -void GLApiBase::glGetVertexAttribivFn(GLuint index, - GLenum pname, - GLint* params) { - driver_->fn.glGetVertexAttribivFn(index, pname, params); -} - -void GLApiBase::glGetVertexAttribPointervFn(GLuint index, - GLenum pname, - void** pointer) { - driver_->fn.glGetVertexAttribPointervFn(index, pname, pointer); -} - -void GLApiBase::glHintFn(GLenum target, GLenum mode) { - driver_->fn.glHintFn(target, mode); -} - -void GLApiBase::glInsertEventMarkerEXTFn(GLsizei length, const char* marker) { - driver_->fn.glInsertEventMarkerEXTFn(length, marker); -} - -void GLApiBase::glInvalidateFramebufferFn(GLenum target, - GLsizei numAttachments, - const GLenum* attachments) { - driver_->fn.glInvalidateFramebufferFn(target, numAttachments, attachments); -} - -void GLApiBase::glInvalidateSubFramebufferFn(GLenum target, - GLsizei numAttachments, - const GLenum* attachments, - GLint x, - GLint y, - GLint width, - GLint height) { - driver_->fn.glInvalidateSubFramebufferFn(target, numAttachments, attachments, - x, y, width, height); -} - -GLboolean GLApiBase::glIsBufferFn(GLuint buffer) { - return driver_->fn.glIsBufferFn(buffer); -} - -GLboolean GLApiBase::glIsEnabledFn(GLenum cap) { - return driver_->fn.glIsEnabledFn(cap); -} - -GLboolean GLApiBase::glIsFenceAPPLEFn(GLuint fence) { - return driver_->fn.glIsFenceAPPLEFn(fence); -} - -GLboolean GLApiBase::glIsFenceNVFn(GLuint fence) { - return driver_->fn.glIsFenceNVFn(fence); -} - -GLboolean GLApiBase::glIsFramebufferEXTFn(GLuint framebuffer) { - return driver_->fn.glIsFramebufferEXTFn(framebuffer); -} - -GLboolean GLApiBase::glIsProgramFn(GLuint program) { - return driver_->fn.glIsProgramFn(program); -} - -GLboolean GLApiBase::glIsQueryFn(GLuint query) { - return driver_->fn.glIsQueryFn(query); -} - -GLboolean GLApiBase::glIsRenderbufferEXTFn(GLuint renderbuffer) { - return driver_->fn.glIsRenderbufferEXTFn(renderbuffer); -} - -GLboolean GLApiBase::glIsSamplerFn(GLuint sampler) { - return driver_->fn.glIsSamplerFn(sampler); -} - -GLboolean GLApiBase::glIsShaderFn(GLuint shader) { - return driver_->fn.glIsShaderFn(shader); -} - -GLboolean GLApiBase::glIsSyncFn(GLsync sync) { - return driver_->fn.glIsSyncFn(sync); -} - -GLboolean GLApiBase::glIsTextureFn(GLuint texture) { - return driver_->fn.glIsTextureFn(texture); -} - -GLboolean GLApiBase::glIsTransformFeedbackFn(GLuint id) { - return driver_->fn.glIsTransformFeedbackFn(id); -} - -GLboolean GLApiBase::glIsVertexArrayOESFn(GLuint array) { - return driver_->fn.glIsVertexArrayOESFn(array); -} - -void GLApiBase::glLineWidthFn(GLfloat width) { - driver_->fn.glLineWidthFn(width); -} - -void GLApiBase::glLinkProgramFn(GLuint program) { - driver_->fn.glLinkProgramFn(program); -} - -void* GLApiBase::glMapBufferFn(GLenum target, GLenum access) { - return driver_->fn.glMapBufferFn(target, access); -} - -void* GLApiBase::glMapBufferRangeFn(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access) { - return driver_->fn.glMapBufferRangeFn(target, offset, length, access); -} - -void GLApiBase::glMatrixLoadfEXTFn(GLenum matrixMode, const GLfloat* m) { - driver_->fn.glMatrixLoadfEXTFn(matrixMode, m); -} - -void GLApiBase::glMatrixLoadIdentityEXTFn(GLenum matrixMode) { - driver_->fn.glMatrixLoadIdentityEXTFn(matrixMode); -} - -void GLApiBase::glObjectLabelKHRFn(GLenum identifier, - GLuint name, - GLsizei length, - const GLchar* label) { - driver_->fn.glObjectLabelKHRFn(identifier, name, length, label); -} - -void GLApiBase::glPauseTransformFeedbackFn(void) { - driver_->fn.glPauseTransformFeedbackFn(); -} - -void GLApiBase::glPixelStoreiFn(GLenum pname, GLint param) { - driver_->fn.glPixelStoreiFn(pname, param); -} - -void GLApiBase::glPointParameteriFn(GLenum pname, GLint param) { - driver_->fn.glPointParameteriFn(pname, param); -} - -void GLApiBase::glPolygonOffsetFn(GLfloat factor, GLfloat units) { - driver_->fn.glPolygonOffsetFn(factor, units); -} - -void GLApiBase::glPopDebugGroupKHRFn(void) { - driver_->fn.glPopDebugGroupKHRFn(); -} - -void GLApiBase::glPopGroupMarkerEXTFn(void) { - driver_->fn.glPopGroupMarkerEXTFn(); -} - -void GLApiBase::glProgramBinaryFn(GLuint program, - GLenum binaryFormat, - const GLvoid* binary, - GLsizei length) { - driver_->fn.glProgramBinaryFn(program, binaryFormat, binary, length); -} - -void GLApiBase::glProgramParameteriFn(GLuint program, - GLenum pname, - GLint value) { - driver_->fn.glProgramParameteriFn(program, pname, value); -} - -void GLApiBase::glPushDebugGroupKHRFn(GLenum source, - GLuint id, - GLsizei length, - const GLchar* message) { - driver_->fn.glPushDebugGroupKHRFn(source, id, length, message); -} - -void GLApiBase::glPushGroupMarkerEXTFn(GLsizei length, const char* marker) { - driver_->fn.glPushGroupMarkerEXTFn(length, marker); -} - -void GLApiBase::glQueryCounterFn(GLuint id, GLenum target) { - driver_->fn.glQueryCounterFn(id, target); -} - -void GLApiBase::glReadBufferFn(GLenum src) { - driver_->fn.glReadBufferFn(src); -} - -void GLApiBase::glReadPixelsFn(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - void* pixels) { - driver_->fn.glReadPixelsFn(x, y, width, height, format, type, pixels); -} - -void GLApiBase::glReleaseShaderCompilerFn(void) { - driver_->fn.glReleaseShaderCompilerFn(); -} - -void GLApiBase::glRenderbufferStorageEXTFn(GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height) { - driver_->fn.glRenderbufferStorageEXTFn(target, internalformat, width, height); -} - -void GLApiBase::glRenderbufferStorageMultisampleFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - driver_->fn.glRenderbufferStorageMultisampleFn(target, samples, - internalformat, width, height); -} - -void GLApiBase::glRenderbufferStorageMultisampleANGLEFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - driver_->fn.glRenderbufferStorageMultisampleANGLEFn( - target, samples, internalformat, width, height); -} - -void GLApiBase::glRenderbufferStorageMultisampleAPPLEFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - driver_->fn.glRenderbufferStorageMultisampleAPPLEFn( - target, samples, internalformat, width, height); -} - -void GLApiBase::glRenderbufferStorageMultisampleEXTFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - driver_->fn.glRenderbufferStorageMultisampleEXTFn( - target, samples, internalformat, width, height); -} - -void GLApiBase::glRenderbufferStorageMultisampleIMGFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - driver_->fn.glRenderbufferStorageMultisampleIMGFn( - target, samples, internalformat, width, height); -} - -void GLApiBase::glResolveMultisampleFramebufferAPPLEFn(void) { - driver_->fn.glResolveMultisampleFramebufferAPPLEFn(); -} - -void GLApiBase::glResumeTransformFeedbackFn(void) { - driver_->fn.glResumeTransformFeedbackFn(); -} - -void GLApiBase::glSampleCoverageFn(GLclampf value, GLboolean invert) { - driver_->fn.glSampleCoverageFn(value, invert); -} - -void GLApiBase::glSamplerParameterfFn(GLuint sampler, - GLenum pname, - GLfloat param) { - driver_->fn.glSamplerParameterfFn(sampler, pname, param); -} - -void GLApiBase::glSamplerParameterfvFn(GLuint sampler, - GLenum pname, - const GLfloat* params) { - driver_->fn.glSamplerParameterfvFn(sampler, pname, params); -} - -void GLApiBase::glSamplerParameteriFn(GLuint sampler, - GLenum pname, - GLint param) { - driver_->fn.glSamplerParameteriFn(sampler, pname, param); -} - -void GLApiBase::glSamplerParameterivFn(GLuint sampler, - GLenum pname, - const GLint* params) { - driver_->fn.glSamplerParameterivFn(sampler, pname, params); -} - -void GLApiBase::glScissorFn(GLint x, GLint y, GLsizei width, GLsizei height) { - driver_->fn.glScissorFn(x, y, width, height); -} - -void GLApiBase::glSetFenceAPPLEFn(GLuint fence) { - driver_->fn.glSetFenceAPPLEFn(fence); -} - -void GLApiBase::glSetFenceNVFn(GLuint fence, GLenum condition) { - driver_->fn.glSetFenceNVFn(fence, condition); -} - -void GLApiBase::glShaderBinaryFn(GLsizei n, - const GLuint* shaders, - GLenum binaryformat, - const void* binary, - GLsizei length) { - driver_->fn.glShaderBinaryFn(n, shaders, binaryformat, binary, length); -} - -void GLApiBase::glShaderSourceFn(GLuint shader, - GLsizei count, - const char* const* str, - const GLint* length) { - driver_->fn.glShaderSourceFn(shader, count, str, length); -} - -void GLApiBase::glStencilFuncFn(GLenum func, GLint ref, GLuint mask) { - driver_->fn.glStencilFuncFn(func, ref, mask); -} - -void GLApiBase::glStencilFuncSeparateFn(GLenum face, - GLenum func, - GLint ref, - GLuint mask) { - driver_->fn.glStencilFuncSeparateFn(face, func, ref, mask); -} - -void GLApiBase::glStencilMaskFn(GLuint mask) { - driver_->fn.glStencilMaskFn(mask); -} - -void GLApiBase::glStencilMaskSeparateFn(GLenum face, GLuint mask) { - driver_->fn.glStencilMaskSeparateFn(face, mask); -} - -void GLApiBase::glStencilOpFn(GLenum fail, GLenum zfail, GLenum zpass) { - driver_->fn.glStencilOpFn(fail, zfail, zpass); -} - -void GLApiBase::glStencilOpSeparateFn(GLenum face, - GLenum fail, - GLenum zfail, - GLenum zpass) { - driver_->fn.glStencilOpSeparateFn(face, fail, zfail, zpass); -} - -GLboolean GLApiBase::glTestFenceAPPLEFn(GLuint fence) { - return driver_->fn.glTestFenceAPPLEFn(fence); -} - -GLboolean GLApiBase::glTestFenceNVFn(GLuint fence) { - return driver_->fn.glTestFenceNVFn(fence); -} - -void GLApiBase::glTexImage2DFn(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const void* pixels) { - driver_->fn.glTexImage2DFn(target, level, internalformat, width, height, - border, format, type, pixels); -} - -void GLApiBase::glTexImage3DFn(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - const void* pixels) { - driver_->fn.glTexImage3DFn(target, level, internalformat, width, height, - depth, border, format, type, pixels); -} - -void GLApiBase::glTexParameterfFn(GLenum target, GLenum pname, GLfloat param) { - driver_->fn.glTexParameterfFn(target, pname, param); -} - -void GLApiBase::glTexParameterfvFn(GLenum target, - GLenum pname, - const GLfloat* params) { - driver_->fn.glTexParameterfvFn(target, pname, params); -} - -void GLApiBase::glTexParameteriFn(GLenum target, GLenum pname, GLint param) { - driver_->fn.glTexParameteriFn(target, pname, param); -} - -void GLApiBase::glTexParameterivFn(GLenum target, - GLenum pname, - const GLint* params) { - driver_->fn.glTexParameterivFn(target, pname, params); -} - -void GLApiBase::glTexStorage2DEXTFn(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height) { - driver_->fn.glTexStorage2DEXTFn(target, levels, internalformat, width, - height); -} - -void GLApiBase::glTexStorage3DFn(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth) { - driver_->fn.glTexStorage3DFn(target, levels, internalformat, width, height, - depth); -} - -void GLApiBase::glTexSubImage2DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const void* pixels) { - driver_->fn.glTexSubImage2DFn(target, level, xoffset, yoffset, width, height, - format, type, pixels); -} - -void GLApiBase::glTextureBarrierNVFn(void) { - driver_->fn.glTextureBarrierNVFn(); -} - -void GLApiBase::glTransformFeedbackVaryingsFn(GLuint program, - GLsizei count, - const char* const* varyings, - GLenum bufferMode) { - driver_->fn.glTransformFeedbackVaryingsFn(program, count, varyings, - bufferMode); -} - -void GLApiBase::glUniform1fFn(GLint location, GLfloat x) { - driver_->fn.glUniform1fFn(location, x); -} - -void GLApiBase::glUniform1fvFn(GLint location, - GLsizei count, - const GLfloat* v) { - driver_->fn.glUniform1fvFn(location, count, v); -} - -void GLApiBase::glUniform1iFn(GLint location, GLint x) { - driver_->fn.glUniform1iFn(location, x); -} - -void GLApiBase::glUniform1ivFn(GLint location, GLsizei count, const GLint* v) { - driver_->fn.glUniform1ivFn(location, count, v); -} - -void GLApiBase::glUniform1uiFn(GLint location, GLuint v0) { - driver_->fn.glUniform1uiFn(location, v0); -} - -void GLApiBase::glUniform1uivFn(GLint location, - GLsizei count, - const GLuint* v) { - driver_->fn.glUniform1uivFn(location, count, v); -} - -void GLApiBase::glUniform2fFn(GLint location, GLfloat x, GLfloat y) { - driver_->fn.glUniform2fFn(location, x, y); -} - -void GLApiBase::glUniform2fvFn(GLint location, - GLsizei count, - const GLfloat* v) { - driver_->fn.glUniform2fvFn(location, count, v); -} - -void GLApiBase::glUniform2iFn(GLint location, GLint x, GLint y) { - driver_->fn.glUniform2iFn(location, x, y); -} - -void GLApiBase::glUniform2ivFn(GLint location, GLsizei count, const GLint* v) { - driver_->fn.glUniform2ivFn(location, count, v); -} - -void GLApiBase::glUniform2uiFn(GLint location, GLuint v0, GLuint v1) { - driver_->fn.glUniform2uiFn(location, v0, v1); -} - -void GLApiBase::glUniform2uivFn(GLint location, - GLsizei count, - const GLuint* v) { - driver_->fn.glUniform2uivFn(location, count, v); -} - -void GLApiBase::glUniform3fFn(GLint location, GLfloat x, GLfloat y, GLfloat z) { - driver_->fn.glUniform3fFn(location, x, y, z); -} - -void GLApiBase::glUniform3fvFn(GLint location, - GLsizei count, - const GLfloat* v) { - driver_->fn.glUniform3fvFn(location, count, v); -} - -void GLApiBase::glUniform3iFn(GLint location, GLint x, GLint y, GLint z) { - driver_->fn.glUniform3iFn(location, x, y, z); -} - -void GLApiBase::glUniform3ivFn(GLint location, GLsizei count, const GLint* v) { - driver_->fn.glUniform3ivFn(location, count, v); -} - -void GLApiBase::glUniform3uiFn(GLint location, - GLuint v0, - GLuint v1, - GLuint v2) { - driver_->fn.glUniform3uiFn(location, v0, v1, v2); -} - -void GLApiBase::glUniform3uivFn(GLint location, - GLsizei count, - const GLuint* v) { - driver_->fn.glUniform3uivFn(location, count, v); -} - -void GLApiBase::glUniform4fFn(GLint location, - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w) { - driver_->fn.glUniform4fFn(location, x, y, z, w); -} - -void GLApiBase::glUniform4fvFn(GLint location, - GLsizei count, - const GLfloat* v) { - driver_->fn.glUniform4fvFn(location, count, v); -} - -void GLApiBase::glUniform4iFn(GLint location, - GLint x, - GLint y, - GLint z, - GLint w) { - driver_->fn.glUniform4iFn(location, x, y, z, w); -} - -void GLApiBase::glUniform4ivFn(GLint location, GLsizei count, const GLint* v) { - driver_->fn.glUniform4ivFn(location, count, v); -} - -void GLApiBase::glUniform4uiFn(GLint location, - GLuint v0, - GLuint v1, - GLuint v2, - GLuint v3) { - driver_->fn.glUniform4uiFn(location, v0, v1, v2, v3); -} - -void GLApiBase::glUniform4uivFn(GLint location, - GLsizei count, - const GLuint* v) { - driver_->fn.glUniform4uivFn(location, count, v); -} - -void GLApiBase::glUniformBlockBindingFn(GLuint program, - GLuint uniformBlockIndex, - GLuint uniformBlockBinding) { - driver_->fn.glUniformBlockBindingFn(program, uniformBlockIndex, - uniformBlockBinding); -} - -void GLApiBase::glUniformMatrix2fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - driver_->fn.glUniformMatrix2fvFn(location, count, transpose, value); -} - -void GLApiBase::glUniformMatrix2x3fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - driver_->fn.glUniformMatrix2x3fvFn(location, count, transpose, value); -} - -void GLApiBase::glUniformMatrix2x4fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - driver_->fn.glUniformMatrix2x4fvFn(location, count, transpose, value); -} - -void GLApiBase::glUniformMatrix3fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - driver_->fn.glUniformMatrix3fvFn(location, count, transpose, value); -} - -void GLApiBase::glUniformMatrix3x2fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - driver_->fn.glUniformMatrix3x2fvFn(location, count, transpose, value); -} - -void GLApiBase::glUniformMatrix3x4fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - driver_->fn.glUniformMatrix3x4fvFn(location, count, transpose, value); -} - -void GLApiBase::glUniformMatrix4fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - driver_->fn.glUniformMatrix4fvFn(location, count, transpose, value); -} - -void GLApiBase::glUniformMatrix4x2fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - driver_->fn.glUniformMatrix4x2fvFn(location, count, transpose, value); -} - -void GLApiBase::glUniformMatrix4x3fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - driver_->fn.glUniformMatrix4x3fvFn(location, count, transpose, value); -} - -GLboolean GLApiBase::glUnmapBufferFn(GLenum target) { - return driver_->fn.glUnmapBufferFn(target); -} - -void GLApiBase::glUseProgramFn(GLuint program) { - driver_->fn.glUseProgramFn(program); -} - -void GLApiBase::glValidateProgramFn(GLuint program) { - driver_->fn.glValidateProgramFn(program); -} - -void GLApiBase::glVertexAttrib1fFn(GLuint indx, GLfloat x) { - driver_->fn.glVertexAttrib1fFn(indx, x); -} - -void GLApiBase::glVertexAttrib1fvFn(GLuint indx, const GLfloat* values) { - driver_->fn.glVertexAttrib1fvFn(indx, values); -} - -void GLApiBase::glVertexAttrib2fFn(GLuint indx, GLfloat x, GLfloat y) { - driver_->fn.glVertexAttrib2fFn(indx, x, y); -} - -void GLApiBase::glVertexAttrib2fvFn(GLuint indx, const GLfloat* values) { - driver_->fn.glVertexAttrib2fvFn(indx, values); -} - -void GLApiBase::glVertexAttrib3fFn(GLuint indx, - GLfloat x, - GLfloat y, - GLfloat z) { - driver_->fn.glVertexAttrib3fFn(indx, x, y, z); -} - -void GLApiBase::glVertexAttrib3fvFn(GLuint indx, const GLfloat* values) { - driver_->fn.glVertexAttrib3fvFn(indx, values); -} - -void GLApiBase::glVertexAttrib4fFn(GLuint indx, - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w) { - driver_->fn.glVertexAttrib4fFn(indx, x, y, z, w); -} - -void GLApiBase::glVertexAttrib4fvFn(GLuint indx, const GLfloat* values) { - driver_->fn.glVertexAttrib4fvFn(indx, values); -} - -void GLApiBase::glVertexAttribDivisorANGLEFn(GLuint index, GLuint divisor) { - driver_->fn.glVertexAttribDivisorANGLEFn(index, divisor); -} - -void GLApiBase::glVertexAttribI4iFn(GLuint indx, - GLint x, - GLint y, - GLint z, - GLint w) { - driver_->fn.glVertexAttribI4iFn(indx, x, y, z, w); -} - -void GLApiBase::glVertexAttribI4ivFn(GLuint indx, const GLint* values) { - driver_->fn.glVertexAttribI4ivFn(indx, values); -} - -void GLApiBase::glVertexAttribI4uiFn(GLuint indx, - GLuint x, - GLuint y, - GLuint z, - GLuint w) { - driver_->fn.glVertexAttribI4uiFn(indx, x, y, z, w); -} - -void GLApiBase::glVertexAttribI4uivFn(GLuint indx, const GLuint* values) { - driver_->fn.glVertexAttribI4uivFn(indx, values); -} - -void GLApiBase::glVertexAttribIPointerFn(GLuint indx, - GLint size, - GLenum type, - GLsizei stride, - const void* ptr) { - driver_->fn.glVertexAttribIPointerFn(indx, size, type, stride, ptr); -} - -void GLApiBase::glVertexAttribPointerFn(GLuint indx, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const void* ptr) { - driver_->fn.glVertexAttribPointerFn(indx, size, type, normalized, stride, - ptr); -} - -void GLApiBase::glViewportFn(GLint x, GLint y, GLsizei width, GLsizei height) { - driver_->fn.glViewportFn(x, y, width, height); -} - -GLenum GLApiBase::glWaitSyncFn(GLsync sync, - GLbitfield flags, - GLuint64 timeout) { - return driver_->fn.glWaitSyncFn(sync, flags, timeout); -} - -void TraceGLApi::glActiveTextureFn(GLenum texture) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glActiveTexture") - gl_api_->glActiveTextureFn(texture); -} - -void TraceGLApi::glAttachShaderFn(GLuint program, GLuint shader) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glAttachShader") - gl_api_->glAttachShaderFn(program, shader); -} - -void TraceGLApi::glBeginQueryFn(GLenum target, GLuint id) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBeginQuery") - gl_api_->glBeginQueryFn(target, id); -} - -void TraceGLApi::glBeginTransformFeedbackFn(GLenum primitiveMode) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBeginTransformFeedback") - gl_api_->glBeginTransformFeedbackFn(primitiveMode); -} - -void TraceGLApi::glBindAttribLocationFn(GLuint program, - GLuint index, - const char* name) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBindAttribLocation") - gl_api_->glBindAttribLocationFn(program, index, name); -} - -void TraceGLApi::glBindBufferFn(GLenum target, GLuint buffer) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBindBuffer") - gl_api_->glBindBufferFn(target, buffer); -} - -void TraceGLApi::glBindBufferBaseFn(GLenum target, - GLuint index, - GLuint buffer) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBindBufferBase") - gl_api_->glBindBufferBaseFn(target, index, buffer); -} - -void TraceGLApi::glBindBufferRangeFn(GLenum target, - GLuint index, - GLuint buffer, - GLintptr offset, - GLsizeiptr size) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBindBufferRange") - gl_api_->glBindBufferRangeFn(target, index, buffer, offset, size); -} - -void TraceGLApi::glBindFragDataLocationFn(GLuint program, - GLuint colorNumber, - const char* name) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBindFragDataLocation") - gl_api_->glBindFragDataLocationFn(program, colorNumber, name); -} - -void TraceGLApi::glBindFragDataLocationIndexedFn(GLuint program, - GLuint colorNumber, - GLuint index, - const char* name) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", - "TraceGLAPI::glBindFragDataLocationIndexed") - gl_api_->glBindFragDataLocationIndexedFn(program, colorNumber, index, name); -} - -void TraceGLApi::glBindFramebufferEXTFn(GLenum target, GLuint framebuffer) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBindFramebufferEXT") - gl_api_->glBindFramebufferEXTFn(target, framebuffer); -} - -void TraceGLApi::glBindRenderbufferEXTFn(GLenum target, GLuint renderbuffer) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBindRenderbufferEXT") - gl_api_->glBindRenderbufferEXTFn(target, renderbuffer); -} - -void TraceGLApi::glBindSamplerFn(GLuint unit, GLuint sampler) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBindSampler") - gl_api_->glBindSamplerFn(unit, sampler); -} - -void TraceGLApi::glBindTextureFn(GLenum target, GLuint texture) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBindTexture") - gl_api_->glBindTextureFn(target, texture); -} - -void TraceGLApi::glBindTransformFeedbackFn(GLenum target, GLuint id) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBindTransformFeedback") - gl_api_->glBindTransformFeedbackFn(target, id); -} - -void TraceGLApi::glBindVertexArrayOESFn(GLuint array) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBindVertexArrayOES") - gl_api_->glBindVertexArrayOESFn(array); -} - -void TraceGLApi::glBlendBarrierKHRFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBlendBarrierKHR") - gl_api_->glBlendBarrierKHRFn(); -} - -void TraceGLApi::glBlendColorFn(GLclampf red, - GLclampf green, - GLclampf blue, - GLclampf alpha) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBlendColor") - gl_api_->glBlendColorFn(red, green, blue, alpha); -} - -void TraceGLApi::glBlendEquationFn(GLenum mode) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBlendEquation") - gl_api_->glBlendEquationFn(mode); -} - -void TraceGLApi::glBlendEquationSeparateFn(GLenum modeRGB, GLenum modeAlpha) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBlendEquationSeparate") - gl_api_->glBlendEquationSeparateFn(modeRGB, modeAlpha); -} - -void TraceGLApi::glBlendFuncFn(GLenum sfactor, GLenum dfactor) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBlendFunc") - gl_api_->glBlendFuncFn(sfactor, dfactor); -} - -void TraceGLApi::glBlendFuncSeparateFn(GLenum srcRGB, - GLenum dstRGB, - GLenum srcAlpha, - GLenum dstAlpha) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBlendFuncSeparate") - gl_api_->glBlendFuncSeparateFn(srcRGB, dstRGB, srcAlpha, dstAlpha); -} - -void TraceGLApi::glBlitFramebufferFn(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBlitFramebuffer") - gl_api_->glBlitFramebufferFn(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, - dstY1, mask, filter); -} - -void TraceGLApi::glBlitFramebufferANGLEFn(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBlitFramebufferANGLE") - gl_api_->glBlitFramebufferANGLEFn(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, - dstX1, dstY1, mask, filter); -} - -void TraceGLApi::glBlitFramebufferEXTFn(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBlitFramebufferEXT") - gl_api_->glBlitFramebufferEXTFn(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, - dstX1, dstY1, mask, filter); -} - -void TraceGLApi::glBufferDataFn(GLenum target, - GLsizeiptr size, - const void* data, - GLenum usage) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBufferData") - gl_api_->glBufferDataFn(target, size, data, usage); -} - -void TraceGLApi::glBufferSubDataFn(GLenum target, - GLintptr offset, - GLsizeiptr size, - const void* data) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glBufferSubData") - gl_api_->glBufferSubDataFn(target, offset, size, data); -} - -GLenum TraceGLApi::glCheckFramebufferStatusEXTFn(GLenum target) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", - "TraceGLAPI::glCheckFramebufferStatusEXT") - return gl_api_->glCheckFramebufferStatusEXTFn(target); -} - -void TraceGLApi::glClearFn(GLbitfield mask) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glClear") - gl_api_->glClearFn(mask); -} - -void TraceGLApi::glClearBufferfiFn(GLenum buffer, - GLint drawbuffer, - const GLfloat depth, - GLint stencil) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glClearBufferfi") - gl_api_->glClearBufferfiFn(buffer, drawbuffer, depth, stencil); -} - -void TraceGLApi::glClearBufferfvFn(GLenum buffer, - GLint drawbuffer, - const GLfloat* value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glClearBufferfv") - gl_api_->glClearBufferfvFn(buffer, drawbuffer, value); -} - -void TraceGLApi::glClearBufferivFn(GLenum buffer, - GLint drawbuffer, - const GLint* value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glClearBufferiv") - gl_api_->glClearBufferivFn(buffer, drawbuffer, value); -} - -void TraceGLApi::glClearBufferuivFn(GLenum buffer, - GLint drawbuffer, - const GLuint* value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glClearBufferuiv") - gl_api_->glClearBufferuivFn(buffer, drawbuffer, value); -} - -void TraceGLApi::glClearColorFn(GLclampf red, - GLclampf green, - GLclampf blue, - GLclampf alpha) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glClearColor") - gl_api_->glClearColorFn(red, green, blue, alpha); -} - -void TraceGLApi::glClearDepthFn(GLclampd depth) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glClearDepth") - gl_api_->glClearDepthFn(depth); -} - -void TraceGLApi::glClearDepthfFn(GLclampf depth) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glClearDepthf") - gl_api_->glClearDepthfFn(depth); -} - -void TraceGLApi::glClearStencilFn(GLint s) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glClearStencil") - gl_api_->glClearStencilFn(s); -} - -GLenum TraceGLApi::glClientWaitSyncFn(GLsync sync, - GLbitfield flags, - GLuint64 timeout) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glClientWaitSync") - return gl_api_->glClientWaitSyncFn(sync, flags, timeout); -} - -void TraceGLApi::glColorMaskFn(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glColorMask") - gl_api_->glColorMaskFn(red, green, blue, alpha); -} - -void TraceGLApi::glCompileShaderFn(GLuint shader) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glCompileShader") - gl_api_->glCompileShaderFn(shader); -} - -void TraceGLApi::glCompressedTexImage2DFn(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const void* data) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glCompressedTexImage2D") - gl_api_->glCompressedTexImage2DFn(target, level, internalformat, width, - height, border, imageSize, data); -} - -void TraceGLApi::glCompressedTexImage3DFn(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLsizei imageSize, - const void* data) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glCompressedTexImage3D") - gl_api_->glCompressedTexImage3DFn(target, level, internalformat, width, - height, depth, border, imageSize, data); -} - -void TraceGLApi::glCompressedTexSubImage2DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const void* data) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glCompressedTexSubImage2D") - gl_api_->glCompressedTexSubImage2DFn(target, level, xoffset, yoffset, width, - height, format, imageSize, data); -} - -void TraceGLApi::glCopyBufferSubDataFn(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glCopyBufferSubData") - gl_api_->glCopyBufferSubDataFn(readTarget, writeTarget, readOffset, - writeOffset, size); -} - -void TraceGLApi::glCopyTexImage2DFn(GLenum target, - GLint level, - GLenum internalformat, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLint border) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glCopyTexImage2D") - gl_api_->glCopyTexImage2DFn(target, level, internalformat, x, y, width, - height, border); -} - -void TraceGLApi::glCopyTexSubImage2DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glCopyTexSubImage2D") - gl_api_->glCopyTexSubImage2DFn(target, level, xoffset, yoffset, x, y, width, - height); -} - -void TraceGLApi::glCopyTexSubImage3DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glCopyTexSubImage3D") - gl_api_->glCopyTexSubImage3DFn(target, level, xoffset, yoffset, zoffset, x, y, - width, height); -} - -GLuint TraceGLApi::glCreateProgramFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glCreateProgram") - return gl_api_->glCreateProgramFn(); -} - -GLuint TraceGLApi::glCreateShaderFn(GLenum type) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glCreateShader") - return gl_api_->glCreateShaderFn(type); -} - -void TraceGLApi::glCullFaceFn(GLenum mode) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glCullFace") - gl_api_->glCullFaceFn(mode); -} - -void TraceGLApi::glDebugMessageCallbackKHRFn(GLDEBUGPROCKHR callback, - const void* userparam) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDebugMessageCallbackKHR") - gl_api_->glDebugMessageCallbackKHRFn(callback, userparam); -} - -void TraceGLApi::glDebugMessageControlKHRFn(GLenum source, - GLenum type, - GLenum severity, - GLsizei count, - const GLuint* ids, - GLboolean enabled) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDebugMessageControlKHR") - gl_api_->glDebugMessageControlKHRFn(source, type, severity, count, ids, - enabled); -} - -void TraceGLApi::glDebugMessageInsertKHRFn(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar* buf) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDebugMessageInsertKHR") - gl_api_->glDebugMessageInsertKHRFn(source, type, id, severity, length, buf); -} - -void TraceGLApi::glDeleteBuffersARBFn(GLsizei n, const GLuint* buffers) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDeleteBuffersARB") - gl_api_->glDeleteBuffersARBFn(n, buffers); -} - -void TraceGLApi::glDeleteFencesAPPLEFn(GLsizei n, const GLuint* fences) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDeleteFencesAPPLE") - gl_api_->glDeleteFencesAPPLEFn(n, fences); -} - -void TraceGLApi::glDeleteFencesNVFn(GLsizei n, const GLuint* fences) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDeleteFencesNV") - gl_api_->glDeleteFencesNVFn(n, fences); -} - -void TraceGLApi::glDeleteFramebuffersEXTFn(GLsizei n, - const GLuint* framebuffers) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDeleteFramebuffersEXT") - gl_api_->glDeleteFramebuffersEXTFn(n, framebuffers); -} - -void TraceGLApi::glDeleteProgramFn(GLuint program) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDeleteProgram") - gl_api_->glDeleteProgramFn(program); -} - -void TraceGLApi::glDeleteQueriesFn(GLsizei n, const GLuint* ids) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDeleteQueries") - gl_api_->glDeleteQueriesFn(n, ids); -} - -void TraceGLApi::glDeleteRenderbuffersEXTFn(GLsizei n, - const GLuint* renderbuffers) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDeleteRenderbuffersEXT") - gl_api_->glDeleteRenderbuffersEXTFn(n, renderbuffers); -} - -void TraceGLApi::glDeleteSamplersFn(GLsizei n, const GLuint* samplers) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDeleteSamplers") - gl_api_->glDeleteSamplersFn(n, samplers); -} - -void TraceGLApi::glDeleteShaderFn(GLuint shader) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDeleteShader") - gl_api_->glDeleteShaderFn(shader); -} - -void TraceGLApi::glDeleteSyncFn(GLsync sync) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDeleteSync") - gl_api_->glDeleteSyncFn(sync); -} - -void TraceGLApi::glDeleteTexturesFn(GLsizei n, const GLuint* textures) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDeleteTextures") - gl_api_->glDeleteTexturesFn(n, textures); -} - -void TraceGLApi::glDeleteTransformFeedbacksFn(GLsizei n, const GLuint* ids) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDeleteTransformFeedbacks") - gl_api_->glDeleteTransformFeedbacksFn(n, ids); -} - -void TraceGLApi::glDeleteVertexArraysOESFn(GLsizei n, const GLuint* arrays) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDeleteVertexArraysOES") - gl_api_->glDeleteVertexArraysOESFn(n, arrays); -} - -void TraceGLApi::glDepthFuncFn(GLenum func) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDepthFunc") - gl_api_->glDepthFuncFn(func); -} - -void TraceGLApi::glDepthMaskFn(GLboolean flag) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDepthMask") - gl_api_->glDepthMaskFn(flag); -} - -void TraceGLApi::glDepthRangeFn(GLclampd zNear, GLclampd zFar) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDepthRange") - gl_api_->glDepthRangeFn(zNear, zFar); -} - -void TraceGLApi::glDepthRangefFn(GLclampf zNear, GLclampf zFar) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDepthRangef") - gl_api_->glDepthRangefFn(zNear, zFar); -} - -void TraceGLApi::glDetachShaderFn(GLuint program, GLuint shader) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDetachShader") - gl_api_->glDetachShaderFn(program, shader); -} - -void TraceGLApi::glDisableFn(GLenum cap) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDisable") - gl_api_->glDisableFn(cap); -} - -void TraceGLApi::glDisableVertexAttribArrayFn(GLuint index) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDisableVertexAttribArray") - gl_api_->glDisableVertexAttribArrayFn(index); -} - -void TraceGLApi::glDiscardFramebufferEXTFn(GLenum target, - GLsizei numAttachments, - const GLenum* attachments) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDiscardFramebufferEXT") - gl_api_->glDiscardFramebufferEXTFn(target, numAttachments, attachments); -} - -void TraceGLApi::glDrawArraysFn(GLenum mode, GLint first, GLsizei count) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDrawArrays") - gl_api_->glDrawArraysFn(mode, first, count); -} - -void TraceGLApi::glDrawArraysInstancedANGLEFn(GLenum mode, - GLint first, - GLsizei count, - GLsizei primcount) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDrawArraysInstancedANGLE") - gl_api_->glDrawArraysInstancedANGLEFn(mode, first, count, primcount); -} - -void TraceGLApi::glDrawBufferFn(GLenum mode) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDrawBuffer") - gl_api_->glDrawBufferFn(mode); -} - -void TraceGLApi::glDrawBuffersARBFn(GLsizei n, const GLenum* bufs) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDrawBuffersARB") - gl_api_->glDrawBuffersARBFn(n, bufs); -} - -void TraceGLApi::glDrawElementsFn(GLenum mode, - GLsizei count, - GLenum type, - const void* indices) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDrawElements") - gl_api_->glDrawElementsFn(mode, count, type, indices); -} - -void TraceGLApi::glDrawElementsInstancedANGLEFn(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei primcount) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", - "TraceGLAPI::glDrawElementsInstancedANGLE") - gl_api_->glDrawElementsInstancedANGLEFn(mode, count, type, indices, - primcount); -} - -void TraceGLApi::glDrawRangeElementsFn(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glDrawRangeElements") - gl_api_->glDrawRangeElementsFn(mode, start, end, count, type, indices); -} - -void TraceGLApi::glEGLImageTargetRenderbufferStorageOESFn(GLenum target, - GLeglImageOES image) { - TRACE_EVENT_BINARY_EFFICIENT0( - "gpu", "TraceGLAPI::glEGLImageTargetRenderbufferStorageOES") - gl_api_->glEGLImageTargetRenderbufferStorageOESFn(target, image); -} - -void TraceGLApi::glEGLImageTargetTexture2DOESFn(GLenum target, - GLeglImageOES image) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", - "TraceGLAPI::glEGLImageTargetTexture2DOES") - gl_api_->glEGLImageTargetTexture2DOESFn(target, image); -} - -void TraceGLApi::glEnableFn(GLenum cap) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glEnable") - gl_api_->glEnableFn(cap); -} - -void TraceGLApi::glEnableVertexAttribArrayFn(GLuint index) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glEnableVertexAttribArray") - gl_api_->glEnableVertexAttribArrayFn(index); -} - -void TraceGLApi::glEndQueryFn(GLenum target) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glEndQuery") - gl_api_->glEndQueryFn(target); -} - -void TraceGLApi::glEndTransformFeedbackFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glEndTransformFeedback") - gl_api_->glEndTransformFeedbackFn(); -} - -GLsync TraceGLApi::glFenceSyncFn(GLenum condition, GLbitfield flags) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glFenceSync") - return gl_api_->glFenceSyncFn(condition, flags); -} - -void TraceGLApi::glFinishFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glFinish") - gl_api_->glFinishFn(); -} - -void TraceGLApi::glFinishFenceAPPLEFn(GLuint fence) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glFinishFenceAPPLE") - gl_api_->glFinishFenceAPPLEFn(fence); -} - -void TraceGLApi::glFinishFenceNVFn(GLuint fence) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glFinishFenceNV") - gl_api_->glFinishFenceNVFn(fence); -} - -void TraceGLApi::glFlushFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glFlush") - gl_api_->glFlushFn(); -} - -void TraceGLApi::glFlushMappedBufferRangeFn(GLenum target, - GLintptr offset, - GLsizeiptr length) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glFlushMappedBufferRange") - gl_api_->glFlushMappedBufferRangeFn(target, offset, length); -} - -void TraceGLApi::glFramebufferRenderbufferEXTFn(GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", - "TraceGLAPI::glFramebufferRenderbufferEXT") - gl_api_->glFramebufferRenderbufferEXTFn(target, attachment, - renderbuffertarget, renderbuffer); -} - -void TraceGLApi::glFramebufferTexture2DEXTFn(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glFramebufferTexture2DEXT") - gl_api_->glFramebufferTexture2DEXTFn(target, attachment, textarget, texture, - level); -} - -void TraceGLApi::glFramebufferTexture2DMultisampleEXTFn(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples) { - TRACE_EVENT_BINARY_EFFICIENT0( - "gpu", "TraceGLAPI::glFramebufferTexture2DMultisampleEXT") - gl_api_->glFramebufferTexture2DMultisampleEXTFn(target, attachment, textarget, - texture, level, samples); -} - -void TraceGLApi::glFramebufferTexture2DMultisampleIMGFn(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples) { - TRACE_EVENT_BINARY_EFFICIENT0( - "gpu", "TraceGLAPI::glFramebufferTexture2DMultisampleIMG") - gl_api_->glFramebufferTexture2DMultisampleIMGFn(target, attachment, textarget, - texture, level, samples); -} - -void TraceGLApi::glFramebufferTextureLayerFn(GLenum target, - GLenum attachment, - GLuint texture, - GLint level, - GLint layer) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glFramebufferTextureLayer") - gl_api_->glFramebufferTextureLayerFn(target, attachment, texture, level, - layer); -} - -void TraceGLApi::glFrontFaceFn(GLenum mode) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glFrontFace") - gl_api_->glFrontFaceFn(mode); -} - -void TraceGLApi::glGenBuffersARBFn(GLsizei n, GLuint* buffers) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGenBuffersARB") - gl_api_->glGenBuffersARBFn(n, buffers); -} - -void TraceGLApi::glGenerateMipmapEXTFn(GLenum target) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGenerateMipmapEXT") - gl_api_->glGenerateMipmapEXTFn(target); -} - -void TraceGLApi::glGenFencesAPPLEFn(GLsizei n, GLuint* fences) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGenFencesAPPLE") - gl_api_->glGenFencesAPPLEFn(n, fences); -} - -void TraceGLApi::glGenFencesNVFn(GLsizei n, GLuint* fences) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGenFencesNV") - gl_api_->glGenFencesNVFn(n, fences); -} - -void TraceGLApi::glGenFramebuffersEXTFn(GLsizei n, GLuint* framebuffers) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGenFramebuffersEXT") - gl_api_->glGenFramebuffersEXTFn(n, framebuffers); -} - -void TraceGLApi::glGenQueriesFn(GLsizei n, GLuint* ids) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGenQueries") - gl_api_->glGenQueriesFn(n, ids); -} - -void TraceGLApi::glGenRenderbuffersEXTFn(GLsizei n, GLuint* renderbuffers) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGenRenderbuffersEXT") - gl_api_->glGenRenderbuffersEXTFn(n, renderbuffers); -} - -void TraceGLApi::glGenSamplersFn(GLsizei n, GLuint* samplers) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGenSamplers") - gl_api_->glGenSamplersFn(n, samplers); -} - -void TraceGLApi::glGenTexturesFn(GLsizei n, GLuint* textures) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGenTextures") - gl_api_->glGenTexturesFn(n, textures); -} - -void TraceGLApi::glGenTransformFeedbacksFn(GLsizei n, GLuint* ids) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGenTransformFeedbacks") - gl_api_->glGenTransformFeedbacksFn(n, ids); -} - -void TraceGLApi::glGenVertexArraysOESFn(GLsizei n, GLuint* arrays) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGenVertexArraysOES") - gl_api_->glGenVertexArraysOESFn(n, arrays); -} - -void TraceGLApi::glGetActiveAttribFn(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - char* name) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetActiveAttrib") - gl_api_->glGetActiveAttribFn(program, index, bufsize, length, size, type, - name); -} - -void TraceGLApi::glGetActiveUniformFn(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - char* name) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetActiveUniform") - gl_api_->glGetActiveUniformFn(program, index, bufsize, length, size, type, - name); -} - -void TraceGLApi::glGetActiveUniformBlockivFn(GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetActiveUniformBlockiv") - gl_api_->glGetActiveUniformBlockivFn(program, uniformBlockIndex, pname, - params); -} - -void TraceGLApi::glGetActiveUniformBlockNameFn(GLuint program, - GLuint uniformBlockIndex, - GLsizei bufSize, - GLsizei* length, - char* uniformBlockName) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", - "TraceGLAPI::glGetActiveUniformBlockName") - gl_api_->glGetActiveUniformBlockNameFn(program, uniformBlockIndex, bufSize, - length, uniformBlockName); -} - -void TraceGLApi::glGetActiveUniformsivFn(GLuint program, - GLsizei uniformCount, - const GLuint* uniformIndices, - GLenum pname, - GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetActiveUniformsiv") - gl_api_->glGetActiveUniformsivFn(program, uniformCount, uniformIndices, pname, - params); -} - -void TraceGLApi::glGetAttachedShadersFn(GLuint program, - GLsizei maxcount, - GLsizei* count, - GLuint* shaders) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetAttachedShaders") - gl_api_->glGetAttachedShadersFn(program, maxcount, count, shaders); -} - -GLint TraceGLApi::glGetAttribLocationFn(GLuint program, const char* name) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetAttribLocation") - return gl_api_->glGetAttribLocationFn(program, name); -} - -void TraceGLApi::glGetBooleanvFn(GLenum pname, GLboolean* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetBooleanv") - gl_api_->glGetBooleanvFn(pname, params); -} - -void TraceGLApi::glGetBufferParameterivFn(GLenum target, - GLenum pname, - GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetBufferParameteriv") - gl_api_->glGetBufferParameterivFn(target, pname, params); -} - -GLuint TraceGLApi::glGetDebugMessageLogKHRFn(GLuint count, - GLsizei bufSize, - GLenum* sources, - GLenum* types, - GLuint* ids, - GLenum* severities, - GLsizei* lengths, - GLchar* messageLog) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetDebugMessageLogKHR") - return gl_api_->glGetDebugMessageLogKHRFn(count, bufSize, sources, types, ids, - severities, lengths, messageLog); -} - -GLenum TraceGLApi::glGetErrorFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetError") - return gl_api_->glGetErrorFn(); -} - -void TraceGLApi::glGetFenceivNVFn(GLuint fence, GLenum pname, GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetFenceivNV") - gl_api_->glGetFenceivNVFn(fence, pname, params); -} - -void TraceGLApi::glGetFloatvFn(GLenum pname, GLfloat* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetFloatv") - gl_api_->glGetFloatvFn(pname, params); -} - -GLint TraceGLApi::glGetFragDataLocationFn(GLuint program, const char* name) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetFragDataLocation") - return gl_api_->glGetFragDataLocationFn(program, name); -} - -void TraceGLApi::glGetFramebufferAttachmentParameterivEXTFn(GLenum target, - GLenum attachment, - GLenum pname, - GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0( - "gpu", "TraceGLAPI::glGetFramebufferAttachmentParameterivEXT") - gl_api_->glGetFramebufferAttachmentParameterivEXTFn(target, attachment, pname, - params); -} - -GLenum TraceGLApi::glGetGraphicsResetStatusARBFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", - "TraceGLAPI::glGetGraphicsResetStatusARB") - return gl_api_->glGetGraphicsResetStatusARBFn(); -} - -void TraceGLApi::glGetInteger64i_vFn(GLenum target, - GLuint index, - GLint64* data) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetInteger64i_v") - gl_api_->glGetInteger64i_vFn(target, index, data); -} - -void TraceGLApi::glGetInteger64vFn(GLenum pname, GLint64* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetInteger64v") - gl_api_->glGetInteger64vFn(pname, params); -} - -void TraceGLApi::glGetIntegeri_vFn(GLenum target, GLuint index, GLint* data) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetIntegeri_v") - gl_api_->glGetIntegeri_vFn(target, index, data); -} - -void TraceGLApi::glGetIntegervFn(GLenum pname, GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetIntegerv") - gl_api_->glGetIntegervFn(pname, params); -} - -void TraceGLApi::glGetInternalformativFn(GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetInternalformativ") - gl_api_->glGetInternalformativFn(target, internalformat, pname, bufSize, - params); -} - -void TraceGLApi::glGetProgramBinaryFn(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - GLvoid* binary) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetProgramBinary") - gl_api_->glGetProgramBinaryFn(program, bufSize, length, binaryFormat, binary); -} - -void TraceGLApi::glGetProgramInfoLogFn(GLuint program, - GLsizei bufsize, - GLsizei* length, - char* infolog) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetProgramInfoLog") - gl_api_->glGetProgramInfoLogFn(program, bufsize, length, infolog); -} - -void TraceGLApi::glGetProgramivFn(GLuint program, GLenum pname, GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetProgramiv") - gl_api_->glGetProgramivFn(program, pname, params); -} - -GLint TraceGLApi::glGetProgramResourceLocationFn(GLuint program, - GLenum programInterface, - const char* name) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", - "TraceGLAPI::glGetProgramResourceLocation") - return gl_api_->glGetProgramResourceLocationFn(program, programInterface, - name); -} - -void TraceGLApi::glGetQueryivFn(GLenum target, GLenum pname, GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetQueryiv") - gl_api_->glGetQueryivFn(target, pname, params); -} - -void TraceGLApi::glGetQueryObjecti64vFn(GLuint id, - GLenum pname, - GLint64* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetQueryObjecti64v") - gl_api_->glGetQueryObjecti64vFn(id, pname, params); -} - -void TraceGLApi::glGetQueryObjectivFn(GLuint id, GLenum pname, GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetQueryObjectiv") - gl_api_->glGetQueryObjectivFn(id, pname, params); -} - -void TraceGLApi::glGetQueryObjectui64vFn(GLuint id, - GLenum pname, - GLuint64* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetQueryObjectui64v") - gl_api_->glGetQueryObjectui64vFn(id, pname, params); -} - -void TraceGLApi::glGetQueryObjectuivFn(GLuint id, - GLenum pname, - GLuint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetQueryObjectuiv") - gl_api_->glGetQueryObjectuivFn(id, pname, params); -} - -void TraceGLApi::glGetRenderbufferParameterivEXTFn(GLenum target, - GLenum pname, - GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", - "TraceGLAPI::glGetRenderbufferParameterivEXT") - gl_api_->glGetRenderbufferParameterivEXTFn(target, pname, params); -} - -void TraceGLApi::glGetSamplerParameterfvFn(GLuint sampler, - GLenum pname, - GLfloat* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetSamplerParameterfv") - gl_api_->glGetSamplerParameterfvFn(sampler, pname, params); -} - -void TraceGLApi::glGetSamplerParameterivFn(GLuint sampler, - GLenum pname, - GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetSamplerParameteriv") - gl_api_->glGetSamplerParameterivFn(sampler, pname, params); -} - -void TraceGLApi::glGetShaderInfoLogFn(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* infolog) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetShaderInfoLog") - gl_api_->glGetShaderInfoLogFn(shader, bufsize, length, infolog); -} - -void TraceGLApi::glGetShaderivFn(GLuint shader, GLenum pname, GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetShaderiv") - gl_api_->glGetShaderivFn(shader, pname, params); -} - -void TraceGLApi::glGetShaderPrecisionFormatFn(GLenum shadertype, - GLenum precisiontype, - GLint* range, - GLint* precision) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetShaderPrecisionFormat") - gl_api_->glGetShaderPrecisionFormatFn(shadertype, precisiontype, range, - precision); -} - -void TraceGLApi::glGetShaderSourceFn(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* source) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetShaderSource") - gl_api_->glGetShaderSourceFn(shader, bufsize, length, source); -} - -const GLubyte* TraceGLApi::glGetStringFn(GLenum name) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetString") - return gl_api_->glGetStringFn(name); -} - -const GLubyte* TraceGLApi::glGetStringiFn(GLenum name, GLuint index) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetStringi") - return gl_api_->glGetStringiFn(name, index); -} - -void TraceGLApi::glGetSyncivFn(GLsync sync, - GLenum pname, - GLsizei bufSize, - GLsizei* length, - GLint* values) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetSynciv") - gl_api_->glGetSyncivFn(sync, pname, bufSize, length, values); -} - -void TraceGLApi::glGetTexLevelParameterfvFn(GLenum target, - GLint level, - GLenum pname, - GLfloat* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetTexLevelParameterfv") - gl_api_->glGetTexLevelParameterfvFn(target, level, pname, params); -} - -void TraceGLApi::glGetTexLevelParameterivFn(GLenum target, - GLint level, - GLenum pname, - GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetTexLevelParameteriv") - gl_api_->glGetTexLevelParameterivFn(target, level, pname, params); -} - -void TraceGLApi::glGetTexParameterfvFn(GLenum target, - GLenum pname, - GLfloat* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetTexParameterfv") - gl_api_->glGetTexParameterfvFn(target, pname, params); -} - -void TraceGLApi::glGetTexParameterivFn(GLenum target, - GLenum pname, - GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetTexParameteriv") - gl_api_->glGetTexParameterivFn(target, pname, params); -} - -void TraceGLApi::glGetTransformFeedbackVaryingFn(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLsizei* size, - GLenum* type, - char* name) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", - "TraceGLAPI::glGetTransformFeedbackVarying") - gl_api_->glGetTransformFeedbackVaryingFn(program, index, bufSize, length, - size, type, name); -} - -void TraceGLApi::glGetTranslatedShaderSourceANGLEFn(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* source) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", - "TraceGLAPI::glGetTranslatedShaderSourceANGLE") - gl_api_->glGetTranslatedShaderSourceANGLEFn(shader, bufsize, length, source); -} - -GLuint TraceGLApi::glGetUniformBlockIndexFn(GLuint program, - const char* uniformBlockName) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetUniformBlockIndex") - return gl_api_->glGetUniformBlockIndexFn(program, uniformBlockName); -} - -void TraceGLApi::glGetUniformfvFn(GLuint program, - GLint location, - GLfloat* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetUniformfv") - gl_api_->glGetUniformfvFn(program, location, params); -} - -void TraceGLApi::glGetUniformIndicesFn(GLuint program, - GLsizei uniformCount, - const char* const* uniformNames, - GLuint* uniformIndices) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetUniformIndices") - gl_api_->glGetUniformIndicesFn(program, uniformCount, uniformNames, - uniformIndices); -} - -void TraceGLApi::glGetUniformivFn(GLuint program, - GLint location, - GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetUniformiv") - gl_api_->glGetUniformivFn(program, location, params); -} - -GLint TraceGLApi::glGetUniformLocationFn(GLuint program, const char* name) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetUniformLocation") - return gl_api_->glGetUniformLocationFn(program, name); -} - -void TraceGLApi::glGetVertexAttribfvFn(GLuint index, - GLenum pname, - GLfloat* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetVertexAttribfv") - gl_api_->glGetVertexAttribfvFn(index, pname, params); -} - -void TraceGLApi::glGetVertexAttribivFn(GLuint index, - GLenum pname, - GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetVertexAttribiv") - gl_api_->glGetVertexAttribivFn(index, pname, params); -} - -void TraceGLApi::glGetVertexAttribPointervFn(GLuint index, - GLenum pname, - void** pointer) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetVertexAttribPointerv") - gl_api_->glGetVertexAttribPointervFn(index, pname, pointer); -} - -void TraceGLApi::glHintFn(GLenum target, GLenum mode) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glHint") - gl_api_->glHintFn(target, mode); -} - -void TraceGLApi::glInsertEventMarkerEXTFn(GLsizei length, const char* marker) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glInsertEventMarkerEXT") - gl_api_->glInsertEventMarkerEXTFn(length, marker); -} - -void TraceGLApi::glInvalidateFramebufferFn(GLenum target, - GLsizei numAttachments, - const GLenum* attachments) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glInvalidateFramebuffer") - gl_api_->glInvalidateFramebufferFn(target, numAttachments, attachments); -} - -void TraceGLApi::glInvalidateSubFramebufferFn(GLenum target, - GLsizei numAttachments, - const GLenum* attachments, - GLint x, - GLint y, - GLint width, - GLint height) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glInvalidateSubFramebuffer") - gl_api_->glInvalidateSubFramebufferFn(target, numAttachments, attachments, x, - y, width, height); -} - -GLboolean TraceGLApi::glIsBufferFn(GLuint buffer) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glIsBuffer") - return gl_api_->glIsBufferFn(buffer); -} - -GLboolean TraceGLApi::glIsEnabledFn(GLenum cap) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glIsEnabled") - return gl_api_->glIsEnabledFn(cap); -} - -GLboolean TraceGLApi::glIsFenceAPPLEFn(GLuint fence) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glIsFenceAPPLE") - return gl_api_->glIsFenceAPPLEFn(fence); -} - -GLboolean TraceGLApi::glIsFenceNVFn(GLuint fence) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glIsFenceNV") - return gl_api_->glIsFenceNVFn(fence); -} - -GLboolean TraceGLApi::glIsFramebufferEXTFn(GLuint framebuffer) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glIsFramebufferEXT") - return gl_api_->glIsFramebufferEXTFn(framebuffer); -} - -GLboolean TraceGLApi::glIsProgramFn(GLuint program) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glIsProgram") - return gl_api_->glIsProgramFn(program); -} - -GLboolean TraceGLApi::glIsQueryFn(GLuint query) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glIsQuery") - return gl_api_->glIsQueryFn(query); -} - -GLboolean TraceGLApi::glIsRenderbufferEXTFn(GLuint renderbuffer) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glIsRenderbufferEXT") - return gl_api_->glIsRenderbufferEXTFn(renderbuffer); -} - -GLboolean TraceGLApi::glIsSamplerFn(GLuint sampler) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glIsSampler") - return gl_api_->glIsSamplerFn(sampler); -} - -GLboolean TraceGLApi::glIsShaderFn(GLuint shader) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glIsShader") - return gl_api_->glIsShaderFn(shader); -} - -GLboolean TraceGLApi::glIsSyncFn(GLsync sync) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glIsSync") - return gl_api_->glIsSyncFn(sync); -} - -GLboolean TraceGLApi::glIsTextureFn(GLuint texture) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glIsTexture") - return gl_api_->glIsTextureFn(texture); -} - -GLboolean TraceGLApi::glIsTransformFeedbackFn(GLuint id) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glIsTransformFeedback") - return gl_api_->glIsTransformFeedbackFn(id); -} - -GLboolean TraceGLApi::glIsVertexArrayOESFn(GLuint array) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glIsVertexArrayOES") - return gl_api_->glIsVertexArrayOESFn(array); -} - -void TraceGLApi::glLineWidthFn(GLfloat width) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glLineWidth") - gl_api_->glLineWidthFn(width); -} - -void TraceGLApi::glLinkProgramFn(GLuint program) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glLinkProgram") - gl_api_->glLinkProgramFn(program); -} - -void* TraceGLApi::glMapBufferFn(GLenum target, GLenum access) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glMapBuffer") - return gl_api_->glMapBufferFn(target, access); -} - -void* TraceGLApi::glMapBufferRangeFn(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glMapBufferRange") - return gl_api_->glMapBufferRangeFn(target, offset, length, access); -} - -void TraceGLApi::glMatrixLoadfEXTFn(GLenum matrixMode, const GLfloat* m) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glMatrixLoadfEXT") - gl_api_->glMatrixLoadfEXTFn(matrixMode, m); -} - -void TraceGLApi::glMatrixLoadIdentityEXTFn(GLenum matrixMode) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glMatrixLoadIdentityEXT") - gl_api_->glMatrixLoadIdentityEXTFn(matrixMode); -} - -void TraceGLApi::glObjectLabelKHRFn(GLenum identifier, - GLuint name, - GLsizei length, - const GLchar* label) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glObjectLabelKHR") - gl_api_->glObjectLabelKHRFn(identifier, name, length, label); -} - -void TraceGLApi::glPauseTransformFeedbackFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glPauseTransformFeedback") - gl_api_->glPauseTransformFeedbackFn(); -} - -void TraceGLApi::glPixelStoreiFn(GLenum pname, GLint param) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glPixelStorei") - gl_api_->glPixelStoreiFn(pname, param); -} - -void TraceGLApi::glPointParameteriFn(GLenum pname, GLint param) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glPointParameteri") - gl_api_->glPointParameteriFn(pname, param); -} - -void TraceGLApi::glPolygonOffsetFn(GLfloat factor, GLfloat units) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glPolygonOffset") - gl_api_->glPolygonOffsetFn(factor, units); -} - -void TraceGLApi::glPopDebugGroupKHRFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glPopDebugGroupKHR") - gl_api_->glPopDebugGroupKHRFn(); -} - -void TraceGLApi::glPopGroupMarkerEXTFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glPopGroupMarkerEXT") - gl_api_->glPopGroupMarkerEXTFn(); -} - -void TraceGLApi::glProgramBinaryFn(GLuint program, - GLenum binaryFormat, - const GLvoid* binary, - GLsizei length) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glProgramBinary") - gl_api_->glProgramBinaryFn(program, binaryFormat, binary, length); -} - -void TraceGLApi::glProgramParameteriFn(GLuint program, - GLenum pname, - GLint value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glProgramParameteri") - gl_api_->glProgramParameteriFn(program, pname, value); -} - -void TraceGLApi::glPushDebugGroupKHRFn(GLenum source, - GLuint id, - GLsizei length, - const GLchar* message) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glPushDebugGroupKHR") - gl_api_->glPushDebugGroupKHRFn(source, id, length, message); -} - -void TraceGLApi::glPushGroupMarkerEXTFn(GLsizei length, const char* marker) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glPushGroupMarkerEXT") - gl_api_->glPushGroupMarkerEXTFn(length, marker); -} - -void TraceGLApi::glQueryCounterFn(GLuint id, GLenum target) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glQueryCounter") - gl_api_->glQueryCounterFn(id, target); -} - -void TraceGLApi::glReadBufferFn(GLenum src) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glReadBuffer") - gl_api_->glReadBufferFn(src); -} - -void TraceGLApi::glReadPixelsFn(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - void* pixels) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glReadPixels") - gl_api_->glReadPixelsFn(x, y, width, height, format, type, pixels); -} - -void TraceGLApi::glReleaseShaderCompilerFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glReleaseShaderCompiler") - gl_api_->glReleaseShaderCompilerFn(); -} - -void TraceGLApi::glRenderbufferStorageEXTFn(GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glRenderbufferStorageEXT") - gl_api_->glRenderbufferStorageEXTFn(target, internalformat, width, height); -} - -void TraceGLApi::glRenderbufferStorageMultisampleFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", - "TraceGLAPI::glRenderbufferStorageMultisample") - gl_api_->glRenderbufferStorageMultisampleFn(target, samples, internalformat, - width, height); -} - -void TraceGLApi::glRenderbufferStorageMultisampleANGLEFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - TRACE_EVENT_BINARY_EFFICIENT0( - "gpu", "TraceGLAPI::glRenderbufferStorageMultisampleANGLE") - gl_api_->glRenderbufferStorageMultisampleANGLEFn( - target, samples, internalformat, width, height); -} - -void TraceGLApi::glRenderbufferStorageMultisampleAPPLEFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - TRACE_EVENT_BINARY_EFFICIENT0( - "gpu", "TraceGLAPI::glRenderbufferStorageMultisampleAPPLE") - gl_api_->glRenderbufferStorageMultisampleAPPLEFn( - target, samples, internalformat, width, height); -} - -void TraceGLApi::glRenderbufferStorageMultisampleEXTFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - TRACE_EVENT_BINARY_EFFICIENT0( - "gpu", "TraceGLAPI::glRenderbufferStorageMultisampleEXT") - gl_api_->glRenderbufferStorageMultisampleEXTFn(target, samples, - internalformat, width, height); -} - -void TraceGLApi::glRenderbufferStorageMultisampleIMGFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - TRACE_EVENT_BINARY_EFFICIENT0( - "gpu", "TraceGLAPI::glRenderbufferStorageMultisampleIMG") - gl_api_->glRenderbufferStorageMultisampleIMGFn(target, samples, - internalformat, width, height); -} - -void TraceGLApi::glResolveMultisampleFramebufferAPPLEFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0( - "gpu", "TraceGLAPI::glResolveMultisampleFramebufferAPPLE") - gl_api_->glResolveMultisampleFramebufferAPPLEFn(); -} - -void TraceGLApi::glResumeTransformFeedbackFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glResumeTransformFeedback") - gl_api_->glResumeTransformFeedbackFn(); -} - -void TraceGLApi::glSampleCoverageFn(GLclampf value, GLboolean invert) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glSampleCoverage") - gl_api_->glSampleCoverageFn(value, invert); -} - -void TraceGLApi::glSamplerParameterfFn(GLuint sampler, - GLenum pname, - GLfloat param) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glSamplerParameterf") - gl_api_->glSamplerParameterfFn(sampler, pname, param); -} - -void TraceGLApi::glSamplerParameterfvFn(GLuint sampler, - GLenum pname, - const GLfloat* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glSamplerParameterfv") - gl_api_->glSamplerParameterfvFn(sampler, pname, params); -} - -void TraceGLApi::glSamplerParameteriFn(GLuint sampler, - GLenum pname, - GLint param) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glSamplerParameteri") - gl_api_->glSamplerParameteriFn(sampler, pname, param); -} - -void TraceGLApi::glSamplerParameterivFn(GLuint sampler, - GLenum pname, - const GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glSamplerParameteriv") - gl_api_->glSamplerParameterivFn(sampler, pname, params); -} - -void TraceGLApi::glScissorFn(GLint x, GLint y, GLsizei width, GLsizei height) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glScissor") - gl_api_->glScissorFn(x, y, width, height); -} - -void TraceGLApi::glSetFenceAPPLEFn(GLuint fence) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glSetFenceAPPLE") - gl_api_->glSetFenceAPPLEFn(fence); -} - -void TraceGLApi::glSetFenceNVFn(GLuint fence, GLenum condition) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glSetFenceNV") - gl_api_->glSetFenceNVFn(fence, condition); -} - -void TraceGLApi::glShaderBinaryFn(GLsizei n, - const GLuint* shaders, - GLenum binaryformat, - const void* binary, - GLsizei length) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glShaderBinary") - gl_api_->glShaderBinaryFn(n, shaders, binaryformat, binary, length); -} - -void TraceGLApi::glShaderSourceFn(GLuint shader, - GLsizei count, - const char* const* str, - const GLint* length) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glShaderSource") - gl_api_->glShaderSourceFn(shader, count, str, length); -} - -void TraceGLApi::glStencilFuncFn(GLenum func, GLint ref, GLuint mask) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glStencilFunc") - gl_api_->glStencilFuncFn(func, ref, mask); -} - -void TraceGLApi::glStencilFuncSeparateFn(GLenum face, - GLenum func, - GLint ref, - GLuint mask) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glStencilFuncSeparate") - gl_api_->glStencilFuncSeparateFn(face, func, ref, mask); -} - -void TraceGLApi::glStencilMaskFn(GLuint mask) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glStencilMask") - gl_api_->glStencilMaskFn(mask); -} - -void TraceGLApi::glStencilMaskSeparateFn(GLenum face, GLuint mask) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glStencilMaskSeparate") - gl_api_->glStencilMaskSeparateFn(face, mask); -} - -void TraceGLApi::glStencilOpFn(GLenum fail, GLenum zfail, GLenum zpass) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glStencilOp") - gl_api_->glStencilOpFn(fail, zfail, zpass); -} - -void TraceGLApi::glStencilOpSeparateFn(GLenum face, - GLenum fail, - GLenum zfail, - GLenum zpass) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glStencilOpSeparate") - gl_api_->glStencilOpSeparateFn(face, fail, zfail, zpass); -} - -GLboolean TraceGLApi::glTestFenceAPPLEFn(GLuint fence) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glTestFenceAPPLE") - return gl_api_->glTestFenceAPPLEFn(fence); -} - -GLboolean TraceGLApi::glTestFenceNVFn(GLuint fence) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glTestFenceNV") - return gl_api_->glTestFenceNVFn(fence); -} - -void TraceGLApi::glTexImage2DFn(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const void* pixels) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glTexImage2D") - gl_api_->glTexImage2DFn(target, level, internalformat, width, height, border, - format, type, pixels); -} - -void TraceGLApi::glTexImage3DFn(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - const void* pixels) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glTexImage3D") - gl_api_->glTexImage3DFn(target, level, internalformat, width, height, depth, - border, format, type, pixels); -} - -void TraceGLApi::glTexParameterfFn(GLenum target, GLenum pname, GLfloat param) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glTexParameterf") - gl_api_->glTexParameterfFn(target, pname, param); -} - -void TraceGLApi::glTexParameterfvFn(GLenum target, - GLenum pname, - const GLfloat* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glTexParameterfv") - gl_api_->glTexParameterfvFn(target, pname, params); -} - -void TraceGLApi::glTexParameteriFn(GLenum target, GLenum pname, GLint param) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glTexParameteri") - gl_api_->glTexParameteriFn(target, pname, param); -} - -void TraceGLApi::glTexParameterivFn(GLenum target, - GLenum pname, - const GLint* params) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glTexParameteriv") - gl_api_->glTexParameterivFn(target, pname, params); -} - -void TraceGLApi::glTexStorage2DEXTFn(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glTexStorage2DEXT") - gl_api_->glTexStorage2DEXTFn(target, levels, internalformat, width, height); -} - -void TraceGLApi::glTexStorage3DFn(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glTexStorage3D") - gl_api_->glTexStorage3DFn(target, levels, internalformat, width, height, - depth); -} - -void TraceGLApi::glTexSubImage2DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const void* pixels) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glTexSubImage2D") - gl_api_->glTexSubImage2DFn(target, level, xoffset, yoffset, width, height, - format, type, pixels); -} - -void TraceGLApi::glTextureBarrierNVFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glTextureBarrierNV") - gl_api_->glTextureBarrierNVFn(); -} - -void TraceGLApi::glTransformFeedbackVaryingsFn(GLuint program, - GLsizei count, - const char* const* varyings, - GLenum bufferMode) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", - "TraceGLAPI::glTransformFeedbackVaryings") - gl_api_->glTransformFeedbackVaryingsFn(program, count, varyings, bufferMode); -} - -void TraceGLApi::glUniform1fFn(GLint location, GLfloat x) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform1f") - gl_api_->glUniform1fFn(location, x); -} - -void TraceGLApi::glUniform1fvFn(GLint location, - GLsizei count, - const GLfloat* v) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform1fv") - gl_api_->glUniform1fvFn(location, count, v); -} - -void TraceGLApi::glUniform1iFn(GLint location, GLint x) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform1i") - gl_api_->glUniform1iFn(location, x); -} - -void TraceGLApi::glUniform1ivFn(GLint location, GLsizei count, const GLint* v) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform1iv") - gl_api_->glUniform1ivFn(location, count, v); -} - -void TraceGLApi::glUniform1uiFn(GLint location, GLuint v0) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform1ui") - gl_api_->glUniform1uiFn(location, v0); -} - -void TraceGLApi::glUniform1uivFn(GLint location, - GLsizei count, - const GLuint* v) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform1uiv") - gl_api_->glUniform1uivFn(location, count, v); -} - -void TraceGLApi::glUniform2fFn(GLint location, GLfloat x, GLfloat y) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform2f") - gl_api_->glUniform2fFn(location, x, y); -} - -void TraceGLApi::glUniform2fvFn(GLint location, - GLsizei count, - const GLfloat* v) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform2fv") - gl_api_->glUniform2fvFn(location, count, v); -} - -void TraceGLApi::glUniform2iFn(GLint location, GLint x, GLint y) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform2i") - gl_api_->glUniform2iFn(location, x, y); -} - -void TraceGLApi::glUniform2ivFn(GLint location, GLsizei count, const GLint* v) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform2iv") - gl_api_->glUniform2ivFn(location, count, v); -} - -void TraceGLApi::glUniform2uiFn(GLint location, GLuint v0, GLuint v1) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform2ui") - gl_api_->glUniform2uiFn(location, v0, v1); -} - -void TraceGLApi::glUniform2uivFn(GLint location, - GLsizei count, - const GLuint* v) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform2uiv") - gl_api_->glUniform2uivFn(location, count, v); -} - -void TraceGLApi::glUniform3fFn(GLint location, - GLfloat x, - GLfloat y, - GLfloat z) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform3f") - gl_api_->glUniform3fFn(location, x, y, z); -} - -void TraceGLApi::glUniform3fvFn(GLint location, - GLsizei count, - const GLfloat* v) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform3fv") - gl_api_->glUniform3fvFn(location, count, v); -} - -void TraceGLApi::glUniform3iFn(GLint location, GLint x, GLint y, GLint z) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform3i") - gl_api_->glUniform3iFn(location, x, y, z); -} - -void TraceGLApi::glUniform3ivFn(GLint location, GLsizei count, const GLint* v) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform3iv") - gl_api_->glUniform3ivFn(location, count, v); -} - -void TraceGLApi::glUniform3uiFn(GLint location, - GLuint v0, - GLuint v1, - GLuint v2) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform3ui") - gl_api_->glUniform3uiFn(location, v0, v1, v2); -} - -void TraceGLApi::glUniform3uivFn(GLint location, - GLsizei count, - const GLuint* v) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform3uiv") - gl_api_->glUniform3uivFn(location, count, v); -} - -void TraceGLApi::glUniform4fFn(GLint location, - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform4f") - gl_api_->glUniform4fFn(location, x, y, z, w); -} - -void TraceGLApi::glUniform4fvFn(GLint location, - GLsizei count, - const GLfloat* v) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform4fv") - gl_api_->glUniform4fvFn(location, count, v); -} - -void TraceGLApi::glUniform4iFn(GLint location, - GLint x, - GLint y, - GLint z, - GLint w) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform4i") - gl_api_->glUniform4iFn(location, x, y, z, w); -} - -void TraceGLApi::glUniform4ivFn(GLint location, GLsizei count, const GLint* v) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform4iv") - gl_api_->glUniform4ivFn(location, count, v); -} - -void TraceGLApi::glUniform4uiFn(GLint location, - GLuint v0, - GLuint v1, - GLuint v2, - GLuint v3) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform4ui") - gl_api_->glUniform4uiFn(location, v0, v1, v2, v3); -} - -void TraceGLApi::glUniform4uivFn(GLint location, - GLsizei count, - const GLuint* v) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniform4uiv") - gl_api_->glUniform4uivFn(location, count, v); -} - -void TraceGLApi::glUniformBlockBindingFn(GLuint program, - GLuint uniformBlockIndex, - GLuint uniformBlockBinding) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniformBlockBinding") - gl_api_->glUniformBlockBindingFn(program, uniformBlockIndex, - uniformBlockBinding); -} - -void TraceGLApi::glUniformMatrix2fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniformMatrix2fv") - gl_api_->glUniformMatrix2fvFn(location, count, transpose, value); -} - -void TraceGLApi::glUniformMatrix2x3fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniformMatrix2x3fv") - gl_api_->glUniformMatrix2x3fvFn(location, count, transpose, value); -} - -void TraceGLApi::glUniformMatrix2x4fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniformMatrix2x4fv") - gl_api_->glUniformMatrix2x4fvFn(location, count, transpose, value); -} - -void TraceGLApi::glUniformMatrix3fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniformMatrix3fv") - gl_api_->glUniformMatrix3fvFn(location, count, transpose, value); -} - -void TraceGLApi::glUniformMatrix3x2fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniformMatrix3x2fv") - gl_api_->glUniformMatrix3x2fvFn(location, count, transpose, value); -} - -void TraceGLApi::glUniformMatrix3x4fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniformMatrix3x4fv") - gl_api_->glUniformMatrix3x4fvFn(location, count, transpose, value); -} - -void TraceGLApi::glUniformMatrix4fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniformMatrix4fv") - gl_api_->glUniformMatrix4fvFn(location, count, transpose, value); -} - -void TraceGLApi::glUniformMatrix4x2fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniformMatrix4x2fv") - gl_api_->glUniformMatrix4x2fvFn(location, count, transpose, value); -} - -void TraceGLApi::glUniformMatrix4x3fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUniformMatrix4x3fv") - gl_api_->glUniformMatrix4x3fvFn(location, count, transpose, value); -} - -GLboolean TraceGLApi::glUnmapBufferFn(GLenum target) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUnmapBuffer") - return gl_api_->glUnmapBufferFn(target); -} - -void TraceGLApi::glUseProgramFn(GLuint program) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glUseProgram") - gl_api_->glUseProgramFn(program); -} - -void TraceGLApi::glValidateProgramFn(GLuint program) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glValidateProgram") - gl_api_->glValidateProgramFn(program); -} - -void TraceGLApi::glVertexAttrib1fFn(GLuint indx, GLfloat x) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glVertexAttrib1f") - gl_api_->glVertexAttrib1fFn(indx, x); -} - -void TraceGLApi::glVertexAttrib1fvFn(GLuint indx, const GLfloat* values) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glVertexAttrib1fv") - gl_api_->glVertexAttrib1fvFn(indx, values); -} - -void TraceGLApi::glVertexAttrib2fFn(GLuint indx, GLfloat x, GLfloat y) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glVertexAttrib2f") - gl_api_->glVertexAttrib2fFn(indx, x, y); -} - -void TraceGLApi::glVertexAttrib2fvFn(GLuint indx, const GLfloat* values) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glVertexAttrib2fv") - gl_api_->glVertexAttrib2fvFn(indx, values); -} - -void TraceGLApi::glVertexAttrib3fFn(GLuint indx, - GLfloat x, - GLfloat y, - GLfloat z) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glVertexAttrib3f") - gl_api_->glVertexAttrib3fFn(indx, x, y, z); -} - -void TraceGLApi::glVertexAttrib3fvFn(GLuint indx, const GLfloat* values) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glVertexAttrib3fv") - gl_api_->glVertexAttrib3fvFn(indx, values); -} - -void TraceGLApi::glVertexAttrib4fFn(GLuint indx, - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glVertexAttrib4f") - gl_api_->glVertexAttrib4fFn(indx, x, y, z, w); -} - -void TraceGLApi::glVertexAttrib4fvFn(GLuint indx, const GLfloat* values) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glVertexAttrib4fv") - gl_api_->glVertexAttrib4fvFn(indx, values); -} - -void TraceGLApi::glVertexAttribDivisorANGLEFn(GLuint index, GLuint divisor) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glVertexAttribDivisorANGLE") - gl_api_->glVertexAttribDivisorANGLEFn(index, divisor); -} - -void TraceGLApi::glVertexAttribI4iFn(GLuint indx, - GLint x, - GLint y, - GLint z, - GLint w) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glVertexAttribI4i") - gl_api_->glVertexAttribI4iFn(indx, x, y, z, w); -} - -void TraceGLApi::glVertexAttribI4ivFn(GLuint indx, const GLint* values) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glVertexAttribI4iv") - gl_api_->glVertexAttribI4ivFn(indx, values); -} - -void TraceGLApi::glVertexAttribI4uiFn(GLuint indx, - GLuint x, - GLuint y, - GLuint z, - GLuint w) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glVertexAttribI4ui") - gl_api_->glVertexAttribI4uiFn(indx, x, y, z, w); -} - -void TraceGLApi::glVertexAttribI4uivFn(GLuint indx, const GLuint* values) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glVertexAttribI4uiv") - gl_api_->glVertexAttribI4uivFn(indx, values); -} - -void TraceGLApi::glVertexAttribIPointerFn(GLuint indx, - GLint size, - GLenum type, - GLsizei stride, - const void* ptr) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glVertexAttribIPointer") - gl_api_->glVertexAttribIPointerFn(indx, size, type, stride, ptr); -} - -void TraceGLApi::glVertexAttribPointerFn(GLuint indx, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const void* ptr) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glVertexAttribPointer") - gl_api_->glVertexAttribPointerFn(indx, size, type, normalized, stride, ptr); -} - -void TraceGLApi::glViewportFn(GLint x, GLint y, GLsizei width, GLsizei height) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glViewport") - gl_api_->glViewportFn(x, y, width, height); -} - -GLenum TraceGLApi::glWaitSyncFn(GLsync sync, - GLbitfield flags, - GLuint64 timeout) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glWaitSync") - return gl_api_->glWaitSyncFn(sync, flags, timeout); -} - -void NoContextGLApi::glActiveTextureFn(GLenum texture) { - NOTREACHED() << "Trying to call glActiveTexture() without current GL context"; - LOG(ERROR) << "Trying to call glActiveTexture() without current GL context"; -} - -void NoContextGLApi::glAttachShaderFn(GLuint program, GLuint shader) { - NOTREACHED() << "Trying to call glAttachShader() without current GL context"; - LOG(ERROR) << "Trying to call glAttachShader() without current GL context"; -} - -void NoContextGLApi::glBeginQueryFn(GLenum target, GLuint id) { - NOTREACHED() << "Trying to call glBeginQuery() without current GL context"; - LOG(ERROR) << "Trying to call glBeginQuery() without current GL context"; -} - -void NoContextGLApi::glBeginTransformFeedbackFn(GLenum primitiveMode) { - NOTREACHED() - << "Trying to call glBeginTransformFeedback() without current GL context"; - LOG(ERROR) - << "Trying to call glBeginTransformFeedback() without current GL context"; -} - -void NoContextGLApi::glBindAttribLocationFn(GLuint program, - GLuint index, - const char* name) { - NOTREACHED() - << "Trying to call glBindAttribLocation() without current GL context"; - LOG(ERROR) - << "Trying to call glBindAttribLocation() without current GL context"; -} - -void NoContextGLApi::glBindBufferFn(GLenum target, GLuint buffer) { - NOTREACHED() << "Trying to call glBindBuffer() without current GL context"; - LOG(ERROR) << "Trying to call glBindBuffer() without current GL context"; -} - -void NoContextGLApi::glBindBufferBaseFn(GLenum target, - GLuint index, - GLuint buffer) { - NOTREACHED() - << "Trying to call glBindBufferBase() without current GL context"; - LOG(ERROR) << "Trying to call glBindBufferBase() without current GL context"; -} - -void NoContextGLApi::glBindBufferRangeFn(GLenum target, - GLuint index, - GLuint buffer, - GLintptr offset, - GLsizeiptr size) { - NOTREACHED() - << "Trying to call glBindBufferRange() without current GL context"; - LOG(ERROR) << "Trying to call glBindBufferRange() without current GL context"; -} - -void NoContextGLApi::glBindFragDataLocationFn(GLuint program, - GLuint colorNumber, - const char* name) { - NOTREACHED() - << "Trying to call glBindFragDataLocation() without current GL context"; - LOG(ERROR) - << "Trying to call glBindFragDataLocation() without current GL context"; -} - -void NoContextGLApi::glBindFragDataLocationIndexedFn(GLuint program, - GLuint colorNumber, - GLuint index, - const char* name) { - NOTREACHED() << "Trying to call glBindFragDataLocationIndexed() without " - "current GL context"; - LOG(ERROR) << "Trying to call glBindFragDataLocationIndexed() without " - "current GL context"; -} - -void NoContextGLApi::glBindFramebufferEXTFn(GLenum target, GLuint framebuffer) { - NOTREACHED() - << "Trying to call glBindFramebufferEXT() without current GL context"; - LOG(ERROR) - << "Trying to call glBindFramebufferEXT() without current GL context"; -} - -void NoContextGLApi::glBindRenderbufferEXTFn(GLenum target, - GLuint renderbuffer) { - NOTREACHED() - << "Trying to call glBindRenderbufferEXT() without current GL context"; - LOG(ERROR) - << "Trying to call glBindRenderbufferEXT() without current GL context"; -} - -void NoContextGLApi::glBindSamplerFn(GLuint unit, GLuint sampler) { - NOTREACHED() << "Trying to call glBindSampler() without current GL context"; - LOG(ERROR) << "Trying to call glBindSampler() without current GL context"; -} - -void NoContextGLApi::glBindTextureFn(GLenum target, GLuint texture) { - NOTREACHED() << "Trying to call glBindTexture() without current GL context"; - LOG(ERROR) << "Trying to call glBindTexture() without current GL context"; -} - -void NoContextGLApi::glBindTransformFeedbackFn(GLenum target, GLuint id) { - NOTREACHED() - << "Trying to call glBindTransformFeedback() without current GL context"; - LOG(ERROR) - << "Trying to call glBindTransformFeedback() without current GL context"; -} - -void NoContextGLApi::glBindVertexArrayOESFn(GLuint array) { - NOTREACHED() - << "Trying to call glBindVertexArrayOES() without current GL context"; - LOG(ERROR) - << "Trying to call glBindVertexArrayOES() without current GL context"; -} - -void NoContextGLApi::glBlendBarrierKHRFn(void) { - NOTREACHED() - << "Trying to call glBlendBarrierKHR() without current GL context"; - LOG(ERROR) << "Trying to call glBlendBarrierKHR() without current GL context"; -} - -void NoContextGLApi::glBlendColorFn(GLclampf red, - GLclampf green, - GLclampf blue, - GLclampf alpha) { - NOTREACHED() << "Trying to call glBlendColor() without current GL context"; - LOG(ERROR) << "Trying to call glBlendColor() without current GL context"; -} - -void NoContextGLApi::glBlendEquationFn(GLenum mode) { - NOTREACHED() << "Trying to call glBlendEquation() without current GL context"; - LOG(ERROR) << "Trying to call glBlendEquation() without current GL context"; -} - -void NoContextGLApi::glBlendEquationSeparateFn(GLenum modeRGB, - GLenum modeAlpha) { - NOTREACHED() - << "Trying to call glBlendEquationSeparate() without current GL context"; - LOG(ERROR) - << "Trying to call glBlendEquationSeparate() without current GL context"; -} - -void NoContextGLApi::glBlendFuncFn(GLenum sfactor, GLenum dfactor) { - NOTREACHED() << "Trying to call glBlendFunc() without current GL context"; - LOG(ERROR) << "Trying to call glBlendFunc() without current GL context"; -} - -void NoContextGLApi::glBlendFuncSeparateFn(GLenum srcRGB, - GLenum dstRGB, - GLenum srcAlpha, - GLenum dstAlpha) { - NOTREACHED() - << "Trying to call glBlendFuncSeparate() without current GL context"; - LOG(ERROR) - << "Trying to call glBlendFuncSeparate() without current GL context"; -} - -void NoContextGLApi::glBlitFramebufferFn(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) { - NOTREACHED() - << "Trying to call glBlitFramebuffer() without current GL context"; - LOG(ERROR) << "Trying to call glBlitFramebuffer() without current GL context"; -} - -void NoContextGLApi::glBlitFramebufferANGLEFn(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) { - NOTREACHED() - << "Trying to call glBlitFramebufferANGLE() without current GL context"; - LOG(ERROR) - << "Trying to call glBlitFramebufferANGLE() without current GL context"; -} - -void NoContextGLApi::glBlitFramebufferEXTFn(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) { - NOTREACHED() - << "Trying to call glBlitFramebufferEXT() without current GL context"; - LOG(ERROR) - << "Trying to call glBlitFramebufferEXT() without current GL context"; -} - -void NoContextGLApi::glBufferDataFn(GLenum target, - GLsizeiptr size, - const void* data, - GLenum usage) { - NOTREACHED() << "Trying to call glBufferData() without current GL context"; - LOG(ERROR) << "Trying to call glBufferData() without current GL context"; -} - -void NoContextGLApi::glBufferSubDataFn(GLenum target, - GLintptr offset, - GLsizeiptr size, - const void* data) { - NOTREACHED() << "Trying to call glBufferSubData() without current GL context"; - LOG(ERROR) << "Trying to call glBufferSubData() without current GL context"; -} - -GLenum NoContextGLApi::glCheckFramebufferStatusEXTFn(GLenum target) { - NOTREACHED() << "Trying to call glCheckFramebufferStatusEXT() without " - "current GL context"; - LOG(ERROR) << "Trying to call glCheckFramebufferStatusEXT() without current " - "GL context"; - return static_cast(0); -} - -void NoContextGLApi::glClearFn(GLbitfield mask) { - NOTREACHED() << "Trying to call glClear() without current GL context"; - LOG(ERROR) << "Trying to call glClear() without current GL context"; -} - -void NoContextGLApi::glClearBufferfiFn(GLenum buffer, - GLint drawbuffer, - const GLfloat depth, - GLint stencil) { - NOTREACHED() << "Trying to call glClearBufferfi() without current GL context"; - LOG(ERROR) << "Trying to call glClearBufferfi() without current GL context"; -} - -void NoContextGLApi::glClearBufferfvFn(GLenum buffer, - GLint drawbuffer, - const GLfloat* value) { - NOTREACHED() << "Trying to call glClearBufferfv() without current GL context"; - LOG(ERROR) << "Trying to call glClearBufferfv() without current GL context"; -} - -void NoContextGLApi::glClearBufferivFn(GLenum buffer, - GLint drawbuffer, - const GLint* value) { - NOTREACHED() << "Trying to call glClearBufferiv() without current GL context"; - LOG(ERROR) << "Trying to call glClearBufferiv() without current GL context"; -} - -void NoContextGLApi::glClearBufferuivFn(GLenum buffer, - GLint drawbuffer, - const GLuint* value) { - NOTREACHED() - << "Trying to call glClearBufferuiv() without current GL context"; - LOG(ERROR) << "Trying to call glClearBufferuiv() without current GL context"; -} - -void NoContextGLApi::glClearColorFn(GLclampf red, - GLclampf green, - GLclampf blue, - GLclampf alpha) { - NOTREACHED() << "Trying to call glClearColor() without current GL context"; - LOG(ERROR) << "Trying to call glClearColor() without current GL context"; -} - -void NoContextGLApi::glClearDepthFn(GLclampd depth) { - NOTREACHED() << "Trying to call glClearDepth() without current GL context"; - LOG(ERROR) << "Trying to call glClearDepth() without current GL context"; -} - -void NoContextGLApi::glClearDepthfFn(GLclampf depth) { - NOTREACHED() << "Trying to call glClearDepthf() without current GL context"; - LOG(ERROR) << "Trying to call glClearDepthf() without current GL context"; -} - -void NoContextGLApi::glClearStencilFn(GLint s) { - NOTREACHED() << "Trying to call glClearStencil() without current GL context"; - LOG(ERROR) << "Trying to call glClearStencil() without current GL context"; -} - -GLenum NoContextGLApi::glClientWaitSyncFn(GLsync sync, - GLbitfield flags, - GLuint64 timeout) { - NOTREACHED() - << "Trying to call glClientWaitSync() without current GL context"; - LOG(ERROR) << "Trying to call glClientWaitSync() without current GL context"; - return static_cast(0); -} - -void NoContextGLApi::glColorMaskFn(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha) { - NOTREACHED() << "Trying to call glColorMask() without current GL context"; - LOG(ERROR) << "Trying to call glColorMask() without current GL context"; -} - -void NoContextGLApi::glCompileShaderFn(GLuint shader) { - NOTREACHED() << "Trying to call glCompileShader() without current GL context"; - LOG(ERROR) << "Trying to call glCompileShader() without current GL context"; -} - -void NoContextGLApi::glCompressedTexImage2DFn(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const void* data) { - NOTREACHED() - << "Trying to call glCompressedTexImage2D() without current GL context"; - LOG(ERROR) - << "Trying to call glCompressedTexImage2D() without current GL context"; -} - -void NoContextGLApi::glCompressedTexImage3DFn(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLsizei imageSize, - const void* data) { - NOTREACHED() - << "Trying to call glCompressedTexImage3D() without current GL context"; - LOG(ERROR) - << "Trying to call glCompressedTexImage3D() without current GL context"; -} - -void NoContextGLApi::glCompressedTexSubImage2DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const void* data) { - NOTREACHED() << "Trying to call glCompressedTexSubImage2D() without current " - "GL context"; - LOG(ERROR) << "Trying to call glCompressedTexSubImage2D() without current GL " - "context"; -} - -void NoContextGLApi::glCopyBufferSubDataFn(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size) { - NOTREACHED() - << "Trying to call glCopyBufferSubData() without current GL context"; - LOG(ERROR) - << "Trying to call glCopyBufferSubData() without current GL context"; -} - -void NoContextGLApi::glCopyTexImage2DFn(GLenum target, - GLint level, - GLenum internalformat, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLint border) { - NOTREACHED() - << "Trying to call glCopyTexImage2D() without current GL context"; - LOG(ERROR) << "Trying to call glCopyTexImage2D() without current GL context"; -} - -void NoContextGLApi::glCopyTexSubImage2DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height) { - NOTREACHED() - << "Trying to call glCopyTexSubImage2D() without current GL context"; - LOG(ERROR) - << "Trying to call glCopyTexSubImage2D() without current GL context"; -} - -void NoContextGLApi::glCopyTexSubImage3DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height) { - NOTREACHED() - << "Trying to call glCopyTexSubImage3D() without current GL context"; - LOG(ERROR) - << "Trying to call glCopyTexSubImage3D() without current GL context"; -} - -GLuint NoContextGLApi::glCreateProgramFn(void) { - NOTREACHED() << "Trying to call glCreateProgram() without current GL context"; - LOG(ERROR) << "Trying to call glCreateProgram() without current GL context"; - return 0U; -} - -GLuint NoContextGLApi::glCreateShaderFn(GLenum type) { - NOTREACHED() << "Trying to call glCreateShader() without current GL context"; - LOG(ERROR) << "Trying to call glCreateShader() without current GL context"; - return 0U; -} - -void NoContextGLApi::glCullFaceFn(GLenum mode) { - NOTREACHED() << "Trying to call glCullFace() without current GL context"; - LOG(ERROR) << "Trying to call glCullFace() without current GL context"; -} - -void NoContextGLApi::glDebugMessageCallbackKHRFn(GLDEBUGPROCKHR callback, - const void* userparam) { - NOTREACHED() << "Trying to call glDebugMessageCallbackKHR() without current " - "GL context"; - LOG(ERROR) << "Trying to call glDebugMessageCallbackKHR() without current GL " - "context"; -} - -void NoContextGLApi::glDebugMessageControlKHRFn(GLenum source, - GLenum type, - GLenum severity, - GLsizei count, - const GLuint* ids, - GLboolean enabled) { - NOTREACHED() - << "Trying to call glDebugMessageControlKHR() without current GL context"; - LOG(ERROR) - << "Trying to call glDebugMessageControlKHR() without current GL context"; -} - -void NoContextGLApi::glDebugMessageInsertKHRFn(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar* buf) { - NOTREACHED() - << "Trying to call glDebugMessageInsertKHR() without current GL context"; - LOG(ERROR) - << "Trying to call glDebugMessageInsertKHR() without current GL context"; -} - -void NoContextGLApi::glDeleteBuffersARBFn(GLsizei n, const GLuint* buffers) { - NOTREACHED() - << "Trying to call glDeleteBuffersARB() without current GL context"; - LOG(ERROR) - << "Trying to call glDeleteBuffersARB() without current GL context"; -} - -void NoContextGLApi::glDeleteFencesAPPLEFn(GLsizei n, const GLuint* fences) { - NOTREACHED() - << "Trying to call glDeleteFencesAPPLE() without current GL context"; - LOG(ERROR) - << "Trying to call glDeleteFencesAPPLE() without current GL context"; -} - -void NoContextGLApi::glDeleteFencesNVFn(GLsizei n, const GLuint* fences) { - NOTREACHED() - << "Trying to call glDeleteFencesNV() without current GL context"; - LOG(ERROR) << "Trying to call glDeleteFencesNV() without current GL context"; -} - -void NoContextGLApi::glDeleteFramebuffersEXTFn(GLsizei n, - const GLuint* framebuffers) { - NOTREACHED() - << "Trying to call glDeleteFramebuffersEXT() without current GL context"; - LOG(ERROR) - << "Trying to call glDeleteFramebuffersEXT() without current GL context"; -} - -void NoContextGLApi::glDeleteProgramFn(GLuint program) { - NOTREACHED() << "Trying to call glDeleteProgram() without current GL context"; - LOG(ERROR) << "Trying to call glDeleteProgram() without current GL context"; -} - -void NoContextGLApi::glDeleteQueriesFn(GLsizei n, const GLuint* ids) { - NOTREACHED() << "Trying to call glDeleteQueries() without current GL context"; - LOG(ERROR) << "Trying to call glDeleteQueries() without current GL context"; -} - -void NoContextGLApi::glDeleteRenderbuffersEXTFn(GLsizei n, - const GLuint* renderbuffers) { - NOTREACHED() - << "Trying to call glDeleteRenderbuffersEXT() without current GL context"; - LOG(ERROR) - << "Trying to call glDeleteRenderbuffersEXT() without current GL context"; -} - -void NoContextGLApi::glDeleteSamplersFn(GLsizei n, const GLuint* samplers) { - NOTREACHED() - << "Trying to call glDeleteSamplers() without current GL context"; - LOG(ERROR) << "Trying to call glDeleteSamplers() without current GL context"; -} - -void NoContextGLApi::glDeleteShaderFn(GLuint shader) { - NOTREACHED() << "Trying to call glDeleteShader() without current GL context"; - LOG(ERROR) << "Trying to call glDeleteShader() without current GL context"; -} - -void NoContextGLApi::glDeleteSyncFn(GLsync sync) { - NOTREACHED() << "Trying to call glDeleteSync() without current GL context"; - LOG(ERROR) << "Trying to call glDeleteSync() without current GL context"; -} - -void NoContextGLApi::glDeleteTexturesFn(GLsizei n, const GLuint* textures) { - NOTREACHED() - << "Trying to call glDeleteTextures() without current GL context"; - LOG(ERROR) << "Trying to call glDeleteTextures() without current GL context"; -} - -void NoContextGLApi::glDeleteTransformFeedbacksFn(GLsizei n, - const GLuint* ids) { - NOTREACHED() << "Trying to call glDeleteTransformFeedbacks() without current " - "GL context"; - LOG(ERROR) << "Trying to call glDeleteTransformFeedbacks() without current " - "GL context"; -} - -void NoContextGLApi::glDeleteVertexArraysOESFn(GLsizei n, - const GLuint* arrays) { - NOTREACHED() - << "Trying to call glDeleteVertexArraysOES() without current GL context"; - LOG(ERROR) - << "Trying to call glDeleteVertexArraysOES() without current GL context"; -} - -void NoContextGLApi::glDepthFuncFn(GLenum func) { - NOTREACHED() << "Trying to call glDepthFunc() without current GL context"; - LOG(ERROR) << "Trying to call glDepthFunc() without current GL context"; -} - -void NoContextGLApi::glDepthMaskFn(GLboolean flag) { - NOTREACHED() << "Trying to call glDepthMask() without current GL context"; - LOG(ERROR) << "Trying to call glDepthMask() without current GL context"; -} - -void NoContextGLApi::glDepthRangeFn(GLclampd zNear, GLclampd zFar) { - NOTREACHED() << "Trying to call glDepthRange() without current GL context"; - LOG(ERROR) << "Trying to call glDepthRange() without current GL context"; -} - -void NoContextGLApi::glDepthRangefFn(GLclampf zNear, GLclampf zFar) { - NOTREACHED() << "Trying to call glDepthRangef() without current GL context"; - LOG(ERROR) << "Trying to call glDepthRangef() without current GL context"; -} - -void NoContextGLApi::glDetachShaderFn(GLuint program, GLuint shader) { - NOTREACHED() << "Trying to call glDetachShader() without current GL context"; - LOG(ERROR) << "Trying to call glDetachShader() without current GL context"; -} - -void NoContextGLApi::glDisableFn(GLenum cap) { - NOTREACHED() << "Trying to call glDisable() without current GL context"; - LOG(ERROR) << "Trying to call glDisable() without current GL context"; -} - -void NoContextGLApi::glDisableVertexAttribArrayFn(GLuint index) { - NOTREACHED() << "Trying to call glDisableVertexAttribArray() without current " - "GL context"; - LOG(ERROR) << "Trying to call glDisableVertexAttribArray() without current " - "GL context"; -} - -void NoContextGLApi::glDiscardFramebufferEXTFn(GLenum target, - GLsizei numAttachments, - const GLenum* attachments) { - NOTREACHED() - << "Trying to call glDiscardFramebufferEXT() without current GL context"; - LOG(ERROR) - << "Trying to call glDiscardFramebufferEXT() without current GL context"; -} - -void NoContextGLApi::glDrawArraysFn(GLenum mode, GLint first, GLsizei count) { - NOTREACHED() << "Trying to call glDrawArrays() without current GL context"; - LOG(ERROR) << "Trying to call glDrawArrays() without current GL context"; -} - -void NoContextGLApi::glDrawArraysInstancedANGLEFn(GLenum mode, - GLint first, - GLsizei count, - GLsizei primcount) { - NOTREACHED() << "Trying to call glDrawArraysInstancedANGLE() without current " - "GL context"; - LOG(ERROR) << "Trying to call glDrawArraysInstancedANGLE() without current " - "GL context"; -} - -void NoContextGLApi::glDrawBufferFn(GLenum mode) { - NOTREACHED() << "Trying to call glDrawBuffer() without current GL context"; - LOG(ERROR) << "Trying to call glDrawBuffer() without current GL context"; -} - -void NoContextGLApi::glDrawBuffersARBFn(GLsizei n, const GLenum* bufs) { - NOTREACHED() - << "Trying to call glDrawBuffersARB() without current GL context"; - LOG(ERROR) << "Trying to call glDrawBuffersARB() without current GL context"; -} - -void NoContextGLApi::glDrawElementsFn(GLenum mode, - GLsizei count, - GLenum type, - const void* indices) { - NOTREACHED() << "Trying to call glDrawElements() without current GL context"; - LOG(ERROR) << "Trying to call glDrawElements() without current GL context"; -} - -void NoContextGLApi::glDrawElementsInstancedANGLEFn(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei primcount) { - NOTREACHED() << "Trying to call glDrawElementsInstancedANGLE() without " - "current GL context"; - LOG(ERROR) << "Trying to call glDrawElementsInstancedANGLE() without current " - "GL context"; -} - -void NoContextGLApi::glDrawRangeElementsFn(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices) { - NOTREACHED() - << "Trying to call glDrawRangeElements() without current GL context"; - LOG(ERROR) - << "Trying to call glDrawRangeElements() without current GL context"; -} - -void NoContextGLApi::glEGLImageTargetRenderbufferStorageOESFn( - GLenum target, - GLeglImageOES image) { - NOTREACHED() << "Trying to call glEGLImageTargetRenderbufferStorageOES() " - "without current GL context"; - LOG(ERROR) << "Trying to call glEGLImageTargetRenderbufferStorageOES() " - "without current GL context"; -} - -void NoContextGLApi::glEGLImageTargetTexture2DOESFn(GLenum target, - GLeglImageOES image) { - NOTREACHED() << "Trying to call glEGLImageTargetTexture2DOES() without " - "current GL context"; - LOG(ERROR) << "Trying to call glEGLImageTargetTexture2DOES() without current " - "GL context"; -} - -void NoContextGLApi::glEnableFn(GLenum cap) { - NOTREACHED() << "Trying to call glEnable() without current GL context"; - LOG(ERROR) << "Trying to call glEnable() without current GL context"; -} - -void NoContextGLApi::glEnableVertexAttribArrayFn(GLuint index) { - NOTREACHED() << "Trying to call glEnableVertexAttribArray() without current " - "GL context"; - LOG(ERROR) << "Trying to call glEnableVertexAttribArray() without current GL " - "context"; -} - -void NoContextGLApi::glEndQueryFn(GLenum target) { - NOTREACHED() << "Trying to call glEndQuery() without current GL context"; - LOG(ERROR) << "Trying to call glEndQuery() without current GL context"; -} - -void NoContextGLApi::glEndTransformFeedbackFn(void) { - NOTREACHED() - << "Trying to call glEndTransformFeedback() without current GL context"; - LOG(ERROR) - << "Trying to call glEndTransformFeedback() without current GL context"; -} - -GLsync NoContextGLApi::glFenceSyncFn(GLenum condition, GLbitfield flags) { - NOTREACHED() << "Trying to call glFenceSync() without current GL context"; - LOG(ERROR) << "Trying to call glFenceSync() without current GL context"; - return NULL; -} - -void NoContextGLApi::glFinishFn(void) { - NOTREACHED() << "Trying to call glFinish() without current GL context"; - LOG(ERROR) << "Trying to call glFinish() without current GL context"; -} - -void NoContextGLApi::glFinishFenceAPPLEFn(GLuint fence) { - NOTREACHED() - << "Trying to call glFinishFenceAPPLE() without current GL context"; - LOG(ERROR) - << "Trying to call glFinishFenceAPPLE() without current GL context"; -} - -void NoContextGLApi::glFinishFenceNVFn(GLuint fence) { - NOTREACHED() << "Trying to call glFinishFenceNV() without current GL context"; - LOG(ERROR) << "Trying to call glFinishFenceNV() without current GL context"; -} - -void NoContextGLApi::glFlushFn(void) { - NOTREACHED() << "Trying to call glFlush() without current GL context"; - LOG(ERROR) << "Trying to call glFlush() without current GL context"; -} - -void NoContextGLApi::glFlushMappedBufferRangeFn(GLenum target, - GLintptr offset, - GLsizeiptr length) { - NOTREACHED() - << "Trying to call glFlushMappedBufferRange() without current GL context"; - LOG(ERROR) - << "Trying to call glFlushMappedBufferRange() without current GL context"; -} - -void NoContextGLApi::glFramebufferRenderbufferEXTFn(GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer) { - NOTREACHED() << "Trying to call glFramebufferRenderbufferEXT() without " - "current GL context"; - LOG(ERROR) << "Trying to call glFramebufferRenderbufferEXT() without current " - "GL context"; -} - -void NoContextGLApi::glFramebufferTexture2DEXTFn(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level) { - NOTREACHED() << "Trying to call glFramebufferTexture2DEXT() without current " - "GL context"; - LOG(ERROR) << "Trying to call glFramebufferTexture2DEXT() without current GL " - "context"; -} - -void NoContextGLApi::glFramebufferTexture2DMultisampleEXTFn(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples) { - NOTREACHED() << "Trying to call glFramebufferTexture2DMultisampleEXT() " - "without current GL context"; - LOG(ERROR) << "Trying to call glFramebufferTexture2DMultisampleEXT() without " - "current GL context"; -} - -void NoContextGLApi::glFramebufferTexture2DMultisampleIMGFn(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples) { - NOTREACHED() << "Trying to call glFramebufferTexture2DMultisampleIMG() " - "without current GL context"; - LOG(ERROR) << "Trying to call glFramebufferTexture2DMultisampleIMG() without " - "current GL context"; -} - -void NoContextGLApi::glFramebufferTextureLayerFn(GLenum target, - GLenum attachment, - GLuint texture, - GLint level, - GLint layer) { - NOTREACHED() << "Trying to call glFramebufferTextureLayer() without current " - "GL context"; - LOG(ERROR) << "Trying to call glFramebufferTextureLayer() without current GL " - "context"; -} - -void NoContextGLApi::glFrontFaceFn(GLenum mode) { - NOTREACHED() << "Trying to call glFrontFace() without current GL context"; - LOG(ERROR) << "Trying to call glFrontFace() without current GL context"; -} - -void NoContextGLApi::glGenBuffersARBFn(GLsizei n, GLuint* buffers) { - NOTREACHED() << "Trying to call glGenBuffersARB() without current GL context"; - LOG(ERROR) << "Trying to call glGenBuffersARB() without current GL context"; -} - -void NoContextGLApi::glGenerateMipmapEXTFn(GLenum target) { - NOTREACHED() - << "Trying to call glGenerateMipmapEXT() without current GL context"; - LOG(ERROR) - << "Trying to call glGenerateMipmapEXT() without current GL context"; -} - -void NoContextGLApi::glGenFencesAPPLEFn(GLsizei n, GLuint* fences) { - NOTREACHED() - << "Trying to call glGenFencesAPPLE() without current GL context"; - LOG(ERROR) << "Trying to call glGenFencesAPPLE() without current GL context"; -} - -void NoContextGLApi::glGenFencesNVFn(GLsizei n, GLuint* fences) { - NOTREACHED() << "Trying to call glGenFencesNV() without current GL context"; - LOG(ERROR) << "Trying to call glGenFencesNV() without current GL context"; -} - -void NoContextGLApi::glGenFramebuffersEXTFn(GLsizei n, GLuint* framebuffers) { - NOTREACHED() - << "Trying to call glGenFramebuffersEXT() without current GL context"; - LOG(ERROR) - << "Trying to call glGenFramebuffersEXT() without current GL context"; -} - -void NoContextGLApi::glGenQueriesFn(GLsizei n, GLuint* ids) { - NOTREACHED() << "Trying to call glGenQueries() without current GL context"; - LOG(ERROR) << "Trying to call glGenQueries() without current GL context"; -} - -void NoContextGLApi::glGenRenderbuffersEXTFn(GLsizei n, GLuint* renderbuffers) { - NOTREACHED() - << "Trying to call glGenRenderbuffersEXT() without current GL context"; - LOG(ERROR) - << "Trying to call glGenRenderbuffersEXT() without current GL context"; -} - -void NoContextGLApi::glGenSamplersFn(GLsizei n, GLuint* samplers) { - NOTREACHED() << "Trying to call glGenSamplers() without current GL context"; - LOG(ERROR) << "Trying to call glGenSamplers() without current GL context"; -} - -void NoContextGLApi::glGenTexturesFn(GLsizei n, GLuint* textures) { - NOTREACHED() << "Trying to call glGenTextures() without current GL context"; - LOG(ERROR) << "Trying to call glGenTextures() without current GL context"; -} - -void NoContextGLApi::glGenTransformFeedbacksFn(GLsizei n, GLuint* ids) { - NOTREACHED() - << "Trying to call glGenTransformFeedbacks() without current GL context"; - LOG(ERROR) - << "Trying to call glGenTransformFeedbacks() without current GL context"; -} - -void NoContextGLApi::glGenVertexArraysOESFn(GLsizei n, GLuint* arrays) { - NOTREACHED() - << "Trying to call glGenVertexArraysOES() without current GL context"; - LOG(ERROR) - << "Trying to call glGenVertexArraysOES() without current GL context"; -} - -void NoContextGLApi::glGetActiveAttribFn(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - char* name) { - NOTREACHED() - << "Trying to call glGetActiveAttrib() without current GL context"; - LOG(ERROR) << "Trying to call glGetActiveAttrib() without current GL context"; -} - -void NoContextGLApi::glGetActiveUniformFn(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - char* name) { - NOTREACHED() - << "Trying to call glGetActiveUniform() without current GL context"; - LOG(ERROR) - << "Trying to call glGetActiveUniform() without current GL context"; -} - -void NoContextGLApi::glGetActiveUniformBlockivFn(GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint* params) { - NOTREACHED() << "Trying to call glGetActiveUniformBlockiv() without current " - "GL context"; - LOG(ERROR) << "Trying to call glGetActiveUniformBlockiv() without current GL " - "context"; -} - -void NoContextGLApi::glGetActiveUniformBlockNameFn(GLuint program, - GLuint uniformBlockIndex, - GLsizei bufSize, - GLsizei* length, - char* uniformBlockName) { - NOTREACHED() << "Trying to call glGetActiveUniformBlockName() without " - "current GL context"; - LOG(ERROR) << "Trying to call glGetActiveUniformBlockName() without current " - "GL context"; -} - -void NoContextGLApi::glGetActiveUniformsivFn(GLuint program, - GLsizei uniformCount, - const GLuint* uniformIndices, - GLenum pname, - GLint* params) { - NOTREACHED() - << "Trying to call glGetActiveUniformsiv() without current GL context"; - LOG(ERROR) - << "Trying to call glGetActiveUniformsiv() without current GL context"; -} - -void NoContextGLApi::glGetAttachedShadersFn(GLuint program, - GLsizei maxcount, - GLsizei* count, - GLuint* shaders) { - NOTREACHED() - << "Trying to call glGetAttachedShaders() without current GL context"; - LOG(ERROR) - << "Trying to call glGetAttachedShaders() without current GL context"; -} - -GLint NoContextGLApi::glGetAttribLocationFn(GLuint program, const char* name) { - NOTREACHED() - << "Trying to call glGetAttribLocation() without current GL context"; - LOG(ERROR) - << "Trying to call glGetAttribLocation() without current GL context"; - return 0; -} - -void NoContextGLApi::glGetBooleanvFn(GLenum pname, GLboolean* params) { - NOTREACHED() << "Trying to call glGetBooleanv() without current GL context"; - LOG(ERROR) << "Trying to call glGetBooleanv() without current GL context"; -} - -void NoContextGLApi::glGetBufferParameterivFn(GLenum target, - GLenum pname, - GLint* params) { - NOTREACHED() - << "Trying to call glGetBufferParameteriv() without current GL context"; - LOG(ERROR) - << "Trying to call glGetBufferParameteriv() without current GL context"; -} - -GLuint NoContextGLApi::glGetDebugMessageLogKHRFn(GLuint count, - GLsizei bufSize, - GLenum* sources, - GLenum* types, - GLuint* ids, - GLenum* severities, - GLsizei* lengths, - GLchar* messageLog) { - NOTREACHED() - << "Trying to call glGetDebugMessageLogKHR() without current GL context"; - LOG(ERROR) - << "Trying to call glGetDebugMessageLogKHR() without current GL context"; - return 0U; -} - -GLenum NoContextGLApi::glGetErrorFn(void) { - NOTREACHED() << "Trying to call glGetError() without current GL context"; - LOG(ERROR) << "Trying to call glGetError() without current GL context"; - return static_cast(0); -} - -void NoContextGLApi::glGetFenceivNVFn(GLuint fence, - GLenum pname, - GLint* params) { - NOTREACHED() << "Trying to call glGetFenceivNV() without current GL context"; - LOG(ERROR) << "Trying to call glGetFenceivNV() without current GL context"; -} - -void NoContextGLApi::glGetFloatvFn(GLenum pname, GLfloat* params) { - NOTREACHED() << "Trying to call glGetFloatv() without current GL context"; - LOG(ERROR) << "Trying to call glGetFloatv() without current GL context"; -} - -GLint NoContextGLApi::glGetFragDataLocationFn(GLuint program, - const char* name) { - NOTREACHED() - << "Trying to call glGetFragDataLocation() without current GL context"; - LOG(ERROR) - << "Trying to call glGetFragDataLocation() without current GL context"; - return 0; -} - -void NoContextGLApi::glGetFramebufferAttachmentParameterivEXTFn( - GLenum target, - GLenum attachment, - GLenum pname, - GLint* params) { - NOTREACHED() << "Trying to call glGetFramebufferAttachmentParameterivEXT() " - "without current GL context"; - LOG(ERROR) << "Trying to call glGetFramebufferAttachmentParameterivEXT() " - "without current GL context"; -} - -GLenum NoContextGLApi::glGetGraphicsResetStatusARBFn(void) { - NOTREACHED() << "Trying to call glGetGraphicsResetStatusARB() without " - "current GL context"; - LOG(ERROR) << "Trying to call glGetGraphicsResetStatusARB() without current " - "GL context"; - return static_cast(0); -} - -void NoContextGLApi::glGetInteger64i_vFn(GLenum target, - GLuint index, - GLint64* data) { - NOTREACHED() - << "Trying to call glGetInteger64i_v() without current GL context"; - LOG(ERROR) << "Trying to call glGetInteger64i_v() without current GL context"; -} - -void NoContextGLApi::glGetInteger64vFn(GLenum pname, GLint64* params) { - NOTREACHED() << "Trying to call glGetInteger64v() without current GL context"; - LOG(ERROR) << "Trying to call glGetInteger64v() without current GL context"; -} - -void NoContextGLApi::glGetIntegeri_vFn(GLenum target, - GLuint index, - GLint* data) { - NOTREACHED() << "Trying to call glGetIntegeri_v() without current GL context"; - LOG(ERROR) << "Trying to call glGetIntegeri_v() without current GL context"; -} - -void NoContextGLApi::glGetIntegervFn(GLenum pname, GLint* params) { - NOTREACHED() << "Trying to call glGetIntegerv() without current GL context"; - LOG(ERROR) << "Trying to call glGetIntegerv() without current GL context"; -} - -void NoContextGLApi::glGetInternalformativFn(GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLint* params) { - NOTREACHED() - << "Trying to call glGetInternalformativ() without current GL context"; - LOG(ERROR) - << "Trying to call glGetInternalformativ() without current GL context"; -} - -void NoContextGLApi::glGetProgramBinaryFn(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - GLvoid* binary) { - NOTREACHED() - << "Trying to call glGetProgramBinary() without current GL context"; - LOG(ERROR) - << "Trying to call glGetProgramBinary() without current GL context"; -} - -void NoContextGLApi::glGetProgramInfoLogFn(GLuint program, - GLsizei bufsize, - GLsizei* length, - char* infolog) { - NOTREACHED() - << "Trying to call glGetProgramInfoLog() without current GL context"; - LOG(ERROR) - << "Trying to call glGetProgramInfoLog() without current GL context"; -} - -void NoContextGLApi::glGetProgramivFn(GLuint program, - GLenum pname, - GLint* params) { - NOTREACHED() << "Trying to call glGetProgramiv() without current GL context"; - LOG(ERROR) << "Trying to call glGetProgramiv() without current GL context"; -} - -GLint NoContextGLApi::glGetProgramResourceLocationFn(GLuint program, - GLenum programInterface, - const char* name) { - NOTREACHED() << "Trying to call glGetProgramResourceLocation() without " - "current GL context"; - LOG(ERROR) << "Trying to call glGetProgramResourceLocation() without current " - "GL context"; - return 0; -} - -void NoContextGLApi::glGetQueryivFn(GLenum target, - GLenum pname, - GLint* params) { - NOTREACHED() << "Trying to call glGetQueryiv() without current GL context"; - LOG(ERROR) << "Trying to call glGetQueryiv() without current GL context"; -} - -void NoContextGLApi::glGetQueryObjecti64vFn(GLuint id, - GLenum pname, - GLint64* params) { - NOTREACHED() - << "Trying to call glGetQueryObjecti64v() without current GL context"; - LOG(ERROR) - << "Trying to call glGetQueryObjecti64v() without current GL context"; -} - -void NoContextGLApi::glGetQueryObjectivFn(GLuint id, - GLenum pname, - GLint* params) { - NOTREACHED() - << "Trying to call glGetQueryObjectiv() without current GL context"; - LOG(ERROR) - << "Trying to call glGetQueryObjectiv() without current GL context"; -} - -void NoContextGLApi::glGetQueryObjectui64vFn(GLuint id, - GLenum pname, - GLuint64* params) { - NOTREACHED() - << "Trying to call glGetQueryObjectui64v() without current GL context"; - LOG(ERROR) - << "Trying to call glGetQueryObjectui64v() without current GL context"; -} - -void NoContextGLApi::glGetQueryObjectuivFn(GLuint id, - GLenum pname, - GLuint* params) { - NOTREACHED() - << "Trying to call glGetQueryObjectuiv() without current GL context"; - LOG(ERROR) - << "Trying to call glGetQueryObjectuiv() without current GL context"; -} - -void NoContextGLApi::glGetRenderbufferParameterivEXTFn(GLenum target, - GLenum pname, - GLint* params) { - NOTREACHED() << "Trying to call glGetRenderbufferParameterivEXT() without " - "current GL context"; - LOG(ERROR) << "Trying to call glGetRenderbufferParameterivEXT() without " - "current GL context"; -} - -void NoContextGLApi::glGetSamplerParameterfvFn(GLuint sampler, - GLenum pname, - GLfloat* params) { - NOTREACHED() - << "Trying to call glGetSamplerParameterfv() without current GL context"; - LOG(ERROR) - << "Trying to call glGetSamplerParameterfv() without current GL context"; -} - -void NoContextGLApi::glGetSamplerParameterivFn(GLuint sampler, - GLenum pname, - GLint* params) { - NOTREACHED() - << "Trying to call glGetSamplerParameteriv() without current GL context"; - LOG(ERROR) - << "Trying to call glGetSamplerParameteriv() without current GL context"; -} - -void NoContextGLApi::glGetShaderInfoLogFn(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* infolog) { - NOTREACHED() - << "Trying to call glGetShaderInfoLog() without current GL context"; - LOG(ERROR) - << "Trying to call glGetShaderInfoLog() without current GL context"; -} - -void NoContextGLApi::glGetShaderivFn(GLuint shader, - GLenum pname, - GLint* params) { - NOTREACHED() << "Trying to call glGetShaderiv() without current GL context"; - LOG(ERROR) << "Trying to call glGetShaderiv() without current GL context"; -} - -void NoContextGLApi::glGetShaderPrecisionFormatFn(GLenum shadertype, - GLenum precisiontype, - GLint* range, - GLint* precision) { - NOTREACHED() << "Trying to call glGetShaderPrecisionFormat() without current " - "GL context"; - LOG(ERROR) << "Trying to call glGetShaderPrecisionFormat() without current " - "GL context"; -} - -void NoContextGLApi::glGetShaderSourceFn(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* source) { - NOTREACHED() - << "Trying to call glGetShaderSource() without current GL context"; - LOG(ERROR) << "Trying to call glGetShaderSource() without current GL context"; -} - -const GLubyte* NoContextGLApi::glGetStringFn(GLenum name) { - NOTREACHED() << "Trying to call glGetString() without current GL context"; - LOG(ERROR) << "Trying to call glGetString() without current GL context"; - return NULL; -} - -const GLubyte* NoContextGLApi::glGetStringiFn(GLenum name, GLuint index) { - NOTREACHED() << "Trying to call glGetStringi() without current GL context"; - LOG(ERROR) << "Trying to call glGetStringi() without current GL context"; - return NULL; -} - -void NoContextGLApi::glGetSyncivFn(GLsync sync, - GLenum pname, - GLsizei bufSize, - GLsizei* length, - GLint* values) { - NOTREACHED() << "Trying to call glGetSynciv() without current GL context"; - LOG(ERROR) << "Trying to call glGetSynciv() without current GL context"; -} - -void NoContextGLApi::glGetTexLevelParameterfvFn(GLenum target, - GLint level, - GLenum pname, - GLfloat* params) { - NOTREACHED() - << "Trying to call glGetTexLevelParameterfv() without current GL context"; - LOG(ERROR) - << "Trying to call glGetTexLevelParameterfv() without current GL context"; -} - -void NoContextGLApi::glGetTexLevelParameterivFn(GLenum target, - GLint level, - GLenum pname, - GLint* params) { - NOTREACHED() - << "Trying to call glGetTexLevelParameteriv() without current GL context"; - LOG(ERROR) - << "Trying to call glGetTexLevelParameteriv() without current GL context"; -} - -void NoContextGLApi::glGetTexParameterfvFn(GLenum target, - GLenum pname, - GLfloat* params) { - NOTREACHED() - << "Trying to call glGetTexParameterfv() without current GL context"; - LOG(ERROR) - << "Trying to call glGetTexParameterfv() without current GL context"; -} - -void NoContextGLApi::glGetTexParameterivFn(GLenum target, - GLenum pname, - GLint* params) { - NOTREACHED() - << "Trying to call glGetTexParameteriv() without current GL context"; - LOG(ERROR) - << "Trying to call glGetTexParameteriv() without current GL context"; -} - -void NoContextGLApi::glGetTransformFeedbackVaryingFn(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLsizei* size, - GLenum* type, - char* name) { - NOTREACHED() << "Trying to call glGetTransformFeedbackVarying() without " - "current GL context"; - LOG(ERROR) << "Trying to call glGetTransformFeedbackVarying() without " - "current GL context"; -} - -void NoContextGLApi::glGetTranslatedShaderSourceANGLEFn(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* source) { - NOTREACHED() << "Trying to call glGetTranslatedShaderSourceANGLE() without " - "current GL context"; - LOG(ERROR) << "Trying to call glGetTranslatedShaderSourceANGLE() without " - "current GL context"; -} - -GLuint NoContextGLApi::glGetUniformBlockIndexFn(GLuint program, - const char* uniformBlockName) { - NOTREACHED() - << "Trying to call glGetUniformBlockIndex() without current GL context"; - LOG(ERROR) - << "Trying to call glGetUniformBlockIndex() without current GL context"; - return 0U; -} - -void NoContextGLApi::glGetUniformfvFn(GLuint program, - GLint location, - GLfloat* params) { - NOTREACHED() << "Trying to call glGetUniformfv() without current GL context"; - LOG(ERROR) << "Trying to call glGetUniformfv() without current GL context"; -} - -void NoContextGLApi::glGetUniformIndicesFn(GLuint program, - GLsizei uniformCount, - const char* const* uniformNames, - GLuint* uniformIndices) { - NOTREACHED() - << "Trying to call glGetUniformIndices() without current GL context"; - LOG(ERROR) - << "Trying to call glGetUniformIndices() without current GL context"; -} - -void NoContextGLApi::glGetUniformivFn(GLuint program, - GLint location, - GLint* params) { - NOTREACHED() << "Trying to call glGetUniformiv() without current GL context"; - LOG(ERROR) << "Trying to call glGetUniformiv() without current GL context"; -} - -GLint NoContextGLApi::glGetUniformLocationFn(GLuint program, const char* name) { - NOTREACHED() - << "Trying to call glGetUniformLocation() without current GL context"; - LOG(ERROR) - << "Trying to call glGetUniformLocation() without current GL context"; - return 0; -} - -void NoContextGLApi::glGetVertexAttribfvFn(GLuint index, - GLenum pname, - GLfloat* params) { - NOTREACHED() - << "Trying to call glGetVertexAttribfv() without current GL context"; - LOG(ERROR) - << "Trying to call glGetVertexAttribfv() without current GL context"; -} - -void NoContextGLApi::glGetVertexAttribivFn(GLuint index, - GLenum pname, - GLint* params) { - NOTREACHED() - << "Trying to call glGetVertexAttribiv() without current GL context"; - LOG(ERROR) - << "Trying to call glGetVertexAttribiv() without current GL context"; -} - -void NoContextGLApi::glGetVertexAttribPointervFn(GLuint index, - GLenum pname, - void** pointer) { - NOTREACHED() << "Trying to call glGetVertexAttribPointerv() without current " - "GL context"; - LOG(ERROR) << "Trying to call glGetVertexAttribPointerv() without current GL " - "context"; -} - -void NoContextGLApi::glHintFn(GLenum target, GLenum mode) { - NOTREACHED() << "Trying to call glHint() without current GL context"; - LOG(ERROR) << "Trying to call glHint() without current GL context"; -} - -void NoContextGLApi::glInsertEventMarkerEXTFn(GLsizei length, - const char* marker) { - NOTREACHED() - << "Trying to call glInsertEventMarkerEXT() without current GL context"; - LOG(ERROR) - << "Trying to call glInsertEventMarkerEXT() without current GL context"; -} - -void NoContextGLApi::glInvalidateFramebufferFn(GLenum target, - GLsizei numAttachments, - const GLenum* attachments) { - NOTREACHED() - << "Trying to call glInvalidateFramebuffer() without current GL context"; - LOG(ERROR) - << "Trying to call glInvalidateFramebuffer() without current GL context"; -} - -void NoContextGLApi::glInvalidateSubFramebufferFn(GLenum target, - GLsizei numAttachments, - const GLenum* attachments, - GLint x, - GLint y, - GLint width, - GLint height) { - NOTREACHED() << "Trying to call glInvalidateSubFramebuffer() without current " - "GL context"; - LOG(ERROR) << "Trying to call glInvalidateSubFramebuffer() without current " - "GL context"; -} - -GLboolean NoContextGLApi::glIsBufferFn(GLuint buffer) { - NOTREACHED() << "Trying to call glIsBuffer() without current GL context"; - LOG(ERROR) << "Trying to call glIsBuffer() without current GL context"; - return GL_FALSE; -} - -GLboolean NoContextGLApi::glIsEnabledFn(GLenum cap) { - NOTREACHED() << "Trying to call glIsEnabled() without current GL context"; - LOG(ERROR) << "Trying to call glIsEnabled() without current GL context"; - return GL_FALSE; -} - -GLboolean NoContextGLApi::glIsFenceAPPLEFn(GLuint fence) { - NOTREACHED() << "Trying to call glIsFenceAPPLE() without current GL context"; - LOG(ERROR) << "Trying to call glIsFenceAPPLE() without current GL context"; - return GL_FALSE; -} - -GLboolean NoContextGLApi::glIsFenceNVFn(GLuint fence) { - NOTREACHED() << "Trying to call glIsFenceNV() without current GL context"; - LOG(ERROR) << "Trying to call glIsFenceNV() without current GL context"; - return GL_FALSE; -} - -GLboolean NoContextGLApi::glIsFramebufferEXTFn(GLuint framebuffer) { - NOTREACHED() - << "Trying to call glIsFramebufferEXT() without current GL context"; - LOG(ERROR) - << "Trying to call glIsFramebufferEXT() without current GL context"; - return GL_FALSE; -} - -GLboolean NoContextGLApi::glIsProgramFn(GLuint program) { - NOTREACHED() << "Trying to call glIsProgram() without current GL context"; - LOG(ERROR) << "Trying to call glIsProgram() without current GL context"; - return GL_FALSE; -} - -GLboolean NoContextGLApi::glIsQueryFn(GLuint query) { - NOTREACHED() << "Trying to call glIsQuery() without current GL context"; - LOG(ERROR) << "Trying to call glIsQuery() without current GL context"; - return GL_FALSE; -} - -GLboolean NoContextGLApi::glIsRenderbufferEXTFn(GLuint renderbuffer) { - NOTREACHED() - << "Trying to call glIsRenderbufferEXT() without current GL context"; - LOG(ERROR) - << "Trying to call glIsRenderbufferEXT() without current GL context"; - return GL_FALSE; -} - -GLboolean NoContextGLApi::glIsSamplerFn(GLuint sampler) { - NOTREACHED() << "Trying to call glIsSampler() without current GL context"; - LOG(ERROR) << "Trying to call glIsSampler() without current GL context"; - return GL_FALSE; -} - -GLboolean NoContextGLApi::glIsShaderFn(GLuint shader) { - NOTREACHED() << "Trying to call glIsShader() without current GL context"; - LOG(ERROR) << "Trying to call glIsShader() without current GL context"; - return GL_FALSE; -} - -GLboolean NoContextGLApi::glIsSyncFn(GLsync sync) { - NOTREACHED() << "Trying to call glIsSync() without current GL context"; - LOG(ERROR) << "Trying to call glIsSync() without current GL context"; - return GL_FALSE; -} - -GLboolean NoContextGLApi::glIsTextureFn(GLuint texture) { - NOTREACHED() << "Trying to call glIsTexture() without current GL context"; - LOG(ERROR) << "Trying to call glIsTexture() without current GL context"; - return GL_FALSE; -} - -GLboolean NoContextGLApi::glIsTransformFeedbackFn(GLuint id) { - NOTREACHED() - << "Trying to call glIsTransformFeedback() without current GL context"; - LOG(ERROR) - << "Trying to call glIsTransformFeedback() without current GL context"; - return GL_FALSE; -} - -GLboolean NoContextGLApi::glIsVertexArrayOESFn(GLuint array) { - NOTREACHED() - << "Trying to call glIsVertexArrayOES() without current GL context"; - LOG(ERROR) - << "Trying to call glIsVertexArrayOES() without current GL context"; - return GL_FALSE; -} - -void NoContextGLApi::glLineWidthFn(GLfloat width) { - NOTREACHED() << "Trying to call glLineWidth() without current GL context"; - LOG(ERROR) << "Trying to call glLineWidth() without current GL context"; -} - -void NoContextGLApi::glLinkProgramFn(GLuint program) { - NOTREACHED() << "Trying to call glLinkProgram() without current GL context"; - LOG(ERROR) << "Trying to call glLinkProgram() without current GL context"; -} - -void* NoContextGLApi::glMapBufferFn(GLenum target, GLenum access) { - NOTREACHED() << "Trying to call glMapBuffer() without current GL context"; - LOG(ERROR) << "Trying to call glMapBuffer() without current GL context"; - return NULL; -} - -void* NoContextGLApi::glMapBufferRangeFn(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access) { - NOTREACHED() - << "Trying to call glMapBufferRange() without current GL context"; - LOG(ERROR) << "Trying to call glMapBufferRange() without current GL context"; - return NULL; -} - -void NoContextGLApi::glMatrixLoadfEXTFn(GLenum matrixMode, const GLfloat* m) { - NOTREACHED() - << "Trying to call glMatrixLoadfEXT() without current GL context"; - LOG(ERROR) << "Trying to call glMatrixLoadfEXT() without current GL context"; -} - -void NoContextGLApi::glMatrixLoadIdentityEXTFn(GLenum matrixMode) { - NOTREACHED() - << "Trying to call glMatrixLoadIdentityEXT() without current GL context"; - LOG(ERROR) - << "Trying to call glMatrixLoadIdentityEXT() without current GL context"; -} - -void NoContextGLApi::glObjectLabelKHRFn(GLenum identifier, - GLuint name, - GLsizei length, - const GLchar* label) { - NOTREACHED() - << "Trying to call glObjectLabelKHR() without current GL context"; - LOG(ERROR) << "Trying to call glObjectLabelKHR() without current GL context"; -} - -void NoContextGLApi::glPauseTransformFeedbackFn(void) { - NOTREACHED() - << "Trying to call glPauseTransformFeedback() without current GL context"; - LOG(ERROR) - << "Trying to call glPauseTransformFeedback() without current GL context"; -} - -void NoContextGLApi::glPixelStoreiFn(GLenum pname, GLint param) { - NOTREACHED() << "Trying to call glPixelStorei() without current GL context"; - LOG(ERROR) << "Trying to call glPixelStorei() without current GL context"; -} - -void NoContextGLApi::glPointParameteriFn(GLenum pname, GLint param) { - NOTREACHED() - << "Trying to call glPointParameteri() without current GL context"; - LOG(ERROR) << "Trying to call glPointParameteri() without current GL context"; -} - -void NoContextGLApi::glPolygonOffsetFn(GLfloat factor, GLfloat units) { - NOTREACHED() << "Trying to call glPolygonOffset() without current GL context"; - LOG(ERROR) << "Trying to call glPolygonOffset() without current GL context"; -} - -void NoContextGLApi::glPopDebugGroupKHRFn(void) { - NOTREACHED() - << "Trying to call glPopDebugGroupKHR() without current GL context"; - LOG(ERROR) - << "Trying to call glPopDebugGroupKHR() without current GL context"; -} - -void NoContextGLApi::glPopGroupMarkerEXTFn(void) { - NOTREACHED() - << "Trying to call glPopGroupMarkerEXT() without current GL context"; - LOG(ERROR) - << "Trying to call glPopGroupMarkerEXT() without current GL context"; -} - -void NoContextGLApi::glProgramBinaryFn(GLuint program, - GLenum binaryFormat, - const GLvoid* binary, - GLsizei length) { - NOTREACHED() << "Trying to call glProgramBinary() without current GL context"; - LOG(ERROR) << "Trying to call glProgramBinary() without current GL context"; -} - -void NoContextGLApi::glProgramParameteriFn(GLuint program, - GLenum pname, - GLint value) { - NOTREACHED() - << "Trying to call glProgramParameteri() without current GL context"; - LOG(ERROR) - << "Trying to call glProgramParameteri() without current GL context"; -} - -void NoContextGLApi::glPushDebugGroupKHRFn(GLenum source, - GLuint id, - GLsizei length, - const GLchar* message) { - NOTREACHED() - << "Trying to call glPushDebugGroupKHR() without current GL context"; - LOG(ERROR) - << "Trying to call glPushDebugGroupKHR() without current GL context"; -} - -void NoContextGLApi::glPushGroupMarkerEXTFn(GLsizei length, - const char* marker) { - NOTREACHED() - << "Trying to call glPushGroupMarkerEXT() without current GL context"; - LOG(ERROR) - << "Trying to call glPushGroupMarkerEXT() without current GL context"; -} - -void NoContextGLApi::glQueryCounterFn(GLuint id, GLenum target) { - NOTREACHED() << "Trying to call glQueryCounter() without current GL context"; - LOG(ERROR) << "Trying to call glQueryCounter() without current GL context"; -} - -void NoContextGLApi::glReadBufferFn(GLenum src) { - NOTREACHED() << "Trying to call glReadBuffer() without current GL context"; - LOG(ERROR) << "Trying to call glReadBuffer() without current GL context"; -} - -void NoContextGLApi::glReadPixelsFn(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - void* pixels) { - NOTREACHED() << "Trying to call glReadPixels() without current GL context"; - LOG(ERROR) << "Trying to call glReadPixels() without current GL context"; -} - -void NoContextGLApi::glReleaseShaderCompilerFn(void) { - NOTREACHED() - << "Trying to call glReleaseShaderCompiler() without current GL context"; - LOG(ERROR) - << "Trying to call glReleaseShaderCompiler() without current GL context"; -} - -void NoContextGLApi::glRenderbufferStorageEXTFn(GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height) { - NOTREACHED() - << "Trying to call glRenderbufferStorageEXT() without current GL context"; - LOG(ERROR) - << "Trying to call glRenderbufferStorageEXT() without current GL context"; -} - -void NoContextGLApi::glRenderbufferStorageMultisampleFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - NOTREACHED() << "Trying to call glRenderbufferStorageMultisample() without " - "current GL context"; - LOG(ERROR) << "Trying to call glRenderbufferStorageMultisample() without " - "current GL context"; -} - -void NoContextGLApi::glRenderbufferStorageMultisampleANGLEFn( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - NOTREACHED() << "Trying to call glRenderbufferStorageMultisampleANGLE() " - "without current GL context"; - LOG(ERROR) << "Trying to call glRenderbufferStorageMultisampleANGLE() " - "without current GL context"; -} - -void NoContextGLApi::glRenderbufferStorageMultisampleAPPLEFn( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - NOTREACHED() << "Trying to call glRenderbufferStorageMultisampleAPPLE() " - "without current GL context"; - LOG(ERROR) << "Trying to call glRenderbufferStorageMultisampleAPPLE() " - "without current GL context"; -} - -void NoContextGLApi::glRenderbufferStorageMultisampleEXTFn( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - NOTREACHED() << "Trying to call glRenderbufferStorageMultisampleEXT() " - "without current GL context"; - LOG(ERROR) << "Trying to call glRenderbufferStorageMultisampleEXT() without " - "current GL context"; -} - -void NoContextGLApi::glRenderbufferStorageMultisampleIMGFn( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - NOTREACHED() << "Trying to call glRenderbufferStorageMultisampleIMG() " - "without current GL context"; - LOG(ERROR) << "Trying to call glRenderbufferStorageMultisampleIMG() without " - "current GL context"; -} - -void NoContextGLApi::glResolveMultisampleFramebufferAPPLEFn(void) { - NOTREACHED() << "Trying to call glResolveMultisampleFramebufferAPPLE() " - "without current GL context"; - LOG(ERROR) << "Trying to call glResolveMultisampleFramebufferAPPLE() without " - "current GL context"; -} - -void NoContextGLApi::glResumeTransformFeedbackFn(void) { - NOTREACHED() << "Trying to call glResumeTransformFeedback() without current " - "GL context"; - LOG(ERROR) << "Trying to call glResumeTransformFeedback() without current GL " - "context"; -} - -void NoContextGLApi::glSampleCoverageFn(GLclampf value, GLboolean invert) { - NOTREACHED() - << "Trying to call glSampleCoverage() without current GL context"; - LOG(ERROR) << "Trying to call glSampleCoverage() without current GL context"; -} - -void NoContextGLApi::glSamplerParameterfFn(GLuint sampler, - GLenum pname, - GLfloat param) { - NOTREACHED() - << "Trying to call glSamplerParameterf() without current GL context"; - LOG(ERROR) - << "Trying to call glSamplerParameterf() without current GL context"; -} - -void NoContextGLApi::glSamplerParameterfvFn(GLuint sampler, - GLenum pname, - const GLfloat* params) { - NOTREACHED() - << "Trying to call glSamplerParameterfv() without current GL context"; - LOG(ERROR) - << "Trying to call glSamplerParameterfv() without current GL context"; -} - -void NoContextGLApi::glSamplerParameteriFn(GLuint sampler, - GLenum pname, - GLint param) { - NOTREACHED() - << "Trying to call glSamplerParameteri() without current GL context"; - LOG(ERROR) - << "Trying to call glSamplerParameteri() without current GL context"; -} - -void NoContextGLApi::glSamplerParameterivFn(GLuint sampler, - GLenum pname, - const GLint* params) { - NOTREACHED() - << "Trying to call glSamplerParameteriv() without current GL context"; - LOG(ERROR) - << "Trying to call glSamplerParameteriv() without current GL context"; -} - -void NoContextGLApi::glScissorFn(GLint x, - GLint y, - GLsizei width, - GLsizei height) { - NOTREACHED() << "Trying to call glScissor() without current GL context"; - LOG(ERROR) << "Trying to call glScissor() without current GL context"; -} - -void NoContextGLApi::glSetFenceAPPLEFn(GLuint fence) { - NOTREACHED() << "Trying to call glSetFenceAPPLE() without current GL context"; - LOG(ERROR) << "Trying to call glSetFenceAPPLE() without current GL context"; -} - -void NoContextGLApi::glSetFenceNVFn(GLuint fence, GLenum condition) { - NOTREACHED() << "Trying to call glSetFenceNV() without current GL context"; - LOG(ERROR) << "Trying to call glSetFenceNV() without current GL context"; -} - -void NoContextGLApi::glShaderBinaryFn(GLsizei n, - const GLuint* shaders, - GLenum binaryformat, - const void* binary, - GLsizei length) { - NOTREACHED() << "Trying to call glShaderBinary() without current GL context"; - LOG(ERROR) << "Trying to call glShaderBinary() without current GL context"; -} - -void NoContextGLApi::glShaderSourceFn(GLuint shader, - GLsizei count, - const char* const* str, - const GLint* length) { - NOTREACHED() << "Trying to call glShaderSource() without current GL context"; - LOG(ERROR) << "Trying to call glShaderSource() without current GL context"; -} - -void NoContextGLApi::glStencilFuncFn(GLenum func, GLint ref, GLuint mask) { - NOTREACHED() << "Trying to call glStencilFunc() without current GL context"; - LOG(ERROR) << "Trying to call glStencilFunc() without current GL context"; -} - -void NoContextGLApi::glStencilFuncSeparateFn(GLenum face, - GLenum func, - GLint ref, - GLuint mask) { - NOTREACHED() - << "Trying to call glStencilFuncSeparate() without current GL context"; - LOG(ERROR) - << "Trying to call glStencilFuncSeparate() without current GL context"; -} - -void NoContextGLApi::glStencilMaskFn(GLuint mask) { - NOTREACHED() << "Trying to call glStencilMask() without current GL context"; - LOG(ERROR) << "Trying to call glStencilMask() without current GL context"; -} - -void NoContextGLApi::glStencilMaskSeparateFn(GLenum face, GLuint mask) { - NOTREACHED() - << "Trying to call glStencilMaskSeparate() without current GL context"; - LOG(ERROR) - << "Trying to call glStencilMaskSeparate() without current GL context"; -} - -void NoContextGLApi::glStencilOpFn(GLenum fail, GLenum zfail, GLenum zpass) { - NOTREACHED() << "Trying to call glStencilOp() without current GL context"; - LOG(ERROR) << "Trying to call glStencilOp() without current GL context"; -} - -void NoContextGLApi::glStencilOpSeparateFn(GLenum face, - GLenum fail, - GLenum zfail, - GLenum zpass) { - NOTREACHED() - << "Trying to call glStencilOpSeparate() without current GL context"; - LOG(ERROR) - << "Trying to call glStencilOpSeparate() without current GL context"; -} - -GLboolean NoContextGLApi::glTestFenceAPPLEFn(GLuint fence) { - NOTREACHED() - << "Trying to call glTestFenceAPPLE() without current GL context"; - LOG(ERROR) << "Trying to call glTestFenceAPPLE() without current GL context"; - return GL_FALSE; -} - -GLboolean NoContextGLApi::glTestFenceNVFn(GLuint fence) { - NOTREACHED() << "Trying to call glTestFenceNV() without current GL context"; - LOG(ERROR) << "Trying to call glTestFenceNV() without current GL context"; - return GL_FALSE; -} - -void NoContextGLApi::glTexImage2DFn(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const void* pixels) { - NOTREACHED() << "Trying to call glTexImage2D() without current GL context"; - LOG(ERROR) << "Trying to call glTexImage2D() without current GL context"; -} - -void NoContextGLApi::glTexImage3DFn(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - const void* pixels) { - NOTREACHED() << "Trying to call glTexImage3D() without current GL context"; - LOG(ERROR) << "Trying to call glTexImage3D() without current GL context"; -} - -void NoContextGLApi::glTexParameterfFn(GLenum target, - GLenum pname, - GLfloat param) { - NOTREACHED() << "Trying to call glTexParameterf() without current GL context"; - LOG(ERROR) << "Trying to call glTexParameterf() without current GL context"; -} - -void NoContextGLApi::glTexParameterfvFn(GLenum target, - GLenum pname, - const GLfloat* params) { - NOTREACHED() - << "Trying to call glTexParameterfv() without current GL context"; - LOG(ERROR) << "Trying to call glTexParameterfv() without current GL context"; -} - -void NoContextGLApi::glTexParameteriFn(GLenum target, - GLenum pname, - GLint param) { - NOTREACHED() << "Trying to call glTexParameteri() without current GL context"; - LOG(ERROR) << "Trying to call glTexParameteri() without current GL context"; -} - -void NoContextGLApi::glTexParameterivFn(GLenum target, - GLenum pname, - const GLint* params) { - NOTREACHED() - << "Trying to call glTexParameteriv() without current GL context"; - LOG(ERROR) << "Trying to call glTexParameteriv() without current GL context"; -} - -void NoContextGLApi::glTexStorage2DEXTFn(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height) { - NOTREACHED() - << "Trying to call glTexStorage2DEXT() without current GL context"; - LOG(ERROR) << "Trying to call glTexStorage2DEXT() without current GL context"; -} - -void NoContextGLApi::glTexStorage3DFn(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth) { - NOTREACHED() << "Trying to call glTexStorage3D() without current GL context"; - LOG(ERROR) << "Trying to call glTexStorage3D() without current GL context"; -} - -void NoContextGLApi::glTexSubImage2DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const void* pixels) { - NOTREACHED() << "Trying to call glTexSubImage2D() without current GL context"; - LOG(ERROR) << "Trying to call glTexSubImage2D() without current GL context"; -} - -void NoContextGLApi::glTextureBarrierNVFn(void) { - NOTREACHED() - << "Trying to call glTextureBarrierNV() without current GL context"; - LOG(ERROR) - << "Trying to call glTextureBarrierNV() without current GL context"; -} - -void NoContextGLApi::glTransformFeedbackVaryingsFn(GLuint program, - GLsizei count, - const char* const* varyings, - GLenum bufferMode) { - NOTREACHED() << "Trying to call glTransformFeedbackVaryings() without " - "current GL context"; - LOG(ERROR) << "Trying to call glTransformFeedbackVaryings() without current " - "GL context"; -} - -void NoContextGLApi::glUniform1fFn(GLint location, GLfloat x) { - NOTREACHED() << "Trying to call glUniform1f() without current GL context"; - LOG(ERROR) << "Trying to call glUniform1f() without current GL context"; -} - -void NoContextGLApi::glUniform1fvFn(GLint location, - GLsizei count, - const GLfloat* v) { - NOTREACHED() << "Trying to call glUniform1fv() without current GL context"; - LOG(ERROR) << "Trying to call glUniform1fv() without current GL context"; -} - -void NoContextGLApi::glUniform1iFn(GLint location, GLint x) { - NOTREACHED() << "Trying to call glUniform1i() without current GL context"; - LOG(ERROR) << "Trying to call glUniform1i() without current GL context"; -} - -void NoContextGLApi::glUniform1ivFn(GLint location, - GLsizei count, - const GLint* v) { - NOTREACHED() << "Trying to call glUniform1iv() without current GL context"; - LOG(ERROR) << "Trying to call glUniform1iv() without current GL context"; -} - -void NoContextGLApi::glUniform1uiFn(GLint location, GLuint v0) { - NOTREACHED() << "Trying to call glUniform1ui() without current GL context"; - LOG(ERROR) << "Trying to call glUniform1ui() without current GL context"; -} - -void NoContextGLApi::glUniform1uivFn(GLint location, - GLsizei count, - const GLuint* v) { - NOTREACHED() << "Trying to call glUniform1uiv() without current GL context"; - LOG(ERROR) << "Trying to call glUniform1uiv() without current GL context"; -} - -void NoContextGLApi::glUniform2fFn(GLint location, GLfloat x, GLfloat y) { - NOTREACHED() << "Trying to call glUniform2f() without current GL context"; - LOG(ERROR) << "Trying to call glUniform2f() without current GL context"; -} - -void NoContextGLApi::glUniform2fvFn(GLint location, - GLsizei count, - const GLfloat* v) { - NOTREACHED() << "Trying to call glUniform2fv() without current GL context"; - LOG(ERROR) << "Trying to call glUniform2fv() without current GL context"; -} - -void NoContextGLApi::glUniform2iFn(GLint location, GLint x, GLint y) { - NOTREACHED() << "Trying to call glUniform2i() without current GL context"; - LOG(ERROR) << "Trying to call glUniform2i() without current GL context"; -} - -void NoContextGLApi::glUniform2ivFn(GLint location, - GLsizei count, - const GLint* v) { - NOTREACHED() << "Trying to call glUniform2iv() without current GL context"; - LOG(ERROR) << "Trying to call glUniform2iv() without current GL context"; -} - -void NoContextGLApi::glUniform2uiFn(GLint location, GLuint v0, GLuint v1) { - NOTREACHED() << "Trying to call glUniform2ui() without current GL context"; - LOG(ERROR) << "Trying to call glUniform2ui() without current GL context"; -} - -void NoContextGLApi::glUniform2uivFn(GLint location, - GLsizei count, - const GLuint* v) { - NOTREACHED() << "Trying to call glUniform2uiv() without current GL context"; - LOG(ERROR) << "Trying to call glUniform2uiv() without current GL context"; -} - -void NoContextGLApi::glUniform3fFn(GLint location, - GLfloat x, - GLfloat y, - GLfloat z) { - NOTREACHED() << "Trying to call glUniform3f() without current GL context"; - LOG(ERROR) << "Trying to call glUniform3f() without current GL context"; -} - -void NoContextGLApi::glUniform3fvFn(GLint location, - GLsizei count, - const GLfloat* v) { - NOTREACHED() << "Trying to call glUniform3fv() without current GL context"; - LOG(ERROR) << "Trying to call glUniform3fv() without current GL context"; -} - -void NoContextGLApi::glUniform3iFn(GLint location, GLint x, GLint y, GLint z) { - NOTREACHED() << "Trying to call glUniform3i() without current GL context"; - LOG(ERROR) << "Trying to call glUniform3i() without current GL context"; -} - -void NoContextGLApi::glUniform3ivFn(GLint location, - GLsizei count, - const GLint* v) { - NOTREACHED() << "Trying to call glUniform3iv() without current GL context"; - LOG(ERROR) << "Trying to call glUniform3iv() without current GL context"; -} - -void NoContextGLApi::glUniform3uiFn(GLint location, - GLuint v0, - GLuint v1, - GLuint v2) { - NOTREACHED() << "Trying to call glUniform3ui() without current GL context"; - LOG(ERROR) << "Trying to call glUniform3ui() without current GL context"; -} - -void NoContextGLApi::glUniform3uivFn(GLint location, - GLsizei count, - const GLuint* v) { - NOTREACHED() << "Trying to call glUniform3uiv() without current GL context"; - LOG(ERROR) << "Trying to call glUniform3uiv() without current GL context"; -} - -void NoContextGLApi::glUniform4fFn(GLint location, - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w) { - NOTREACHED() << "Trying to call glUniform4f() without current GL context"; - LOG(ERROR) << "Trying to call glUniform4f() without current GL context"; -} - -void NoContextGLApi::glUniform4fvFn(GLint location, - GLsizei count, - const GLfloat* v) { - NOTREACHED() << "Trying to call glUniform4fv() without current GL context"; - LOG(ERROR) << "Trying to call glUniform4fv() without current GL context"; -} - -void NoContextGLApi::glUniform4iFn(GLint location, - GLint x, - GLint y, - GLint z, - GLint w) { - NOTREACHED() << "Trying to call glUniform4i() without current GL context"; - LOG(ERROR) << "Trying to call glUniform4i() without current GL context"; -} - -void NoContextGLApi::glUniform4ivFn(GLint location, - GLsizei count, - const GLint* v) { - NOTREACHED() << "Trying to call glUniform4iv() without current GL context"; - LOG(ERROR) << "Trying to call glUniform4iv() without current GL context"; -} - -void NoContextGLApi::glUniform4uiFn(GLint location, - GLuint v0, - GLuint v1, - GLuint v2, - GLuint v3) { - NOTREACHED() << "Trying to call glUniform4ui() without current GL context"; - LOG(ERROR) << "Trying to call glUniform4ui() without current GL context"; -} - -void NoContextGLApi::glUniform4uivFn(GLint location, - GLsizei count, - const GLuint* v) { - NOTREACHED() << "Trying to call glUniform4uiv() without current GL context"; - LOG(ERROR) << "Trying to call glUniform4uiv() without current GL context"; -} - -void NoContextGLApi::glUniformBlockBindingFn(GLuint program, - GLuint uniformBlockIndex, - GLuint uniformBlockBinding) { - NOTREACHED() - << "Trying to call glUniformBlockBinding() without current GL context"; - LOG(ERROR) - << "Trying to call glUniformBlockBinding() without current GL context"; -} - -void NoContextGLApi::glUniformMatrix2fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - NOTREACHED() - << "Trying to call glUniformMatrix2fv() without current GL context"; - LOG(ERROR) - << "Trying to call glUniformMatrix2fv() without current GL context"; -} - -void NoContextGLApi::glUniformMatrix2x3fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - NOTREACHED() - << "Trying to call glUniformMatrix2x3fv() without current GL context"; - LOG(ERROR) - << "Trying to call glUniformMatrix2x3fv() without current GL context"; -} - -void NoContextGLApi::glUniformMatrix2x4fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - NOTREACHED() - << "Trying to call glUniformMatrix2x4fv() without current GL context"; - LOG(ERROR) - << "Trying to call glUniformMatrix2x4fv() without current GL context"; -} - -void NoContextGLApi::glUniformMatrix3fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - NOTREACHED() - << "Trying to call glUniformMatrix3fv() without current GL context"; - LOG(ERROR) - << "Trying to call glUniformMatrix3fv() without current GL context"; -} - -void NoContextGLApi::glUniformMatrix3x2fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - NOTREACHED() - << "Trying to call glUniformMatrix3x2fv() without current GL context"; - LOG(ERROR) - << "Trying to call glUniformMatrix3x2fv() without current GL context"; -} - -void NoContextGLApi::glUniformMatrix3x4fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - NOTREACHED() - << "Trying to call glUniformMatrix3x4fv() without current GL context"; - LOG(ERROR) - << "Trying to call glUniformMatrix3x4fv() without current GL context"; -} - -void NoContextGLApi::glUniformMatrix4fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - NOTREACHED() - << "Trying to call glUniformMatrix4fv() without current GL context"; - LOG(ERROR) - << "Trying to call glUniformMatrix4fv() without current GL context"; -} - -void NoContextGLApi::glUniformMatrix4x2fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - NOTREACHED() - << "Trying to call glUniformMatrix4x2fv() without current GL context"; - LOG(ERROR) - << "Trying to call glUniformMatrix4x2fv() without current GL context"; -} - -void NoContextGLApi::glUniformMatrix4x3fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - NOTREACHED() - << "Trying to call glUniformMatrix4x3fv() without current GL context"; - LOG(ERROR) - << "Trying to call glUniformMatrix4x3fv() without current GL context"; -} - -GLboolean NoContextGLApi::glUnmapBufferFn(GLenum target) { - NOTREACHED() << "Trying to call glUnmapBuffer() without current GL context"; - LOG(ERROR) << "Trying to call glUnmapBuffer() without current GL context"; - return GL_FALSE; -} - -void NoContextGLApi::glUseProgramFn(GLuint program) { - NOTREACHED() << "Trying to call glUseProgram() without current GL context"; - LOG(ERROR) << "Trying to call glUseProgram() without current GL context"; -} - -void NoContextGLApi::glValidateProgramFn(GLuint program) { - NOTREACHED() - << "Trying to call glValidateProgram() without current GL context"; - LOG(ERROR) << "Trying to call glValidateProgram() without current GL context"; -} - -void NoContextGLApi::glVertexAttrib1fFn(GLuint indx, GLfloat x) { - NOTREACHED() - << "Trying to call glVertexAttrib1f() without current GL context"; - LOG(ERROR) << "Trying to call glVertexAttrib1f() without current GL context"; -} - -void NoContextGLApi::glVertexAttrib1fvFn(GLuint indx, const GLfloat* values) { - NOTREACHED() - << "Trying to call glVertexAttrib1fv() without current GL context"; - LOG(ERROR) << "Trying to call glVertexAttrib1fv() without current GL context"; -} - -void NoContextGLApi::glVertexAttrib2fFn(GLuint indx, GLfloat x, GLfloat y) { - NOTREACHED() - << "Trying to call glVertexAttrib2f() without current GL context"; - LOG(ERROR) << "Trying to call glVertexAttrib2f() without current GL context"; -} - -void NoContextGLApi::glVertexAttrib2fvFn(GLuint indx, const GLfloat* values) { - NOTREACHED() - << "Trying to call glVertexAttrib2fv() without current GL context"; - LOG(ERROR) << "Trying to call glVertexAttrib2fv() without current GL context"; -} - -void NoContextGLApi::glVertexAttrib3fFn(GLuint indx, - GLfloat x, - GLfloat y, - GLfloat z) { - NOTREACHED() - << "Trying to call glVertexAttrib3f() without current GL context"; - LOG(ERROR) << "Trying to call glVertexAttrib3f() without current GL context"; -} - -void NoContextGLApi::glVertexAttrib3fvFn(GLuint indx, const GLfloat* values) { - NOTREACHED() - << "Trying to call glVertexAttrib3fv() without current GL context"; - LOG(ERROR) << "Trying to call glVertexAttrib3fv() without current GL context"; -} - -void NoContextGLApi::glVertexAttrib4fFn(GLuint indx, - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w) { - NOTREACHED() - << "Trying to call glVertexAttrib4f() without current GL context"; - LOG(ERROR) << "Trying to call glVertexAttrib4f() without current GL context"; -} - -void NoContextGLApi::glVertexAttrib4fvFn(GLuint indx, const GLfloat* values) { - NOTREACHED() - << "Trying to call glVertexAttrib4fv() without current GL context"; - LOG(ERROR) << "Trying to call glVertexAttrib4fv() without current GL context"; -} - -void NoContextGLApi::glVertexAttribDivisorANGLEFn(GLuint index, - GLuint divisor) { - NOTREACHED() << "Trying to call glVertexAttribDivisorANGLE() without current " - "GL context"; - LOG(ERROR) << "Trying to call glVertexAttribDivisorANGLE() without current " - "GL context"; -} - -void NoContextGLApi::glVertexAttribI4iFn(GLuint indx, - GLint x, - GLint y, - GLint z, - GLint w) { - NOTREACHED() - << "Trying to call glVertexAttribI4i() without current GL context"; - LOG(ERROR) << "Trying to call glVertexAttribI4i() without current GL context"; -} - -void NoContextGLApi::glVertexAttribI4ivFn(GLuint indx, const GLint* values) { - NOTREACHED() - << "Trying to call glVertexAttribI4iv() without current GL context"; - LOG(ERROR) - << "Trying to call glVertexAttribI4iv() without current GL context"; -} - -void NoContextGLApi::glVertexAttribI4uiFn(GLuint indx, - GLuint x, - GLuint y, - GLuint z, - GLuint w) { - NOTREACHED() - << "Trying to call glVertexAttribI4ui() without current GL context"; - LOG(ERROR) - << "Trying to call glVertexAttribI4ui() without current GL context"; -} - -void NoContextGLApi::glVertexAttribI4uivFn(GLuint indx, const GLuint* values) { - NOTREACHED() - << "Trying to call glVertexAttribI4uiv() without current GL context"; - LOG(ERROR) - << "Trying to call glVertexAttribI4uiv() without current GL context"; -} - -void NoContextGLApi::glVertexAttribIPointerFn(GLuint indx, - GLint size, - GLenum type, - GLsizei stride, - const void* ptr) { - NOTREACHED() - << "Trying to call glVertexAttribIPointer() without current GL context"; - LOG(ERROR) - << "Trying to call glVertexAttribIPointer() without current GL context"; -} - -void NoContextGLApi::glVertexAttribPointerFn(GLuint indx, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const void* ptr) { - NOTREACHED() - << "Trying to call glVertexAttribPointer() without current GL context"; - LOG(ERROR) - << "Trying to call glVertexAttribPointer() without current GL context"; -} - -void NoContextGLApi::glViewportFn(GLint x, - GLint y, - GLsizei width, - GLsizei height) { - NOTREACHED() << "Trying to call glViewport() without current GL context"; - LOG(ERROR) << "Trying to call glViewport() without current GL context"; -} - -GLenum NoContextGLApi::glWaitSyncFn(GLsync sync, - GLbitfield flags, - GLuint64 timeout) { - NOTREACHED() << "Trying to call glWaitSync() without current GL context"; - LOG(ERROR) << "Trying to call glWaitSync() without current GL context"; - return static_cast(0); -} - -} // namespace gfx diff --git a/ui/gl/gl_bindings_autogen_gl.h b/ui/gl/gl_bindings_autogen_gl.h deleted file mode 100644 index 34c83f909..000000000 --- a/ui/gl/gl_bindings_autogen_gl.h +++ /dev/null @@ -1,2452 +0,0 @@ -// Copyright 2014 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 is auto-generated from -// ui/gl/generate_bindings.py -// It's formatted by clang-format using chromium coding style: -// clang-format -i -style=chromium filename -// DO NOT EDIT! - -#ifndef UI_GFX_GL_GL_BINDINGS_AUTOGEN_GL_H_ -#define UI_GFX_GL_GL_BINDINGS_AUTOGEN_GL_H_ - -namespace gfx { - -class GLContext; - -typedef void(GL_BINDING_CALL* glActiveTextureProc)(GLenum texture); -typedef void(GL_BINDING_CALL* glAttachShaderProc)(GLuint program, - GLuint shader); -typedef void(GL_BINDING_CALL* glBeginQueryProc)(GLenum target, GLuint id); -typedef void(GL_BINDING_CALL* glBeginTransformFeedbackProc)( - GLenum primitiveMode); -typedef void(GL_BINDING_CALL* glBindAttribLocationProc)(GLuint program, - GLuint index, - const char* name); -typedef void(GL_BINDING_CALL* glBindBufferProc)(GLenum target, GLuint buffer); -typedef void(GL_BINDING_CALL* glBindBufferBaseProc)(GLenum target, - GLuint index, - GLuint buffer); -typedef void(GL_BINDING_CALL* glBindBufferRangeProc)(GLenum target, - GLuint index, - GLuint buffer, - GLintptr offset, - GLsizeiptr size); -typedef void(GL_BINDING_CALL* glBindFragDataLocationProc)(GLuint program, - GLuint colorNumber, - const char* name); -typedef void(GL_BINDING_CALL* glBindFragDataLocationIndexedProc)( - GLuint program, - GLuint colorNumber, - GLuint index, - const char* name); -typedef void(GL_BINDING_CALL* glBindFramebufferEXTProc)(GLenum target, - GLuint framebuffer); -typedef void(GL_BINDING_CALL* glBindRenderbufferEXTProc)(GLenum target, - GLuint renderbuffer); -typedef void(GL_BINDING_CALL* glBindSamplerProc)(GLuint unit, GLuint sampler); -typedef void(GL_BINDING_CALL* glBindTextureProc)(GLenum target, GLuint texture); -typedef void(GL_BINDING_CALL* glBindTransformFeedbackProc)(GLenum target, - GLuint id); -typedef void(GL_BINDING_CALL* glBindVertexArrayOESProc)(GLuint array); -typedef void(GL_BINDING_CALL* glBlendBarrierKHRProc)(void); -typedef void(GL_BINDING_CALL* glBlendColorProc)(GLclampf red, - GLclampf green, - GLclampf blue, - GLclampf alpha); -typedef void(GL_BINDING_CALL* glBlendEquationProc)(GLenum mode); -typedef void(GL_BINDING_CALL* glBlendEquationSeparateProc)(GLenum modeRGB, - GLenum modeAlpha); -typedef void(GL_BINDING_CALL* glBlendFuncProc)(GLenum sfactor, GLenum dfactor); -typedef void(GL_BINDING_CALL* glBlendFuncSeparateProc)(GLenum srcRGB, - GLenum dstRGB, - GLenum srcAlpha, - GLenum dstAlpha); -typedef void(GL_BINDING_CALL* glBlitFramebufferProc)(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter); -typedef void(GL_BINDING_CALL* glBlitFramebufferANGLEProc)(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter); -typedef void(GL_BINDING_CALL* glBlitFramebufferEXTProc)(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter); -typedef void(GL_BINDING_CALL* glBufferDataProc)(GLenum target, - GLsizeiptr size, - const void* data, - GLenum usage); -typedef void(GL_BINDING_CALL* glBufferSubDataProc)(GLenum target, - GLintptr offset, - GLsizeiptr size, - const void* data); -typedef GLenum(GL_BINDING_CALL* glCheckFramebufferStatusEXTProc)(GLenum target); -typedef void(GL_BINDING_CALL* glClearProc)(GLbitfield mask); -typedef void(GL_BINDING_CALL* glClearBufferfiProc)(GLenum buffer, - GLint drawbuffer, - const GLfloat depth, - GLint stencil); -typedef void(GL_BINDING_CALL* glClearBufferfvProc)(GLenum buffer, - GLint drawbuffer, - const GLfloat* value); -typedef void(GL_BINDING_CALL* glClearBufferivProc)(GLenum buffer, - GLint drawbuffer, - const GLint* value); -typedef void(GL_BINDING_CALL* glClearBufferuivProc)(GLenum buffer, - GLint drawbuffer, - const GLuint* value); -typedef void(GL_BINDING_CALL* glClearColorProc)(GLclampf red, - GLclampf green, - GLclampf blue, - GLclampf alpha); -typedef void(GL_BINDING_CALL* glClearDepthProc)(GLclampd depth); -typedef void(GL_BINDING_CALL* glClearDepthfProc)(GLclampf depth); -typedef void(GL_BINDING_CALL* glClearStencilProc)(GLint s); -typedef GLenum(GL_BINDING_CALL* glClientWaitSyncProc)(GLsync sync, - GLbitfield flags, - GLuint64 timeout); -typedef void(GL_BINDING_CALL* glColorMaskProc)(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha); -typedef void(GL_BINDING_CALL* glCompileShaderProc)(GLuint shader); -typedef void(GL_BINDING_CALL* glCompressedTexImage2DProc)(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const void* data); -typedef void(GL_BINDING_CALL* glCompressedTexImage3DProc)(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLsizei imageSize, - const void* data); -typedef void(GL_BINDING_CALL* glCompressedTexSubImage2DProc)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const void* data); -typedef void(GL_BINDING_CALL* glCopyBufferSubDataProc)(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size); -typedef void(GL_BINDING_CALL* glCopyTexImage2DProc)(GLenum target, - GLint level, - GLenum internalformat, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLint border); -typedef void(GL_BINDING_CALL* glCopyTexSubImage2DProc)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef void(GL_BINDING_CALL* glCopyTexSubImage3DProc)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef GLuint(GL_BINDING_CALL* glCreateProgramProc)(void); -typedef GLuint(GL_BINDING_CALL* glCreateShaderProc)(GLenum type); -typedef void(GL_BINDING_CALL* glCullFaceProc)(GLenum mode); -typedef void(GL_BINDING_CALL* glDebugMessageCallbackKHRProc)( - GLDEBUGPROCKHR callback, - const void* userparam); -typedef void(GL_BINDING_CALL* glDebugMessageControlKHRProc)(GLenum source, - GLenum type, - GLenum severity, - GLsizei count, - const GLuint* ids, - GLboolean enabled); -typedef void(GL_BINDING_CALL* glDebugMessageInsertKHRProc)(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar* buf); -typedef void(GL_BINDING_CALL* glDeleteBuffersARBProc)(GLsizei n, - const GLuint* buffers); -typedef void(GL_BINDING_CALL* glDeleteFencesAPPLEProc)(GLsizei n, - const GLuint* fences); -typedef void(GL_BINDING_CALL* glDeleteFencesNVProc)(GLsizei n, - const GLuint* fences); -typedef void(GL_BINDING_CALL* glDeleteFramebuffersEXTProc)( - GLsizei n, - const GLuint* framebuffers); -typedef void(GL_BINDING_CALL* glDeleteProgramProc)(GLuint program); -typedef void(GL_BINDING_CALL* glDeleteQueriesProc)(GLsizei n, - const GLuint* ids); -typedef void(GL_BINDING_CALL* glDeleteRenderbuffersEXTProc)( - GLsizei n, - const GLuint* renderbuffers); -typedef void(GL_BINDING_CALL* glDeleteSamplersProc)(GLsizei n, - const GLuint* samplers); -typedef void(GL_BINDING_CALL* glDeleteShaderProc)(GLuint shader); -typedef void(GL_BINDING_CALL* glDeleteSyncProc)(GLsync sync); -typedef void(GL_BINDING_CALL* glDeleteTexturesProc)(GLsizei n, - const GLuint* textures); -typedef void(GL_BINDING_CALL* glDeleteTransformFeedbacksProc)( - GLsizei n, - const GLuint* ids); -typedef void(GL_BINDING_CALL* glDeleteVertexArraysOESProc)( - GLsizei n, - const GLuint* arrays); -typedef void(GL_BINDING_CALL* glDepthFuncProc)(GLenum func); -typedef void(GL_BINDING_CALL* glDepthMaskProc)(GLboolean flag); -typedef void(GL_BINDING_CALL* glDepthRangeProc)(GLclampd zNear, GLclampd zFar); -typedef void(GL_BINDING_CALL* glDepthRangefProc)(GLclampf zNear, GLclampf zFar); -typedef void(GL_BINDING_CALL* glDetachShaderProc)(GLuint program, - GLuint shader); -typedef void(GL_BINDING_CALL* glDisableProc)(GLenum cap); -typedef void(GL_BINDING_CALL* glDisableVertexAttribArrayProc)(GLuint index); -typedef void(GL_BINDING_CALL* glDiscardFramebufferEXTProc)( - GLenum target, - GLsizei numAttachments, - const GLenum* attachments); -typedef void(GL_BINDING_CALL* glDrawArraysProc)(GLenum mode, - GLint first, - GLsizei count); -typedef void(GL_BINDING_CALL* glDrawArraysInstancedANGLEProc)( - GLenum mode, - GLint first, - GLsizei count, - GLsizei primcount); -typedef void(GL_BINDING_CALL* glDrawBufferProc)(GLenum mode); -typedef void(GL_BINDING_CALL* glDrawBuffersARBProc)(GLsizei n, - const GLenum* bufs); -typedef void(GL_BINDING_CALL* glDrawElementsProc)(GLenum mode, - GLsizei count, - GLenum type, - const void* indices); -typedef void(GL_BINDING_CALL* glDrawElementsInstancedANGLEProc)( - GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei primcount); -typedef void(GL_BINDING_CALL* glDrawRangeElementsProc)(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices); -typedef void(GL_BINDING_CALL* glEGLImageTargetRenderbufferStorageOESProc)( - GLenum target, - GLeglImageOES image); -typedef void(GL_BINDING_CALL* glEGLImageTargetTexture2DOESProc)( - GLenum target, - GLeglImageOES image); -typedef void(GL_BINDING_CALL* glEnableProc)(GLenum cap); -typedef void(GL_BINDING_CALL* glEnableVertexAttribArrayProc)(GLuint index); -typedef void(GL_BINDING_CALL* glEndQueryProc)(GLenum target); -typedef void(GL_BINDING_CALL* glEndTransformFeedbackProc)(void); -typedef GLsync(GL_BINDING_CALL* glFenceSyncProc)(GLenum condition, - GLbitfield flags); -typedef void(GL_BINDING_CALL* glFinishProc)(void); -typedef void(GL_BINDING_CALL* glFinishFenceAPPLEProc)(GLuint fence); -typedef void(GL_BINDING_CALL* glFinishFenceNVProc)(GLuint fence); -typedef void(GL_BINDING_CALL* glFlushProc)(void); -typedef void(GL_BINDING_CALL* glFlushMappedBufferRangeProc)(GLenum target, - GLintptr offset, - GLsizeiptr length); -typedef void(GL_BINDING_CALL* glFramebufferRenderbufferEXTProc)( - GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer); -typedef void(GL_BINDING_CALL* glFramebufferTexture2DEXTProc)(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level); -typedef void(GL_BINDING_CALL* glFramebufferTexture2DMultisampleEXTProc)( - GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples); -typedef void(GL_BINDING_CALL* glFramebufferTexture2DMultisampleIMGProc)( - GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples); -typedef void(GL_BINDING_CALL* glFramebufferTextureLayerProc)(GLenum target, - GLenum attachment, - GLuint texture, - GLint level, - GLint layer); -typedef void(GL_BINDING_CALL* glFrontFaceProc)(GLenum mode); -typedef void(GL_BINDING_CALL* glGenBuffersARBProc)(GLsizei n, GLuint* buffers); -typedef void(GL_BINDING_CALL* glGenerateMipmapEXTProc)(GLenum target); -typedef void(GL_BINDING_CALL* glGenFencesAPPLEProc)(GLsizei n, GLuint* fences); -typedef void(GL_BINDING_CALL* glGenFencesNVProc)(GLsizei n, GLuint* fences); -typedef void(GL_BINDING_CALL* glGenFramebuffersEXTProc)(GLsizei n, - GLuint* framebuffers); -typedef void(GL_BINDING_CALL* glGenQueriesProc)(GLsizei n, GLuint* ids); -typedef void(GL_BINDING_CALL* glGenRenderbuffersEXTProc)(GLsizei n, - GLuint* renderbuffers); -typedef void(GL_BINDING_CALL* glGenSamplersProc)(GLsizei n, GLuint* samplers); -typedef void(GL_BINDING_CALL* glGenTexturesProc)(GLsizei n, GLuint* textures); -typedef void(GL_BINDING_CALL* glGenTransformFeedbacksProc)(GLsizei n, - GLuint* ids); -typedef void(GL_BINDING_CALL* glGenVertexArraysOESProc)(GLsizei n, - GLuint* arrays); -typedef void(GL_BINDING_CALL* glGetActiveAttribProc)(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - char* name); -typedef void(GL_BINDING_CALL* glGetActiveUniformProc)(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - char* name); -typedef void(GL_BINDING_CALL* glGetActiveUniformBlockivProc)( - GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint* params); -typedef void(GL_BINDING_CALL* glGetActiveUniformBlockNameProc)( - GLuint program, - GLuint uniformBlockIndex, - GLsizei bufSize, - GLsizei* length, - char* uniformBlockName); -typedef void(GL_BINDING_CALL* glGetActiveUniformsivProc)( - GLuint program, - GLsizei uniformCount, - const GLuint* uniformIndices, - GLenum pname, - GLint* params); -typedef void(GL_BINDING_CALL* glGetAttachedShadersProc)(GLuint program, - GLsizei maxcount, - GLsizei* count, - GLuint* shaders); -typedef GLint(GL_BINDING_CALL* glGetAttribLocationProc)(GLuint program, - const char* name); -typedef void(GL_BINDING_CALL* glGetBooleanvProc)(GLenum pname, - GLboolean* params); -typedef void(GL_BINDING_CALL* glGetBufferParameterivProc)(GLenum target, - GLenum pname, - GLint* params); -typedef GLuint(GL_BINDING_CALL* glGetDebugMessageLogKHRProc)( - GLuint count, - GLsizei bufSize, - GLenum* sources, - GLenum* types, - GLuint* ids, - GLenum* severities, - GLsizei* lengths, - GLchar* messageLog); -typedef GLenum(GL_BINDING_CALL* glGetErrorProc)(void); -typedef void(GL_BINDING_CALL* glGetFenceivNVProc)(GLuint fence, - GLenum pname, - GLint* params); -typedef void(GL_BINDING_CALL* glGetFloatvProc)(GLenum pname, GLfloat* params); -typedef GLint(GL_BINDING_CALL* glGetFragDataLocationProc)(GLuint program, - const char* name); -typedef void(GL_BINDING_CALL* glGetFramebufferAttachmentParameterivEXTProc)( - GLenum target, - GLenum attachment, - GLenum pname, - GLint* params); -typedef GLenum(GL_BINDING_CALL* glGetGraphicsResetStatusARBProc)(void); -typedef void(GL_BINDING_CALL* glGetInteger64i_vProc)(GLenum target, - GLuint index, - GLint64* data); -typedef void(GL_BINDING_CALL* glGetInteger64vProc)(GLenum pname, - GLint64* params); -typedef void(GL_BINDING_CALL* glGetIntegeri_vProc)(GLenum target, - GLuint index, - GLint* data); -typedef void(GL_BINDING_CALL* glGetIntegervProc)(GLenum pname, GLint* params); -typedef void(GL_BINDING_CALL* glGetInternalformativProc)(GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLint* params); -typedef void(GL_BINDING_CALL* glGetProgramBinaryProc)(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - GLvoid* binary); -typedef void(GL_BINDING_CALL* glGetProgramInfoLogProc)(GLuint program, - GLsizei bufsize, - GLsizei* length, - char* infolog); -typedef void(GL_BINDING_CALL* glGetProgramivProc)(GLuint program, - GLenum pname, - GLint* params); -typedef GLint(GL_BINDING_CALL* glGetProgramResourceLocationProc)( - GLuint program, - GLenum programInterface, - const char* name); -typedef void(GL_BINDING_CALL* glGetQueryivProc)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_BINDING_CALL* glGetQueryObjecti64vProc)(GLuint id, - GLenum pname, - GLint64* params); -typedef void(GL_BINDING_CALL* glGetQueryObjectivProc)(GLuint id, - GLenum pname, - GLint* params); -typedef void(GL_BINDING_CALL* glGetQueryObjectui64vProc)(GLuint id, - GLenum pname, - GLuint64* params); -typedef void(GL_BINDING_CALL* glGetQueryObjectuivProc)(GLuint id, - GLenum pname, - GLuint* params); -typedef void(GL_BINDING_CALL* glGetRenderbufferParameterivEXTProc)( - GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_BINDING_CALL* glGetSamplerParameterfvProc)(GLuint sampler, - GLenum pname, - GLfloat* params); -typedef void(GL_BINDING_CALL* glGetSamplerParameterivProc)(GLuint sampler, - GLenum pname, - GLint* params); -typedef void(GL_BINDING_CALL* glGetShaderInfoLogProc)(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* infolog); -typedef void(GL_BINDING_CALL* glGetShaderivProc)(GLuint shader, - GLenum pname, - GLint* params); -typedef void(GL_BINDING_CALL* glGetShaderPrecisionFormatProc)( - GLenum shadertype, - GLenum precisiontype, - GLint* range, - GLint* precision); -typedef void(GL_BINDING_CALL* glGetShaderSourceProc)(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* source); -typedef const GLubyte*(GL_BINDING_CALL* glGetStringProc)(GLenum name); -typedef const GLubyte*(GL_BINDING_CALL* glGetStringiProc)(GLenum name, - GLuint index); -typedef void(GL_BINDING_CALL* glGetSyncivProc)(GLsync sync, - GLenum pname, - GLsizei bufSize, - GLsizei* length, - GLint* values); -typedef void(GL_BINDING_CALL* glGetTexLevelParameterfvProc)(GLenum target, - GLint level, - GLenum pname, - GLfloat* params); -typedef void(GL_BINDING_CALL* glGetTexLevelParameterivProc)(GLenum target, - GLint level, - GLenum pname, - GLint* params); -typedef void(GL_BINDING_CALL* glGetTexParameterfvProc)(GLenum target, - GLenum pname, - GLfloat* params); -typedef void(GL_BINDING_CALL* glGetTexParameterivProc)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_BINDING_CALL* glGetTransformFeedbackVaryingProc)( - GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLsizei* size, - GLenum* type, - char* name); -typedef void(GL_BINDING_CALL* glGetTranslatedShaderSourceANGLEProc)( - GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* source); -typedef GLuint(GL_BINDING_CALL* glGetUniformBlockIndexProc)( - GLuint program, - const char* uniformBlockName); -typedef void(GL_BINDING_CALL* glGetUniformfvProc)(GLuint program, - GLint location, - GLfloat* params); -typedef void(GL_BINDING_CALL* glGetUniformIndicesProc)( - GLuint program, - GLsizei uniformCount, - const char* const* uniformNames, - GLuint* uniformIndices); -typedef void(GL_BINDING_CALL* glGetUniformivProc)(GLuint program, - GLint location, - GLint* params); -typedef GLint(GL_BINDING_CALL* glGetUniformLocationProc)(GLuint program, - const char* name); -typedef void(GL_BINDING_CALL* glGetVertexAttribfvProc)(GLuint index, - GLenum pname, - GLfloat* params); -typedef void(GL_BINDING_CALL* glGetVertexAttribivProc)(GLuint index, - GLenum pname, - GLint* params); -typedef void(GL_BINDING_CALL* glGetVertexAttribPointervProc)(GLuint index, - GLenum pname, - void** pointer); -typedef void(GL_BINDING_CALL* glHintProc)(GLenum target, GLenum mode); -typedef void(GL_BINDING_CALL* glInsertEventMarkerEXTProc)(GLsizei length, - const char* marker); -typedef void(GL_BINDING_CALL* glInvalidateFramebufferProc)( - GLenum target, - GLsizei numAttachments, - const GLenum* attachments); -typedef void(GL_BINDING_CALL* glInvalidateSubFramebufferProc)( - GLenum target, - GLsizei numAttachments, - const GLenum* attachments, - GLint x, - GLint y, - GLint width, - GLint height); -typedef GLboolean(GL_BINDING_CALL* glIsBufferProc)(GLuint buffer); -typedef GLboolean(GL_BINDING_CALL* glIsEnabledProc)(GLenum cap); -typedef GLboolean(GL_BINDING_CALL* glIsFenceAPPLEProc)(GLuint fence); -typedef GLboolean(GL_BINDING_CALL* glIsFenceNVProc)(GLuint fence); -typedef GLboolean(GL_BINDING_CALL* glIsFramebufferEXTProc)(GLuint framebuffer); -typedef GLboolean(GL_BINDING_CALL* glIsProgramProc)(GLuint program); -typedef GLboolean(GL_BINDING_CALL* glIsQueryProc)(GLuint query); -typedef GLboolean(GL_BINDING_CALL* glIsRenderbufferEXTProc)( - GLuint renderbuffer); -typedef GLboolean(GL_BINDING_CALL* glIsSamplerProc)(GLuint sampler); -typedef GLboolean(GL_BINDING_CALL* glIsShaderProc)(GLuint shader); -typedef GLboolean(GL_BINDING_CALL* glIsSyncProc)(GLsync sync); -typedef GLboolean(GL_BINDING_CALL* glIsTextureProc)(GLuint texture); -typedef GLboolean(GL_BINDING_CALL* glIsTransformFeedbackProc)(GLuint id); -typedef GLboolean(GL_BINDING_CALL* glIsVertexArrayOESProc)(GLuint array); -typedef void(GL_BINDING_CALL* glLineWidthProc)(GLfloat width); -typedef void(GL_BINDING_CALL* glLinkProgramProc)(GLuint program); -typedef void*(GL_BINDING_CALL* glMapBufferProc)(GLenum target, GLenum access); -typedef void*(GL_BINDING_CALL* glMapBufferRangeProc)(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access); -typedef void(GL_BINDING_CALL* glMatrixLoadfEXTProc)(GLenum matrixMode, - const GLfloat* m); -typedef void(GL_BINDING_CALL* glMatrixLoadIdentityEXTProc)(GLenum matrixMode); -typedef void(GL_BINDING_CALL* glObjectLabelKHRProc)(GLenum identifier, - GLuint name, - GLsizei length, - const GLchar* label); -typedef void(GL_BINDING_CALL* glPauseTransformFeedbackProc)(void); -typedef void(GL_BINDING_CALL* glPixelStoreiProc)(GLenum pname, GLint param); -typedef void(GL_BINDING_CALL* glPointParameteriProc)(GLenum pname, GLint param); -typedef void(GL_BINDING_CALL* glPolygonOffsetProc)(GLfloat factor, - GLfloat units); -typedef void(GL_BINDING_CALL* glPopDebugGroupKHRProc)(void); -typedef void(GL_BINDING_CALL* glPopGroupMarkerEXTProc)(void); -typedef void(GL_BINDING_CALL* glProgramBinaryProc)(GLuint program, - GLenum binaryFormat, - const GLvoid* binary, - GLsizei length); -typedef void(GL_BINDING_CALL* glProgramParameteriProc)(GLuint program, - GLenum pname, - GLint value); -typedef void(GL_BINDING_CALL* glPushDebugGroupKHRProc)(GLenum source, - GLuint id, - GLsizei length, - const GLchar* message); -typedef void(GL_BINDING_CALL* glPushGroupMarkerEXTProc)(GLsizei length, - const char* marker); -typedef void(GL_BINDING_CALL* glQueryCounterProc)(GLuint id, GLenum target); -typedef void(GL_BINDING_CALL* glReadBufferProc)(GLenum src); -typedef void(GL_BINDING_CALL* glReadPixelsProc)(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - void* pixels); -typedef void(GL_BINDING_CALL* glReleaseShaderCompilerProc)(void); -typedef void(GL_BINDING_CALL* glRenderbufferStorageEXTProc)( - GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_BINDING_CALL* glRenderbufferStorageMultisampleProc)( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_BINDING_CALL* glRenderbufferStorageMultisampleANGLEProc)( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_BINDING_CALL* glRenderbufferStorageMultisampleAPPLEProc)( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_BINDING_CALL* glRenderbufferStorageMultisampleEXTProc)( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_BINDING_CALL* glRenderbufferStorageMultisampleIMGProc)( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_BINDING_CALL* glResolveMultisampleFramebufferAPPLEProc)(void); -typedef void(GL_BINDING_CALL* glResumeTransformFeedbackProc)(void); -typedef void(GL_BINDING_CALL* glSampleCoverageProc)(GLclampf value, - GLboolean invert); -typedef void(GL_BINDING_CALL* glSamplerParameterfProc)(GLuint sampler, - GLenum pname, - GLfloat param); -typedef void(GL_BINDING_CALL* glSamplerParameterfvProc)(GLuint sampler, - GLenum pname, - const GLfloat* params); -typedef void(GL_BINDING_CALL* glSamplerParameteriProc)(GLuint sampler, - GLenum pname, - GLint param); -typedef void(GL_BINDING_CALL* glSamplerParameterivProc)(GLuint sampler, - GLenum pname, - const GLint* params); -typedef void(GL_BINDING_CALL* glScissorProc)(GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef void(GL_BINDING_CALL* glSetFenceAPPLEProc)(GLuint fence); -typedef void(GL_BINDING_CALL* glSetFenceNVProc)(GLuint fence, GLenum condition); -typedef void(GL_BINDING_CALL* glShaderBinaryProc)(GLsizei n, - const GLuint* shaders, - GLenum binaryformat, - const void* binary, - GLsizei length); -typedef void(GL_BINDING_CALL* glShaderSourceProc)(GLuint shader, - GLsizei count, - const char* const* str, - const GLint* length); -typedef void(GL_BINDING_CALL* glStencilFuncProc)(GLenum func, - GLint ref, - GLuint mask); -typedef void(GL_BINDING_CALL* glStencilFuncSeparateProc)(GLenum face, - GLenum func, - GLint ref, - GLuint mask); -typedef void(GL_BINDING_CALL* glStencilMaskProc)(GLuint mask); -typedef void(GL_BINDING_CALL* glStencilMaskSeparateProc)(GLenum face, - GLuint mask); -typedef void(GL_BINDING_CALL* glStencilOpProc)(GLenum fail, - GLenum zfail, - GLenum zpass); -typedef void(GL_BINDING_CALL* glStencilOpSeparateProc)(GLenum face, - GLenum fail, - GLenum zfail, - GLenum zpass); -typedef GLboolean(GL_BINDING_CALL* glTestFenceAPPLEProc)(GLuint fence); -typedef GLboolean(GL_BINDING_CALL* glTestFenceNVProc)(GLuint fence); -typedef void(GL_BINDING_CALL* glTexImage2DProc)(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const void* pixels); -typedef void(GL_BINDING_CALL* glTexImage3DProc)(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - const void* pixels); -typedef void(GL_BINDING_CALL* glTexParameterfProc)(GLenum target, - GLenum pname, - GLfloat param); -typedef void(GL_BINDING_CALL* glTexParameterfvProc)(GLenum target, - GLenum pname, - const GLfloat* params); -typedef void(GL_BINDING_CALL* glTexParameteriProc)(GLenum target, - GLenum pname, - GLint param); -typedef void(GL_BINDING_CALL* glTexParameterivProc)(GLenum target, - GLenum pname, - const GLint* params); -typedef void(GL_BINDING_CALL* glTexStorage2DEXTProc)(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_BINDING_CALL* glTexStorage3DProc)(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth); -typedef void(GL_BINDING_CALL* glTexSubImage2DProc)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const void* pixels); -typedef void(GL_BINDING_CALL* glTextureBarrierNVProc)(void); -typedef void(GL_BINDING_CALL* glTransformFeedbackVaryingsProc)( - GLuint program, - GLsizei count, - const char* const* varyings, - GLenum bufferMode); -typedef void(GL_BINDING_CALL* glUniform1fProc)(GLint location, GLfloat x); -typedef void(GL_BINDING_CALL* glUniform1fvProc)(GLint location, - GLsizei count, - const GLfloat* v); -typedef void(GL_BINDING_CALL* glUniform1iProc)(GLint location, GLint x); -typedef void(GL_BINDING_CALL* glUniform1ivProc)(GLint location, - GLsizei count, - const GLint* v); -typedef void(GL_BINDING_CALL* glUniform1uiProc)(GLint location, GLuint v0); -typedef void(GL_BINDING_CALL* glUniform1uivProc)(GLint location, - GLsizei count, - const GLuint* v); -typedef void(GL_BINDING_CALL* glUniform2fProc)(GLint location, - GLfloat x, - GLfloat y); -typedef void(GL_BINDING_CALL* glUniform2fvProc)(GLint location, - GLsizei count, - const GLfloat* v); -typedef void(GL_BINDING_CALL* glUniform2iProc)(GLint location, - GLint x, - GLint y); -typedef void(GL_BINDING_CALL* glUniform2ivProc)(GLint location, - GLsizei count, - const GLint* v); -typedef void(GL_BINDING_CALL* glUniform2uiProc)(GLint location, - GLuint v0, - GLuint v1); -typedef void(GL_BINDING_CALL* glUniform2uivProc)(GLint location, - GLsizei count, - const GLuint* v); -typedef void(GL_BINDING_CALL* glUniform3fProc)(GLint location, - GLfloat x, - GLfloat y, - GLfloat z); -typedef void(GL_BINDING_CALL* glUniform3fvProc)(GLint location, - GLsizei count, - const GLfloat* v); -typedef void(GL_BINDING_CALL* glUniform3iProc)(GLint location, - GLint x, - GLint y, - GLint z); -typedef void(GL_BINDING_CALL* glUniform3ivProc)(GLint location, - GLsizei count, - const GLint* v); -typedef void(GL_BINDING_CALL* glUniform3uiProc)(GLint location, - GLuint v0, - GLuint v1, - GLuint v2); -typedef void(GL_BINDING_CALL* glUniform3uivProc)(GLint location, - GLsizei count, - const GLuint* v); -typedef void(GL_BINDING_CALL* glUniform4fProc)(GLint location, - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w); -typedef void(GL_BINDING_CALL* glUniform4fvProc)(GLint location, - GLsizei count, - const GLfloat* v); -typedef void(GL_BINDING_CALL* glUniform4iProc)(GLint location, - GLint x, - GLint y, - GLint z, - GLint w); -typedef void(GL_BINDING_CALL* glUniform4ivProc)(GLint location, - GLsizei count, - const GLint* v); -typedef void(GL_BINDING_CALL* glUniform4uiProc)(GLint location, - GLuint v0, - GLuint v1, - GLuint v2, - GLuint v3); -typedef void(GL_BINDING_CALL* glUniform4uivProc)(GLint location, - GLsizei count, - const GLuint* v); -typedef void(GL_BINDING_CALL* glUniformBlockBindingProc)( - GLuint program, - GLuint uniformBlockIndex, - GLuint uniformBlockBinding); -typedef void(GL_BINDING_CALL* glUniformMatrix2fvProc)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_BINDING_CALL* glUniformMatrix2x3fvProc)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_BINDING_CALL* glUniformMatrix2x4fvProc)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_BINDING_CALL* glUniformMatrix3fvProc)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_BINDING_CALL* glUniformMatrix3x2fvProc)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_BINDING_CALL* glUniformMatrix3x4fvProc)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_BINDING_CALL* glUniformMatrix4fvProc)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_BINDING_CALL* glUniformMatrix4x2fvProc)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_BINDING_CALL* glUniformMatrix4x3fvProc)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef GLboolean(GL_BINDING_CALL* glUnmapBufferProc)(GLenum target); -typedef void(GL_BINDING_CALL* glUseProgramProc)(GLuint program); -typedef void(GL_BINDING_CALL* glValidateProgramProc)(GLuint program); -typedef void(GL_BINDING_CALL* glVertexAttrib1fProc)(GLuint indx, GLfloat x); -typedef void(GL_BINDING_CALL* glVertexAttrib1fvProc)(GLuint indx, - const GLfloat* values); -typedef void(GL_BINDING_CALL* glVertexAttrib2fProc)(GLuint indx, - GLfloat x, - GLfloat y); -typedef void(GL_BINDING_CALL* glVertexAttrib2fvProc)(GLuint indx, - const GLfloat* values); -typedef void(GL_BINDING_CALL* glVertexAttrib3fProc)(GLuint indx, - GLfloat x, - GLfloat y, - GLfloat z); -typedef void(GL_BINDING_CALL* glVertexAttrib3fvProc)(GLuint indx, - const GLfloat* values); -typedef void(GL_BINDING_CALL* glVertexAttrib4fProc)(GLuint indx, - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w); -typedef void(GL_BINDING_CALL* glVertexAttrib4fvProc)(GLuint indx, - const GLfloat* values); -typedef void(GL_BINDING_CALL* glVertexAttribDivisorANGLEProc)(GLuint index, - GLuint divisor); -typedef void(GL_BINDING_CALL* glVertexAttribI4iProc)(GLuint indx, - GLint x, - GLint y, - GLint z, - GLint w); -typedef void(GL_BINDING_CALL* glVertexAttribI4ivProc)(GLuint indx, - const GLint* values); -typedef void(GL_BINDING_CALL* glVertexAttribI4uiProc)(GLuint indx, - GLuint x, - GLuint y, - GLuint z, - GLuint w); -typedef void(GL_BINDING_CALL* glVertexAttribI4uivProc)(GLuint indx, - const GLuint* values); -typedef void(GL_BINDING_CALL* glVertexAttribIPointerProc)(GLuint indx, - GLint size, - GLenum type, - GLsizei stride, - const void* ptr); -typedef void(GL_BINDING_CALL* glVertexAttribPointerProc)(GLuint indx, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const void* ptr); -typedef void(GL_BINDING_CALL* glViewportProc)(GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef GLenum(GL_BINDING_CALL* glWaitSyncProc)(GLsync sync, - GLbitfield flags, - GLuint64 timeout); - -struct ExtensionsGL { - bool b_GL_ANGLE_framebuffer_blit; - bool b_GL_ANGLE_framebuffer_multisample; - bool b_GL_ANGLE_instanced_arrays; - bool b_GL_ANGLE_translated_shader_source; - bool b_GL_APPLE_fence; - bool b_GL_APPLE_framebuffer_multisample; - bool b_GL_APPLE_vertex_array_object; - bool b_GL_ARB_draw_buffers; - bool b_GL_ARB_draw_instanced; - bool b_GL_ARB_get_program_binary; - bool b_GL_ARB_instanced_arrays; - bool b_GL_ARB_map_buffer_range; - bool b_GL_ARB_occlusion_query; - bool b_GL_ARB_robustness; - bool b_GL_ARB_sync; - bool b_GL_ARB_texture_storage; - bool b_GL_ARB_timer_query; - bool b_GL_ARB_vertex_array_object; - bool b_GL_CHROMIUM_gles_depth_binding_hack; - bool b_GL_EXT_debug_marker; - bool b_GL_EXT_direct_state_access; - bool b_GL_EXT_discard_framebuffer; - bool b_GL_EXT_disjoint_timer_query; - bool b_GL_EXT_draw_buffers; - bool b_GL_EXT_framebuffer_blit; - bool b_GL_EXT_framebuffer_multisample; - bool b_GL_EXT_framebuffer_object; - bool b_GL_EXT_map_buffer_range; - bool b_GL_EXT_multisampled_render_to_texture; - bool b_GL_EXT_occlusion_query_boolean; - bool b_GL_EXT_robustness; - bool b_GL_EXT_texture_storage; - bool b_GL_EXT_timer_query; - bool b_GL_IMG_multisampled_render_to_texture; - bool b_GL_KHR_blend_equation_advanced; - bool b_GL_KHR_debug; - bool b_GL_KHR_robustness; - bool b_GL_NV_blend_equation_advanced; - bool b_GL_NV_fence; - bool b_GL_NV_path_rendering; - bool b_GL_NV_texture_barrier; - bool b_GL_OES_EGL_image; - bool b_GL_OES_get_program_binary; - bool b_GL_OES_mapbuffer; - bool b_GL_OES_vertex_array_object; -}; - -struct ProcsGL { - glActiveTextureProc glActiveTextureFn; - glAttachShaderProc glAttachShaderFn; - glBeginQueryProc glBeginQueryFn; - glBeginTransformFeedbackProc glBeginTransformFeedbackFn; - glBindAttribLocationProc glBindAttribLocationFn; - glBindBufferProc glBindBufferFn; - glBindBufferBaseProc glBindBufferBaseFn; - glBindBufferRangeProc glBindBufferRangeFn; - glBindFragDataLocationProc glBindFragDataLocationFn; - glBindFragDataLocationIndexedProc glBindFragDataLocationIndexedFn; - glBindFramebufferEXTProc glBindFramebufferEXTFn; - glBindRenderbufferEXTProc glBindRenderbufferEXTFn; - glBindSamplerProc glBindSamplerFn; - glBindTextureProc glBindTextureFn; - glBindTransformFeedbackProc glBindTransformFeedbackFn; - glBindVertexArrayOESProc glBindVertexArrayOESFn; - glBlendBarrierKHRProc glBlendBarrierKHRFn; - glBlendColorProc glBlendColorFn; - glBlendEquationProc glBlendEquationFn; - glBlendEquationSeparateProc glBlendEquationSeparateFn; - glBlendFuncProc glBlendFuncFn; - glBlendFuncSeparateProc glBlendFuncSeparateFn; - glBlitFramebufferProc glBlitFramebufferFn; - glBlitFramebufferANGLEProc glBlitFramebufferANGLEFn; - glBlitFramebufferEXTProc glBlitFramebufferEXTFn; - glBufferDataProc glBufferDataFn; - glBufferSubDataProc glBufferSubDataFn; - glCheckFramebufferStatusEXTProc glCheckFramebufferStatusEXTFn; - glClearProc glClearFn; - glClearBufferfiProc glClearBufferfiFn; - glClearBufferfvProc glClearBufferfvFn; - glClearBufferivProc glClearBufferivFn; - glClearBufferuivProc glClearBufferuivFn; - glClearColorProc glClearColorFn; - glClearDepthProc glClearDepthFn; - glClearDepthfProc glClearDepthfFn; - glClearStencilProc glClearStencilFn; - glClientWaitSyncProc glClientWaitSyncFn; - glColorMaskProc glColorMaskFn; - glCompileShaderProc glCompileShaderFn; - glCompressedTexImage2DProc glCompressedTexImage2DFn; - glCompressedTexImage3DProc glCompressedTexImage3DFn; - glCompressedTexSubImage2DProc glCompressedTexSubImage2DFn; - glCopyBufferSubDataProc glCopyBufferSubDataFn; - glCopyTexImage2DProc glCopyTexImage2DFn; - glCopyTexSubImage2DProc glCopyTexSubImage2DFn; - glCopyTexSubImage3DProc glCopyTexSubImage3DFn; - glCreateProgramProc glCreateProgramFn; - glCreateShaderProc glCreateShaderFn; - glCullFaceProc glCullFaceFn; - glDebugMessageCallbackKHRProc glDebugMessageCallbackKHRFn; - glDebugMessageControlKHRProc glDebugMessageControlKHRFn; - glDebugMessageInsertKHRProc glDebugMessageInsertKHRFn; - glDeleteBuffersARBProc glDeleteBuffersARBFn; - glDeleteFencesAPPLEProc glDeleteFencesAPPLEFn; - glDeleteFencesNVProc glDeleteFencesNVFn; - glDeleteFramebuffersEXTProc glDeleteFramebuffersEXTFn; - glDeleteProgramProc glDeleteProgramFn; - glDeleteQueriesProc glDeleteQueriesFn; - glDeleteRenderbuffersEXTProc glDeleteRenderbuffersEXTFn; - glDeleteSamplersProc glDeleteSamplersFn; - glDeleteShaderProc glDeleteShaderFn; - glDeleteSyncProc glDeleteSyncFn; - glDeleteTexturesProc glDeleteTexturesFn; - glDeleteTransformFeedbacksProc glDeleteTransformFeedbacksFn; - glDeleteVertexArraysOESProc glDeleteVertexArraysOESFn; - glDepthFuncProc glDepthFuncFn; - glDepthMaskProc glDepthMaskFn; - glDepthRangeProc glDepthRangeFn; - glDepthRangefProc glDepthRangefFn; - glDetachShaderProc glDetachShaderFn; - glDisableProc glDisableFn; - glDisableVertexAttribArrayProc glDisableVertexAttribArrayFn; - glDiscardFramebufferEXTProc glDiscardFramebufferEXTFn; - glDrawArraysProc glDrawArraysFn; - glDrawArraysInstancedANGLEProc glDrawArraysInstancedANGLEFn; - glDrawBufferProc glDrawBufferFn; - glDrawBuffersARBProc glDrawBuffersARBFn; - glDrawElementsProc glDrawElementsFn; - glDrawElementsInstancedANGLEProc glDrawElementsInstancedANGLEFn; - glDrawRangeElementsProc glDrawRangeElementsFn; - glEGLImageTargetRenderbufferStorageOESProc - glEGLImageTargetRenderbufferStorageOESFn; - glEGLImageTargetTexture2DOESProc glEGLImageTargetTexture2DOESFn; - glEnableProc glEnableFn; - glEnableVertexAttribArrayProc glEnableVertexAttribArrayFn; - glEndQueryProc glEndQueryFn; - glEndTransformFeedbackProc glEndTransformFeedbackFn; - glFenceSyncProc glFenceSyncFn; - glFinishProc glFinishFn; - glFinishFenceAPPLEProc glFinishFenceAPPLEFn; - glFinishFenceNVProc glFinishFenceNVFn; - glFlushProc glFlushFn; - glFlushMappedBufferRangeProc glFlushMappedBufferRangeFn; - glFramebufferRenderbufferEXTProc glFramebufferRenderbufferEXTFn; - glFramebufferTexture2DEXTProc glFramebufferTexture2DEXTFn; - glFramebufferTexture2DMultisampleEXTProc - glFramebufferTexture2DMultisampleEXTFn; - glFramebufferTexture2DMultisampleIMGProc - glFramebufferTexture2DMultisampleIMGFn; - glFramebufferTextureLayerProc glFramebufferTextureLayerFn; - glFrontFaceProc glFrontFaceFn; - glGenBuffersARBProc glGenBuffersARBFn; - glGenerateMipmapEXTProc glGenerateMipmapEXTFn; - glGenFencesAPPLEProc glGenFencesAPPLEFn; - glGenFencesNVProc glGenFencesNVFn; - glGenFramebuffersEXTProc glGenFramebuffersEXTFn; - glGenQueriesProc glGenQueriesFn; - glGenRenderbuffersEXTProc glGenRenderbuffersEXTFn; - glGenSamplersProc glGenSamplersFn; - glGenTexturesProc glGenTexturesFn; - glGenTransformFeedbacksProc glGenTransformFeedbacksFn; - glGenVertexArraysOESProc glGenVertexArraysOESFn; - glGetActiveAttribProc glGetActiveAttribFn; - glGetActiveUniformProc glGetActiveUniformFn; - glGetActiveUniformBlockivProc glGetActiveUniformBlockivFn; - glGetActiveUniformBlockNameProc glGetActiveUniformBlockNameFn; - glGetActiveUniformsivProc glGetActiveUniformsivFn; - glGetAttachedShadersProc glGetAttachedShadersFn; - glGetAttribLocationProc glGetAttribLocationFn; - glGetBooleanvProc glGetBooleanvFn; - glGetBufferParameterivProc glGetBufferParameterivFn; - glGetDebugMessageLogKHRProc glGetDebugMessageLogKHRFn; - glGetErrorProc glGetErrorFn; - glGetFenceivNVProc glGetFenceivNVFn; - glGetFloatvProc glGetFloatvFn; - glGetFragDataLocationProc glGetFragDataLocationFn; - glGetFramebufferAttachmentParameterivEXTProc - glGetFramebufferAttachmentParameterivEXTFn; - glGetGraphicsResetStatusARBProc glGetGraphicsResetStatusARBFn; - glGetInteger64i_vProc glGetInteger64i_vFn; - glGetInteger64vProc glGetInteger64vFn; - glGetIntegeri_vProc glGetIntegeri_vFn; - glGetIntegervProc glGetIntegervFn; - glGetInternalformativProc glGetInternalformativFn; - glGetProgramBinaryProc glGetProgramBinaryFn; - glGetProgramInfoLogProc glGetProgramInfoLogFn; - glGetProgramivProc glGetProgramivFn; - glGetProgramResourceLocationProc glGetProgramResourceLocationFn; - glGetQueryivProc glGetQueryivFn; - glGetQueryObjecti64vProc glGetQueryObjecti64vFn; - glGetQueryObjectivProc glGetQueryObjectivFn; - glGetQueryObjectui64vProc glGetQueryObjectui64vFn; - glGetQueryObjectuivProc glGetQueryObjectuivFn; - glGetRenderbufferParameterivEXTProc glGetRenderbufferParameterivEXTFn; - glGetSamplerParameterfvProc glGetSamplerParameterfvFn; - glGetSamplerParameterivProc glGetSamplerParameterivFn; - glGetShaderInfoLogProc glGetShaderInfoLogFn; - glGetShaderivProc glGetShaderivFn; - glGetShaderPrecisionFormatProc glGetShaderPrecisionFormatFn; - glGetShaderSourceProc glGetShaderSourceFn; - glGetStringProc glGetStringFn; - glGetStringiProc glGetStringiFn; - glGetSyncivProc glGetSyncivFn; - glGetTexLevelParameterfvProc glGetTexLevelParameterfvFn; - glGetTexLevelParameterivProc glGetTexLevelParameterivFn; - glGetTexParameterfvProc glGetTexParameterfvFn; - glGetTexParameterivProc glGetTexParameterivFn; - glGetTransformFeedbackVaryingProc glGetTransformFeedbackVaryingFn; - glGetTranslatedShaderSourceANGLEProc glGetTranslatedShaderSourceANGLEFn; - glGetUniformBlockIndexProc glGetUniformBlockIndexFn; - glGetUniformfvProc glGetUniformfvFn; - glGetUniformIndicesProc glGetUniformIndicesFn; - glGetUniformivProc glGetUniformivFn; - glGetUniformLocationProc glGetUniformLocationFn; - glGetVertexAttribfvProc glGetVertexAttribfvFn; - glGetVertexAttribivProc glGetVertexAttribivFn; - glGetVertexAttribPointervProc glGetVertexAttribPointervFn; - glHintProc glHintFn; - glInsertEventMarkerEXTProc glInsertEventMarkerEXTFn; - glInvalidateFramebufferProc glInvalidateFramebufferFn; - glInvalidateSubFramebufferProc glInvalidateSubFramebufferFn; - glIsBufferProc glIsBufferFn; - glIsEnabledProc glIsEnabledFn; - glIsFenceAPPLEProc glIsFenceAPPLEFn; - glIsFenceNVProc glIsFenceNVFn; - glIsFramebufferEXTProc glIsFramebufferEXTFn; - glIsProgramProc glIsProgramFn; - glIsQueryProc glIsQueryFn; - glIsRenderbufferEXTProc glIsRenderbufferEXTFn; - glIsSamplerProc glIsSamplerFn; - glIsShaderProc glIsShaderFn; - glIsSyncProc glIsSyncFn; - glIsTextureProc glIsTextureFn; - glIsTransformFeedbackProc glIsTransformFeedbackFn; - glIsVertexArrayOESProc glIsVertexArrayOESFn; - glLineWidthProc glLineWidthFn; - glLinkProgramProc glLinkProgramFn; - glMapBufferProc glMapBufferFn; - glMapBufferRangeProc glMapBufferRangeFn; - glMatrixLoadfEXTProc glMatrixLoadfEXTFn; - glMatrixLoadIdentityEXTProc glMatrixLoadIdentityEXTFn; - glObjectLabelKHRProc glObjectLabelKHRFn; - glPauseTransformFeedbackProc glPauseTransformFeedbackFn; - glPixelStoreiProc glPixelStoreiFn; - glPointParameteriProc glPointParameteriFn; - glPolygonOffsetProc glPolygonOffsetFn; - glPopDebugGroupKHRProc glPopDebugGroupKHRFn; - glPopGroupMarkerEXTProc glPopGroupMarkerEXTFn; - glProgramBinaryProc glProgramBinaryFn; - glProgramParameteriProc glProgramParameteriFn; - glPushDebugGroupKHRProc glPushDebugGroupKHRFn; - glPushGroupMarkerEXTProc glPushGroupMarkerEXTFn; - glQueryCounterProc glQueryCounterFn; - glReadBufferProc glReadBufferFn; - glReadPixelsProc glReadPixelsFn; - glReleaseShaderCompilerProc glReleaseShaderCompilerFn; - glRenderbufferStorageEXTProc glRenderbufferStorageEXTFn; - glRenderbufferStorageMultisampleProc glRenderbufferStorageMultisampleFn; - glRenderbufferStorageMultisampleANGLEProc - glRenderbufferStorageMultisampleANGLEFn; - glRenderbufferStorageMultisampleAPPLEProc - glRenderbufferStorageMultisampleAPPLEFn; - glRenderbufferStorageMultisampleEXTProc glRenderbufferStorageMultisampleEXTFn; - glRenderbufferStorageMultisampleIMGProc glRenderbufferStorageMultisampleIMGFn; - glResolveMultisampleFramebufferAPPLEProc - glResolveMultisampleFramebufferAPPLEFn; - glResumeTransformFeedbackProc glResumeTransformFeedbackFn; - glSampleCoverageProc glSampleCoverageFn; - glSamplerParameterfProc glSamplerParameterfFn; - glSamplerParameterfvProc glSamplerParameterfvFn; - glSamplerParameteriProc glSamplerParameteriFn; - glSamplerParameterivProc glSamplerParameterivFn; - glScissorProc glScissorFn; - glSetFenceAPPLEProc glSetFenceAPPLEFn; - glSetFenceNVProc glSetFenceNVFn; - glShaderBinaryProc glShaderBinaryFn; - glShaderSourceProc glShaderSourceFn; - glStencilFuncProc glStencilFuncFn; - glStencilFuncSeparateProc glStencilFuncSeparateFn; - glStencilMaskProc glStencilMaskFn; - glStencilMaskSeparateProc glStencilMaskSeparateFn; - glStencilOpProc glStencilOpFn; - glStencilOpSeparateProc glStencilOpSeparateFn; - glTestFenceAPPLEProc glTestFenceAPPLEFn; - glTestFenceNVProc glTestFenceNVFn; - glTexImage2DProc glTexImage2DFn; - glTexImage3DProc glTexImage3DFn; - glTexParameterfProc glTexParameterfFn; - glTexParameterfvProc glTexParameterfvFn; - glTexParameteriProc glTexParameteriFn; - glTexParameterivProc glTexParameterivFn; - glTexStorage2DEXTProc glTexStorage2DEXTFn; - glTexStorage3DProc glTexStorage3DFn; - glTexSubImage2DProc glTexSubImage2DFn; - glTextureBarrierNVProc glTextureBarrierNVFn; - glTransformFeedbackVaryingsProc glTransformFeedbackVaryingsFn; - glUniform1fProc glUniform1fFn; - glUniform1fvProc glUniform1fvFn; - glUniform1iProc glUniform1iFn; - glUniform1ivProc glUniform1ivFn; - glUniform1uiProc glUniform1uiFn; - glUniform1uivProc glUniform1uivFn; - glUniform2fProc glUniform2fFn; - glUniform2fvProc glUniform2fvFn; - glUniform2iProc glUniform2iFn; - glUniform2ivProc glUniform2ivFn; - glUniform2uiProc glUniform2uiFn; - glUniform2uivProc glUniform2uivFn; - glUniform3fProc glUniform3fFn; - glUniform3fvProc glUniform3fvFn; - glUniform3iProc glUniform3iFn; - glUniform3ivProc glUniform3ivFn; - glUniform3uiProc glUniform3uiFn; - glUniform3uivProc glUniform3uivFn; - glUniform4fProc glUniform4fFn; - glUniform4fvProc glUniform4fvFn; - glUniform4iProc glUniform4iFn; - glUniform4ivProc glUniform4ivFn; - glUniform4uiProc glUniform4uiFn; - glUniform4uivProc glUniform4uivFn; - glUniformBlockBindingProc glUniformBlockBindingFn; - glUniformMatrix2fvProc glUniformMatrix2fvFn; - glUniformMatrix2x3fvProc glUniformMatrix2x3fvFn; - glUniformMatrix2x4fvProc glUniformMatrix2x4fvFn; - glUniformMatrix3fvProc glUniformMatrix3fvFn; - glUniformMatrix3x2fvProc glUniformMatrix3x2fvFn; - glUniformMatrix3x4fvProc glUniformMatrix3x4fvFn; - glUniformMatrix4fvProc glUniformMatrix4fvFn; - glUniformMatrix4x2fvProc glUniformMatrix4x2fvFn; - glUniformMatrix4x3fvProc glUniformMatrix4x3fvFn; - glUnmapBufferProc glUnmapBufferFn; - glUseProgramProc glUseProgramFn; - glValidateProgramProc glValidateProgramFn; - glVertexAttrib1fProc glVertexAttrib1fFn; - glVertexAttrib1fvProc glVertexAttrib1fvFn; - glVertexAttrib2fProc glVertexAttrib2fFn; - glVertexAttrib2fvProc glVertexAttrib2fvFn; - glVertexAttrib3fProc glVertexAttrib3fFn; - glVertexAttrib3fvProc glVertexAttrib3fvFn; - glVertexAttrib4fProc glVertexAttrib4fFn; - glVertexAttrib4fvProc glVertexAttrib4fvFn; - glVertexAttribDivisorANGLEProc glVertexAttribDivisorANGLEFn; - glVertexAttribI4iProc glVertexAttribI4iFn; - glVertexAttribI4ivProc glVertexAttribI4ivFn; - glVertexAttribI4uiProc glVertexAttribI4uiFn; - glVertexAttribI4uivProc glVertexAttribI4uivFn; - glVertexAttribIPointerProc glVertexAttribIPointerFn; - glVertexAttribPointerProc glVertexAttribPointerFn; - glViewportProc glViewportFn; - glWaitSyncProc glWaitSyncFn; -}; - -class GL_EXPORT GLApi { - public: - GLApi(); - virtual ~GLApi(); - - virtual void glActiveTextureFn(GLenum texture) = 0; - virtual void glAttachShaderFn(GLuint program, GLuint shader) = 0; - virtual void glBeginQueryFn(GLenum target, GLuint id) = 0; - virtual void glBeginTransformFeedbackFn(GLenum primitiveMode) = 0; - virtual void glBindAttribLocationFn(GLuint program, - GLuint index, - const char* name) = 0; - virtual void glBindBufferFn(GLenum target, GLuint buffer) = 0; - virtual void glBindBufferBaseFn(GLenum target, - GLuint index, - GLuint buffer) = 0; - virtual void glBindBufferRangeFn(GLenum target, - GLuint index, - GLuint buffer, - GLintptr offset, - GLsizeiptr size) = 0; - virtual void glBindFragDataLocationFn(GLuint program, - GLuint colorNumber, - const char* name) = 0; - virtual void glBindFragDataLocationIndexedFn(GLuint program, - GLuint colorNumber, - GLuint index, - const char* name) = 0; - virtual void glBindFramebufferEXTFn(GLenum target, GLuint framebuffer) = 0; - virtual void glBindRenderbufferEXTFn(GLenum target, GLuint renderbuffer) = 0; - virtual void glBindSamplerFn(GLuint unit, GLuint sampler) = 0; - virtual void glBindTextureFn(GLenum target, GLuint texture) = 0; - virtual void glBindTransformFeedbackFn(GLenum target, GLuint id) = 0; - virtual void glBindVertexArrayOESFn(GLuint array) = 0; - virtual void glBlendBarrierKHRFn(void) = 0; - virtual void glBlendColorFn(GLclampf red, - GLclampf green, - GLclampf blue, - GLclampf alpha) = 0; - virtual void glBlendEquationFn(GLenum mode) = 0; - virtual void glBlendEquationSeparateFn(GLenum modeRGB, GLenum modeAlpha) = 0; - virtual void glBlendFuncFn(GLenum sfactor, GLenum dfactor) = 0; - virtual void glBlendFuncSeparateFn(GLenum srcRGB, - GLenum dstRGB, - GLenum srcAlpha, - GLenum dstAlpha) = 0; - virtual void glBlitFramebufferFn(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) = 0; - virtual void glBlitFramebufferANGLEFn(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) = 0; - virtual void glBlitFramebufferEXTFn(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) = 0; - virtual void glBufferDataFn(GLenum target, - GLsizeiptr size, - const void* data, - GLenum usage) = 0; - virtual void glBufferSubDataFn(GLenum target, - GLintptr offset, - GLsizeiptr size, - const void* data) = 0; - virtual GLenum glCheckFramebufferStatusEXTFn(GLenum target) = 0; - virtual void glClearFn(GLbitfield mask) = 0; - virtual void glClearBufferfiFn(GLenum buffer, - GLint drawbuffer, - const GLfloat depth, - GLint stencil) = 0; - virtual void glClearBufferfvFn(GLenum buffer, - GLint drawbuffer, - const GLfloat* value) = 0; - virtual void glClearBufferivFn(GLenum buffer, - GLint drawbuffer, - const GLint* value) = 0; - virtual void glClearBufferuivFn(GLenum buffer, - GLint drawbuffer, - const GLuint* value) = 0; - virtual void glClearColorFn(GLclampf red, - GLclampf green, - GLclampf blue, - GLclampf alpha) = 0; - virtual void glClearDepthFn(GLclampd depth) = 0; - virtual void glClearDepthfFn(GLclampf depth) = 0; - virtual void glClearStencilFn(GLint s) = 0; - virtual GLenum glClientWaitSyncFn(GLsync sync, - GLbitfield flags, - GLuint64 timeout) = 0; - virtual void glColorMaskFn(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha) = 0; - virtual void glCompileShaderFn(GLuint shader) = 0; - virtual void glCompressedTexImage2DFn(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const void* data) = 0; - virtual void glCompressedTexImage3DFn(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLsizei imageSize, - const void* data) = 0; - virtual void glCompressedTexSubImage2DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const void* data) = 0; - virtual void glCopyBufferSubDataFn(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size) = 0; - virtual void glCopyTexImage2DFn(GLenum target, - GLint level, - GLenum internalformat, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLint border) = 0; - virtual void glCopyTexSubImage2DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height) = 0; - virtual void glCopyTexSubImage3DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height) = 0; - virtual GLuint glCreateProgramFn(void) = 0; - virtual GLuint glCreateShaderFn(GLenum type) = 0; - virtual void glCullFaceFn(GLenum mode) = 0; - virtual void glDebugMessageCallbackKHRFn(GLDEBUGPROCKHR callback, - const void* userparam) = 0; - virtual void glDebugMessageControlKHRFn(GLenum source, - GLenum type, - GLenum severity, - GLsizei count, - const GLuint* ids, - GLboolean enabled) = 0; - virtual void glDebugMessageInsertKHRFn(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar* buf) = 0; - virtual void glDeleteBuffersARBFn(GLsizei n, const GLuint* buffers) = 0; - virtual void glDeleteFencesAPPLEFn(GLsizei n, const GLuint* fences) = 0; - virtual void glDeleteFencesNVFn(GLsizei n, const GLuint* fences) = 0; - virtual void glDeleteFramebuffersEXTFn(GLsizei n, - const GLuint* framebuffers) = 0; - virtual void glDeleteProgramFn(GLuint program) = 0; - virtual void glDeleteQueriesFn(GLsizei n, const GLuint* ids) = 0; - virtual void glDeleteRenderbuffersEXTFn(GLsizei n, - const GLuint* renderbuffers) = 0; - virtual void glDeleteSamplersFn(GLsizei n, const GLuint* samplers) = 0; - virtual void glDeleteShaderFn(GLuint shader) = 0; - virtual void glDeleteSyncFn(GLsync sync) = 0; - virtual void glDeleteTexturesFn(GLsizei n, const GLuint* textures) = 0; - virtual void glDeleteTransformFeedbacksFn(GLsizei n, const GLuint* ids) = 0; - virtual void glDeleteVertexArraysOESFn(GLsizei n, const GLuint* arrays) = 0; - virtual void glDepthFuncFn(GLenum func) = 0; - virtual void glDepthMaskFn(GLboolean flag) = 0; - virtual void glDepthRangeFn(GLclampd zNear, GLclampd zFar) = 0; - virtual void glDepthRangefFn(GLclampf zNear, GLclampf zFar) = 0; - virtual void glDetachShaderFn(GLuint program, GLuint shader) = 0; - virtual void glDisableFn(GLenum cap) = 0; - virtual void glDisableVertexAttribArrayFn(GLuint index) = 0; - virtual void glDiscardFramebufferEXTFn(GLenum target, - GLsizei numAttachments, - const GLenum* attachments) = 0; - virtual void glDrawArraysFn(GLenum mode, GLint first, GLsizei count) = 0; - virtual void glDrawArraysInstancedANGLEFn(GLenum mode, - GLint first, - GLsizei count, - GLsizei primcount) = 0; - virtual void glDrawBufferFn(GLenum mode) = 0; - virtual void glDrawBuffersARBFn(GLsizei n, const GLenum* bufs) = 0; - virtual void glDrawElementsFn(GLenum mode, - GLsizei count, - GLenum type, - const void* indices) = 0; - virtual void glDrawElementsInstancedANGLEFn(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei primcount) = 0; - virtual void glDrawRangeElementsFn(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices) = 0; - virtual void glEGLImageTargetRenderbufferStorageOESFn( - GLenum target, - GLeglImageOES image) = 0; - virtual void glEGLImageTargetTexture2DOESFn(GLenum target, - GLeglImageOES image) = 0; - virtual void glEnableFn(GLenum cap) = 0; - virtual void glEnableVertexAttribArrayFn(GLuint index) = 0; - virtual void glEndQueryFn(GLenum target) = 0; - virtual void glEndTransformFeedbackFn(void) = 0; - virtual GLsync glFenceSyncFn(GLenum condition, GLbitfield flags) = 0; - virtual void glFinishFn(void) = 0; - virtual void glFinishFenceAPPLEFn(GLuint fence) = 0; - virtual void glFinishFenceNVFn(GLuint fence) = 0; - virtual void glFlushFn(void) = 0; - virtual void glFlushMappedBufferRangeFn(GLenum target, - GLintptr offset, - GLsizeiptr length) = 0; - virtual void glFramebufferRenderbufferEXTFn(GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer) = 0; - virtual void glFramebufferTexture2DEXTFn(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level) = 0; - virtual void glFramebufferTexture2DMultisampleEXTFn(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples) = 0; - virtual void glFramebufferTexture2DMultisampleIMGFn(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples) = 0; - virtual void glFramebufferTextureLayerFn(GLenum target, - GLenum attachment, - GLuint texture, - GLint level, - GLint layer) = 0; - virtual void glFrontFaceFn(GLenum mode) = 0; - virtual void glGenBuffersARBFn(GLsizei n, GLuint* buffers) = 0; - virtual void glGenerateMipmapEXTFn(GLenum target) = 0; - virtual void glGenFencesAPPLEFn(GLsizei n, GLuint* fences) = 0; - virtual void glGenFencesNVFn(GLsizei n, GLuint* fences) = 0; - virtual void glGenFramebuffersEXTFn(GLsizei n, GLuint* framebuffers) = 0; - virtual void glGenQueriesFn(GLsizei n, GLuint* ids) = 0; - virtual void glGenRenderbuffersEXTFn(GLsizei n, GLuint* renderbuffers) = 0; - virtual void glGenSamplersFn(GLsizei n, GLuint* samplers) = 0; - virtual void glGenTexturesFn(GLsizei n, GLuint* textures) = 0; - virtual void glGenTransformFeedbacksFn(GLsizei n, GLuint* ids) = 0; - virtual void glGenVertexArraysOESFn(GLsizei n, GLuint* arrays) = 0; - virtual void glGetActiveAttribFn(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - char* name) = 0; - virtual void glGetActiveUniformFn(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - char* name) = 0; - virtual void glGetActiveUniformBlockivFn(GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint* params) = 0; - virtual void glGetActiveUniformBlockNameFn(GLuint program, - GLuint uniformBlockIndex, - GLsizei bufSize, - GLsizei* length, - char* uniformBlockName) = 0; - virtual void glGetActiveUniformsivFn(GLuint program, - GLsizei uniformCount, - const GLuint* uniformIndices, - GLenum pname, - GLint* params) = 0; - virtual void glGetAttachedShadersFn(GLuint program, - GLsizei maxcount, - GLsizei* count, - GLuint* shaders) = 0; - virtual GLint glGetAttribLocationFn(GLuint program, const char* name) = 0; - virtual void glGetBooleanvFn(GLenum pname, GLboolean* params) = 0; - virtual void glGetBufferParameterivFn(GLenum target, - GLenum pname, - GLint* params) = 0; - virtual GLuint glGetDebugMessageLogKHRFn(GLuint count, - GLsizei bufSize, - GLenum* sources, - GLenum* types, - GLuint* ids, - GLenum* severities, - GLsizei* lengths, - GLchar* messageLog) = 0; - virtual GLenum glGetErrorFn(void) = 0; - virtual void glGetFenceivNVFn(GLuint fence, GLenum pname, GLint* params) = 0; - virtual void glGetFloatvFn(GLenum pname, GLfloat* params) = 0; - virtual GLint glGetFragDataLocationFn(GLuint program, const char* name) = 0; - virtual void glGetFramebufferAttachmentParameterivEXTFn(GLenum target, - GLenum attachment, - GLenum pname, - GLint* params) = 0; - virtual GLenum glGetGraphicsResetStatusARBFn(void) = 0; - virtual void glGetInteger64i_vFn(GLenum target, - GLuint index, - GLint64* data) = 0; - virtual void glGetInteger64vFn(GLenum pname, GLint64* params) = 0; - virtual void glGetIntegeri_vFn(GLenum target, GLuint index, GLint* data) = 0; - virtual void glGetIntegervFn(GLenum pname, GLint* params) = 0; - virtual void glGetInternalformativFn(GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLint* params) = 0; - virtual void glGetProgramBinaryFn(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - GLvoid* binary) = 0; - virtual void glGetProgramInfoLogFn(GLuint program, - GLsizei bufsize, - GLsizei* length, - char* infolog) = 0; - virtual void glGetProgramivFn(GLuint program, - GLenum pname, - GLint* params) = 0; - virtual GLint glGetProgramResourceLocationFn(GLuint program, - GLenum programInterface, - const char* name) = 0; - virtual void glGetQueryivFn(GLenum target, GLenum pname, GLint* params) = 0; - virtual void glGetQueryObjecti64vFn(GLuint id, - GLenum pname, - GLint64* params) = 0; - virtual void glGetQueryObjectivFn(GLuint id, GLenum pname, GLint* params) = 0; - virtual void glGetQueryObjectui64vFn(GLuint id, - GLenum pname, - GLuint64* params) = 0; - virtual void glGetQueryObjectuivFn(GLuint id, - GLenum pname, - GLuint* params) = 0; - virtual void glGetRenderbufferParameterivEXTFn(GLenum target, - GLenum pname, - GLint* params) = 0; - virtual void glGetSamplerParameterfvFn(GLuint sampler, - GLenum pname, - GLfloat* params) = 0; - virtual void glGetSamplerParameterivFn(GLuint sampler, - GLenum pname, - GLint* params) = 0; - virtual void glGetShaderInfoLogFn(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* infolog) = 0; - virtual void glGetShaderivFn(GLuint shader, GLenum pname, GLint* params) = 0; - virtual void glGetShaderPrecisionFormatFn(GLenum shadertype, - GLenum precisiontype, - GLint* range, - GLint* precision) = 0; - virtual void glGetShaderSourceFn(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* source) = 0; - virtual const GLubyte* glGetStringFn(GLenum name) = 0; - virtual const GLubyte* glGetStringiFn(GLenum name, GLuint index) = 0; - virtual void glGetSyncivFn(GLsync sync, - GLenum pname, - GLsizei bufSize, - GLsizei* length, - GLint* values) = 0; - virtual void glGetTexLevelParameterfvFn(GLenum target, - GLint level, - GLenum pname, - GLfloat* params) = 0; - virtual void glGetTexLevelParameterivFn(GLenum target, - GLint level, - GLenum pname, - GLint* params) = 0; - virtual void glGetTexParameterfvFn(GLenum target, - GLenum pname, - GLfloat* params) = 0; - virtual void glGetTexParameterivFn(GLenum target, - GLenum pname, - GLint* params) = 0; - virtual void glGetTransformFeedbackVaryingFn(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLsizei* size, - GLenum* type, - char* name) = 0; - virtual void glGetTranslatedShaderSourceANGLEFn(GLuint shader, - GLsizei bufsize, - GLsizei* length, - char* source) = 0; - virtual GLuint glGetUniformBlockIndexFn(GLuint program, - const char* uniformBlockName) = 0; - virtual void glGetUniformfvFn(GLuint program, - GLint location, - GLfloat* params) = 0; - virtual void glGetUniformIndicesFn(GLuint program, - GLsizei uniformCount, - const char* const* uniformNames, - GLuint* uniformIndices) = 0; - virtual void glGetUniformivFn(GLuint program, - GLint location, - GLint* params) = 0; - virtual GLint glGetUniformLocationFn(GLuint program, const char* name) = 0; - virtual void glGetVertexAttribfvFn(GLuint index, - GLenum pname, - GLfloat* params) = 0; - virtual void glGetVertexAttribivFn(GLuint index, - GLenum pname, - GLint* params) = 0; - virtual void glGetVertexAttribPointervFn(GLuint index, - GLenum pname, - void** pointer) = 0; - virtual void glHintFn(GLenum target, GLenum mode) = 0; - virtual void glInsertEventMarkerEXTFn(GLsizei length, const char* marker) = 0; - virtual void glInvalidateFramebufferFn(GLenum target, - GLsizei numAttachments, - const GLenum* attachments) = 0; - virtual void glInvalidateSubFramebufferFn(GLenum target, - GLsizei numAttachments, - const GLenum* attachments, - GLint x, - GLint y, - GLint width, - GLint height) = 0; - virtual GLboolean glIsBufferFn(GLuint buffer) = 0; - virtual GLboolean glIsEnabledFn(GLenum cap) = 0; - virtual GLboolean glIsFenceAPPLEFn(GLuint fence) = 0; - virtual GLboolean glIsFenceNVFn(GLuint fence) = 0; - virtual GLboolean glIsFramebufferEXTFn(GLuint framebuffer) = 0; - virtual GLboolean glIsProgramFn(GLuint program) = 0; - virtual GLboolean glIsQueryFn(GLuint query) = 0; - virtual GLboolean glIsRenderbufferEXTFn(GLuint renderbuffer) = 0; - virtual GLboolean glIsSamplerFn(GLuint sampler) = 0; - virtual GLboolean glIsShaderFn(GLuint shader) = 0; - virtual GLboolean glIsSyncFn(GLsync sync) = 0; - virtual GLboolean glIsTextureFn(GLuint texture) = 0; - virtual GLboolean glIsTransformFeedbackFn(GLuint id) = 0; - virtual GLboolean glIsVertexArrayOESFn(GLuint array) = 0; - virtual void glLineWidthFn(GLfloat width) = 0; - virtual void glLinkProgramFn(GLuint program) = 0; - virtual void* glMapBufferFn(GLenum target, GLenum access) = 0; - virtual void* glMapBufferRangeFn(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access) = 0; - virtual void glMatrixLoadfEXTFn(GLenum matrixMode, const GLfloat* m) = 0; - virtual void glMatrixLoadIdentityEXTFn(GLenum matrixMode) = 0; - virtual void glObjectLabelKHRFn(GLenum identifier, - GLuint name, - GLsizei length, - const GLchar* label) = 0; - virtual void glPauseTransformFeedbackFn(void) = 0; - virtual void glPixelStoreiFn(GLenum pname, GLint param) = 0; - virtual void glPointParameteriFn(GLenum pname, GLint param) = 0; - virtual void glPolygonOffsetFn(GLfloat factor, GLfloat units) = 0; - virtual void glPopDebugGroupKHRFn(void) = 0; - virtual void glPopGroupMarkerEXTFn(void) = 0; - virtual void glProgramBinaryFn(GLuint program, - GLenum binaryFormat, - const GLvoid* binary, - GLsizei length) = 0; - virtual void glProgramParameteriFn(GLuint program, - GLenum pname, - GLint value) = 0; - virtual void glPushDebugGroupKHRFn(GLenum source, - GLuint id, - GLsizei length, - const GLchar* message) = 0; - virtual void glPushGroupMarkerEXTFn(GLsizei length, const char* marker) = 0; - virtual void glQueryCounterFn(GLuint id, GLenum target) = 0; - virtual void glReadBufferFn(GLenum src) = 0; - virtual void glReadPixelsFn(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - void* pixels) = 0; - virtual void glReleaseShaderCompilerFn(void) = 0; - virtual void glRenderbufferStorageEXTFn(GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height) = 0; - virtual void glRenderbufferStorageMultisampleFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) = 0; - virtual void glRenderbufferStorageMultisampleANGLEFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) = 0; - virtual void glRenderbufferStorageMultisampleAPPLEFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) = 0; - virtual void glRenderbufferStorageMultisampleEXTFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) = 0; - virtual void glRenderbufferStorageMultisampleIMGFn(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) = 0; - virtual void glResolveMultisampleFramebufferAPPLEFn(void) = 0; - virtual void glResumeTransformFeedbackFn(void) = 0; - virtual void glSampleCoverageFn(GLclampf value, GLboolean invert) = 0; - virtual void glSamplerParameterfFn(GLuint sampler, - GLenum pname, - GLfloat param) = 0; - virtual void glSamplerParameterfvFn(GLuint sampler, - GLenum pname, - const GLfloat* params) = 0; - virtual void glSamplerParameteriFn(GLuint sampler, - GLenum pname, - GLint param) = 0; - virtual void glSamplerParameterivFn(GLuint sampler, - GLenum pname, - const GLint* params) = 0; - virtual void glScissorFn(GLint x, GLint y, GLsizei width, GLsizei height) = 0; - virtual void glSetFenceAPPLEFn(GLuint fence) = 0; - virtual void glSetFenceNVFn(GLuint fence, GLenum condition) = 0; - virtual void glShaderBinaryFn(GLsizei n, - const GLuint* shaders, - GLenum binaryformat, - const void* binary, - GLsizei length) = 0; - virtual void glShaderSourceFn(GLuint shader, - GLsizei count, - const char* const* str, - const GLint* length) = 0; - virtual void glStencilFuncFn(GLenum func, GLint ref, GLuint mask) = 0; - virtual void glStencilFuncSeparateFn(GLenum face, - GLenum func, - GLint ref, - GLuint mask) = 0; - virtual void glStencilMaskFn(GLuint mask) = 0; - virtual void glStencilMaskSeparateFn(GLenum face, GLuint mask) = 0; - virtual void glStencilOpFn(GLenum fail, GLenum zfail, GLenum zpass) = 0; - virtual void glStencilOpSeparateFn(GLenum face, - GLenum fail, - GLenum zfail, - GLenum zpass) = 0; - virtual GLboolean glTestFenceAPPLEFn(GLuint fence) = 0; - virtual GLboolean glTestFenceNVFn(GLuint fence) = 0; - virtual void glTexImage2DFn(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const void* pixels) = 0; - virtual void glTexImage3DFn(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - const void* pixels) = 0; - virtual void glTexParameterfFn(GLenum target, - GLenum pname, - GLfloat param) = 0; - virtual void glTexParameterfvFn(GLenum target, - GLenum pname, - const GLfloat* params) = 0; - virtual void glTexParameteriFn(GLenum target, GLenum pname, GLint param) = 0; - virtual void glTexParameterivFn(GLenum target, - GLenum pname, - const GLint* params) = 0; - virtual void glTexStorage2DEXTFn(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height) = 0; - virtual void glTexStorage3DFn(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth) = 0; - virtual void glTexSubImage2DFn(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const void* pixels) = 0; - virtual void glTextureBarrierNVFn(void) = 0; - virtual void glTransformFeedbackVaryingsFn(GLuint program, - GLsizei count, - const char* const* varyings, - GLenum bufferMode) = 0; - virtual void glUniform1fFn(GLint location, GLfloat x) = 0; - virtual void glUniform1fvFn(GLint location, - GLsizei count, - const GLfloat* v) = 0; - virtual void glUniform1iFn(GLint location, GLint x) = 0; - virtual void glUniform1ivFn(GLint location, - GLsizei count, - const GLint* v) = 0; - virtual void glUniform1uiFn(GLint location, GLuint v0) = 0; - virtual void glUniform1uivFn(GLint location, - GLsizei count, - const GLuint* v) = 0; - virtual void glUniform2fFn(GLint location, GLfloat x, GLfloat y) = 0; - virtual void glUniform2fvFn(GLint location, - GLsizei count, - const GLfloat* v) = 0; - virtual void glUniform2iFn(GLint location, GLint x, GLint y) = 0; - virtual void glUniform2ivFn(GLint location, - GLsizei count, - const GLint* v) = 0; - virtual void glUniform2uiFn(GLint location, GLuint v0, GLuint v1) = 0; - virtual void glUniform2uivFn(GLint location, - GLsizei count, - const GLuint* v) = 0; - virtual void glUniform3fFn(GLint location, - GLfloat x, - GLfloat y, - GLfloat z) = 0; - virtual void glUniform3fvFn(GLint location, - GLsizei count, - const GLfloat* v) = 0; - virtual void glUniform3iFn(GLint location, GLint x, GLint y, GLint z) = 0; - virtual void glUniform3ivFn(GLint location, - GLsizei count, - const GLint* v) = 0; - virtual void glUniform3uiFn(GLint location, - GLuint v0, - GLuint v1, - GLuint v2) = 0; - virtual void glUniform3uivFn(GLint location, - GLsizei count, - const GLuint* v) = 0; - virtual void glUniform4fFn(GLint location, - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w) = 0; - virtual void glUniform4fvFn(GLint location, - GLsizei count, - const GLfloat* v) = 0; - virtual void glUniform4iFn(GLint location, - GLint x, - GLint y, - GLint z, - GLint w) = 0; - virtual void glUniform4ivFn(GLint location, - GLsizei count, - const GLint* v) = 0; - virtual void glUniform4uiFn(GLint location, - GLuint v0, - GLuint v1, - GLuint v2, - GLuint v3) = 0; - virtual void glUniform4uivFn(GLint location, - GLsizei count, - const GLuint* v) = 0; - virtual void glUniformBlockBindingFn(GLuint program, - GLuint uniformBlockIndex, - GLuint uniformBlockBinding) = 0; - virtual void glUniformMatrix2fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) = 0; - virtual void glUniformMatrix2x3fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) = 0; - virtual void glUniformMatrix2x4fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) = 0; - virtual void glUniformMatrix3fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) = 0; - virtual void glUniformMatrix3x2fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) = 0; - virtual void glUniformMatrix3x4fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) = 0; - virtual void glUniformMatrix4fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) = 0; - virtual void glUniformMatrix4x2fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) = 0; - virtual void glUniformMatrix4x3fvFn(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) = 0; - virtual GLboolean glUnmapBufferFn(GLenum target) = 0; - virtual void glUseProgramFn(GLuint program) = 0; - virtual void glValidateProgramFn(GLuint program) = 0; - virtual void glVertexAttrib1fFn(GLuint indx, GLfloat x) = 0; - virtual void glVertexAttrib1fvFn(GLuint indx, const GLfloat* values) = 0; - virtual void glVertexAttrib2fFn(GLuint indx, GLfloat x, GLfloat y) = 0; - virtual void glVertexAttrib2fvFn(GLuint indx, const GLfloat* values) = 0; - virtual void glVertexAttrib3fFn(GLuint indx, - GLfloat x, - GLfloat y, - GLfloat z) = 0; - virtual void glVertexAttrib3fvFn(GLuint indx, const GLfloat* values) = 0; - virtual void glVertexAttrib4fFn(GLuint indx, - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w) = 0; - virtual void glVertexAttrib4fvFn(GLuint indx, const GLfloat* values) = 0; - virtual void glVertexAttribDivisorANGLEFn(GLuint index, GLuint divisor) = 0; - virtual void glVertexAttribI4iFn(GLuint indx, - GLint x, - GLint y, - GLint z, - GLint w) = 0; - virtual void glVertexAttribI4ivFn(GLuint indx, const GLint* values) = 0; - virtual void glVertexAttribI4uiFn(GLuint indx, - GLuint x, - GLuint y, - GLuint z, - GLuint w) = 0; - virtual void glVertexAttribI4uivFn(GLuint indx, const GLuint* values) = 0; - virtual void glVertexAttribIPointerFn(GLuint indx, - GLint size, - GLenum type, - GLsizei stride, - const void* ptr) = 0; - virtual void glVertexAttribPointerFn(GLuint indx, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const void* ptr) = 0; - virtual void glViewportFn(GLint x, - GLint y, - GLsizei width, - GLsizei height) = 0; - virtual GLenum glWaitSyncFn(GLsync sync, - GLbitfield flags, - GLuint64 timeout) = 0; -}; - -} // namespace gfx - -#define glActiveTexture ::gfx::g_current_gl_context->glActiveTextureFn -#define glAttachShader ::gfx::g_current_gl_context->glAttachShaderFn -#define glBeginQuery ::gfx::g_current_gl_context->glBeginQueryFn -#define glBeginTransformFeedback \ - ::gfx::g_current_gl_context->glBeginTransformFeedbackFn -#define glBindAttribLocation ::gfx::g_current_gl_context->glBindAttribLocationFn -#define glBindBuffer ::gfx::g_current_gl_context->glBindBufferFn -#define glBindBufferBase ::gfx::g_current_gl_context->glBindBufferBaseFn -#define glBindBufferRange ::gfx::g_current_gl_context->glBindBufferRangeFn -#define glBindFragDataLocation \ - ::gfx::g_current_gl_context->glBindFragDataLocationFn -#define glBindFragDataLocationIndexed \ - ::gfx::g_current_gl_context->glBindFragDataLocationIndexedFn -#define glBindFramebufferEXT ::gfx::g_current_gl_context->glBindFramebufferEXTFn -#define glBindRenderbufferEXT \ - ::gfx::g_current_gl_context->glBindRenderbufferEXTFn -#define glBindSampler ::gfx::g_current_gl_context->glBindSamplerFn -#define glBindTexture ::gfx::g_current_gl_context->glBindTextureFn -#define glBindTransformFeedback \ - ::gfx::g_current_gl_context->glBindTransformFeedbackFn -#define glBindVertexArrayOES ::gfx::g_current_gl_context->glBindVertexArrayOESFn -#define glBlendBarrierKHR ::gfx::g_current_gl_context->glBlendBarrierKHRFn -#define glBlendColor ::gfx::g_current_gl_context->glBlendColorFn -#define glBlendEquation ::gfx::g_current_gl_context->glBlendEquationFn -#define glBlendEquationSeparate \ - ::gfx::g_current_gl_context->glBlendEquationSeparateFn -#define glBlendFunc ::gfx::g_current_gl_context->glBlendFuncFn -#define glBlendFuncSeparate ::gfx::g_current_gl_context->glBlendFuncSeparateFn -#define glBlitFramebuffer ::gfx::g_current_gl_context->glBlitFramebufferFn -#define glBlitFramebufferANGLE \ - ::gfx::g_current_gl_context->glBlitFramebufferANGLEFn -#define glBlitFramebufferEXT ::gfx::g_current_gl_context->glBlitFramebufferEXTFn -#define glBufferData ::gfx::g_current_gl_context->glBufferDataFn -#define glBufferSubData ::gfx::g_current_gl_context->glBufferSubDataFn -#define glCheckFramebufferStatusEXT \ - ::gfx::g_current_gl_context->glCheckFramebufferStatusEXTFn -#define glClear ::gfx::g_current_gl_context->glClearFn -#define glClearBufferfi ::gfx::g_current_gl_context->glClearBufferfiFn -#define glClearBufferfv ::gfx::g_current_gl_context->glClearBufferfvFn -#define glClearBufferiv ::gfx::g_current_gl_context->glClearBufferivFn -#define glClearBufferuiv ::gfx::g_current_gl_context->glClearBufferuivFn -#define glClearColor ::gfx::g_current_gl_context->glClearColorFn -#define glClearDepth ::gfx::g_current_gl_context->glClearDepthFn -#define glClearDepthf ::gfx::g_current_gl_context->glClearDepthfFn -#define glClearStencil ::gfx::g_current_gl_context->glClearStencilFn -#define glClientWaitSync ::gfx::g_current_gl_context->glClientWaitSyncFn -#define glColorMask ::gfx::g_current_gl_context->glColorMaskFn -#define glCompileShader ::gfx::g_current_gl_context->glCompileShaderFn -#define glCompressedTexImage2D \ - ::gfx::g_current_gl_context->glCompressedTexImage2DFn -#define glCompressedTexImage3D \ - ::gfx::g_current_gl_context->glCompressedTexImage3DFn -#define glCompressedTexSubImage2D \ - ::gfx::g_current_gl_context->glCompressedTexSubImage2DFn -#define glCopyBufferSubData ::gfx::g_current_gl_context->glCopyBufferSubDataFn -#define glCopyTexImage2D ::gfx::g_current_gl_context->glCopyTexImage2DFn -#define glCopyTexSubImage2D ::gfx::g_current_gl_context->glCopyTexSubImage2DFn -#define glCopyTexSubImage3D ::gfx::g_current_gl_context->glCopyTexSubImage3DFn -#define glCreateProgram ::gfx::g_current_gl_context->glCreateProgramFn -#define glCreateShader ::gfx::g_current_gl_context->glCreateShaderFn -#define glCullFace ::gfx::g_current_gl_context->glCullFaceFn -#define glDebugMessageCallbackKHR \ - ::gfx::g_current_gl_context->glDebugMessageCallbackKHRFn -#define glDebugMessageControlKHR \ - ::gfx::g_current_gl_context->glDebugMessageControlKHRFn -#define glDebugMessageInsertKHR \ - ::gfx::g_current_gl_context->glDebugMessageInsertKHRFn -#define glDeleteBuffersARB ::gfx::g_current_gl_context->glDeleteBuffersARBFn -#define glDeleteFencesAPPLE ::gfx::g_current_gl_context->glDeleteFencesAPPLEFn -#define glDeleteFencesNV ::gfx::g_current_gl_context->glDeleteFencesNVFn -#define glDeleteFramebuffersEXT \ - ::gfx::g_current_gl_context->glDeleteFramebuffersEXTFn -#define glDeleteProgram ::gfx::g_current_gl_context->glDeleteProgramFn -#define glDeleteQueries ::gfx::g_current_gl_context->glDeleteQueriesFn -#define glDeleteRenderbuffersEXT \ - ::gfx::g_current_gl_context->glDeleteRenderbuffersEXTFn -#define glDeleteSamplers ::gfx::g_current_gl_context->glDeleteSamplersFn -#define glDeleteShader ::gfx::g_current_gl_context->glDeleteShaderFn -#define glDeleteSync ::gfx::g_current_gl_context->glDeleteSyncFn -#define glDeleteTextures ::gfx::g_current_gl_context->glDeleteTexturesFn -#define glDeleteTransformFeedbacks \ - ::gfx::g_current_gl_context->glDeleteTransformFeedbacksFn -#define glDeleteVertexArraysOES \ - ::gfx::g_current_gl_context->glDeleteVertexArraysOESFn -#define glDepthFunc ::gfx::g_current_gl_context->glDepthFuncFn -#define glDepthMask ::gfx::g_current_gl_context->glDepthMaskFn -#define glDepthRange ::gfx::g_current_gl_context->glDepthRangeFn -#define glDepthRangef ::gfx::g_current_gl_context->glDepthRangefFn -#define glDetachShader ::gfx::g_current_gl_context->glDetachShaderFn -#define glDisable ::gfx::g_current_gl_context->glDisableFn -#define glDisableVertexAttribArray \ - ::gfx::g_current_gl_context->glDisableVertexAttribArrayFn -#define glDiscardFramebufferEXT \ - ::gfx::g_current_gl_context->glDiscardFramebufferEXTFn -#define glDrawArrays ::gfx::g_current_gl_context->glDrawArraysFn -#define glDrawArraysInstancedANGLE \ - ::gfx::g_current_gl_context->glDrawArraysInstancedANGLEFn -#define glDrawBuffer ::gfx::g_current_gl_context->glDrawBufferFn -#define glDrawBuffersARB ::gfx::g_current_gl_context->glDrawBuffersARBFn -#define glDrawElements ::gfx::g_current_gl_context->glDrawElementsFn -#define glDrawElementsInstancedANGLE \ - ::gfx::g_current_gl_context->glDrawElementsInstancedANGLEFn -#define glDrawRangeElements ::gfx::g_current_gl_context->glDrawRangeElementsFn -#define glEGLImageTargetRenderbufferStorageOES \ - ::gfx::g_current_gl_context->glEGLImageTargetRenderbufferStorageOESFn -#define glEGLImageTargetTexture2DOES \ - ::gfx::g_current_gl_context->glEGLImageTargetTexture2DOESFn -#define glEnable ::gfx::g_current_gl_context->glEnableFn -#define glEnableVertexAttribArray \ - ::gfx::g_current_gl_context->glEnableVertexAttribArrayFn -#define glEndQuery ::gfx::g_current_gl_context->glEndQueryFn -#define glEndTransformFeedback \ - ::gfx::g_current_gl_context->glEndTransformFeedbackFn -#define glFenceSync ::gfx::g_current_gl_context->glFenceSyncFn -#define glFinish ::gfx::g_current_gl_context->glFinishFn -#define glFinishFenceAPPLE ::gfx::g_current_gl_context->glFinishFenceAPPLEFn -#define glFinishFenceNV ::gfx::g_current_gl_context->glFinishFenceNVFn -#define glFlush ::gfx::g_current_gl_context->glFlushFn -#define glFlushMappedBufferRange \ - ::gfx::g_current_gl_context->glFlushMappedBufferRangeFn -#define glFramebufferRenderbufferEXT \ - ::gfx::g_current_gl_context->glFramebufferRenderbufferEXTFn -#define glFramebufferTexture2DEXT \ - ::gfx::g_current_gl_context->glFramebufferTexture2DEXTFn -#define glFramebufferTexture2DMultisampleEXT \ - ::gfx::g_current_gl_context->glFramebufferTexture2DMultisampleEXTFn -#define glFramebufferTexture2DMultisampleIMG \ - ::gfx::g_current_gl_context->glFramebufferTexture2DMultisampleIMGFn -#define glFramebufferTextureLayer \ - ::gfx::g_current_gl_context->glFramebufferTextureLayerFn -#define glFrontFace ::gfx::g_current_gl_context->glFrontFaceFn -#define glGenBuffersARB ::gfx::g_current_gl_context->glGenBuffersARBFn -#define glGenerateMipmapEXT ::gfx::g_current_gl_context->glGenerateMipmapEXTFn -#define glGenFencesAPPLE ::gfx::g_current_gl_context->glGenFencesAPPLEFn -#define glGenFencesNV ::gfx::g_current_gl_context->glGenFencesNVFn -#define glGenFramebuffersEXT ::gfx::g_current_gl_context->glGenFramebuffersEXTFn -#define glGenQueries ::gfx::g_current_gl_context->glGenQueriesFn -#define glGenRenderbuffersEXT \ - ::gfx::g_current_gl_context->glGenRenderbuffersEXTFn -#define glGenSamplers ::gfx::g_current_gl_context->glGenSamplersFn -#define glGenTextures ::gfx::g_current_gl_context->glGenTexturesFn -#define glGenTransformFeedbacks \ - ::gfx::g_current_gl_context->glGenTransformFeedbacksFn -#define glGenVertexArraysOES ::gfx::g_current_gl_context->glGenVertexArraysOESFn -#define glGetActiveAttrib ::gfx::g_current_gl_context->glGetActiveAttribFn -#define glGetActiveUniform ::gfx::g_current_gl_context->glGetActiveUniformFn -#define glGetActiveUniformBlockiv \ - ::gfx::g_current_gl_context->glGetActiveUniformBlockivFn -#define glGetActiveUniformBlockName \ - ::gfx::g_current_gl_context->glGetActiveUniformBlockNameFn -#define glGetActiveUniformsiv \ - ::gfx::g_current_gl_context->glGetActiveUniformsivFn -#define glGetAttachedShaders ::gfx::g_current_gl_context->glGetAttachedShadersFn -#define glGetAttribLocation ::gfx::g_current_gl_context->glGetAttribLocationFn -#define glGetBooleanv ::gfx::g_current_gl_context->glGetBooleanvFn -#define glGetBufferParameteriv \ - ::gfx::g_current_gl_context->glGetBufferParameterivFn -#define glGetDebugMessageLogKHR \ - ::gfx::g_current_gl_context->glGetDebugMessageLogKHRFn -#define glGetError ::gfx::g_current_gl_context->glGetErrorFn -#define glGetFenceivNV ::gfx::g_current_gl_context->glGetFenceivNVFn -#define glGetFloatv ::gfx::g_current_gl_context->glGetFloatvFn -#define glGetFragDataLocation \ - ::gfx::g_current_gl_context->glGetFragDataLocationFn -#define glGetFramebufferAttachmentParameterivEXT \ - ::gfx::g_current_gl_context->glGetFramebufferAttachmentParameterivEXTFn -#define glGetGraphicsResetStatusARB \ - ::gfx::g_current_gl_context->glGetGraphicsResetStatusARBFn -#define glGetInteger64i_v ::gfx::g_current_gl_context->glGetInteger64i_vFn -#define glGetInteger64v ::gfx::g_current_gl_context->glGetInteger64vFn -#define glGetIntegeri_v ::gfx::g_current_gl_context->glGetIntegeri_vFn -#define glGetIntegerv ::gfx::g_current_gl_context->glGetIntegervFn -#define glGetInternalformativ \ - ::gfx::g_current_gl_context->glGetInternalformativFn -#define glGetProgramBinary ::gfx::g_current_gl_context->glGetProgramBinaryFn -#define glGetProgramInfoLog ::gfx::g_current_gl_context->glGetProgramInfoLogFn -#define glGetProgramiv ::gfx::g_current_gl_context->glGetProgramivFn -#define glGetProgramResourceLocation \ - ::gfx::g_current_gl_context->glGetProgramResourceLocationFn -#define glGetQueryiv ::gfx::g_current_gl_context->glGetQueryivFn -#define glGetQueryObjecti64v ::gfx::g_current_gl_context->glGetQueryObjecti64vFn -#define glGetQueryObjectiv ::gfx::g_current_gl_context->glGetQueryObjectivFn -#define glGetQueryObjectui64v \ - ::gfx::g_current_gl_context->glGetQueryObjectui64vFn -#define glGetQueryObjectuiv ::gfx::g_current_gl_context->glGetQueryObjectuivFn -#define glGetRenderbufferParameterivEXT \ - ::gfx::g_current_gl_context->glGetRenderbufferParameterivEXTFn -#define glGetSamplerParameterfv \ - ::gfx::g_current_gl_context->glGetSamplerParameterfvFn -#define glGetSamplerParameteriv \ - ::gfx::g_current_gl_context->glGetSamplerParameterivFn -#define glGetShaderInfoLog ::gfx::g_current_gl_context->glGetShaderInfoLogFn -#define glGetShaderiv ::gfx::g_current_gl_context->glGetShaderivFn -#define glGetShaderPrecisionFormat \ - ::gfx::g_current_gl_context->glGetShaderPrecisionFormatFn -#define glGetShaderSource ::gfx::g_current_gl_context->glGetShaderSourceFn -#define glGetString ::gfx::g_current_gl_context->glGetStringFn -#define glGetStringi ::gfx::g_current_gl_context->glGetStringiFn -#define glGetSynciv ::gfx::g_current_gl_context->glGetSyncivFn -#define glGetTexLevelParameterfv \ - ::gfx::g_current_gl_context->glGetTexLevelParameterfvFn -#define glGetTexLevelParameteriv \ - ::gfx::g_current_gl_context->glGetTexLevelParameterivFn -#define glGetTexParameterfv ::gfx::g_current_gl_context->glGetTexParameterfvFn -#define glGetTexParameteriv ::gfx::g_current_gl_context->glGetTexParameterivFn -#define glGetTransformFeedbackVarying \ - ::gfx::g_current_gl_context->glGetTransformFeedbackVaryingFn -#define glGetTranslatedShaderSourceANGLE \ - ::gfx::g_current_gl_context->glGetTranslatedShaderSourceANGLEFn -#define glGetUniformBlockIndex \ - ::gfx::g_current_gl_context->glGetUniformBlockIndexFn -#define glGetUniformfv ::gfx::g_current_gl_context->glGetUniformfvFn -#define glGetUniformIndices ::gfx::g_current_gl_context->glGetUniformIndicesFn -#define glGetUniformiv ::gfx::g_current_gl_context->glGetUniformivFn -#define glGetUniformLocation ::gfx::g_current_gl_context->glGetUniformLocationFn -#define glGetVertexAttribfv ::gfx::g_current_gl_context->glGetVertexAttribfvFn -#define glGetVertexAttribiv ::gfx::g_current_gl_context->glGetVertexAttribivFn -#define glGetVertexAttribPointerv \ - ::gfx::g_current_gl_context->glGetVertexAttribPointervFn -#define glHint ::gfx::g_current_gl_context->glHintFn -#define glInsertEventMarkerEXT \ - ::gfx::g_current_gl_context->glInsertEventMarkerEXTFn -#define glInvalidateFramebuffer \ - ::gfx::g_current_gl_context->glInvalidateFramebufferFn -#define glInvalidateSubFramebuffer \ - ::gfx::g_current_gl_context->glInvalidateSubFramebufferFn -#define glIsBuffer ::gfx::g_current_gl_context->glIsBufferFn -#define glIsEnabled ::gfx::g_current_gl_context->glIsEnabledFn -#define glIsFenceAPPLE ::gfx::g_current_gl_context->glIsFenceAPPLEFn -#define glIsFenceNV ::gfx::g_current_gl_context->glIsFenceNVFn -#define glIsFramebufferEXT ::gfx::g_current_gl_context->glIsFramebufferEXTFn -#define glIsProgram ::gfx::g_current_gl_context->glIsProgramFn -#define glIsQuery ::gfx::g_current_gl_context->glIsQueryFn -#define glIsRenderbufferEXT ::gfx::g_current_gl_context->glIsRenderbufferEXTFn -#define glIsSampler ::gfx::g_current_gl_context->glIsSamplerFn -#define glIsShader ::gfx::g_current_gl_context->glIsShaderFn -#define glIsSync ::gfx::g_current_gl_context->glIsSyncFn -#define glIsTexture ::gfx::g_current_gl_context->glIsTextureFn -#define glIsTransformFeedback \ - ::gfx::g_current_gl_context->glIsTransformFeedbackFn -#define glIsVertexArrayOES ::gfx::g_current_gl_context->glIsVertexArrayOESFn -#define glLineWidth ::gfx::g_current_gl_context->glLineWidthFn -#define glLinkProgram ::gfx::g_current_gl_context->glLinkProgramFn -#define glMapBuffer ::gfx::g_current_gl_context->glMapBufferFn -#define glMapBufferRange ::gfx::g_current_gl_context->glMapBufferRangeFn -#define glMatrixLoadfEXT ::gfx::g_current_gl_context->glMatrixLoadfEXTFn -#define glMatrixLoadIdentityEXT \ - ::gfx::g_current_gl_context->glMatrixLoadIdentityEXTFn -#define glObjectLabelKHR ::gfx::g_current_gl_context->glObjectLabelKHRFn -#define glPauseTransformFeedback \ - ::gfx::g_current_gl_context->glPauseTransformFeedbackFn -#define glPixelStorei ::gfx::g_current_gl_context->glPixelStoreiFn -#define glPointParameteri ::gfx::g_current_gl_context->glPointParameteriFn -#define glPolygonOffset ::gfx::g_current_gl_context->glPolygonOffsetFn -#define glPopDebugGroupKHR ::gfx::g_current_gl_context->glPopDebugGroupKHRFn -#define glPopGroupMarkerEXT ::gfx::g_current_gl_context->glPopGroupMarkerEXTFn -#define glProgramBinary ::gfx::g_current_gl_context->glProgramBinaryFn -#define glProgramParameteri ::gfx::g_current_gl_context->glProgramParameteriFn -#define glPushDebugGroupKHR ::gfx::g_current_gl_context->glPushDebugGroupKHRFn -#define glPushGroupMarkerEXT ::gfx::g_current_gl_context->glPushGroupMarkerEXTFn -#define glQueryCounter ::gfx::g_current_gl_context->glQueryCounterFn -#define glReadBuffer ::gfx::g_current_gl_context->glReadBufferFn -#define glReadPixels ::gfx::g_current_gl_context->glReadPixelsFn -#define glReleaseShaderCompiler \ - ::gfx::g_current_gl_context->glReleaseShaderCompilerFn -#define glRenderbufferStorageEXT \ - ::gfx::g_current_gl_context->glRenderbufferStorageEXTFn -#define glRenderbufferStorageMultisample \ - ::gfx::g_current_gl_context->glRenderbufferStorageMultisampleFn -#define glRenderbufferStorageMultisampleANGLE \ - ::gfx::g_current_gl_context->glRenderbufferStorageMultisampleANGLEFn -#define glRenderbufferStorageMultisampleAPPLE \ - ::gfx::g_current_gl_context->glRenderbufferStorageMultisampleAPPLEFn -#define glRenderbufferStorageMultisampleEXT \ - ::gfx::g_current_gl_context->glRenderbufferStorageMultisampleEXTFn -#define glRenderbufferStorageMultisampleIMG \ - ::gfx::g_current_gl_context->glRenderbufferStorageMultisampleIMGFn -#define glResolveMultisampleFramebufferAPPLE \ - ::gfx::g_current_gl_context->glResolveMultisampleFramebufferAPPLEFn -#define glResumeTransformFeedback \ - ::gfx::g_current_gl_context->glResumeTransformFeedbackFn -#define glSampleCoverage ::gfx::g_current_gl_context->glSampleCoverageFn -#define glSamplerParameterf ::gfx::g_current_gl_context->glSamplerParameterfFn -#define glSamplerParameterfv ::gfx::g_current_gl_context->glSamplerParameterfvFn -#define glSamplerParameteri ::gfx::g_current_gl_context->glSamplerParameteriFn -#define glSamplerParameteriv ::gfx::g_current_gl_context->glSamplerParameterivFn -#define glScissor ::gfx::g_current_gl_context->glScissorFn -#define glSetFenceAPPLE ::gfx::g_current_gl_context->glSetFenceAPPLEFn -#define glSetFenceNV ::gfx::g_current_gl_context->glSetFenceNVFn -#define glShaderBinary ::gfx::g_current_gl_context->glShaderBinaryFn -#define glShaderSource ::gfx::g_current_gl_context->glShaderSourceFn -#define glStencilFunc ::gfx::g_current_gl_context->glStencilFuncFn -#define glStencilFuncSeparate \ - ::gfx::g_current_gl_context->glStencilFuncSeparateFn -#define glStencilMask ::gfx::g_current_gl_context->glStencilMaskFn -#define glStencilMaskSeparate \ - ::gfx::g_current_gl_context->glStencilMaskSeparateFn -#define glStencilOp ::gfx::g_current_gl_context->glStencilOpFn -#define glStencilOpSeparate ::gfx::g_current_gl_context->glStencilOpSeparateFn -#define glTestFenceAPPLE ::gfx::g_current_gl_context->glTestFenceAPPLEFn -#define glTestFenceNV ::gfx::g_current_gl_context->glTestFenceNVFn -#define glTexImage2D ::gfx::g_current_gl_context->glTexImage2DFn -#define glTexImage3D ::gfx::g_current_gl_context->glTexImage3DFn -#define glTexParameterf ::gfx::g_current_gl_context->glTexParameterfFn -#define glTexParameterfv ::gfx::g_current_gl_context->glTexParameterfvFn -#define glTexParameteri ::gfx::g_current_gl_context->glTexParameteriFn -#define glTexParameteriv ::gfx::g_current_gl_context->glTexParameterivFn -#define glTexStorage2DEXT ::gfx::g_current_gl_context->glTexStorage2DEXTFn -#define glTexStorage3D ::gfx::g_current_gl_context->glTexStorage3DFn -#define glTexSubImage2D ::gfx::g_current_gl_context->glTexSubImage2DFn -#define glTextureBarrierNV ::gfx::g_current_gl_context->glTextureBarrierNVFn -#define glTransformFeedbackVaryings \ - ::gfx::g_current_gl_context->glTransformFeedbackVaryingsFn -#define glUniform1f ::gfx::g_current_gl_context->glUniform1fFn -#define glUniform1fv ::gfx::g_current_gl_context->glUniform1fvFn -#define glUniform1i ::gfx::g_current_gl_context->glUniform1iFn -#define glUniform1iv ::gfx::g_current_gl_context->glUniform1ivFn -#define glUniform1ui ::gfx::g_current_gl_context->glUniform1uiFn -#define glUniform1uiv ::gfx::g_current_gl_context->glUniform1uivFn -#define glUniform2f ::gfx::g_current_gl_context->glUniform2fFn -#define glUniform2fv ::gfx::g_current_gl_context->glUniform2fvFn -#define glUniform2i ::gfx::g_current_gl_context->glUniform2iFn -#define glUniform2iv ::gfx::g_current_gl_context->glUniform2ivFn -#define glUniform2ui ::gfx::g_current_gl_context->glUniform2uiFn -#define glUniform2uiv ::gfx::g_current_gl_context->glUniform2uivFn -#define glUniform3f ::gfx::g_current_gl_context->glUniform3fFn -#define glUniform3fv ::gfx::g_current_gl_context->glUniform3fvFn -#define glUniform3i ::gfx::g_current_gl_context->glUniform3iFn -#define glUniform3iv ::gfx::g_current_gl_context->glUniform3ivFn -#define glUniform3ui ::gfx::g_current_gl_context->glUniform3uiFn -#define glUniform3uiv ::gfx::g_current_gl_context->glUniform3uivFn -#define glUniform4f ::gfx::g_current_gl_context->glUniform4fFn -#define glUniform4fv ::gfx::g_current_gl_context->glUniform4fvFn -#define glUniform4i ::gfx::g_current_gl_context->glUniform4iFn -#define glUniform4iv ::gfx::g_current_gl_context->glUniform4ivFn -#define glUniform4ui ::gfx::g_current_gl_context->glUniform4uiFn -#define glUniform4uiv ::gfx::g_current_gl_context->glUniform4uivFn -#define glUniformBlockBinding \ - ::gfx::g_current_gl_context->glUniformBlockBindingFn -#define glUniformMatrix2fv ::gfx::g_current_gl_context->glUniformMatrix2fvFn -#define glUniformMatrix2x3fv ::gfx::g_current_gl_context->glUniformMatrix2x3fvFn -#define glUniformMatrix2x4fv ::gfx::g_current_gl_context->glUniformMatrix2x4fvFn -#define glUniformMatrix3fv ::gfx::g_current_gl_context->glUniformMatrix3fvFn -#define glUniformMatrix3x2fv ::gfx::g_current_gl_context->glUniformMatrix3x2fvFn -#define glUniformMatrix3x4fv ::gfx::g_current_gl_context->glUniformMatrix3x4fvFn -#define glUniformMatrix4fv ::gfx::g_current_gl_context->glUniformMatrix4fvFn -#define glUniformMatrix4x2fv ::gfx::g_current_gl_context->glUniformMatrix4x2fvFn -#define glUniformMatrix4x3fv ::gfx::g_current_gl_context->glUniformMatrix4x3fvFn -#define glUnmapBuffer ::gfx::g_current_gl_context->glUnmapBufferFn -#define glUseProgram ::gfx::g_current_gl_context->glUseProgramFn -#define glValidateProgram ::gfx::g_current_gl_context->glValidateProgramFn -#define glVertexAttrib1f ::gfx::g_current_gl_context->glVertexAttrib1fFn -#define glVertexAttrib1fv ::gfx::g_current_gl_context->glVertexAttrib1fvFn -#define glVertexAttrib2f ::gfx::g_current_gl_context->glVertexAttrib2fFn -#define glVertexAttrib2fv ::gfx::g_current_gl_context->glVertexAttrib2fvFn -#define glVertexAttrib3f ::gfx::g_current_gl_context->glVertexAttrib3fFn -#define glVertexAttrib3fv ::gfx::g_current_gl_context->glVertexAttrib3fvFn -#define glVertexAttrib4f ::gfx::g_current_gl_context->glVertexAttrib4fFn -#define glVertexAttrib4fv ::gfx::g_current_gl_context->glVertexAttrib4fvFn -#define glVertexAttribDivisorANGLE \ - ::gfx::g_current_gl_context->glVertexAttribDivisorANGLEFn -#define glVertexAttribI4i ::gfx::g_current_gl_context->glVertexAttribI4iFn -#define glVertexAttribI4iv ::gfx::g_current_gl_context->glVertexAttribI4ivFn -#define glVertexAttribI4ui ::gfx::g_current_gl_context->glVertexAttribI4uiFn -#define glVertexAttribI4uiv ::gfx::g_current_gl_context->glVertexAttribI4uivFn -#define glVertexAttribIPointer \ - ::gfx::g_current_gl_context->glVertexAttribIPointerFn -#define glVertexAttribPointer \ - ::gfx::g_current_gl_context->glVertexAttribPointerFn -#define glViewport ::gfx::g_current_gl_context->glViewportFn -#define glWaitSync ::gfx::g_current_gl_context->glWaitSyncFn - -#endif // UI_GFX_GL_GL_BINDINGS_AUTOGEN_GL_H_ diff --git a/ui/gl/gl_bindings_autogen_osmesa.cc b/ui/gl/gl_bindings_autogen_osmesa.cc deleted file mode 100644 index 299f9f28a..000000000 --- a/ui/gl/gl_bindings_autogen_osmesa.cc +++ /dev/null @@ -1,367 +0,0 @@ -// Copyright 2014 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 is auto-generated from -// ui/gl/generate_bindings.py -// It's formatted by clang-format using chromium coding style: -// clang-format -i -style=chromium filename -// DO NOT EDIT! - -#include - -#include "base/trace_event/trace_event.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_enums.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_osmesa_api_implementation.h" -#include "ui/gl/gl_version_info.h" - -namespace gfx { - -static bool g_debugBindingsInitialized; -DriverOSMESA g_driver_osmesa; - -void DriverOSMESA::InitializeStaticBindings() { - fn.OSMesaColorClampFn = reinterpret_cast( - GetGLProcAddress("OSMesaColorClamp")); - fn.OSMesaCreateContextFn = reinterpret_cast( - GetGLProcAddress("OSMesaCreateContext")); - fn.OSMesaCreateContextExtFn = reinterpret_cast( - GetGLProcAddress("OSMesaCreateContextExt")); - fn.OSMesaDestroyContextFn = reinterpret_cast( - GetGLProcAddress("OSMesaDestroyContext")); - fn.OSMesaGetColorBufferFn = reinterpret_cast( - GetGLProcAddress("OSMesaGetColorBuffer")); - fn.OSMesaGetCurrentContextFn = reinterpret_cast( - GetGLProcAddress("OSMesaGetCurrentContext")); - fn.OSMesaGetDepthBufferFn = reinterpret_cast( - GetGLProcAddress("OSMesaGetDepthBuffer")); - fn.OSMesaGetIntegervFn = reinterpret_cast( - GetGLProcAddress("OSMesaGetIntegerv")); - fn.OSMesaGetProcAddressFn = reinterpret_cast( - GetGLProcAddress("OSMesaGetProcAddress")); - fn.OSMesaMakeCurrentFn = reinterpret_cast( - GetGLProcAddress("OSMesaMakeCurrent")); - fn.OSMesaPixelStoreFn = reinterpret_cast( - GetGLProcAddress("OSMesaPixelStore")); - std::string extensions(GetPlatformExtensions()); - extensions += " "; - ALLOW_UNUSED_LOCAL(extensions); - - if (g_debugBindingsInitialized) - InitializeDebugBindings(); -} - -extern "C" { - -static void GL_BINDING_CALL Debug_OSMesaColorClamp(GLboolean enable) { - GL_SERVICE_LOG("OSMesaColorClamp" - << "(" << GLEnums::GetStringBool(enable) << ")"); - g_driver_osmesa.debug_fn.OSMesaColorClampFn(enable); -} - -static OSMesaContext GL_BINDING_CALL -Debug_OSMesaCreateContext(GLenum format, OSMesaContext sharelist) { - GL_SERVICE_LOG("OSMesaCreateContext" - << "(" << GLEnums::GetStringEnum(format) << ", " << sharelist - << ")"); - OSMesaContext result = - g_driver_osmesa.debug_fn.OSMesaCreateContextFn(format, sharelist); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static OSMesaContext GL_BINDING_CALL -Debug_OSMesaCreateContextExt(GLenum format, - GLint depthBits, - GLint stencilBits, - GLint accumBits, - OSMesaContext sharelist) { - GL_SERVICE_LOG("OSMesaCreateContextExt" - << "(" << GLEnums::GetStringEnum(format) << ", " << depthBits - << ", " << stencilBits << ", " << accumBits << ", " - << sharelist << ")"); - OSMesaContext result = g_driver_osmesa.debug_fn.OSMesaCreateContextExtFn( - format, depthBits, stencilBits, accumBits, sharelist); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void GL_BINDING_CALL Debug_OSMesaDestroyContext(OSMesaContext ctx) { - GL_SERVICE_LOG("OSMesaDestroyContext" - << "(" << ctx << ")"); - g_driver_osmesa.debug_fn.OSMesaDestroyContextFn(ctx); -} - -static GLboolean GL_BINDING_CALL Debug_OSMesaGetColorBuffer(OSMesaContext c, - GLint* width, - GLint* height, - GLint* format, - void** buffer) { - GL_SERVICE_LOG("OSMesaGetColorBuffer" - << "(" << c << ", " << static_cast(width) << ", " - << static_cast(height) << ", " - << static_cast(format) << ", " << buffer << ")"); - GLboolean result = g_driver_osmesa.debug_fn.OSMesaGetColorBufferFn( - c, width, height, format, buffer); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static OSMesaContext GL_BINDING_CALL Debug_OSMesaGetCurrentContext(void) { - GL_SERVICE_LOG("OSMesaGetCurrentContext" - << "(" - << ")"); - OSMesaContext result = g_driver_osmesa.debug_fn.OSMesaGetCurrentContextFn(); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLboolean GL_BINDING_CALL -Debug_OSMesaGetDepthBuffer(OSMesaContext c, - GLint* width, - GLint* height, - GLint* bytesPerValue, - void** buffer) { - GL_SERVICE_LOG("OSMesaGetDepthBuffer" - << "(" << c << ", " << static_cast(width) << ", " - << static_cast(height) << ", " - << static_cast(bytesPerValue) << ", " << buffer - << ")"); - GLboolean result = g_driver_osmesa.debug_fn.OSMesaGetDepthBufferFn( - c, width, height, bytesPerValue, buffer); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void GL_BINDING_CALL Debug_OSMesaGetIntegerv(GLint pname, GLint* value) { - GL_SERVICE_LOG("OSMesaGetIntegerv" - << "(" << pname << ", " << static_cast(value) - << ")"); - g_driver_osmesa.debug_fn.OSMesaGetIntegervFn(pname, value); -} - -static OSMESAproc GL_BINDING_CALL -Debug_OSMesaGetProcAddress(const char* funcName) { - GL_SERVICE_LOG("OSMesaGetProcAddress" - << "(" << funcName << ")"); - OSMESAproc result = g_driver_osmesa.debug_fn.OSMesaGetProcAddressFn(funcName); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static GLboolean GL_BINDING_CALL Debug_OSMesaMakeCurrent(OSMesaContext ctx, - void* buffer, - GLenum type, - GLsizei width, - GLsizei height) { - GL_SERVICE_LOG("OSMesaMakeCurrent" - << "(" << ctx << ", " << static_cast(buffer) - << ", " << GLEnums::GetStringEnum(type) << ", " << width - << ", " << height << ")"); - GLboolean result = g_driver_osmesa.debug_fn.OSMesaMakeCurrentFn( - ctx, buffer, type, width, height); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; -} - -static void GL_BINDING_CALL Debug_OSMesaPixelStore(GLint pname, GLint value) { - GL_SERVICE_LOG("OSMesaPixelStore" - << "(" << pname << ", " << value << ")"); - g_driver_osmesa.debug_fn.OSMesaPixelStoreFn(pname, value); -} -} // extern "C" - -void DriverOSMESA::InitializeDebugBindings() { - if (!debug_fn.OSMesaColorClampFn) { - debug_fn.OSMesaColorClampFn = fn.OSMesaColorClampFn; - fn.OSMesaColorClampFn = Debug_OSMesaColorClamp; - } - if (!debug_fn.OSMesaCreateContextFn) { - debug_fn.OSMesaCreateContextFn = fn.OSMesaCreateContextFn; - fn.OSMesaCreateContextFn = Debug_OSMesaCreateContext; - } - if (!debug_fn.OSMesaCreateContextExtFn) { - debug_fn.OSMesaCreateContextExtFn = fn.OSMesaCreateContextExtFn; - fn.OSMesaCreateContextExtFn = Debug_OSMesaCreateContextExt; - } - if (!debug_fn.OSMesaDestroyContextFn) { - debug_fn.OSMesaDestroyContextFn = fn.OSMesaDestroyContextFn; - fn.OSMesaDestroyContextFn = Debug_OSMesaDestroyContext; - } - if (!debug_fn.OSMesaGetColorBufferFn) { - debug_fn.OSMesaGetColorBufferFn = fn.OSMesaGetColorBufferFn; - fn.OSMesaGetColorBufferFn = Debug_OSMesaGetColorBuffer; - } - if (!debug_fn.OSMesaGetCurrentContextFn) { - debug_fn.OSMesaGetCurrentContextFn = fn.OSMesaGetCurrentContextFn; - fn.OSMesaGetCurrentContextFn = Debug_OSMesaGetCurrentContext; - } - if (!debug_fn.OSMesaGetDepthBufferFn) { - debug_fn.OSMesaGetDepthBufferFn = fn.OSMesaGetDepthBufferFn; - fn.OSMesaGetDepthBufferFn = Debug_OSMesaGetDepthBuffer; - } - if (!debug_fn.OSMesaGetIntegervFn) { - debug_fn.OSMesaGetIntegervFn = fn.OSMesaGetIntegervFn; - fn.OSMesaGetIntegervFn = Debug_OSMesaGetIntegerv; - } - if (!debug_fn.OSMesaGetProcAddressFn) { - debug_fn.OSMesaGetProcAddressFn = fn.OSMesaGetProcAddressFn; - fn.OSMesaGetProcAddressFn = Debug_OSMesaGetProcAddress; - } - if (!debug_fn.OSMesaMakeCurrentFn) { - debug_fn.OSMesaMakeCurrentFn = fn.OSMesaMakeCurrentFn; - fn.OSMesaMakeCurrentFn = Debug_OSMesaMakeCurrent; - } - if (!debug_fn.OSMesaPixelStoreFn) { - debug_fn.OSMesaPixelStoreFn = fn.OSMesaPixelStoreFn; - fn.OSMesaPixelStoreFn = Debug_OSMesaPixelStore; - } - g_debugBindingsInitialized = true; -} - -void DriverOSMESA::ClearBindings() { - memset(this, 0, sizeof(*this)); -} - -void OSMESAApiBase::OSMesaColorClampFn(GLboolean enable) { - driver_->fn.OSMesaColorClampFn(enable); -} - -OSMesaContext OSMESAApiBase::OSMesaCreateContextFn(GLenum format, - OSMesaContext sharelist) { - return driver_->fn.OSMesaCreateContextFn(format, sharelist); -} - -OSMesaContext OSMESAApiBase::OSMesaCreateContextExtFn(GLenum format, - GLint depthBits, - GLint stencilBits, - GLint accumBits, - OSMesaContext sharelist) { - return driver_->fn.OSMesaCreateContextExtFn(format, depthBits, stencilBits, - accumBits, sharelist); -} - -void OSMESAApiBase::OSMesaDestroyContextFn(OSMesaContext ctx) { - driver_->fn.OSMesaDestroyContextFn(ctx); -} - -GLboolean OSMESAApiBase::OSMesaGetColorBufferFn(OSMesaContext c, - GLint* width, - GLint* height, - GLint* format, - void** buffer) { - return driver_->fn.OSMesaGetColorBufferFn(c, width, height, format, buffer); -} - -OSMesaContext OSMESAApiBase::OSMesaGetCurrentContextFn(void) { - return driver_->fn.OSMesaGetCurrentContextFn(); -} - -GLboolean OSMESAApiBase::OSMesaGetDepthBufferFn(OSMesaContext c, - GLint* width, - GLint* height, - GLint* bytesPerValue, - void** buffer) { - return driver_->fn.OSMesaGetDepthBufferFn(c, width, height, bytesPerValue, - buffer); -} - -void OSMESAApiBase::OSMesaGetIntegervFn(GLint pname, GLint* value) { - driver_->fn.OSMesaGetIntegervFn(pname, value); -} - -OSMESAproc OSMESAApiBase::OSMesaGetProcAddressFn(const char* funcName) { - return driver_->fn.OSMesaGetProcAddressFn(funcName); -} - -GLboolean OSMESAApiBase::OSMesaMakeCurrentFn(OSMesaContext ctx, - void* buffer, - GLenum type, - GLsizei width, - GLsizei height) { - return driver_->fn.OSMesaMakeCurrentFn(ctx, buffer, type, width, height); -} - -void OSMESAApiBase::OSMesaPixelStoreFn(GLint pname, GLint value) { - driver_->fn.OSMesaPixelStoreFn(pname, value); -} - -void TraceOSMESAApi::OSMesaColorClampFn(GLboolean enable) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaColorClamp") - osmesa_api_->OSMesaColorClampFn(enable); -} - -OSMesaContext TraceOSMESAApi::OSMesaCreateContextFn(GLenum format, - OSMesaContext sharelist) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaCreateContext") - return osmesa_api_->OSMesaCreateContextFn(format, sharelist); -} - -OSMesaContext TraceOSMESAApi::OSMesaCreateContextExtFn( - GLenum format, - GLint depthBits, - GLint stencilBits, - GLint accumBits, - OSMesaContext sharelist) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaCreateContextExt") - return osmesa_api_->OSMesaCreateContextExtFn(format, depthBits, stencilBits, - accumBits, sharelist); -} - -void TraceOSMESAApi::OSMesaDestroyContextFn(OSMesaContext ctx) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaDestroyContext") - osmesa_api_->OSMesaDestroyContextFn(ctx); -} - -GLboolean TraceOSMESAApi::OSMesaGetColorBufferFn(OSMesaContext c, - GLint* width, - GLint* height, - GLint* format, - void** buffer) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaGetColorBuffer") - return osmesa_api_->OSMesaGetColorBufferFn(c, width, height, format, buffer); -} - -OSMesaContext TraceOSMESAApi::OSMesaGetCurrentContextFn(void) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaGetCurrentContext") - return osmesa_api_->OSMesaGetCurrentContextFn(); -} - -GLboolean TraceOSMESAApi::OSMesaGetDepthBufferFn(OSMesaContext c, - GLint* width, - GLint* height, - GLint* bytesPerValue, - void** buffer) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaGetDepthBuffer") - return osmesa_api_->OSMesaGetDepthBufferFn(c, width, height, bytesPerValue, - buffer); -} - -void TraceOSMESAApi::OSMesaGetIntegervFn(GLint pname, GLint* value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaGetIntegerv") - osmesa_api_->OSMesaGetIntegervFn(pname, value); -} - -OSMESAproc TraceOSMESAApi::OSMesaGetProcAddressFn(const char* funcName) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaGetProcAddress") - return osmesa_api_->OSMesaGetProcAddressFn(funcName); -} - -GLboolean TraceOSMESAApi::OSMesaMakeCurrentFn(OSMesaContext ctx, - void* buffer, - GLenum type, - GLsizei width, - GLsizei height) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaMakeCurrent") - return osmesa_api_->OSMesaMakeCurrentFn(ctx, buffer, type, width, height); -} - -void TraceOSMESAApi::OSMesaPixelStoreFn(GLint pname, GLint value) { - TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::OSMesaPixelStore") - osmesa_api_->OSMesaPixelStoreFn(pname, value); -} - -} // namespace gfx diff --git a/ui/gl/gl_bindings_autogen_osmesa.h b/ui/gl/gl_bindings_autogen_osmesa.h deleted file mode 100644 index 8a6bb6699..000000000 --- a/ui/gl/gl_bindings_autogen_osmesa.h +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2014 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 is auto-generated from -// ui/gl/generate_bindings.py -// It's formatted by clang-format using chromium coding style: -// clang-format -i -style=chromium filename -// DO NOT EDIT! - -#ifndef UI_GFX_GL_GL_BINDINGS_AUTOGEN_OSMESA_H_ -#define UI_GFX_GL_GL_BINDINGS_AUTOGEN_OSMESA_H_ - -namespace gfx { - -class GLContext; - -typedef void(GL_BINDING_CALL* OSMesaColorClampProc)(GLboolean enable); -typedef OSMesaContext(GL_BINDING_CALL* OSMesaCreateContextProc)( - GLenum format, - OSMesaContext sharelist); -typedef OSMesaContext(GL_BINDING_CALL* OSMesaCreateContextExtProc)( - GLenum format, - GLint depthBits, - GLint stencilBits, - GLint accumBits, - OSMesaContext sharelist); -typedef void(GL_BINDING_CALL* OSMesaDestroyContextProc)(OSMesaContext ctx); -typedef GLboolean(GL_BINDING_CALL* OSMesaGetColorBufferProc)(OSMesaContext c, - GLint* width, - GLint* height, - GLint* format, - void** buffer); -typedef OSMesaContext(GL_BINDING_CALL* OSMesaGetCurrentContextProc)(void); -typedef GLboolean(GL_BINDING_CALL* OSMesaGetDepthBufferProc)( - OSMesaContext c, - GLint* width, - GLint* height, - GLint* bytesPerValue, - void** buffer); -typedef void(GL_BINDING_CALL* OSMesaGetIntegervProc)(GLint pname, GLint* value); -typedef OSMESAproc(GL_BINDING_CALL* OSMesaGetProcAddressProc)( - const char* funcName); -typedef GLboolean(GL_BINDING_CALL* OSMesaMakeCurrentProc)(OSMesaContext ctx, - void* buffer, - GLenum type, - GLsizei width, - GLsizei height); -typedef void(GL_BINDING_CALL* OSMesaPixelStoreProc)(GLint pname, GLint value); - -struct ExtensionsOSMESA {}; - -struct ProcsOSMESA { - OSMesaColorClampProc OSMesaColorClampFn; - OSMesaCreateContextProc OSMesaCreateContextFn; - OSMesaCreateContextExtProc OSMesaCreateContextExtFn; - OSMesaDestroyContextProc OSMesaDestroyContextFn; - OSMesaGetColorBufferProc OSMesaGetColorBufferFn; - OSMesaGetCurrentContextProc OSMesaGetCurrentContextFn; - OSMesaGetDepthBufferProc OSMesaGetDepthBufferFn; - OSMesaGetIntegervProc OSMesaGetIntegervFn; - OSMesaGetProcAddressProc OSMesaGetProcAddressFn; - OSMesaMakeCurrentProc OSMesaMakeCurrentFn; - OSMesaPixelStoreProc OSMesaPixelStoreFn; -}; - -class GL_EXPORT OSMESAApi { - public: - OSMESAApi(); - virtual ~OSMESAApi(); - - virtual void OSMesaColorClampFn(GLboolean enable) = 0; - virtual OSMesaContext OSMesaCreateContextFn(GLenum format, - OSMesaContext sharelist) = 0; - virtual OSMesaContext OSMesaCreateContextExtFn(GLenum format, - GLint depthBits, - GLint stencilBits, - GLint accumBits, - OSMesaContext sharelist) = 0; - virtual void OSMesaDestroyContextFn(OSMesaContext ctx) = 0; - virtual GLboolean OSMesaGetColorBufferFn(OSMesaContext c, - GLint* width, - GLint* height, - GLint* format, - void** buffer) = 0; - virtual OSMesaContext OSMesaGetCurrentContextFn(void) = 0; - virtual GLboolean OSMesaGetDepthBufferFn(OSMesaContext c, - GLint* width, - GLint* height, - GLint* bytesPerValue, - void** buffer) = 0; - virtual void OSMesaGetIntegervFn(GLint pname, GLint* value) = 0; - virtual OSMESAproc OSMesaGetProcAddressFn(const char* funcName) = 0; - virtual GLboolean OSMesaMakeCurrentFn(OSMesaContext ctx, - void* buffer, - GLenum type, - GLsizei width, - GLsizei height) = 0; - virtual void OSMesaPixelStoreFn(GLint pname, GLint value) = 0; -}; - -} // namespace gfx - -#define OSMesaColorClamp ::gfx::g_current_osmesa_context->OSMesaColorClampFn -#define OSMesaCreateContext \ - ::gfx::g_current_osmesa_context->OSMesaCreateContextFn -#define OSMesaCreateContextExt \ - ::gfx::g_current_osmesa_context->OSMesaCreateContextExtFn -#define OSMesaDestroyContext \ - ::gfx::g_current_osmesa_context->OSMesaDestroyContextFn -#define OSMesaGetColorBuffer \ - ::gfx::g_current_osmesa_context->OSMesaGetColorBufferFn -#define OSMesaGetCurrentContext \ - ::gfx::g_current_osmesa_context->OSMesaGetCurrentContextFn -#define OSMesaGetDepthBuffer \ - ::gfx::g_current_osmesa_context->OSMesaGetDepthBufferFn -#define OSMesaGetIntegerv ::gfx::g_current_osmesa_context->OSMesaGetIntegervFn -#define OSMesaGetProcAddress \ - ::gfx::g_current_osmesa_context->OSMesaGetProcAddressFn -#define OSMesaMakeCurrent ::gfx::g_current_osmesa_context->OSMesaMakeCurrentFn -#define OSMesaPixelStore ::gfx::g_current_osmesa_context->OSMesaPixelStoreFn - -#endif // UI_GFX_GL_GL_BINDINGS_AUTOGEN_OSMESA_H_ diff --git a/ui/gl/gl_bindings_egl.cc b/ui/gl/gl_bindings_egl.cc deleted file mode 100644 index 0ea21c250..000000000 --- a/ui/gl/gl_bindings_egl.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 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 "build/build_config.h" - -#if !defined(OS_ANDROID) -#error EGL should only be used on Android. -#endif -#include - -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_surface_egl.h" - -namespace gfx { - -std::string DriverOSMESA::GetPlatformExtensions() { - return ""; -} - -std::string DriverEGL::GetPlatformExtensions() { - EGLDisplay display = - g_driver_egl.fn.eglGetDisplayFn(GetPlatformDefaultEGLNativeDisplay()); - - DCHECK(g_driver_egl.fn.eglInitializeFn); - g_driver_egl.fn.eglInitializeFn(display, NULL, NULL); - DCHECK(g_driver_egl.fn.eglQueryStringFn); - const char* str = g_driver_egl.fn.eglQueryStringFn(display, EGL_EXTENSIONS); - return str ? std::string(str) : ""; -} - -} // namespace gfx diff --git a/ui/gl/gl_bindings_skia_in_process.cc b/ui/gl/gl_bindings_skia_in_process.cc deleted file mode 100644 index f9cd5a205..000000000 --- a/ui/gl/gl_bindings_skia_in_process.cc +++ /dev/null @@ -1,19 +0,0 @@ -// 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 "ui/gl/gl_bindings_skia_in_process.h" - -#include "base/logging.h" -#include "third_party/skia/include/gpu/gl/GrGLInterface.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_implementation.h" - -namespace gfx { - -const GrGLInterface* CreateInProcessSkiaGLBinding() { - return GrGLCreateNativeInterface(); -} - -} // namespace gfx diff --git a/ui/gl/gl_bindings_skia_in_process.h b/ui/gl/gl_bindings_skia_in_process.h deleted file mode 100644 index d270218a2..000000000 --- a/ui/gl/gl_bindings_skia_in_process.h +++ /dev/null @@ -1,20 +0,0 @@ -// 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 UI_GL_GL_BINDINGS_SKIA_IN_PROCESS_H_ -#define UI_GL_GL_BINDINGS_SKIA_IN_PROCESS_H_ - -#include "ui/gl/gl_export.h" - -struct GrGLInterface; - -namespace gfx { - -// The GPU back-end for skia requires pointers to GL functions. This function -// creates a binding for skia-gpu to the in-process GL -GL_EXPORT const GrGLInterface* CreateInProcessSkiaGLBinding(); - -} // namespace gfx - -#endif // UI_GL_GL_BINDINGS_SKIA_IN_PROCESS_H_ diff --git a/ui/gl/gl_context.cc b/ui/gl/gl_context.cc deleted file mode 100644 index e64d03135..000000000 --- a/ui/gl/gl_context.cc +++ /dev/null @@ -1,257 +0,0 @@ -// 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 - -#include "base/bind.h" -#include "base/cancelable_callback.h" -#include "base/command_line.h" -#include "base/lazy_instance.h" -#include "base/logging.h" -#include "base/threading/thread_local.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_gl_api_implementation.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_surface.h" -#include "ui/gl/gl_switches.h" -#include "ui/gl/gl_version_info.h" -#include "ui/gl/gpu_timing.h" - -namespace gfx { - -namespace { -base::LazyInstance >::Leaky - current_context_ = LAZY_INSTANCE_INITIALIZER; - -base::LazyInstance >::Leaky - current_real_context_ = LAZY_INSTANCE_INITIALIZER; -} // namespace - -GLContext::ScopedReleaseCurrent::ScopedReleaseCurrent() : canceled_(false) {} - -GLContext::ScopedReleaseCurrent::~ScopedReleaseCurrent() { - if (!canceled_ && GetCurrent()) { - GetCurrent()->ReleaseCurrent(NULL); - } -} - -void GLContext::ScopedReleaseCurrent::Cancel() { - canceled_ = true; -} - -GLContext::GLContext(GLShareGroup* share_group) : - share_group_(share_group), - state_dirtied_externally_(false), - swap_interval_(1), - force_swap_interval_zero_(false), - state_dirtied_callback_( - base::Bind(&GLContext::SetStateWasDirtiedExternally, - // Note that if this is not unretained, it will create a cycle (and - // will never be freed. - base::Unretained(this), - true)) { - if (!share_group_.get()) - share_group_ = new GLShareGroup; - - share_group_->AddContext(this); -} - -GLContext::~GLContext() { - share_group_->RemoveContext(this); - if (GetCurrent() == this) { - SetCurrent(NULL); - } -} - -bool GLContext::GetTotalGpuMemory(size_t* bytes) { - DCHECK(bytes); - *bytes = 0; - return false; -} - -void GLContext::SetSafeToForceGpuSwitch() { -} - -bool GLContext::ForceGpuSwitchIfNeeded() { - return true; -} - -void GLContext::SetUnbindFboOnMakeCurrent() { - NOTIMPLEMENTED(); -} - -std::string GLContext::GetExtensions() { - DCHECK(IsCurrent(NULL)); - const char* ext = reinterpret_cast(glGetString(GL_EXTENSIONS)); - return std::string(ext ? ext : ""); -} - -std::string GLContext::GetGLVersion() { - DCHECK(IsCurrent(NULL)); - const char *version = - reinterpret_cast(glGetString(GL_VERSION)); - return std::string(version ? version : ""); -} - -std::string GLContext::GetGLRenderer() { - DCHECK(IsCurrent(NULL)); - const char *renderer = - reinterpret_cast(glGetString(GL_RENDERER)); - return std::string(renderer ? renderer : ""); -} - -base::Closure GLContext::GetStateWasDirtiedExternallyCallback() { - return state_dirtied_callback_.callback(); -} - -void GLContext::RestoreStateIfDirtiedExternally() { - NOTREACHED(); -} - -bool GLContext::GetStateWasDirtiedExternally() const { - DCHECK(virtual_gl_api_); - return state_dirtied_externally_; -} - -void GLContext::SetStateWasDirtiedExternally(bool dirtied_externally) { - DCHECK(virtual_gl_api_); - state_dirtied_externally_ = dirtied_externally; -} - -bool GLContext::HasExtension(const char* name) { - std::string extensions = GetExtensions(); - extensions += " "; - - std::string delimited_name(name); - delimited_name += " "; - - return extensions.find(delimited_name) != std::string::npos; -} - -const GLVersionInfo* GLContext::GetVersionInfo() { - if(!version_info_) { - std::string version = GetGLVersion(); - std::string renderer = GetGLRenderer(); - version_info_ = - make_scoped_ptr(new GLVersionInfo(version.c_str(), renderer.c_str())); - } - return version_info_.get(); -} - -GLShareGroup* GLContext::share_group() { - return share_group_.get(); -} - -bool GLContext::LosesAllContextsOnContextLost() { - switch (GetGLImplementation()) { - case kGLImplementationDesktopGL: - return false; - case kGLImplementationEGLGLES2: - return true; - case kGLImplementationOSMesaGL: - case kGLImplementationAppleGL: - return false; - case kGLImplementationMockGL: - return false; - default: - NOTREACHED(); - return true; - } -} - -GLContext* GLContext::GetCurrent() { - return current_context_.Pointer()->Get(); -} - -GLContext* GLContext::GetRealCurrent() { - return current_real_context_.Pointer()->Get(); -} - -void GLContext::SetCurrent(GLSurface* surface) { - current_context_.Pointer()->Set(surface ? this : NULL); - GLSurface::SetCurrent(surface); - // Leave the real GL api current so that unit tests work correctly. - // TODO(sievers): Remove this, but needs all gpu_unittest classes - // to create and make current a context. - if (!surface && GetGLImplementation() != kGLImplementationMockGL) { - SetGLApiToNoContext(); - } -} - -GLStateRestorer* GLContext::GetGLStateRestorer() { - return state_restorer_.get(); -} - -void GLContext::SetGLStateRestorer(GLStateRestorer* state_restorer) { - state_restorer_ = make_scoped_ptr(state_restorer); -} - -void GLContext::SetSwapInterval(int interval) { - swap_interval_ = interval; - OnSetSwapInterval(force_swap_interval_zero_ ? 0 : swap_interval_); -} - -void GLContext::ForceSwapIntervalZero(bool force) { - force_swap_interval_zero_ = force; - OnSetSwapInterval(force_swap_interval_zero_ ? 0 : swap_interval_); -} - -bool GLContext::WasAllocatedUsingRobustnessExtension() { - return false; -} - -bool GLContext::InitializeDynamicBindings() { - DCHECK(IsCurrent(NULL)); - static bool initialized = false; - if (initialized) - return initialized; - initialized = InitializeDynamicGLBindings(GetGLImplementation(), this); - if (!initialized) - LOG(ERROR) << "Could not initialize dynamic bindings."; - return initialized; -} - -void GLContext::SetupForVirtualization() { - if (!virtual_gl_api_) { - virtual_gl_api_.reset(new VirtualGLApi()); - virtual_gl_api_->Initialize(&g_driver_gl, this); - } -} - -bool GLContext::MakeVirtuallyCurrent( - GLContext* virtual_context, GLSurface* surface) { - DCHECK(virtual_gl_api_); - if (!ForceGpuSwitchIfNeeded()) - return false; - return virtual_gl_api_->MakeCurrent(virtual_context, surface); -} - -void GLContext::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { - if (virtual_gl_api_) - virtual_gl_api_->OnReleaseVirtuallyCurrent(virtual_context); -} - -void GLContext::SetRealGLApi() { - SetGLToRealGLApi(); -} - -GLContextReal::GLContextReal(GLShareGroup* share_group) - : GLContext(share_group) {} - -scoped_refptr GLContextReal::CreateGPUTimingClient() { - if (!gpu_timing_) { - gpu_timing_.reset(new gfx::GPUTiming(this)); - } - return gpu_timing_->CreateGPUTimingClient(); -} - -GLContextReal::~GLContextReal() {} - -void GLContextReal::SetCurrent(GLSurface* surface) { - GLContext::SetCurrent(surface); - current_real_context_.Pointer()->Set(surface ? this : NULL); -} - -} // namespace gfx diff --git a/ui/gl/gl_context.h b/ui/gl/gl_context.h deleted file mode 100644 index 95986613e..000000000 --- a/ui/gl/gl_context.h +++ /dev/null @@ -1,216 +0,0 @@ -// 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 UI_GL_GL_CONTEXT_H_ -#define UI_GL_GL_CONTEXT_H_ - -#include -#include - -#include "base/basictypes.h" -#include "base/cancelable_callback.h" -#include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" -#include "base/synchronization/cancellation_flag.h" -#include "ui/gl/gl_share_group.h" -#include "ui/gl/gl_state_restorer.h" -#include "ui/gl/gpu_preference.h" - -namespace gpu { -class GLContextVirtual; -} // namespace gpu - -namespace gfx { - -class GLSurface; -class GPUTiming; -class GPUTimingClient; -class VirtualGLApi; -struct GLVersionInfo; - - -// Encapsulates an OpenGL context, hiding platform specific management. -class GL_EXPORT GLContext : public base::RefCounted { - public: - explicit GLContext(GLShareGroup* share_group); - - // Initializes the GL context to be compatible with the given surface. The GL - // context can be made with other surface's of the same type. The compatible - // surface is only needed for certain platforms like WGL, OSMesa and GLX. It - // should be specific for all platforms though. - virtual bool Initialize( - GLSurface* compatible_surface, GpuPreference gpu_preference) = 0; - - // Destroys the GL context. - virtual void Destroy() = 0; - - // Makes the GL context and a surface current on the current thread. - virtual bool MakeCurrent(GLSurface* surface) = 0; - - // Releases this GL context and surface as current on the current thread. - virtual void ReleaseCurrent(GLSurface* surface) = 0; - - // Returns true if this context and surface is current. Pass a null surface - // if the current surface is not important. - virtual bool IsCurrent(GLSurface* surface) = 0; - - // Get the underlying platform specific GL context "handle". - virtual void* GetHandle() = 0; - - // Creates a GPUTimingClient class which abstracts various GPU Timing exts. - virtual scoped_refptr CreateGPUTimingClient() = 0; - - // Gets the GLStateRestorer for the context. - GLStateRestorer* GetGLStateRestorer(); - - // Sets the GLStateRestorer for the context (takes ownership). - void SetGLStateRestorer(GLStateRestorer* state_restorer); - - // Set swap interval. This context must be current. - void SetSwapInterval(int interval); - - // Forces the swap interval to zero (no vsync) regardless of any future values - // passed to SetSwapInterval. - void ForceSwapIntervalZero(bool force); - - // Returns space separated list of extensions. The context must be current. - virtual std::string GetExtensions(); - - // Returns in bytes the total amount of GPU memory for the GPU which this - // context is currently rendering on. Returns false if no extension exists - // to get the exact amount of GPU memory. - virtual bool GetTotalGpuMemory(size_t* bytes); - - // Indicate that it is safe to force this context to switch GPUs, since - // transitioning can cause corruption and hangs (OS X only). - virtual void SetSafeToForceGpuSwitch(); - - // Attempt to force the context to move to the GPU of its sharegroup. Return - // false only in the event of an unexpected error on the context. - virtual bool ForceGpuSwitchIfNeeded(); - - // Indicate that the real context switches should unbind the FBO first - // (For an Android work-around only). - virtual void SetUnbindFboOnMakeCurrent(); - - // Returns whether the current context supports the named extension. The - // context must be current. - bool HasExtension(const char* name); - - // Returns version info of the underlying GL context. The context must be - // current. - const GLVersionInfo* GetVersionInfo(); - - GLShareGroup* share_group(); - - // Create a GL context that is compatible with the given surface. - // |share_group|, if non-NULL, is a group of contexts which the - // internally created OpenGL context shares textures and other resources. - static scoped_refptr CreateGLContext( - GLShareGroup* share_group, - GLSurface* compatible_surface, - GpuPreference gpu_preference); - - static bool LosesAllContextsOnContextLost(); - - // Returns the last GLContext made current, virtual or real. - static GLContext* GetCurrent(); - - virtual bool WasAllocatedUsingRobustnessExtension(); - - // Use this context for virtualization. - void SetupForVirtualization(); - - // Make this context current when used for context virtualization. - bool MakeVirtuallyCurrent(GLContext* virtual_context, GLSurface* surface); - - // Notify this context that |virtual_context|, that was using us, is - // being released or destroyed. - void OnReleaseVirtuallyCurrent(GLContext* virtual_context); - - // Returns the GL version string. The context must be current. - virtual std::string GetGLVersion(); - - // Returns the GL renderer string. The context must be current. - virtual std::string GetGLRenderer(); - - // Return a callback that, when called, indicates that the state the - // underlying context has been changed by code outside of the command buffer, - // and will need to be restored. - virtual base::Closure GetStateWasDirtiedExternallyCallback(); - - // Restore the context's state if it was dirtied by an external caller. - virtual void RestoreStateIfDirtiedExternally(); - - protected: - virtual ~GLContext(); - - // Will release the current context when going out of scope, unless canceled. - class ScopedReleaseCurrent { - public: - ScopedReleaseCurrent(); - ~ScopedReleaseCurrent(); - - void Cancel(); - - private: - bool canceled_; - }; - - // Sets the GL api to the real hardware API (vs the VirtualAPI) - static void SetRealGLApi(); - virtual void SetCurrent(GLSurface* surface); - - // Initialize function pointers to functions where the bound version depends - // on GL version or supported extensions. Should be called immediately after - // this context is made current. - bool InitializeDynamicBindings(); - - // Returns the last real (non-virtual) GLContext made current. - static GLContext* GetRealCurrent(); - - virtual void OnSetSwapInterval(int interval) = 0; - - bool GetStateWasDirtiedExternally() const; - void SetStateWasDirtiedExternally(bool dirtied_externally); - - private: - friend class base::RefCounted; - - // For GetRealCurrent. - friend class VirtualGLApi; - friend class gpu::GLContextVirtual; - - scoped_refptr share_group_; - scoped_ptr virtual_gl_api_; - bool state_dirtied_externally_; - scoped_ptr state_restorer_; - scoped_ptr version_info_; - - int swap_interval_; - bool force_swap_interval_zero_; - - base::CancelableCallback state_dirtied_callback_; - - DISALLOW_COPY_AND_ASSIGN(GLContext); -}; - -class GL_EXPORT GLContextReal : public GLContext { - public: - explicit GLContextReal(GLShareGroup* share_group); - scoped_refptr CreateGPUTimingClient() override; - - protected: - ~GLContextReal() override; - - void SetCurrent(GLSurface* surface) override; - - private: - scoped_ptr gpu_timing_; - DISALLOW_COPY_AND_ASSIGN(GLContextReal); -}; - -} // namespace gfx - -#endif // UI_GL_GL_CONTEXT_H_ diff --git a/ui/gl/gl_context_android.cc b/ui/gl/gl_context_android.cc deleted file mode 100644 index 9d3c86cf4..000000000 --- a/ui/gl/gl_context_android.cc +++ /dev/null @@ -1,151 +0,0 @@ -// 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 "ui/gl/gl_context.h" - -#include "base/logging.h" -#include "base/memory/ref_counted.h" -#include "base/sys_info.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_context_egl.h" -#include "ui/gl/gl_context_osmesa.h" -#include "ui/gl/gl_context_stub.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_surface.h" - -namespace gfx { - -namespace { - -// Used to render into an already current context+surface, -// that we do not have ownership of (draw callback). -// TODO(boliu): Make this inherit from GLContextEGL. -class GLNonOwnedContext : public GLContextReal { - public: - GLNonOwnedContext(GLShareGroup* share_group); - - // Implement GLContext. - bool Initialize(GLSurface* compatible_surface, - GpuPreference gpu_preference) override; - void Destroy() override {} - bool MakeCurrent(GLSurface* surface) override; - void ReleaseCurrent(GLSurface* surface) override {} - bool IsCurrent(GLSurface* surface) override { return true; } - void* GetHandle() override { return NULL; } - void OnSetSwapInterval(int interval) override {} - std::string GetExtensions() override; - - protected: - ~GLNonOwnedContext() override {} - - private: - DISALLOW_COPY_AND_ASSIGN(GLNonOwnedContext); - - EGLDisplay display_; -}; - -GLNonOwnedContext::GLNonOwnedContext(GLShareGroup* share_group) - : GLContextReal(share_group), display_(NULL) {} - -bool GLNonOwnedContext::Initialize(GLSurface* compatible_surface, - GpuPreference gpu_preference) { - display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY); - return true; -} - -bool GLNonOwnedContext::MakeCurrent(GLSurface* surface) { - SetCurrent(surface); - SetRealGLApi(); - return true; -} - -std::string GLNonOwnedContext::GetExtensions() { - const char* extensions = eglQueryString(display_, EGL_EXTENSIONS); - if (!extensions) - return GLContext::GetExtensions(); - - return GLContext::GetExtensions() + " " + extensions; -} - -} // anonymous namespace - -// static -scoped_refptr GLContext::CreateGLContext( - GLShareGroup* share_group, - GLSurface* compatible_surface, - GpuPreference gpu_preference) { - scoped_refptr context; - switch (GetGLImplementation()) { - case kGLImplementationMockGL: - return scoped_refptr(new GLContextStub()); - case kGLImplementationOSMesaGL: - context = new GLContextOSMesa(share_group); - break; - default: - if (compatible_surface->GetHandle()) - context = new GLContextEGL(share_group); - else - context = new GLNonOwnedContext(share_group); - break; - } - - if (!context->Initialize(compatible_surface, gpu_preference)) - return NULL; - - return context; -} - -bool GLContextEGL::GetTotalGpuMemory(size_t* bytes) { - DCHECK(bytes); - *bytes = 0; - - // We can't query available GPU memory from the system on Android. - // Physical memory is also mis-reported sometimes (eg. Nexus 10 reports - // 1262MB when it actually has 2GB, while Razr M has 1GB but only reports - // 128MB java heap size). First we estimate physical memory using both. - size_t dalvik_mb = base::SysInfo::DalvikHeapSizeMB(); - size_t physical_mb = base::SysInfo::AmountOfPhysicalMemoryMB(); - size_t physical_memory_mb = 0; - if (dalvik_mb >= 256) - physical_memory_mb = dalvik_mb * 4; - else - physical_memory_mb = std::max(dalvik_mb * 4, - (physical_mb * 4) / 3); - - // Now we take a default of 1/8th of memory on high-memory devices, - // and gradually scale that back for low-memory devices (to be nicer - // to other apps so they don't get killed). Examples: - // Nexus 4/10(2GB) 256MB (normally 128MB) - // Droid Razr M(1GB) 114MB (normally 57MB) - // Galaxy Nexus(1GB) 100MB (normally 50MB) - // Xoom(1GB) 100MB (normally 50MB) - // Nexus S(low-end) 8MB (normally 8MB) - // Note that the compositor now uses only some of this memory for - // pre-painting and uses the rest only for 'emergencies'. - static size_t limit_bytes = 0; - if (limit_bytes == 0) { - // NOTE: Non-low-end devices use only 50% of these limits, - // except during 'emergencies' where 100% can be used. - if (!base::SysInfo::IsLowEndDevice()) { - if (physical_memory_mb >= 1536) - limit_bytes = physical_memory_mb / 8; // >192MB - else if (physical_memory_mb >= 1152) - limit_bytes = physical_memory_mb / 8; // >144MB - else if (physical_memory_mb >= 768) - limit_bytes = physical_memory_mb / 10; // >76MB - else - limit_bytes = physical_memory_mb / 12; // <64MB - } else { - // Low-end devices have 512MB or less memory by definition - // so we hard code the limit rather than relying on the heuristics - // above. Low-end devices use 4444 textures so we can use a lower limit. - limit_bytes = 8; - } - limit_bytes = limit_bytes * 1024 * 1024; - } - *bytes = limit_bytes; - return true; -} - -} diff --git a/ui/gl/gl_context_cgl.cc b/ui/gl/gl_context_cgl.cc deleted file mode 100644 index ba063b0a2..000000000 --- a/ui/gl/gl_context_cgl.cc +++ /dev/null @@ -1,304 +0,0 @@ -// 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 "ui/gl/gl_context_cgl.h" - -#include -#include -#include - -#include - -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "base/trace_event/trace_event.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_surface.h" -#include "ui/gl/gpu_switching_manager.h" - -extern "C" { -extern CGLError CGLChoosePixelFormat(const CGLPixelFormatAttribute *attribs, - CGLPixelFormatObj *pix, GLint *npix); -extern CGLError CGLDescribePixelFormat(CGLPixelFormatObj pix, GLint pix_num, - CGLPixelFormatAttribute attrib, - GLint *value); -extern void CGLReleasePixelFormat(CGLPixelFormatObj pix); - -extern CGLError CGLCreateContext(CGLPixelFormatObj pix, CGLContextObj share, - CGLContextObj *ctx); -extern CGLError CGLDestroyContext(CGLContextObj ctx); - -extern CGLError CGLGetParameter(CGLContextObj ctx, CGLContextParameter pname, - GLint *params); - -extern CGLError CGLGetVirtualScreen(CGLContextObj ctx, GLint *screen); -extern CGLError CGLSetVirtualScreen(CGLContextObj ctx, GLint screen); - -extern CGLError CGLQueryRendererInfo(GLuint display_mask, - CGLRendererInfoObj *rend, GLint *nrend); -extern CGLError CGLDescribeRenderer(CGLRendererInfoObj rend, GLint rend_num, - CGLRendererProperty prop, GLint *value); -extern CGLError CGLDestroyRendererInfo(CGLRendererInfoObj rend); -} // extern "C" - -namespace gfx { - -namespace { - -bool g_support_renderer_switching; - -struct CGLRendererInfoObjDeleter { - void operator()(CGLRendererInfoObj* x) { - if (x) - CGLDestroyRendererInfo(*x); - } -}; - -} // namespace - -static CGLPixelFormatObj GetPixelFormat() { - static CGLPixelFormatObj format; - if (format) - return format; - std::vector attribs; - // If the system supports dual gpus then allow offline renderers for every - // context, so that they can all be in the same share group. - if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) { - attribs.push_back(kCGLPFAAllowOfflineRenderers); - g_support_renderer_switching = true; - } - if (GetGLImplementation() == kGLImplementationAppleGL) { - attribs.push_back(kCGLPFARendererID); - attribs.push_back((CGLPixelFormatAttribute) kCGLRendererGenericFloatID); - g_support_renderer_switching = false; - } - - attribs.push_back((CGLPixelFormatAttribute) 0); - - GLint num_virtual_screens; - if (CGLChoosePixelFormat(&attribs.front(), - &format, - &num_virtual_screens) != kCGLNoError) { - LOG(ERROR) << "Error choosing pixel format."; - return nullptr; - } - if (!format) { - LOG(ERROR) << "format == 0."; - return nullptr; - } - DCHECK_NE(num_virtual_screens, 0); - return format; -} - -GLContextCGL::GLContextCGL(GLShareGroup* share_group) - : GLContextReal(share_group), - context_(nullptr), - gpu_preference_(PreferIntegratedGpu), - discrete_pixelformat_(nullptr), - screen_(-1), - renderer_id_(-1), - safe_to_force_gpu_switch_(false) { -} - -bool GLContextCGL::Initialize(GLSurface* compatible_surface, - GpuPreference gpu_preference) { - DCHECK(compatible_surface); - - gpu_preference = ui::GpuSwitchingManager::GetInstance()->AdjustGpuPreference( - gpu_preference); - - GLContextCGL* share_context = share_group() ? - static_cast(share_group()->GetContext()) : nullptr; - - CGLPixelFormatObj format = GetPixelFormat(); - if (!format) - return false; - - // If using the discrete gpu, create a pixel format requiring it before we - // create the context. - if (!ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus() || - gpu_preference == PreferDiscreteGpu) { - std::vector discrete_attribs; - discrete_attribs.push_back((CGLPixelFormatAttribute) 0); - GLint num_pixel_formats; - if (CGLChoosePixelFormat(&discrete_attribs.front(), - &discrete_pixelformat_, - &num_pixel_formats) != kCGLNoError) { - LOG(ERROR) << "Error choosing pixel format."; - return false; - } - } - - CGLError res = CGLCreateContext( - format, - share_context ? - static_cast(share_context->GetHandle()) : nullptr, - reinterpret_cast(&context_)); - if (res != kCGLNoError) { - LOG(ERROR) << "Error creating context."; - Destroy(); - return false; - } - - gpu_preference_ = gpu_preference; - return true; -} - -void GLContextCGL::Destroy() { - if (discrete_pixelformat_) { - if (base::MessageLoop::current() != nullptr) { - // Delay releasing the pixel format for 10 seconds to reduce the number of - // unnecessary GPU switches. - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, base::Bind(&CGLReleasePixelFormat, discrete_pixelformat_), - base::TimeDelta::FromSeconds(10)); - } else { - CGLReleasePixelFormat(discrete_pixelformat_); - } - discrete_pixelformat_ = nullptr; - } - if (context_) { - CGLDestroyContext(static_cast(context_)); - context_ = nullptr; - } -} - -bool GLContextCGL::ForceGpuSwitchIfNeeded() { - DCHECK(context_); - return true; -} - -bool GLContextCGL::MakeCurrent(GLSurface* surface) { - DCHECK(context_); - - if (!ForceGpuSwitchIfNeeded()) - return false; - - if (IsCurrent(surface)) - return true; - - ScopedReleaseCurrent release_current; - TRACE_EVENT0("gpu", "GLContextCGL::MakeCurrent"); - - if (CGLSetCurrentContext( - static_cast(context_)) != kCGLNoError) { - LOG(ERROR) << "Unable to make gl context current."; - return false; - } - - // Set this as soon as the context is current, since we might call into GL. - SetRealGLApi(); - - SetCurrent(surface); - if (!InitializeDynamicBindings()) { - return false; - } - - if (!surface->OnMakeCurrent(this)) { - LOG(ERROR) << "Unable to make gl context current."; - return false; - } - - release_current.Cancel(); - return true; -} - -void GLContextCGL::ReleaseCurrent(GLSurface* surface) { - if (!IsCurrent(surface)) - return; - - SetCurrent(nullptr); - CGLSetCurrentContext(nullptr); -} - -bool GLContextCGL::IsCurrent(GLSurface* surface) { - bool native_context_is_current = CGLGetCurrentContext() == context_; - - // If our context is current then our notion of which GLContext is - // current must be correct. On the other hand, third-party code - // using OpenGL might change the current context. - DCHECK(!native_context_is_current || (GetRealCurrent() == this)); - - if (!native_context_is_current) - return false; - - return true; -} - -void* GLContextCGL::GetHandle() { - return context_; -} - -void GLContextCGL::OnSetSwapInterval(int interval) { - DCHECK(IsCurrent(nullptr)); -} - -bool GLContextCGL::GetTotalGpuMemory(size_t* bytes) { - DCHECK(bytes); - *bytes = 0; - - CGLContextObj context = reinterpret_cast(context_); - if (!context) - return false; - - // Retrieve the current renderer ID - GLint current_renderer_id = 0; - if (CGLGetParameter(context, - kCGLCPCurrentRendererID, - ¤t_renderer_id) != kCGLNoError) - return false; - - // Iterate through the list of all renderers - GLuint display_mask = static_cast(-1); - CGLRendererInfoObj renderer_info = nullptr; - GLint num_renderers = 0; - if (CGLQueryRendererInfo(display_mask, - &renderer_info, - &num_renderers) != kCGLNoError) - return false; - - scoped_ptr scoper(&renderer_info); - - for (GLint renderer_index = 0; - renderer_index < num_renderers; - ++renderer_index) { - // Skip this if this renderer is not the current renderer. - GLint renderer_id = 0; - if (CGLDescribeRenderer(renderer_info, - renderer_index, - kCGLRPRendererID, - &renderer_id) != kCGLNoError) - continue; - if (renderer_id != current_renderer_id) - continue; - // Retrieve the video memory for the renderer. - GLint video_memory = 0; - if (CGLDescribeRenderer(renderer_info, - renderer_index, - kCGLRPVideoMemoryMegabytes, - &video_memory) != kCGLNoError) - continue; - *bytes = (video_memory * 1000000); - return true; - } - - return false; -} - -void GLContextCGL::SetSafeToForceGpuSwitch() { - safe_to_force_gpu_switch_ = true; -} - - -GLContextCGL::~GLContextCGL() { - Destroy(); -} - -GpuPreference GLContextCGL::GetGpuPreference() { - return gpu_preference_; -} - -} // namespace gfx diff --git a/ui/gl/gl_context_cgl.h b/ui/gl/gl_context_cgl.h deleted file mode 100644 index 88813b39c..000000000 --- a/ui/gl/gl_context_cgl.h +++ /dev/null @@ -1,54 +0,0 @@ -// 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 UI_GL_GL_CONTEXT_CGL_H_ -#define UI_GL_GL_CONTEXT_CGL_H_ - -#include - -#include "ui/gl/gl_context.h" - -namespace gfx { - -class GLSurface; - -// Encapsulates a CGL OpenGL context. -class GLContextCGL : public GLContextReal { - public: - explicit GLContextCGL(GLShareGroup* share_group); - - // Implement GLContext. - bool Initialize(GLSurface* compatible_surface, - GpuPreference gpu_preference) override; - void Destroy() override; - bool MakeCurrent(GLSurface* surface) override; - void ReleaseCurrent(GLSurface* surface) override; - bool IsCurrent(GLSurface* surface) override; - void* GetHandle() override; - void OnSetSwapInterval(int interval) override; - bool GetTotalGpuMemory(size_t* bytes) override; - void SetSafeToForceGpuSwitch() override; - bool ForceGpuSwitchIfNeeded() override; - - protected: - ~GLContextCGL() override; - - private: - GpuPreference GetGpuPreference(); - - void* context_; - GpuPreference gpu_preference_; - - CGLPixelFormatObj discrete_pixelformat_; - - int screen_; - int renderer_id_; - bool safe_to_force_gpu_switch_; - - DISALLOW_COPY_AND_ASSIGN(GLContextCGL); -}; - -} // namespace gfx - -#endif // UI_GL_GL_CONTEXT_CGL_H_ diff --git a/ui/gl/gl_context_egl.cc b/ui/gl/gl_context_egl.cc deleted file mode 100644 index 20bc8e2b8..000000000 --- a/ui/gl/gl_context_egl.cc +++ /dev/null @@ -1,235 +0,0 @@ -// 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 "ui/gl/gl_context_egl.h" - -#include -#include - -#include "base/command_line.h" -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "base/trace_event/trace_event.h" -#include "build/build_config.h" -#include "ui/gl/egl_util.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_surface_egl.h" - -#if defined(USE_X11) -extern "C" { -#include -} -#endif - -#if !defined(EGL_EXT_create_context_robustness) -#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF -#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138 -#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE -#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF -#endif - -using ui::GetLastEGLErrorString; - -namespace gfx { - -GLContextEGL::GLContextEGL(GLShareGroup* share_group) - : GLContextReal(share_group), - context_(NULL), - display_(NULL), - config_(NULL), - unbind_fbo_on_makecurrent_(false), - swap_interval_(1) { -} - -bool GLContextEGL::Initialize( - GLSurface* compatible_surface, GpuPreference gpu_preference) { - DCHECK(compatible_surface); - DCHECK(!context_); - - EGLint context_client_version = 2; - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableUnsafeES3APIs)) { - context_client_version = 3; - } - - const EGLint kContextAttributes[] = { - EGL_CONTEXT_CLIENT_VERSION, context_client_version, - EGL_NONE - }; - const EGLint kContextRobustnessAttributes[] = { - EGL_CONTEXT_CLIENT_VERSION, context_client_version, - EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, - EGL_LOSE_CONTEXT_ON_RESET_EXT, - EGL_NONE - }; - - display_ = compatible_surface->GetDisplay(); - config_ = compatible_surface->GetConfig(); - - const EGLint* context_attributes = NULL; - if (GLSurfaceEGL::IsCreateContextRobustnessSupported()) { - DVLOG(1) << "EGL_EXT_create_context_robustness supported."; - context_attributes = kContextRobustnessAttributes; - } else { - // At some point we should require the presence of the robustness - // extension and remove this code path. - DVLOG(1) << "EGL_EXT_create_context_robustness NOT supported."; - context_attributes = kContextAttributes; - } - - context_ = eglCreateContext( - display_, - config_, - share_group() ? share_group()->GetHandle() : NULL, - context_attributes); - - if (!context_) { - LOG(ERROR) << "eglCreateContext failed with error " - << GetLastEGLErrorString(); - return false; - } - - return true; -} - -void GLContextEGL::Destroy() { - if (context_) { - if (!eglDestroyContext(display_, context_)) { - LOG(ERROR) << "eglDestroyContext failed with error " - << GetLastEGLErrorString(); - } - - context_ = NULL; - } -} - -bool GLContextEGL::MakeCurrent(GLSurface* surface) { - DCHECK(context_); - if (IsCurrent(surface)) - return true; - - ScopedReleaseCurrent release_current; - TRACE_EVENT2("gpu", "GLContextEGL::MakeCurrent", - "context", context_, - "surface", surface); - - if (unbind_fbo_on_makecurrent_ && - eglGetCurrentContext() != EGL_NO_CONTEXT) { - glBindFramebufferEXT(GL_FRAMEBUFFER, 0); - } - - if (!eglMakeCurrent(display_, - surface->GetHandle(), - surface->GetHandle(), - context_)) { - DVLOG(1) << "eglMakeCurrent failed with error " - << GetLastEGLErrorString(); - return false; - } - - // Set this as soon as the context is current, since we might call into GL. - SetRealGLApi(); - - SetCurrent(surface); - if (!InitializeDynamicBindings()) { - return false; - } - - if (!surface->OnMakeCurrent(this)) { - LOG(ERROR) << "Could not make current."; - return false; - } - - surface->OnSetSwapInterval(swap_interval_); - - release_current.Cancel(); - return true; -} - -void GLContextEGL::SetUnbindFboOnMakeCurrent() { - unbind_fbo_on_makecurrent_ = true; -} - -void GLContextEGL::ReleaseCurrent(GLSurface* surface) { - if (!IsCurrent(surface)) - return; - - if (unbind_fbo_on_makecurrent_) - glBindFramebufferEXT(GL_FRAMEBUFFER, 0); - - SetCurrent(NULL); - eglMakeCurrent(display_, - EGL_NO_SURFACE, - EGL_NO_SURFACE, - EGL_NO_CONTEXT); -} - -bool GLContextEGL::IsCurrent(GLSurface* surface) { - DCHECK(context_); - - bool native_context_is_current = context_ == eglGetCurrentContext(); - - // If our context is current then our notion of which GLContext is - // current must be correct. On the other hand, third-party code - // using OpenGL might change the current context. - DCHECK(!native_context_is_current || (GetRealCurrent() == this)); - - if (!native_context_is_current) - return false; - - if (surface) { - if (surface->GetHandle() != eglGetCurrentSurface(EGL_DRAW)) - return false; - } - - return true; -} - -void* GLContextEGL::GetHandle() { - return context_; -} - -void GLContextEGL::OnSetSwapInterval(int interval) { - DCHECK(IsCurrent(NULL) && GLSurface::GetCurrent()); - - // This is a surfaceless context. eglSwapInterval doesn't take any effect in - // this case and will just return EGL_BAD_SURFACE. - if (GLSurface::GetCurrent()->IsSurfaceless()) - return; - - if (!eglSwapInterval(display_, interval)) { - LOG(ERROR) << "eglSwapInterval failed with error " - << GetLastEGLErrorString(); - } else { - swap_interval_ = interval; - GLSurface::GetCurrent()->OnSetSwapInterval(interval); - } -} - -std::string GLContextEGL::GetExtensions() { - const char* extensions = eglQueryString(display_, - EGL_EXTENSIONS); - if (!extensions) - return GLContext::GetExtensions(); - - return GLContext::GetExtensions() + " " + extensions; -} - -bool GLContextEGL::WasAllocatedUsingRobustnessExtension() { - return GLSurfaceEGL::IsCreateContextRobustnessSupported(); -} - -GLContextEGL::~GLContextEGL() { - Destroy(); -} - -#if !defined(OS_ANDROID) -bool GLContextEGL::GetTotalGpuMemory(size_t* bytes) { - DCHECK(bytes); - *bytes = 0; - return false; -} -#endif - -} // namespace gfx diff --git a/ui/gl/gl_context_egl.h b/ui/gl/gl_context_egl.h deleted file mode 100644 index 39b26d0c3..000000000 --- a/ui/gl/gl_context_egl.h +++ /dev/null @@ -1,55 +0,0 @@ -// 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 UI_GL_GL_CONTEXT_EGL_H_ -#define UI_GL_GL_CONTEXT_EGL_H_ - -#include - -#include "base/compiler_specific.h" -#include "ui/gl/gl_context.h" - -typedef void* EGLContext; -typedef void* EGLDisplay; -typedef void* EGLConfig; - -namespace gfx { - -class GLSurface; - -// Encapsulates an EGL OpenGL ES context. -class GLContextEGL : public GLContextReal { - public: - explicit GLContextEGL(GLShareGroup* share_group); - - // Implement GLContext. - bool Initialize(GLSurface* compatible_surface, - GpuPreference gpu_preference) override; - void Destroy() override; - bool MakeCurrent(GLSurface* surface) override; - void ReleaseCurrent(GLSurface* surface) override; - bool IsCurrent(GLSurface* surface) override; - void* GetHandle() override; - void OnSetSwapInterval(int interval) override; - std::string GetExtensions() override; - bool WasAllocatedUsingRobustnessExtension() override; - bool GetTotalGpuMemory(size_t* bytes) override; - void SetUnbindFboOnMakeCurrent() override; - - protected: - ~GLContextEGL() override; - - private: - EGLContext context_; - EGLDisplay display_; - EGLConfig config_; - bool unbind_fbo_on_makecurrent_; - int swap_interval_; - - DISALLOW_COPY_AND_ASSIGN(GLContextEGL); -}; - -} // namespace gfx - -#endif // UI_GL_GL_CONTEXT_EGL_H_ diff --git a/ui/gl/gl_context_glfw.cc b/ui/gl/gl_context_glfw.cc deleted file mode 100644 index 5a3ea6d35..000000000 --- a/ui/gl/gl_context_glfw.cc +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright 2016 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 "ui/gl/gl_context_glfw.h" - -#include - -#include "base/command_line.h" -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "base/trace_event/trace_event.h" -#include "build/build_config.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_context_stub.h" -#include "ui/gl/gl_surface_glfw.h" - -namespace gfx { - -GLContextGlfw::GLContextGlfw(GLShareGroup* share_group) - : GLContextReal(share_group), - surface_(NULL), - context_(NULL), - unbind_fbo_on_makecurrent_(false), - swap_interval_(1) { -} - -scoped_refptr GLContext::CreateGLContext( - GLShareGroup* share_group, - GLSurface* compatible_surface, - GpuPreference gpu_preference) { - TRACE_EVENT0("gpu", "GLContext::CreateGLContext"); - switch (GetGLImplementation()) { - case kGLImplementationDesktopGL: - case kGLImplementationEGLGLES2: { - scoped_refptr context; - context = new GLContextGlfw(share_group); - if (!context->Initialize(compatible_surface, gpu_preference)) - return NULL; - - return context; - } - case kGLImplementationMockGL: - return new GLContextStub; - default: - NOTREACHED(); - return NULL; - } -} - - -bool GLContextGlfw::Initialize( - GLSurface* compatible_surface, GpuPreference gpu_preference) { - DCHECK(compatible_surface); - DCHECK(!surface_); - DCHECK(!context_); - - surface_ = compatible_surface; - context_ = reinterpret_cast(surface_->GetHandle()); - - return true; -} - -void GLContextGlfw::Destroy() { - if (surface_) { - surface_ = NULL; - } - if (context_) { - context_ = NULL; - } -} - -bool GLContextGlfw::MakeCurrent(GLSurface* surface) { - DCHECK(surface_); - if (IsCurrent(surface)) - return true; - - ScopedReleaseCurrent release_current; - TRACE_EVENT2("gpu", "GLContextEGL::MakeCurrent", - "context", surface_, - "surface", surface); - - if (unbind_fbo_on_makecurrent_ && glfwGetCurrentContext() != NULL) { - glBindFramebufferEXT(GL_FRAMEBUFFER, 0); - } - - // Make the surface's context current. - glfwMakeContextCurrent(context_); - - // Set this as soon as the context is current, since we might call into GL. - SetRealGLApi(); - - SetCurrent(surface); - if (!InitializeDynamicBindings()) { - return false; - } - - if (!surface->OnMakeCurrent(this)) { - LOG(ERROR) << "Could not make current."; - return false; - } - - surface->OnSetSwapInterval(swap_interval_); - - release_current.Cancel(); - return true; -} - -void GLContextGlfw::SetUnbindFboOnMakeCurrent() { - unbind_fbo_on_makecurrent_ = true; -} - -void GLContextGlfw::ReleaseCurrent(GLSurface* surface) { - if (!IsCurrent(surface)) - return; - - if (unbind_fbo_on_makecurrent_) - glBindFramebufferEXT(GL_FRAMEBUFFER, 0); - - SetCurrent(NULL); - glfwMakeContextCurrent(NULL); -} - -bool GLContextGlfw::IsCurrent(GLSurface* surface) { - DCHECK(surface_); - DCHECK(context_); - - bool native_context_is_current = context_ == glfwGetCurrentContext(); - - // If our context is current then our notion of which GLContext is - // current must be correct. On the other hand, third-party code - // using OpenGL might change the current context. - DCHECK(!native_context_is_current || (GetRealCurrent() == this)); - - if (!native_context_is_current) - return false; - - return true; -} - -void* GLContextGlfw::GetHandle() { - return (void *)context_; -} - -void GLContextGlfw::OnSetSwapInterval(int interval) { - DCHECK(IsCurrent(NULL) && GLSurface::GetCurrent()); - - glfwSwapInterval(interval); - swap_interval_ = interval; - GLSurface::GetCurrent()->OnSetSwapInterval(interval); -} - -std::string GLContextGlfw::GetExtensions() { - return GLContext::GetExtensions(); -} - -bool GLContextGlfw::WasAllocatedUsingRobustnessExtension() { - int robust = glfwGetWindowAttrib(context_, GLFW_CONTEXT_ROBUSTNESS); - return (robust != GLFW_NO_ROBUSTNESS); -} - -GLContextGlfw::~GLContextGlfw() { - Destroy(); -} - -#if !defined(OS_ANDROID) -bool GLContextGlfw::GetTotalGpuMemory(size_t* bytes) { - // TODO(dalyj): Unimplemented. - DCHECK(bytes); - *bytes = 0; - return false; -} -#endif - -} // namespace gfx diff --git a/ui/gl/gl_context_glfw.h b/ui/gl/gl_context_glfw.h deleted file mode 100644 index e85908949..000000000 --- a/ui/gl/gl_context_glfw.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2016 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 UI_GL_GL_CONTEXT_GLFW_H_ -#define UI_GL_GL_CONTEXT_GLFW_H_ - -#include - -#include "base/compiler_specific.h" -#include "ui/gl/gl_context.h" -#include "ui/gfx/native_widget_types.h" - -typedef void* EGLContext; -typedef void* EGLDisplay; -typedef void* EGLConfig; - -namespace gfx { - -class GLSurface; - -// Presents a GLFW window as a GLContext. -class GLContextGlfw : public GLContextReal { - public: - explicit GLContextGlfw(GLShareGroup* share_group); - - - // Implement GLContext. - bool Initialize(GLSurface* compatible_surface, - GpuPreference gpu_preference) override; - void Destroy() override; - bool MakeCurrent(GLSurface* surface) override; - void ReleaseCurrent(GLSurface* surface) override; - bool IsCurrent(GLSurface* surface) override; - void* GetHandle() override; - void OnSetSwapInterval(int interval) override; - std::string GetExtensions() override; - bool WasAllocatedUsingRobustnessExtension() override; - bool GetTotalGpuMemory(size_t* bytes) override; - void SetUnbindFboOnMakeCurrent() override; - - protected: - ~GLContextGlfw() override; - - private: - GLSurface* surface_; - gfx::AcceleratedWidget context_; - bool unbind_fbo_on_makecurrent_; - int swap_interval_; - - DISALLOW_COPY_AND_ASSIGN(GLContextGlfw); -}; - -} // namespace gfx - -#endif // UI_GL_GL_CONTEXT_EGL_H_ diff --git a/ui/gl/gl_context_ios.h b/ui/gl/gl_context_ios.h deleted file mode 100644 index 3cecc0307..000000000 --- a/ui/gl/gl_context_ios.h +++ /dev/null @@ -1,43 +0,0 @@ -// 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 UI_GL_GL_CONTEXT_IOS_H_ -#define UI_GL_GL_CONTEXT_IOS_H_ - -#include "base/compiler_specific.h" -#include "ui/gl/gl_context.h" - -namespace gfx { - -class GLSurface; - -class GLContextIOS : public GLContextReal { - public: - explicit GLContextIOS(GLShareGroup* share_group); - - bool Initialize(GLSurface* compatible_surface, - GpuPreference gpu_preference) override; - void Destroy() override; - bool MakeCurrent(GLSurface* surface) override; - void ReleaseCurrent(GLSurface* surface) override; - bool IsCurrent(GLSurface* surface) override; - void* GetHandle() override; - void OnSetSwapInterval(int interval) override; - std::string GetExtensions() override; - bool WasAllocatedUsingRobustnessExtension() override; - bool GetTotalGpuMemory(size_t* bytes) override; - void SetUnbindFboOnMakeCurrent() override; - - protected: - ~GLContextIOS() override; - - private: - uintptr_t context_; - - DISALLOW_COPY_AND_ASSIGN(GLContextIOS); -}; - -} // namespace gfx - -#endif // UI_GL_GL_CONTEXT_IOS_H_ diff --git a/ui/gl/gl_context_ios.mm b/ui/gl/gl_context_ios.mm deleted file mode 100644 index 39b542146..000000000 --- a/ui/gl/gl_context_ios.mm +++ /dev/null @@ -1,114 +0,0 @@ -// 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/basictypes.h" -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "base/trace_event/trace_event.h" -#include "ui/gl/gl_context_ios.h" -#include "ui/gl/gl_context_stub.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_surface.h" -#include "ui/gl/gl_switches.h" - -#include -#include -#include - -#define CAST_CONTEXT (reinterpret_cast(context_)) - -namespace gfx { - -GLContextIOS::GLContextIOS(GLShareGroup* share_group) - : GLContextReal(share_group) { - EAGLContext* context = - [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; - DCHECK(context); - context_ = reinterpret_cast(context); -} - -GLContextIOS::~GLContextIOS() { - Destroy(); -} - -bool GLContextIOS::Initialize(GLSurface* compatible_surface, - GpuPreference gpu_preference) { - return CAST_CONTEXT != nullptr && compatible_surface != nullptr; -} - -void GLContextIOS::Destroy() { - [CAST_CONTEXT release]; -} - -bool GLContextIOS::MakeCurrent(GLSurface* surface) { - bool result = [EAGLContext setCurrentContext:CAST_CONTEXT]; - - if (!result) { - return false; - } - - SetRealGLApi(); - - if (!InitializeDynamicBindings()) { - return false; - } - - if (!surface->OnMakeCurrent(this)) { - return false; - } - - return true; -} - -void GLContextIOS::ReleaseCurrent(GLSurface* surface) { - [EAGLContext setCurrentContext:nil]; -} - -bool GLContextIOS::IsCurrent(GLSurface* surface) { - return [EAGLContext currentContext] == CAST_CONTEXT; -} - -void* GLContextIOS::GetHandle() { - return CAST_CONTEXT; -} - -void GLContextIOS::OnSetSwapInterval(int interval) { -} - -std::string GLContextIOS::GetExtensions() { - return reinterpret_cast(glGetString(GL_EXTENSIONS)); -} - -bool GLContextIOS::WasAllocatedUsingRobustnessExtension() { - return false; -} - -bool GLContextIOS::GetTotalGpuMemory(size_t* bytes) { - DCHECK(false); - return false; -} - -void GLContextIOS::SetUnbindFboOnMakeCurrent() { - DCHECK(false); -} - -class GLShareGroup; - -scoped_refptr GLContext::CreateGLContext( - GLShareGroup* share_group, - GLSurface* compatible_surface, - GpuPreference gpu_preference) { - TRACE_EVENT0("gpu", "GLContext::CreateGLContext"); - - scoped_refptr context; - - context = new GLContextIOS(share_group); - - if (!context->Initialize(compatible_surface, gpu_preference)) - return nullptr; - - return context; -} - -} // namespace gfx diff --git a/ui/gl/gl_context_mac.h b/ui/gl/gl_context_mac.h deleted file mode 100644 index 6577c1f3c..000000000 --- a/ui/gl/gl_context_mac.h +++ /dev/null @@ -1,43 +0,0 @@ -// 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. - -#ifndef __UI_GL_GL_CONTEXT_MAC_H__ -#define __UI_GL_GL_CONTEXT_MAC_H__ - -#include "base/compiler_specific.h" -#include "ui/gl/gl_context.h" - -namespace gfx { - -class GLSurface; - -class GLContextMac : public GLContextReal { - public: - explicit GLContextMac(GLShareGroup* share_group); - - bool Initialize(GLSurface* compatible_surface, - GpuPreference gpu_preference) override; - void Destroy() override; - bool MakeCurrent(GLSurface* surface) override; - void ReleaseCurrent(GLSurface* surface) override; - bool IsCurrent(GLSurface* surface) override; - void* GetHandle() override; - void OnSetSwapInterval(int interval) override; - std::string GetExtensions() override; - bool WasAllocatedUsingRobustnessExtension() override; - bool GetTotalGpuMemory(size_t* bytes) override; - void SetUnbindFboOnMakeCurrent() override; - - protected: - ~GLContextMac() override; - - private: - uintptr_t context_; - - DISALLOW_COPY_AND_ASSIGN(GLContextMac); -}; - -} // namespace gfx - -#endif /* defined(__UI_GL_GL_CONTEXT_MAC_H__) */ diff --git a/ui/gl/gl_context_mac.mm b/ui/gl/gl_context_mac.mm deleted file mode 100644 index 1b2b301fc..000000000 --- a/ui/gl/gl_context_mac.mm +++ /dev/null @@ -1,124 +0,0 @@ -// 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/basictypes.h" -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "base/trace_event/trace_event.h" -#include "ui/gl/gl_context_mac.h" -#include "ui/gl/gl_context_stub.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_surface.h" -#include "ui/gl/gl_switches.h" - -#import -#import - -#define CAST_CONTEXT (reinterpret_cast(context_)) - -namespace gfx { - -class GLShareGroup; - -GLContextMac::GLContextMac(GLShareGroup* share_group) - : GLContextReal(share_group), - context_(0) { - // Instead of creating a context here, we steal one from the NSOpenGLView - // that is passed to us in the initialize call. -} - -bool GLContextMac::Initialize(GLSurface* compatible_surface, - GpuPreference gpu_preference) { - if (compatible_surface == nullptr) { - return false; - } - - auto view = reinterpret_cast(compatible_surface->GetHandle()); - context_ = reinterpret_cast(view.openGLContext); - [CAST_CONTEXT retain]; - - return CAST_CONTEXT != nullptr; -} - -void GLContextMac::Destroy() { - [CAST_CONTEXT release]; - context_ = 0; -} - -bool GLContextMac::MakeCurrent(GLSurface* surface) { - [CAST_CONTEXT makeCurrentContext]; - - SetRealGLApi(); - - if (!InitializeDynamicBindings()) { - return false; - } - - if (!surface->OnMakeCurrent(this)) { - return false; - } - - return true; -} - -void GLContextMac::ReleaseCurrent(GLSurface* surface) { - [NSOpenGLContext clearCurrentContext]; -} - -bool GLContextMac::IsCurrent(GLSurface* surface) { - return [NSOpenGLContext currentContext] == CAST_CONTEXT; -} - -void* GLContextMac::GetHandle() { - return reinterpret_cast(context_); -} - -void GLContextMac::OnSetSwapInterval(int interval) { -} - -std::string GLContextMac::GetExtensions() { - return reinterpret_cast(glGetString(GL_EXTENSIONS)); -} - -bool GLContextMac::WasAllocatedUsingRobustnessExtension() { - return false; -} - -bool GLContextMac::GetTotalGpuMemory(size_t* bytes) { - DCHECK(false); - return false; -} - -void GLContextMac::SetUnbindFboOnMakeCurrent() { - DCHECK(false); -} - -GLContextMac::~GLContextMac() { - Destroy(); -} - -scoped_refptr GLContext::CreateGLContext( - GLShareGroup* share_group, - GLSurface* compatible_surface, - GpuPreference gpu_preference) { - TRACE_EVENT0("gpu", "GLContext::CreateGLContext"); - switch (GetGLImplementation()) { - case kGLImplementationDesktopGL: - case kGLImplementationAppleGL: { - scoped_refptr context; - context = new GLContextMac(share_group); - if (!context->Initialize(compatible_surface, gpu_preference)) - return NULL; - - return context; - } - case kGLImplementationMockGL: - return new GLContextStub; - default: - NOTREACHED(); - return NULL; - } -} - -} // namespace gfx diff --git a/ui/gl/gl_context_osmesa.cc b/ui/gl/gl_context_osmesa.cc deleted file mode 100644 index f08189cd5..000000000 --- a/ui/gl/gl_context_osmesa.cc +++ /dev/null @@ -1,134 +0,0 @@ -// 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 "ui/gl/gl_context_osmesa.h" - -#include - -#include "base/logging.h" -#include "ui/gfx/geometry/size.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_surface.h" - -namespace gfx { - -GLContextOSMesa::GLContextOSMesa(GLShareGroup* share_group) - : GLContextReal(share_group), - context_(NULL) { -} - -bool GLContextOSMesa::Initialize(GLSurface* compatible_surface, - GpuPreference gpu_preference) { - DCHECK(!context_); - - OSMesaContext share_handle = static_cast( - share_group() ? share_group()->GetHandle() : NULL); - - GLuint format = compatible_surface->GetFormat(); - DCHECK_NE(format, (unsigned)0); - context_ = OSMesaCreateContextExt(format, - 0, // depth bits - 0, // stencil bits - 0, // accum bits - share_handle); - if (!context_) { - LOG(ERROR) << "OSMesaCreateContextExt failed."; - return false; - } - - return true; -} - -void GLContextOSMesa::Destroy() { - if (context_) { - OSMesaDestroyContext(static_cast(context_)); - context_ = NULL; - } -} - -bool GLContextOSMesa::MakeCurrent(GLSurface* surface) { - DCHECK(context_); - - gfx::Size size = surface->GetSize(); - - ScopedReleaseCurrent release_current; - if (!OSMesaMakeCurrent(context_, - surface->GetHandle(), - GL_UNSIGNED_BYTE, - size.width(), - size.height())) { - LOG(ERROR) << "OSMesaMakeCurrent failed."; - Destroy(); - return false; - } - - // Set this as soon as the context is current, since we might call into GL. - SetRealGLApi(); - - // Row 0 is at the top. - OSMesaPixelStore(OSMESA_Y_UP, 0); - - SetCurrent(surface); - if (!InitializeDynamicBindings()) { - return false; - } - - if (!surface->OnMakeCurrent(this)) { - LOG(ERROR) << "Could not make current."; - return false; - } - - release_current.Cancel(); - return true; -} - -void GLContextOSMesa::ReleaseCurrent(GLSurface* surface) { - if (!IsCurrent(surface)) - return; - - SetCurrent(NULL); - // TODO: Calling with NULL here does not work to release the context. - OSMesaMakeCurrent(NULL, NULL, GL_UNSIGNED_BYTE, 0, 0); -} - -bool GLContextOSMesa::IsCurrent(GLSurface* surface) { - DCHECK(context_); - - bool native_context_is_current = - context_ == OSMesaGetCurrentContext(); - - // If our context is current then our notion of which GLContext is - // current must be correct. On the other hand, third-party code - // using OpenGL might change the current context. - DCHECK(!native_context_is_current || (GetRealCurrent() == this)); - - if (!native_context_is_current) - return false; - - if (surface) { - GLint width; - GLint height; - GLint format; - void* buffer = NULL; - OSMesaGetColorBuffer(context_, &width, &height, &format, &buffer); - if (buffer != surface->GetHandle()) - return false; - } - - return true; -} - -void* GLContextOSMesa::GetHandle() { - return context_; -} - -void GLContextOSMesa::OnSetSwapInterval(int interval) { - DCHECK(IsCurrent(NULL)); -} - -GLContextOSMesa::~GLContextOSMesa() { - Destroy(); -} - -} // namespace gfx diff --git a/ui/gl/gl_context_osmesa.h b/ui/gl/gl_context_osmesa.h deleted file mode 100644 index 9ce37d71b..000000000 --- a/ui/gl/gl_context_osmesa.h +++ /dev/null @@ -1,45 +0,0 @@ -// 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 UI_GL_GL_CONTEXT_OSMESA_H_ -#define UI_GL_GL_CONTEXT_OSMESA_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/gl/gl_context.h" - -typedef struct osmesa_context* OSMesaContext; - -namespace gfx { - -class GLShareGroup; -class GLSurface; - -// Encapsulates an OSMesa OpenGL context that uses software rendering. -class GLContextOSMesa : public GLContextReal { - public: - explicit GLContextOSMesa(GLShareGroup* share_group); - - // Implement GLContext. - bool Initialize(GLSurface* compatible_surface, - GpuPreference gpu_preference) override; - void Destroy() override; - bool MakeCurrent(GLSurface* surface) override; - void ReleaseCurrent(GLSurface* surface) override; - bool IsCurrent(GLSurface* surface) override; - void* GetHandle() override; - void OnSetSwapInterval(int interval) override; - - protected: - ~GLContextOSMesa() override; - - private: - OSMesaContext context_; - - DISALLOW_COPY_AND_ASSIGN(GLContextOSMesa); -}; - -} // namespace gfx - -#endif // UI_GL_GL_CONTEXT_OSMESA_H_ diff --git a/ui/gl/gl_context_osmesa_x11.cc b/ui/gl/gl_context_osmesa_x11.cc deleted file mode 100644 index 7a1c60d2b..000000000 --- a/ui/gl/gl_context_osmesa_x11.cc +++ /dev/null @@ -1,28 +0,0 @@ -// 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 "ui/gl/gl_context.h" - -#include "base/logging.h" -#include "base/memory/ref_counted.h" -#include "base/trace_event/trace_event.h" -#include "ui/gl/gl_context_osmesa.h" - -namespace gfx { - -class GLShareGroup; - -scoped_refptr GLContext::CreateGLContext( - GLShareGroup* share_group, - GLSurface* compatible_surface, - GpuPreference gpu_preference) { - TRACE_EVENT0("gpu", "GLContext::CreateGLContext"); - scoped_refptr context(new GLContextOSMesa(share_group)); - if (!context->Initialize(compatible_surface, gpu_preference)) - return NULL; - - return context; -} - -} // namespace gfx diff --git a/ui/gl/gl_context_stub.cc b/ui/gl/gl_context_stub.cc deleted file mode 100644 index ff3a85d33..000000000 --- a/ui/gl/gl_context_stub.cc +++ /dev/null @@ -1,49 +0,0 @@ -// 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 "ui/gl/gl_context_stub.h" - -namespace gfx { - -GLContextStub::GLContextStub() : GLContextReal(NULL) {} - -bool GLContextStub::Initialize( - GLSurface* compatible_surface, GpuPreference gpu_preference) { - return true; -} - -void GLContextStub::Destroy() {} - -bool GLContextStub::MakeCurrent(GLSurface* surface) { - SetCurrent(surface); - SetRealGLApi(); - return true; -} - -void GLContextStub::ReleaseCurrent(GLSurface* surface) { - SetCurrent(NULL); -} - -bool GLContextStub::IsCurrent(GLSurface* surface) { - return true; -} - -void* GLContextStub::GetHandle() { - return NULL; -} - -void GLContextStub::OnSetSwapInterval(int interval) { -} - -std::string GLContextStub::GetExtensions() { - return std::string(); -} - -std::string GLContextStub::GetGLRenderer() { - return std::string("CHROMIUM"); -} - -GLContextStub::~GLContextStub() {} - -} // namespace gfx diff --git a/ui/gl/gl_context_stub.h b/ui/gl/gl_context_stub.h deleted file mode 100644 index b4eef9328..000000000 --- a/ui/gl/gl_context_stub.h +++ /dev/null @@ -1,38 +0,0 @@ -// 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 UI_GL_GL_CONTEXT_STUB_H_ -#define UI_GL_GL_CONTEXT_STUB_H_ - -#include "ui/gl/gl_context.h" - -namespace gfx { - -// A GLContext that does nothing for unit tests. -class GL_EXPORT GLContextStub : public GLContextReal { - public: - GLContextStub(); - - // Implement GLContext. - bool Initialize(GLSurface* compatible_surface, - GpuPreference gpu_preference) override; - void Destroy() override; - bool MakeCurrent(GLSurface* surface) override; - void ReleaseCurrent(GLSurface* surface) override; - bool IsCurrent(GLSurface* surface) override; - void* GetHandle() override; - void OnSetSwapInterval(int interval) override; - std::string GetExtensions() override; - std::string GetGLRenderer() override; - - protected: - ~GLContextStub() override; - - private: - DISALLOW_COPY_AND_ASSIGN(GLContextStub); -}; - -} // namespace gfx - -#endif // UI_GL_GL_CONTEXT_STUB_H_ diff --git a/ui/gl/gl_context_stub_with_extensions.cc b/ui/gl/gl_context_stub_with_extensions.cc deleted file mode 100644 index 855eaa2a2..000000000 --- a/ui/gl/gl_context_stub_with_extensions.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 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 "ui/gl/gl_context_stub_with_extensions.h" - -namespace gfx { - -void GLContextStubWithExtensions::AddExtensionsString(const char* extensions) { - if (extensions == NULL) - return; - - if (extensions_.size() != 0) - extensions_ += ' '; - extensions_ += extensions; -} - -std::string GLContextStubWithExtensions::GetExtensions() { - return extensions_; -} - -void GLContextStubWithExtensions::SetGLVersionString(const char* version_str) { - version_str_ = std::string(version_str ? version_str : ""); -} - -std::string GLContextStubWithExtensions::GetGLVersion() { - return version_str_; -} - -bool GLContextStubWithExtensions::WasAllocatedUsingRobustnessExtension() { - return HasExtension("GL_ARB_robustness") || - HasExtension("GL_KHR_robustness") || - HasExtension("GL_EXT_robustness"); -} - -} // namespace gfx diff --git a/ui/gl/gl_context_stub_with_extensions.h b/ui/gl/gl_context_stub_with_extensions.h deleted file mode 100644 index d9da9d526..000000000 --- a/ui/gl/gl_context_stub_with_extensions.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 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 UI_GL_GL_CONTEXT_STUB_WITH_EXTENSIONS_H_ -#define UI_GL_GL_CONTEXT_STUB_WITH_EXTENSIONS_H_ - -#include "ui/gl/gl_context_stub.h" - -namespace gfx { - -// Lightweight GLContext stub implementation that returns a constructed -// extensions string. We use this to create a context that we can use to -// initialize GL extensions with, without actually creating a platform context. -class GL_EXPORT GLContextStubWithExtensions : public gfx::GLContextStub { - public: - GLContextStubWithExtensions() {} - std::string GetExtensions() override; - - void AddExtensionsString(const char* extensions); - void SetGLVersionString(const char* version_str); - bool WasAllocatedUsingRobustnessExtension() override; - - protected: - std::string GetGLVersion() override; - - ~GLContextStubWithExtensions() override {} - - private: - std::string extensions_; - std::string version_str_; - - DISALLOW_COPY_AND_ASSIGN(GLContextStubWithExtensions); -}; - -} // namespace gfx - -#endif // UI_GL_GL_CONTEXT_STUB_WITH_EXTENSIONS_H_ diff --git a/ui/gl/gl_egl_api_implementation.cc b/ui/gl/gl_egl_api_implementation.cc deleted file mode 100644 index 53a1bf638..000000000 --- a/ui/gl/gl_egl_api_implementation.cc +++ /dev/null @@ -1,81 +0,0 @@ -// 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 "ui/gl/gl_egl_api_implementation.h" -#include "ui/gl/gl_implementation.h" - -namespace gfx { - -RealEGLApi* g_real_egl; - -void InitializeStaticGLBindingsEGL() { - if (!g_real_egl) { - g_real_egl = new RealEGLApi(); - } - g_real_egl->Initialize(&g_driver_egl); - g_current_egl_context = g_real_egl; - g_driver_egl.InitializeStaticBindings(); -} - -void InitializeDebugGLBindingsEGL() { - g_driver_egl.InitializeDebugBindings(); -} - -void ClearGLBindingsEGL() { - if (g_real_egl) { - delete g_real_egl; - g_real_egl = NULL; - } - g_current_egl_context = NULL; - g_driver_egl.ClearBindings(); -} - -EGLApi::EGLApi() { -} - -EGLApi::~EGLApi() { -} - -EGLApiBase::EGLApiBase() - : driver_(NULL) { -} - -EGLApiBase::~EGLApiBase() { -} - -void EGLApiBase::InitializeBase(DriverEGL* driver) { - driver_ = driver; -} - -RealEGLApi::RealEGLApi() { -} - -RealEGLApi::~RealEGLApi() { -} - -void RealEGLApi::Initialize(DriverEGL* driver) { - InitializeBase(driver); -} - -TraceEGLApi::~TraceEGLApi() { -} - -bool GetGLWindowSystemBindingInfoEGL(GLWindowSystemBindingInfo* info) { - EGLDisplay display = eglGetCurrentDisplay(); - const char* vendor = eglQueryString(display, EGL_VENDOR); - const char* version = eglQueryString(display, EGL_VERSION); - const char* extensions = eglQueryString(display, EGL_EXTENSIONS); - *info = GLWindowSystemBindingInfo(); - if (vendor) - info->vendor = vendor; - if (version) - info->version = version; - if (extensions) - info->extensions = extensions; - return true; -} - -} // namespace gfx - - diff --git a/ui/gl/gl_egl_api_implementation.h b/ui/gl/gl_egl_api_implementation.h deleted file mode 100644 index a2ff28d09..000000000 --- a/ui/gl/gl_egl_api_implementation.h +++ /dev/null @@ -1,65 +0,0 @@ -// 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 UI_GL_GL_EGL_API_IMPLEMENTATION_H_ -#define UI_GL_GL_EGL_API_IMPLEMENTATION_H_ - -#include "base/compiler_specific.h" -#include "gl_bindings.h" -#include "ui/gl/gl_export.h" - -namespace gfx { - -class GLContext; -struct GLWindowSystemBindingInfo; - -void InitializeStaticGLBindingsEGL(); -void InitializeDebugGLBindingsEGL(); -void ClearGLBindingsEGL(); -bool GetGLWindowSystemBindingInfoEGL(GLWindowSystemBindingInfo* info); - -class GL_EXPORT EGLApiBase : public EGLApi { - public: - // Include the auto-generated part of this class. We split this because - // it means we can easily edit the non-auto generated parts right here in - // this file instead of having to edit some template or the code generator. - #include "gl_bindings_api_autogen_egl.h" - - protected: - EGLApiBase(); - ~EGLApiBase() override; - void InitializeBase(DriverEGL* driver); - - DriverEGL* driver_; -}; - -class GL_EXPORT RealEGLApi : public EGLApiBase { - public: - RealEGLApi(); - ~RealEGLApi() override; - void Initialize(DriverEGL* driver); -}; - - -// Inserts a TRACE for every EGL call. -class GL_EXPORT TraceEGLApi : public EGLApi { - public: - TraceEGLApi(EGLApi* egl_api) : egl_api_(egl_api) { } - ~TraceEGLApi() override; - - // Include the auto-generated part of this class. We split this because - // it means we can easily edit the non-auto generated parts right here in - // this file instead of having to edit some template or the code generator. - #include "gl_bindings_api_autogen_egl.h" - - private: - EGLApi* egl_api_; -}; - -} // namespace gfx - -#endif // UI_GL_GL_EGL_API_IMPLEMENTATION_H_ - - - diff --git a/ui/gl/gl_enums.cc b/ui/gl/gl_enums.cc deleted file mode 100644 index 8b439d6ae..000000000 --- a/ui/gl/gl_enums.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 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 - -#include "ui/gl/gl_enums.h" - -namespace gfx { - -std::string GLEnums::GetStringEnum(uint32 value) { - const EnumToString* entry = enum_to_string_table_; - const EnumToString* end = entry + enum_to_string_table_len_; - for (;entry < end; ++entry) { - if (value == entry->value) { - return entry->name; - } - } - std::stringstream ss; - ss.fill('0'); - ss.width(value < 0x10000 ? 4 : 8); - ss << std::hex << value; - return "0x" + ss.str(); -} - -std::string GLEnums::GetStringError(uint32 value) { - if (value == 0u) - return "GL_NONE"; - return GetStringEnum(value); -} - -std::string GLEnums::GetStringBool(uint32 value) { - return value ? "GL_TRUE" : "GL_FALSE"; -} - -#include "ui/gl/gl_enums_implementation_autogen.h" - -} // namespace gfx - diff --git a/ui/gl/gl_enums.h b/ui/gl/gl_enums.h deleted file mode 100644 index 30dee6c46..000000000 --- a/ui/gl/gl_enums.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 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 UI_GL_GL_ENUMS_H_ -#define UI_GL_GL_ENUMS_H_ - -#include - -#include "base/basictypes.h" -#include "ui/gl/gl_export.h" - -namespace gfx { - -class GL_EXPORT GLEnums { - public: - struct EnumToString { - uint32_t value; - const char* name; - }; - - static std::string GetStringEnum(uint32_t value); - static std::string GetStringBool(uint32_t value); - static std::string GetStringError(uint32_t value); - - private: - static const EnumToString* const enum_to_string_table_; - static const size_t enum_to_string_table_len_; -}; - -} // namespace gfx - -#endif // UI_GL_GL_ENUMS_H_ - diff --git a/ui/gl/gl_enums_implementation_autogen.h b/ui/gl/gl_enums_implementation_autogen.h deleted file mode 100644 index c42fb2c25..000000000 --- a/ui/gl/gl_enums_implementation_autogen.h +++ /dev/null @@ -1,3338 +0,0 @@ -// Copyright 2014 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 is auto-generated from -// ui/gl/generate_bindings.py -// It's formatted by clang-format using chromium coding style: -// clang-format -i -style=chromium filename -// DO NOT EDIT! - -static const GLEnums::EnumToString enum_to_string_table[] = { - { - 0x8D77, "GL_RGB16UI", - }, - { - 0x8D76, "GL_RGBA16UI", - }, - { - 0x9260, "GL_GCCSO_SHADER_BINARY_FJ", - }, - { - 0x9009, "GL_TEXTURE_CUBE_MAP_ARRAY_EXT", - }, - { - 0x8D71, "GL_RGB32UI", - }, - { - 0x8D70, "GL_RGBA32UI", - }, - { - 0x8C76, "GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH", - }, - { - 0x8825, "GL_DRAW_BUFFER0_EXT", - }, - { - 0x8D94, "GL_RED_INTEGER", - }, - { - 0x0BC1, "GL_ALPHA_TEST_FUNC_QCOM", - }, - { - 0x884C, "GL_TEXTURE_COMPARE_MODE_EXT", - }, - { - 0x0BC2, "GL_ALPHA_TEST_REF_QCOM", - }, - { - 0x78EF, "GL_PIXEL_UNPACK_TRANSFER_BUFFER_BINDING_CHROMIUM", - }, - { - 0x884D, "GL_TEXTURE_COMPARE_FUNC_EXT", - }, - { - 0x884E, "GL_COMPARE_REF_TO_TEXTURE_EXT", - }, - { - 0x8E76, "GL_TESS_GEN_MODE_EXT", - }, - { - 0x8E77, "GL_TESS_GEN_SPACING_EXT", - }, - { - 0x000D, "GL_TRIANGLE_STRIP_ADJACENCY_EXT", - }, - { - 0x000E, "GL_PATCHES_EXT", - }, - { - 0x000B, "GL_LINE_STRIP_ADJACENCY_EXT", - }, - { - 0x000C, "GL_TRIANGLES_ADJACENCY_EXT", - }, - { - 0x000A, "GL_LINES_ADJACENCY_EXT", - }, - { - 0x92CF, "GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT", - }, - { - 0x93A1, "GL_BGRA8_EXT", - }, - { - 0x813C, "GL_TEXTURE_BASE_LEVEL", - }, - { - 0, "GL_FALSE", - }, - { - 0x00400000, "GL_STENCIL_BUFFER_BIT6_QCOM", - }, - { - 0x9500, "GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL", - }, - { - 0x78F2, "GL_SCANOUT_CHROMIUM", - }, - { - 0x9138, "GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG", - }, - { - 0x8FC4, "GL_SHADER_BINARY_VIV", - }, - { - 0x9130, "GL_SGX_PROGRAM_BINARY_IMG", - }, - { - 0x9133, "GL_RENDERBUFFER_SAMPLES_IMG", - }, - { - 0x82E0, "GL_BUFFER_KHR", - }, - { - 0x9135, "GL_MAX_SAMPLES_IMG", - }, - { - 0x9134, "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG", - }, - { - 0x9137, "GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG", - }, - { - 0x9136, "GL_TEXTURE_SAMPLES_IMG", - }, - { - 0x8D88, "GL_RGBA16I", - }, - { - 0x8D89, "GL_RGB16I", - }, - { - 0x00000020, "GL_COLOR_BUFFER_BIT5_QCOM", - }, - { - 0x0008, "GL_MAP_INVALIDATE_BUFFER_BIT_EXT", - }, - { - 0x0BC0, "GL_ALPHA_TEST_QCOM", - }, - { - 0x0006, "GL_TRIANGLE_FAN", - }, - { - 0x0007, "GL_QUADS_EXT", - }, - { - 0x0004, "GL_TRIANGLES", - }, - { - 0x0005, "GL_TRIANGLE_STRIP", - }, - { - 0x0002, "GL_LINE_LOOP", - }, - { - 0x0003, "GL_LINE_STRIP", - }, - { - 0x0000, "GL_POINTS", - }, - { - 0x0001, "GL_LINES", - }, - { - 0x8D7D, "GL_RGB8UI", - }, - { - 0x93F0, "GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG", - }, - { - 0x93F1, "GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG", - }, - { - 0x0D04, "GL_PACK_SKIP_PIXELS", - }, - { - 0x900E, "GL_INT_SAMPLER_CUBE_MAP_ARRAY_EXT", - }, - { - 0x900D, "GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_EXT", - }, - { - 0x8C7F, "GL_TRANSFORM_FEEDBACK_BUFFER_MODE", - }, - { - 0x900F, "GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_EXT", - }, - { - 0x900A, "GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT", - }, - { - 0x900C, "GL_SAMPLER_CUBE_MAP_ARRAY_EXT", - }, - { - 0x88B8, "GL_READ_ONLY", - }, - { - 0x88B9, "GL_WRITE_ONLY_OES", - }, - { - 0x8211, "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT", - }, - { - 0x8210, "GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT", - }, - { - 0x8741, "GL_PROGRAM_BINARY_LENGTH_OES", - }, - { - 0x8740, "GL_Z400_BINARY_AMD", - }, - { - 0x8215, "GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE", - }, - { - 0x8C4D, "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV", - }, - { - 0x8192, "GL_GENERATE_MIPMAP_HINT", - }, - { - 0x8E79, "GL_TESS_GEN_POINT_MODE_EXT", - }, - { - 0x8A54, "GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT", - }, - { - 0x8A55, "GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT", - }, - { - 0x8A56, "GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT", - }, - { - 0x8A57, "GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT", - }, - { - 0x8A51, "GL_RGB_RAW_422_APPLE", - }, - { - 0x87F9, "GL_3DC_X_AMD", - }, - { - 0x8A53, "GL_SYNC_OBJECT_APPLE", - }, - { - 0x8DF8, "GL_SHADER_BINARY_FORMATS", - }, - { - 0x8DF9, "GL_NUM_SHADER_BINARY_FORMATS", - }, - { - 0x826D, "GL_DEBUG_GROUP_STACK_DEPTH_KHR", - }, - { - 0x8E75, "GL_TESS_CONTROL_OUTPUT_VERTICES_EXT", - }, - { - 0x826B, "GL_DEBUG_SEVERITY_NOTIFICATION_KHR", - }, - { - 0x826C, "GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR", - }, - { - 0x8B59, "GL_BOOL_VEC4", - }, - { - 0x826A, "GL_DEBUG_TYPE_POP_GROUP_KHR", - }, - { - 0x8B57, "GL_BOOL_VEC2", - }, - { - 0x8DF1, "GL_MEDIUM_FLOAT", - }, - { - 0x8B55, "GL_INT_VEC4", - }, - { - 0x8B54, "GL_INT_VEC3", - }, - { - 0x8DF4, "GL_MEDIUM_INT", - }, - { - 0x8DF5, "GL_HIGH_INT", - }, - { - 0x8B51, "GL_FLOAT_VEC3", - }, - { - 0x8B50, "GL_FLOAT_VEC2", - }, - { - 0x806D, "GL_UNPACK_SKIP_IMAGES", - }, - { - 0x806E, "GL_UNPACK_IMAGE_HEIGHT", - }, - { - 0x806F, "GL_TEXTURE_3D_OES", - }, - { - 0x92E7, "GL_IS_PER_PATCH_EXT", - }, - { - 0x92E0, "GL_DEBUG_OUTPUT_KHR", - }, - { - 0x806A, "GL_TEXTURE_BINDING_3D_OES", - }, - { - 0x8D8E, "GL_RGBA8I", - }, - { - 0x8CE3, "GL_COLOR_ATTACHMENT3_EXT", - }, - { - 0x9274, "GL_COMPRESSED_RGB8_ETC2", - }, - { - 0x1904, "GL_GREEN_NV", - }, - { - 0x928D, "GL_DST_OUT_NV", - }, - { - 0x8069, "GL_TEXTURE_BINDING_2D", - }, - { - 0x8A2E, "GL_MAX_COMBINED_UNIFORM_BLOCKS", - }, - { - 0x8F96, "GL_RGB8_SNORM", - }, - { - 0x8F95, "GL_RG8_SNORM", - }, - { - 0x8260, "GL_UNDEFINED_VERTEX_EXT", - }, - { - 0x8261, "GL_NO_RESET_NOTIFICATION_KHR", - }, - { - 0x0D02, "GL_PACK_ROW_LENGTH", - }, - { - 0x8DFA, "GL_SHADER_COMPILER", - }, - { - 0x8DFB, "GL_MAX_VERTEX_UNIFORM_VECTORS", - }, - { - 0x8DFC, "GL_MAX_VARYING_VECTORS", - }, - { - 0x8B5C, "GL_FLOAT_MAT4", - }, - { - 0x8B5B, "GL_FLOAT_MAT3", - }, - { - 0x8268, "GL_DEBUG_TYPE_MARKER_KHR", - }, - { - 0x8269, "GL_DEBUG_TYPE_PUSH_GROUP_KHR", - }, - { - 0x8A43, "GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES", - }, - { - 0x1905, "GL_BLUE_NV", - }, - { - 0x87FF, "GL_PROGRAM_BINARY_FORMATS_OES", - }, - { - 0x87FE, "GL_NUM_PROGRAM_BINARY_FORMATS_OES", - }, - { - 0x8A41, "GL_UNIFORM_BLOCK_NAME_LENGTH", - }, - { - 0x2600, "GL_NEAREST", - }, - { - 0x2601, "GL_LINEAR", - }, - { - 0x8C03, "GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG", - }, - { - 0x821B, "GL_MAJOR_VERSION", - }, - { - 0x821A, "GL_DEPTH_STENCIL_ATTACHMENT", - }, - { - 0x8A40, "GL_UNIFORM_BLOCK_DATA_SIZE", - }, - { - 0x9242, "GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM", - }, - { - 0x821D, "GL_NUM_EXTENSIONS", - }, - { - 0x88BB, "GL_BUFFER_ACCESS_OES", - }, - { - 0x88BC, "GL_BUFFER_MAPPED_OES", - }, - { - 0x88BD, "GL_BUFFER_MAP_POINTER_OES", - }, - { - 0x88BF, "GL_TIME_ELAPSED_EXT", - }, - { - 0x8A46, "GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER", - }, - { - 0x6003, "GL_GET_ERROR_QUERY_CHROMIUM", - }, - { - 0x8F94, "GL_R8_SNORM", - }, - { - 0x0C10, "GL_SCISSOR_BOX", - }, - { - 0x0C11, "GL_SCISSOR_TEST", - }, - { - 0x1700, "GL_PATH_MODELVIEW_CHROMIUM", - }, - { - 0x80000000, "GL_MULTISAMPLE_BUFFER_BIT7_QCOM", - }, - { - 0x94F8, "GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL", - }, - { - 0x8A48, "GL_TEXTURE_SRGB_DECODE_EXT", - }, - { - 0x300E, "GL_CONTEXT_LOST", - }, - { - 0x02000000, "GL_MULTISAMPLE_BUFFER_BIT1_QCOM", - }, - { - 0x8C2F, "GL_ANY_SAMPLES_PASSED_EXT", - }, - { - 0x8BD2, "GL_TEXTURE_WIDTH_QCOM", - }, - { - 0x8C2D, "GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT", - }, - { - 0x8C2C, "GL_TEXTURE_BINDING_BUFFER_EXT", - }, - { - 0x8C2B, "GL_MAX_TEXTURE_BUFFER_SIZE_EXT", - }, - { - 0x8C2A, "GL_TEXTURE_BUFFER_EXT", - }, - { - 0x8BD7, "GL_TEXTURE_TYPE_QCOM", - }, - { - 0x8B8D, "GL_CURRENT_PROGRAM", - }, - { - 0x8BD9, "GL_TEXTURE_NUM_LEVELS_QCOM", - }, - { - 0x00200000, "GL_STENCIL_BUFFER_BIT5_QCOM", - }, - { - 0x8D9F, "GL_INT_2_10_10_10_REV", - }, - { - 0x8B8A, "GL_ACTIVE_ATTRIBUTE_MAX_LENGTH", - }, - { - 0x8B8B, "GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES", - }, - { - 0x8B8C, "GL_SHADING_LANGUAGE_VERSION", - }, - { - 0x8BDA, "GL_TEXTURE_TARGET_QCOM", - }, - { - 0x8BDB, "GL_TEXTURE_OBJECT_VALID_QCOM", - }, - { - 0x8BDC, "GL_STATE_RESTORE", - }, - { - 0x8B88, "GL_SHADER_SOURCE_LENGTH", - }, - { - 0x8B89, "GL_ACTIVE_ATTRIBUTES", - }, - { - 0x93C9, "GL_COMPRESSED_RGBA_ASTC_6x6x6_OES", - }, - { - 0x93C8, "GL_COMPRESSED_RGBA_ASTC_6x6x5_OES", - }, - { - 0x8B84, "GL_INFO_LOG_LENGTH", - }, - { - 0x8B85, "GL_ATTACHED_SHADERS", - }, - { - 0x8B86, "GL_ACTIVE_UNIFORMS", - }, - { - 0x8B87, "GL_ACTIVE_UNIFORM_MAX_LENGTH", - }, - { - 0x8B80, "GL_DELETE_STATUS", - }, - { - 0x8B81, "GL_COMPILE_STATUS", - }, - { - 0x8B82, "GL_LINK_STATUS", - }, - { - 0x8B83, "GL_VALIDATE_STATUS", - }, - { - 0x9380, "GL_NUM_SAMPLE_COUNTS", - }, - { - 0x8D48, "GL_STENCIL_INDEX8", - }, - { - 0x8D46, "GL_STENCIL_INDEX1_OES", - }, - { - 0x8D47, "GL_STENCIL_INDEX4_OES", - }, - { - 0x8D44, "GL_RENDERBUFFER_INTERNAL_FORMAT", - }, - { - 0x00000100, "GL_DEPTH_BUFFER_BIT", - }, - { - 0x8D42, "GL_RENDERBUFFER_WIDTH", - }, - { - 0x8D43, "GL_RENDERBUFFER_HEIGHT", - }, - { - 0x8D40, "GL_FRAMEBUFFER", - }, - { - 0x8D41, "GL_RENDERBUFFER", - }, - { - 0x8A3A, "GL_UNIFORM_BLOCK_INDEX", - }, - { - 0x0BD0, "GL_DITHER", - }, - { - 0x93D3, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR", - }, - { - 0x9144, "GL_MAX_DEBUG_LOGGED_MESSAGES_KHR", - }, - { - 0x1801, "GL_DEPTH_EXT", - }, - { - 0x1800, "GL_COLOR_EXT", - }, - { - 0x1802, "GL_STENCIL_EXT", - }, - { - 0x9288, "GL_SRC_OVER_NV", - }, - { - 0x9120, "GL_BUFFER_MAP_LENGTH", - }, - { - 0x0B21, "GL_LINE_WIDTH", - }, - { - 0x9308, "GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT", - }, - { - 0x81A5, "GL_DEPTH_COMPONENT16", - }, - { - 0x81A6, "GL_DEPTH_COMPONENT24_OES", - }, - { - 0x81A7, "GL_DEPTH_COMPONENT32_OES", - }, - { - 0x88FD, "GL_VERTEX_ATTRIB_ARRAY_INTEGER", - }, - { - 0x88FE, "GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE", - }, - { - 0x88FF, "GL_MAX_ARRAY_TEXTURE_LAYERS", - }, - { - 0x8B6A, "GL_FLOAT_MAT4x3_NV", - }, - { - 0x93D0, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR", - }, - { - 0x9143, "GL_MAX_DEBUG_MESSAGE_LENGTH_KHR", - }, - { - 0x8DFD, "GL_MAX_FRAGMENT_UNIFORM_VECTORS", - }, - { - 0x9145, "GL_DEBUG_LOGGED_MESSAGES_KHR", - }, - { - 0x9146, "GL_DEBUG_SEVERITY_HIGH_KHR", - }, - { - 0x9147, "GL_DEBUG_SEVERITY_MEDIUM_KHR", - }, - { - 0x9148, "GL_DEBUG_SEVERITY_LOW_KHR", - }, - { - 0x8F63, "GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT", - }, - { - 0x8F60, "GL_MALI_SHADER_BINARY_ARM", - }, - { - 0x8F61, "GL_MALI_PROGRAM_BINARY_ARM", - }, - { - 0x8F66, "GL_FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM", - }, - { - 0x8F67, "GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_SIZE_EXT", - }, - { - 0x8F64, "GL_SHADER_PIXEL_LOCAL_STORAGE_EXT", - }, - { - 0x8F65, "GL_FETCH_PER_SAMPLE_ARM", - }, - { - 0x92D3, "GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT", - }, - { - 0x87EE, "GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD", - }, - { - 0x822B, "GL_RG8_EXT", - }, - { - 0x822F, "GL_RG16F_EXT", - }, - { - 0x822D, "GL_R16F_EXT", - }, - { - 0x822E, "GL_R32F_EXT", - }, - { - 1, "GL_ES_VERSION_2_0", - }, - { - 0x84F9, "GL_DEPTH_STENCIL_OES", - }, - { - 0x82DB, "GL_TEXTURE_VIEW_MIN_LEVEL_EXT", - }, - { - 0x8368, "GL_UNSIGNED_INT_2_10_10_10_REV_EXT", - }, - { - 0x8819, "GL_LUMINANCE_ALPHA32F_EXT", - }, - { - 0x8818, "GL_LUMINANCE32F_EXT", - }, - { - 0x82DF, "GL_TEXTURE_IMMUTABLE_LEVELS", - }, - { - 0x8363, "GL_UNSIGNED_SHORT_5_6_5", - }, - { - 0x9051, "GL_IMAGE_BUFFER_EXT", - }, - { - 0x84F2, "GL_ALL_COMPLETED_NV", - }, - { - 0x8E5A, "GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT", - }, - { - 0x84F4, "GL_FENCE_CONDITION_NV", - }, - { - 0x8366, "GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT", - }, - { - 0x8365, "GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT", - }, - { - 0x84F7, "GL_COMMANDS_COMPLETED_CHROMIUM", - }, - { - 0x8F9C, "GL_SIGNED_NORMALIZED", - }, - { - 0x92D5, "GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT", - }, - { - 0x881E, "GL_LUMINANCE16F_EXT", - }, - { - 0x84FA, "GL_UNSIGNED_INT_24_8_OES", - }, - { - 0x92D4, "GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT", - }, - { - 0x881A, "GL_RGBA16F_EXT", - }, - { - 0x84FE, "GL_TEXTURE_MAX_ANISOTROPY_EXT", - }, - { - 0x0901, "GL_CCW", - }, - { - 0x0900, "GL_CW", - }, - { - 0x9317, "GL_MAX_FRAMEBUFFER_LAYERS_EXT", - }, - { - 0x8229, "GL_R8_EXT", - }, - { - 0x8230, "GL_RG32F_EXT", - }, - { - 0x9312, "GL_FRAMEBUFFER_DEFAULT_LAYERS_EXT", - }, - { - 0x9283, "GL_DISJOINT_NV", - }, - { - 0x8221, "GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED", - }, - { - 0x8227, "GL_RG_EXT", - }, - { - 0x8B66, "GL_FLOAT_MAT2x4_NV", - }, - { - 0x8B67, "GL_FLOAT_MAT3x2_NV", - }, - { - 0x8E1E, "GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT", - }, - { - 0x8B62, "GL_SAMPLER_2D_SHADOW_EXT", - }, - { - 0x8B63, "GL_SAMPLER_2D_RECT_ARB", - }, - { - 0x8B60, "GL_SAMPLER_CUBE", - }, - { - 0x00001000, "GL_DEPTH_BUFFER_BIT4_QCOM", - }, - { - 0x8B68, "GL_FLOAT_MAT3x4_NV", - }, - { - 0x83F0, "GL_COMPRESSED_RGB_S3TC_DXT1_EXT", - }, - { - 0x8D6A, "GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT", - }, - { - 0x00000080, "GL_COLOR_BUFFER_BIT7_QCOM", - }, - { - 0x88F0, "GL_DEPTH24_STENCIL8_OES", - }, - { - 0x8E1F, "GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT", - }, - { - 0x80A0, "GL_SAMPLE_COVERAGE", - }, - { - 0x928F, "GL_DST_ATOP_NV", - }, - { - 0x8213, "GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE", - }, - { - 0x80A9, "GL_SAMPLES", - }, - { - 0x80A8, "GL_SAMPLE_BUFFERS", - }, - { - 0x0D55, "GL_ALPHA_BITS", - }, - { - 0x0D54, "GL_BLUE_BITS", - }, - { - 0x0D57, "GL_STENCIL_BITS", - }, - { - 0x0D56, "GL_DEPTH_BITS", - }, - { - 0x8CD5, "GL_FRAMEBUFFER_COMPLETE", - }, - { - 0x0D50, "GL_SUBPIXEL_BITS", - }, - { - 0x0D53, "GL_GREEN_BITS", - }, - { - 0x0D52, "GL_RED_BITS", - }, - { - 0x8037, "GL_POLYGON_OFFSET_FILL", - }, - { - 0x928C, "GL_SRC_OUT_NV", - }, - { - 0x8034, "GL_UNSIGNED_SHORT_5_5_5_1", - }, - { - 0x8033, "GL_UNSIGNED_SHORT_4_4_4_4", - }, - { - 0x928B, "GL_DST_IN_NV", - }, - { - 0x0305, "GL_ONE_MINUS_DST_ALPHA", - }, - { - 0x0304, "GL_DST_ALPHA", - }, - { - 0x0307, "GL_ONE_MINUS_DST_COLOR", - }, - { - 0x0306, "GL_DST_COLOR", - }, - { - 0x0301, "GL_ONE_MINUS_SRC_COLOR", - }, - { - 0x0300, "GL_SRC_COLOR", - }, - { - 0x0303, "GL_ONE_MINUS_SRC_ALPHA", - }, - { - 0x0302, "GL_SRC_ALPHA", - }, - { - 0x8212, "GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE", - }, - { - 0x0308, "GL_SRC_ALPHA_SATURATE", - }, - { - 0x2A00, "GL_POLYGON_OFFSET_UNITS", - }, - { - 0xFFFFFFFF, "GL_ALL_SHADER_BITS_EXT", - }, - { - 0x82DC, "GL_TEXTURE_VIEW_NUM_LEVELS_EXT", - }, - { - 0x8C29, "GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT", - }, - { - 0x82DD, "GL_TEXTURE_VIEW_MIN_LAYER_EXT", - }, - { - 0x00800000, "GL_STENCIL_BUFFER_BIT7_QCOM", - }, - { - 0x82DE, "GL_TEXTURE_VIEW_NUM_LAYERS_EXT", - }, - { - 0x00020000, "GL_STENCIL_BUFFER_BIT1_QCOM", - }, - { - 0x8D00, "GL_DEPTH_ATTACHMENT", - }, - { - 0x8FA0, "GL_PERFMON_GLOBAL_MODE_QCOM", - }, - { - 0x8815, "GL_RGB32F_EXT", - }, - { - 0x8A35, "GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH", - }, - { - 0x8814, "GL_RGBA32F_EXT", - }, - { - 0x9277, "GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", - }, - { - 0x6004, "GL_COMMANDS_ISSUED_CHROMIUM", - }, - { - 0x813D, "GL_TEXTURE_MAX_LEVEL_APPLE", - }, - { - 0x8816, "GL_ALPHA32F_EXT", - }, - { - 0x813B, "GL_TEXTURE_MAX_LOD", - }, - { - 0x8CDD, "GL_FRAMEBUFFER_UNSUPPORTED", - }, - { - 0x8CDF, "GL_MAX_COLOR_ATTACHMENTS_EXT", - }, - { - 0x90F3, "GL_CONTEXT_ROBUST_ACCESS_KHR", - }, - { - 0x90F2, "GL_MAX_MULTIVIEW_BUFFERS_EXT", - }, - { - 0x90F1, "GL_MULTIVIEW_EXT", - }, - { - 0x90F0, "GL_COLOR_ATTACHMENT_EXT", - }, - { - 0x803C, "GL_ALPHA8_OES", - }, - { - 0x8904, "GL_MIN_PROGRAM_TEXEL_OFFSET", - }, - { - 0x84F5, "GL_TEXTURE_RECTANGLE_ARB", - }, - { - 0x882A, "GL_DRAW_BUFFER5_EXT", - }, - { - 0x8E7F, "GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT", - }, - { - 0x80AA, "GL_SAMPLE_COVERAGE_VALUE", - }, - { - 0x84F6, "GL_TEXTURE_BINDING_RECTANGLE_ARB", - }, - { - 0x80AB, "GL_SAMPLE_COVERAGE_INVERT", - }, - { - 0x8E7D, "GL_MAX_PATCH_VERTICES_EXT", - }, - { - 0x6005, "GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM", - }, - { - 0x9105, "GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES", - }, - { - 0x8E7E, "GL_MAX_TESS_GEN_LEVEL_EXT", - }, - { - 0x9102, "GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES", - }, - { - 0x8C40, "GL_SRGB_EXT", - }, - { - 0x8236, "GL_R32UI", - }, - { - 0x8E7B, "GL_FRACTIONAL_ODD_EXT", - }, - { - 0x00000040, "GL_COLOR_BUFFER_BIT6_QCOM", - }, - { - 0x882B, "GL_DRAW_BUFFER6_EXT", - }, - { - 0x8E7C, "GL_FRACTIONAL_EVEN_EXT", - }, - { - 0x8C8E, "GL_TRANSFORM_FEEDBACK_BUFFER", - }, - { - 0x8C8D, "GL_SEPARATE_ATTRIBS", - }, - { - 0x8C8F, "GL_TRANSFORM_FEEDBACK_BUFFER_BINDING", - }, - { - 0x8C8A, "GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS", - }, - { - 0x8C8C, "GL_INTERLEAVED_ATTRIBS", - }, - { - 0x8C8B, "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS", - }, - { - 0x8C17, "GL_UNSIGNED_NORMALIZED_EXT", - }, - { - 0x8A3E, "GL_UNIFORM_IS_ROW_MAJOR", - }, - { - 0x8E7A, "GL_ISOLINES_EXT", - }, - { - 0x6006, "GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM", - }, - { - 0x8D99, "GL_RGBA_INTEGER", - }, - { - 0x8D98, "GL_RGB_INTEGER", - }, - { - 0x8A4A, "GL_SKIP_DECODE_EXT", - }, - { - 0x8A4F, "GL_PROGRAM_PIPELINE_OBJECT_EXT", - }, - { - 0x882C, "GL_DRAW_BUFFER7_EXT", - }, - { - 0x0010, "GL_MAP_FLUSH_EXPLICIT_BIT_EXT", - }, - { - 0x8918, "GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT", - }, - { - 0x8919, "GL_SAMPLER_BINDING", - }, - { - 0x92CD, "GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT", - }, - { - 0x92CE, "GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT", - }, - { - 0x8C85, "GL_TRANSFORM_FEEDBACK_BUFFER_SIZE", - }, - { - 0x8D7C, "GL_RGBA8UI", - }, - { - 0x6007, "GL_LATENCY_QUERY_CHROMIUM", - }, - { - 0x8D83, "GL_RGB32I", - }, - { - 0x8916, "GL_GEOMETRY_LINKED_VERTICES_OUT_EXT", - }, - { - 0x8917, "GL_GEOMETRY_LINKED_INPUT_TYPE_EXT", - }, - { - 0x881F, "GL_LUMINANCE_ALPHA16F_EXT", - }, - { - 0x84FD, "GL_MAX_TEXTURE_LOD_BIAS", - }, - { - 0x882D, "GL_DRAW_BUFFER8_EXT", - }, - { - 0x0BA6, "GL_PATH_MODELVIEW_MATRIX_CHROMIUM", - }, - { - 0x8A42, "GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS", - }, - { - 0x8F37, "GL_COPY_WRITE_BUFFER_NV", - }, - { - 0x8F36, "GL_COPY_READ_BUFFER_NV", - }, - { - 0x84FF, "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT", - }, - { - 0x8A3C, "GL_UNIFORM_ARRAY_STRIDE", - }, - { - 0x8A44, "GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER", - }, - { - 0x6000, "GL_TEXTURE_POOL_CHROMIUM", - }, - { - 0x0B74, "GL_DEPTH_FUNC", - }, - { - 0x8A49, "GL_DECODE_EXT", - }, - { - 0x881B, "GL_RGB16F_EXT", - }, - { - 0x0B71, "GL_DEPTH_TEST", - }, - { - 0x0B70, "GL_DEPTH_RANGE", - }, - { - 0x0B73, "GL_DEPTH_CLEAR_VALUE", - }, - { - 0x0B72, "GL_DEPTH_WRITEMASK", - }, - { - 0x8BD5, "GL_TEXTURE_INTERNAL_FORMAT_QCOM", - }, - { - 0x85BA, "GL_UNSIGNED_SHORT_8_8_APPLE", - }, - { - 0x8C87, "GL_PRIMITIVES_GENERATED_EXT", - }, - { - 0x8C80, "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS", - }, - { - 0x8C83, "GL_TRANSFORM_FEEDBACK_VARYINGS", - }, - { - 0x8D69, "GL_PRIMITIVE_RESTART_FIXED_INDEX", - }, - { - 0x882E, "GL_DRAW_BUFFER9_EXT", - }, - { - 0x8A32, "GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT", - }, - { - 0x8A31, "GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS", - }, - { - 0x8C89, "GL_RASTERIZER_DISCARD", - }, - { - 0x8C88, "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN", - }, - { - 0x8C1A, "GL_TEXTURE_2D_ARRAY", - }, - { - 0x910D, "GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES", - }, - { - 0x8E80, "GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT", - }, - { - 0x910B, "GL_SAMPLER_2D_MULTISAMPLE_ARRAY_OES", - }, - { - 0x910C, "GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES", - }, - { - 0x94FA, "GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL", - }, - { - 0x8073, "GL_MAX_3D_TEXTURE_SIZE_OES", - }, - { - 0x8072, "GL_TEXTURE_WRAP_R_OES", - }, - { - 0x9289, "GL_DST_OVER_NV", - }, - { - 0x882F, "GL_DRAW_BUFFER10_EXT", - }, - { - 0x8074, "GL_VERTEX_ARRAY_KHR", - }, - { - 0x80E1, "GL_BGRA_EXT", - }, - { - 0x8ED7, "GL_COVERAGE_AUTOMATIC_NV", - }, - { - 0x8ED6, "GL_COVERAGE_EDGE_FRAGMENTS_NV", - }, - { - 0x8ED5, "GL_COVERAGE_ALL_FRAGMENTS_NV", - }, - { - 0x8ED4, "GL_COVERAGE_SAMPLES_NV", - }, - { - 0x8ED3, "GL_COVERAGE_BUFFERS_NV", - }, - { - 0x8ED2, "GL_COVERAGE_ATTACHMENT_NV", - }, - { - 0x8ED1, "GL_COVERAGE_COMPONENT4_NV", - }, - { - 0x8ED0, "GL_COVERAGE_COMPONENT_NV", - }, - { - 0x8217, "GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE", - }, - { - 0x8E89, "GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT", - }, - { - 0x8216, "GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE", - }, - { - 0x8A36, "GL_ACTIVE_UNIFORM_BLOCKS", - }, - { - 0x8A37, "GL_UNIFORM_TYPE", - }, - { - 0x8A34, "GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT", - }, - { - 0x3006, "GL_CLIP_DISTANCE6_APPLE", - }, - { - 0x800B, "GL_FUNC_REVERSE_SUBTRACT", - }, - { - 0x8A33, "GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS", - }, - { - 0x00000400, "GL_STENCIL_BUFFER_BIT", - }, - { - 0x800A, "GL_FUNC_SUBTRACT", - }, - { - 0x8214, "GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE", - }, - { - 0x8A38, "GL_UNIFORM_SIZE", - }, - { - 0x8A39, "GL_UNIFORM_NAME_LENGTH", - }, - { - 0x8E2C, "GL_DEPTH_COMPONENT16_NONLINEAR_NV", - }, - { - 0x889F, "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING", - }, - { - 0x8219, "GL_FRAMEBUFFER_UNDEFINED_OES", - }, - { - 0x8E23, "GL_TRANSFORM_FEEDBACK_PAUSED", - }, - { - 0x8E22, "GL_TRANSFORM_FEEDBACK", - }, - { - 0x8E25, "GL_TRANSFORM_FEEDBACK_BINDING", - }, - { - 0x9054, "GL_IMAGE_CUBE_MAP_ARRAY_EXT", - }, - { - 0x8E28, "GL_TIMESTAMP_EXT", - }, - { - 0x8006, "GL_FUNC_ADD", - }, - { - 0x8007, "GL_MIN_EXT", - }, - { - 0x8004, "GL_ONE_MINUS_CONSTANT_ALPHA", - }, - { - 0x8005, "GL_BLEND_COLOR", - }, - { - 0x8002, "GL_ONE_MINUS_CONSTANT_COLOR", - }, - { - 0x8003, "GL_CONSTANT_ALPHA", - }, - { - 0x8001, "GL_CONSTANT_COLOR", - }, - { - 0x0204, "GL_GREATER", - }, - { - 0x0205, "GL_NOTEQUAL", - }, - { - 0x0206, "GL_GEQUAL", - }, - { - 0x0207, "GL_ALWAYS", - }, - { - 0x0200, "GL_NEVER", - }, - { - 0x0201, "GL_LESS", - }, - { - 0x0202, "GL_EQUAL", - }, - { - 0x0203, "GL_LEQUAL", - }, - { - 0x8BD6, "GL_TEXTURE_FORMAT_QCOM", - }, - { - 0x8228, "GL_RG_INTEGER", - }, - { - 0x2901, "GL_REPEAT", - }, - { - 0x9067, "GL_UNSIGNED_INT_IMAGE_BUFFER_EXT", - }, - { - 0x92A0, "GL_EXCLUSION_KHR", - }, - { - 0x93D8, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR", - }, - { - 0x93D9, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR", - }, - { - 0x8FB2, "GL_GPU_OPTIMIZED_QCOM", - }, - { - 0x190A, "GL_LUMINANCE_ALPHA", - }, - { - 0x8FB0, "GL_BINNING_CONTROL_HINT_QCOM", - }, - { - 0x905C, "GL_INT_IMAGE_BUFFER_EXT", - }, - { - 0x1E00, "GL_KEEP", - }, - { - 0x1E01, "GL_REPLACE", - }, - { - 0x1E02, "GL_INCR", - }, - { - 0x1E03, "GL_DECR", - }, - { - 0x93D6, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR", - }, - { - 0x93D7, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR", - }, - { - 0x93D4, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR", - }, - { - 0x93D5, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR", - }, - { - 0x886D, "GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT", - }, - { - 0x0BE2, "GL_BLEND", - }, - { - 0x84CB, "GL_TEXTURE11", - }, - { - 0x8D55, "GL_RENDERBUFFER_STENCIL_SIZE", - }, - { - 0x8D54, "GL_RENDERBUFFER_DEPTH_SIZE", - }, - { - 0x8D57, "GL_MAX_SAMPLES_ANGLE", - }, - { - 0x8D56, "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE", - }, - { - 0x8D51, "GL_RENDERBUFFER_GREEN_SIZE", - }, - { - 0x8D50, "GL_RENDERBUFFER_RED_SIZE", - }, - { - 0x8D53, "GL_RENDERBUFFER_ALPHA_SIZE", - }, - { - 0x8D52, "GL_RENDERBUFFER_BLUE_SIZE", - }, - { - 0x92A6, "GL_VIVIDLIGHT_NV", - }, - { - 0x8A2A, "GL_UNIFORM_BUFFER_SIZE", - }, - { - 0x8DCC, "GL_INT_SAMPLER_CUBE", - }, - { - 0x78F1, "GL_MAP_CHROMIUM", - }, - { - 0x00080000, "GL_STENCIL_BUFFER_BIT3_QCOM", - }, - { - 0x92A7, "GL_LINEARLIGHT_NV", - }, - { - 0x8DCF, "GL_INT_SAMPLER_2D_ARRAY", - }, - { - 0x886A, "GL_VERTEX_ATTRIB_ARRAY_NORMALIZED", - }, - { - 0x8C41, "GL_SRGB8_NV", - }, - { - 0x0C01, "GL_DRAW_BUFFER_EXT", - }, - { - 0x886C, "GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT", - }, - { - 0x90CB, "GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT", - }, - { - 0x8DCA, "GL_INT_SAMPLER_2D", - }, - { - 0x93C7, "GL_COMPRESSED_RGBA_ASTC_6x5x5_OES", - }, - { - 0x8B5F, "GL_SAMPLER_3D_OES", - }, - { - 0x8B95, "GL_PALETTE8_RGB8_OES", - }, - { - 0x9250, "GL_SHADER_BINARY_DMP", - }, - { - 0x9251, "GL_SMAPHS30_PROGRAM_BINARY_DMP", - }, - { - 0x9252, "GL_SMAPHS_PROGRAM_BINARY_DMP", - }, - { - 0x9253, "GL_DMP_PROGRAM_BINARY_DMP", - }, - { - 0x8DC8, "GL_UNSIGNED_INT_VEC4", - }, - { - 0x3000, "GL_CLIP_DISTANCE0_APPLE", - }, - { - 0x8C92, "GL_ATC_RGB_AMD", - }, - { - 0x8DC1, "GL_SAMPLER_2D_ARRAY", - }, - { - 0x9154, "GL_VERTEX_ARRAY_OBJECT_EXT", - }, - { - 0x9153, "GL_QUERY_OBJECT_EXT", - }, - { - 0x8864, "GL_QUERY_COUNTER_BITS_EXT", - }, - { - 0x9151, "GL_BUFFER_OBJECT_EXT", - }, - { - 0x8C93, "GL_ATC_RGBA_EXPLICIT_ALPHA_AMD", - }, - { - 0x00000002, "GL_CONTEXT_FLAG_DEBUG_BIT_KHR", - }, - { - 0x8A3F, "GL_UNIFORM_BLOCK_BINDING", - }, - { - 0x00000000, "GL_PERFQUERY_SINGLE_CONTEXT_INTEL", - }, - { - 0x00000001, "GL_SYNC_FLUSH_COMMANDS_BIT_APPLE", - }, - { - 0x9248, "GL_OVERLAY_TRANSFORM_ROTATE_90_CHROMIUM", - }, - { - 0x00000004, "GL_GEOMETRY_SHADER_BIT_EXT", - }, - { - 0x1702, "GL_TEXTURE", - }, - { - 0x3003, "GL_CLIP_DISTANCE3_APPLE", - }, - { - 0x00000008, "GL_TESS_CONTROL_SHADER_BIT_EXT", - }, - { - 0x8B58, "GL_BOOL_VEC3", - }, - { - 0x8A3D, "GL_UNIFORM_MATRIX_STRIDE", - }, - { - 0x8828, "GL_DRAW_BUFFER3_EXT", - }, - { - 0x8DF0, "GL_LOW_FLOAT", - }, - { - 0x1906, "GL_ALPHA", - }, - { - 0x1907, "GL_RGB", - }, - { - 0x8FBB, "GL_GPU_DISJOINT_EXT", - }, - { - 0x1901, "GL_STENCIL_INDEX_OES", - }, - { - 0x1902, "GL_DEPTH_COMPONENT", - }, - { - 0x8B56, "GL_BOOL", - }, - { - 0x93DB, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR", - }, - { - 0x8B9B, "GL_IMPLEMENTATION_COLOR_READ_FORMAT", - }, - { - 0x8B9A, "GL_IMPLEMENTATION_COLOR_READ_TYPE", - }, - { - 0x93DA, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR", - }, - { - 0x1908, "GL_RGBA", - }, - { - 0x8DF2, "GL_HIGH_FLOAT", - }, - { - 0x93DD, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR", - }, - { - 0x8827, "GL_DRAW_BUFFER2_EXT", - }, - { - 0x9243, "GL_UNPACK_COLORSPACE_CONVERSION_CHROMIUM", - }, - { - 0x8DF3, "GL_LOW_INT", - }, - { - 0x82E8, "GL_MAX_LABEL_LENGTH_KHR", - }, - { - 0x82E6, "GL_SAMPLER_KHR", - }, - { - 0x0C02, "GL_READ_BUFFER_EXT", - }, - { - 0x82E3, "GL_QUERY_KHR", - }, - { - 0x82E2, "GL_PROGRAM_KHR", - }, - { - 0x82E1, "GL_SHADER_KHR", - }, - { - 0x8B52, "GL_FLOAT_VEC4", - }, - { - 0x8239, "GL_RG16I", - }, - { - 0x8238, "GL_RG8UI", - }, - { - 0x9240, "GL_UNPACK_FLIP_Y_CHROMIUM", - }, - { - 0x8DF6, "GL_UNSIGNED_INT_10_10_10_2_OES", - }, - { - 0x8A30, "GL_MAX_UNIFORM_BLOCK_SIZE", - }, - { - 0x9273, "GL_COMPRESSED_SIGNED_RG11_EAC", - }, - { - 0x8231, "GL_R8I", - }, - { - 0x8866, "GL_QUERY_RESULT_EXT", - }, - { - 0x8233, "GL_R16I", - }, - { - 0x8DF7, "GL_INT_10_10_10_2_OES", - }, - { - 0x8235, "GL_R32I", - }, - { - 0x8234, "GL_R16UI", - }, - { - 0x8237, "GL_RG8I", - }, - { - 0x9246, "GL_OVERLAY_TRANSFORM_FLIP_HORIZONTAL_CHROMIUM", - }, - { - 0x8B69, "GL_FLOAT_MAT4x2_NV", - }, - { - 0x812D, "GL_CLAMP_TO_BORDER_EXT", - }, - { - 0x812F, "GL_CLAMP_TO_EDGE", - }, - { - 0x92A4, "GL_LINEARDODGE_NV", - }, - { - 0x8DD8, "GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT", - }, - { - 0x8DD9, "GL_GEOMETRY_SHADER_EXT", - }, - { - 0x86A3, "GL_COMPRESSED_TEXTURE_FORMATS", - }, - { - 0x8DD4, "GL_UNSIGNED_INT_SAMPLER_CUBE", - }, - { - 0x9244, "GL_BIND_GENERATES_RESOURCE_CHROMIUM", - }, - { - 0x8DD2, "GL_UNSIGNED_INT_SAMPLER_2D", - }, - { - 0x8DD3, "GL_UNSIGNED_INT_SAMPLER_3D", - }, - { - 0x8DD0, "GL_INT_SAMPLER_BUFFER_EXT", - }, - { - 0x86A2, "GL_NUM_COMPRESSED_TEXTURE_FORMATS", - }, - { - 0x0CF3, "GL_UNPACK_SKIP_ROWS_EXT", - }, - { - 0x0CF2, "GL_UNPACK_ROW_LENGTH_EXT", - }, - { - 0x140C, "GL_FIXED", - }, - { - 0x140B, "GL_HALF_FLOAT", - }, - { - 0x8008, "GL_MAX_EXT", - }, - { - 0x0CF5, "GL_UNPACK_ALIGNMENT", - }, - { - 0x8867, "GL_QUERY_RESULT_AVAILABLE_EXT", - }, - { - 0x8D82, "GL_RGBA32I", - }, - { - 0x8009, "GL_BLEND_EQUATION", - }, - { - 0x911F, "GL_BUFFER_ACCESS_FLAGS", - }, - { - 0x1401, "GL_UNSIGNED_BYTE", - }, - { - 0x1400, "GL_BYTE", - }, - { - 0x1403, "GL_UNSIGNED_SHORT", - }, - { - 0x1402, "GL_SHORT", - }, - { - 0x1405, "GL_UNSIGNED_INT", - }, - { - 0x1404, "GL_INT", - }, - { - 0x1406, "GL_FLOAT", - }, - { - 0x8C1D, "GL_TEXTURE_BINDING_2D_ARRAY", - }, - { - 0x8DDF, "GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT", - }, - { - 0x8043, "GL_LUMINANCE4_ALPHA4_OES", - }, - { - 0x8040, "GL_LUMINANCE8_OES", - }, - { - 0x8045, "GL_LUMINANCE8_ALPHA8_OES", - }, - { - 0x8CD1, "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME", - }, - { - 0x00040000, "GL_STENCIL_BUFFER_BIT2_QCOM", - }, - { - 0x8CD0, "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE", - }, - { - 0x823A, "GL_RG16UI", - }, - { - 0x8CE4, "GL_COLOR_ATTACHMENT4_EXT", - }, - { - 0x823B, "GL_RG32I", - }, - { - 0x8CD3, "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE", - }, - { - 0x846E, "GL_ALIASED_LINE_WIDTH_RANGE", - }, - { - 0x0B90, "GL_STENCIL_TEST", - }, - { - 0x8CD2, "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL", - }, - { - 0x881C, "GL_ALPHA16F_EXT", - }, - { - 0x928E, "GL_SRC_ATOP_NV", - }, - { - 0x8CD4, "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES", - }, - { - 0x9113, "GL_SYNC_CONDITION_APPLE", - }, - { - 0x8CD7, "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT", - }, - { - 0x08000000, "GL_MULTISAMPLE_BUFFER_BIT3_QCOM", - }, - { - 0x93A4, "GL_PACK_REVERSE_ROW_ORDER_ANGLE", - }, - { - 0x8038, "GL_POLYGON_OFFSET_FACTOR", - }, - { - 0x94F9, "GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL", - }, - { - 0x851A, "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z", - }, - { - 0x851C, "GL_MAX_CUBE_MAP_TEXTURE_SIZE", - }, - { - 0x8CD9, "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS", - }, - { - 0x84CC, "GL_TEXTURE12", - }, - { - 0x0BA2, "GL_VIEWPORT", - }, - { - 0x84CA, "GL_TEXTURE10", - }, - { - 0x0BA7, "GL_PATH_PROJECTION_MATRIX_CHROMIUM", - }, - { - 0x84CF, "GL_TEXTURE15", - }, - { - 0x84CE, "GL_TEXTURE14", - }, - { - 0x84CD, "GL_TEXTURE13", - }, - { - 0x83F9, "GL_PERFQUERY_DONOT_FLUSH_INTEL", - }, - { - 0x9115, "GL_SYNC_FLAGS_APPLE", - }, - { - 0x9286, "GL_SRC_NV", - }, - { - 0x83F3, "GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE", - }, - { - 0x83F2, "GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE", - }, - { - 0x83F1, "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT", - }, - { - 0x9114, "GL_SYNC_STATUS_APPLE", - }, - { - 0x8C0A, "GL_SGX_BINARY_IMG", - }, - { - 0x93BB, "GL_COMPRESSED_RGBA_ASTC_10x10_KHR", - }, - { - 0x911C, "GL_CONDITION_SATISFIED_APPLE", - }, - { - 0x911B, "GL_TIMEOUT_EXPIRED_APPLE", - }, - { - 0x911A, "GL_ALREADY_SIGNALED_APPLE", - }, - { - 0x9284, "GL_CONJOINT_NV", - }, - { - 0x9124, "GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT", - }, - { - 0x911D, "GL_WAIT_FAILED_APPLE", - }, - { - 0x929A, "GL_COLORBURN_KHR", - }, - { - 0x929B, "GL_HARDLIGHT_KHR", - }, - { - 0x929C, "GL_SOFTLIGHT_KHR", - }, - { - 0x846D, "GL_ALIASED_POINT_SIZE_RANGE", - }, - { - 0x929E, "GL_DIFFERENCE_KHR", - }, - { - 0x929F, "GL_MINUS_NV", - }, - { - 0x9282, "GL_UNCORRELATED_NV", - }, - { - 0x9298, "GL_LIGHTEN_KHR", - }, - { - 0x9299, "GL_COLORDODGE_KHR", - }, - { - 0x9111, "GL_MAX_SERVER_WAIT_TIMEOUT_APPLE", - }, - { - 0x93A6, "GL_PROGRAM_BINARY_ANGLE", - }, - { - 0x9117, "GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE", - }, - { - 0x93A0, "GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE", - }, - { - 0x93A3, "GL_FRAMEBUFFER_ATTACHMENT_ANGLE", - }, - { - 0x93A2, "GL_TEXTURE_USAGE_ANGLE", - }, - { - 0x8802, "GL_STENCIL_BACK_PASS_DEPTH_FAIL", - }, - { - 0x9119, "GL_SIGNALED_APPLE", - }, - { - 0x9118, "GL_UNSIGNALED_APPLE", - }, - { - 0x9294, "GL_MULTIPLY_KHR", - }, - { - 0x9295, "GL_SCREEN_KHR", - }, - { - 0x9296, "GL_OVERLAY_KHR", - }, - { - 0x9297, "GL_DARKEN_KHR", - }, - { - 0x0020, "GL_MAP_UNSYNCHRONIZED_BIT_EXT", - }, - { - 0x8E78, "GL_TESS_GEN_VERTEX_ORDER_EXT", - }, - { - 0x8C01, "GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG", - }, - { - 0x8C00, "GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG", - }, - { - 0x8A52, "GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT", - }, - { - 0x8C02, "GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG", - }, - { - 0x84C9, "GL_TEXTURE9", - }, - { - 0x84C8, "GL_TEXTURE8", - }, - { - 0x8869, "GL_MAX_VERTEX_ATTRIBS", - }, - { - 0x84C3, "GL_TEXTURE3", - }, - { - 0x84C2, "GL_TEXTURE2", - }, - { - 0x84C1, "GL_TEXTURE1", - }, - { - 0x84C0, "GL_TEXTURE0", - }, - { - 0x84C7, "GL_TEXTURE7", - }, - { - 0x84C6, "GL_TEXTURE6", - }, - { - 0x84C5, "GL_TEXTURE5", - }, - { - 0x8803, "GL_STENCIL_BACK_PASS_DEPTH_PASS", - }, - { - 0x928A, "GL_SRC_IN_NV", - }, - { - 0x8518, "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y", - }, - { - 0x8519, "GL_TEXTURE_CUBE_MAP_POSITIVE_Z", - }, - { - 0x8514, "GL_TEXTURE_BINDING_CUBE_MAP", - }, - { - 0x8515, "GL_TEXTURE_CUBE_MAP_POSITIVE_X", - }, - { - 0x8516, "GL_TEXTURE_CUBE_MAP_NEGATIVE_X", - }, - { - 0x8517, "GL_TEXTURE_CUBE_MAP_POSITIVE_Y", - }, - { - 0x8218, "GL_FRAMEBUFFER_DEFAULT", - }, - { - 0x8513, "GL_TEXTURE_CUBE_MAP", - }, - { - 0x8626, "GL_CURRENT_VERTEX_ATTRIB", - }, - { - 0x92B1, "GL_PLUS_CLAMPED_NV", - }, - { - 0x92B0, "GL_HSL_LUMINOSITY_KHR", - }, - { - 0x92B3, "GL_MINUS_CLAMPED_NV", - }, - { - 0x92B2, "GL_PLUS_CLAMPED_ALPHA_NV", - }, - { - 0x8765, "GL_BUFFER_USAGE", - }, - { - 0x8764, "GL_BUFFER_SIZE", - }, - { - 0x8B99, "GL_PALETTE8_RGB5_A1_OES", - }, - { - 0x0503, "GL_STACK_OVERFLOW_KHR", - }, - { - 0x0502, "GL_INVALID_OPERATION", - }, - { - 0x0501, "GL_INVALID_VALUE", - }, - { - 0x0500, "GL_INVALID_ENUM", - }, - { - 0x0507, "GL_CONTEXT_LOST_KHR", - }, - { - 0x0506, "GL_INVALID_FRAMEBUFFER_OPERATION", - }, - { - 0x0505, "GL_OUT_OF_MEMORY", - }, - { - 0x0504, "GL_STACK_UNDERFLOW_KHR", - }, - { - 0x0CF4, "GL_UNPACK_SKIP_PIXELS_EXT", - }, - { - 0x0B44, "GL_CULL_FACE", - }, - { - 0x8B5E, "GL_SAMPLER_2D", - }, - { - 0x0B46, "GL_FRONT_FACE", - }, - { - 0x8FB3, "GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM", - }, - { - 0x824A, "GL_DEBUG_SOURCE_APPLICATION_KHR", - }, - { - 0x824B, "GL_DEBUG_SOURCE_OTHER_KHR", - }, - { - 0x824C, "GL_DEBUG_TYPE_ERROR_KHR", - }, - { - 0x824D, "GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR", - }, - { - 0x824E, "GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR", - }, - { - 0x824F, "GL_DEBUG_TYPE_PORTABILITY_KHR", - }, - { - 0x8DD7, "GL_UNSIGNED_INT_SAMPLER_2D_ARRAY", - }, - { - 0x8B31, "GL_VERTEX_SHADER", - }, - { - 0x8B30, "GL_FRAGMENT_SHADER", - }, - { - 0x8FB1, "GL_CPU_OPTIMIZED_QCOM", - }, - { - 0x93D2, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR", - }, - { - 0x82FB, "GL_CONTEXT_RELEASE_BEHAVIOR_KHR", - }, - { - 0x8B5A, "GL_FLOAT_MAT2", - }, - { - 0x84D8, "GL_TEXTURE24", - }, - { - 0x84D9, "GL_TEXTURE25", - }, - { - 0x84D6, "GL_TEXTURE22", - }, - { - 0x84D7, "GL_TEXTURE23", - }, - { - 0x84D4, "GL_TEXTURE20", - }, - { - 0x0D05, "GL_PACK_ALIGNMENT", - }, - { - 0x84D2, "GL_TEXTURE18", - }, - { - 0x84D3, "GL_TEXTURE19", - }, - { - 0x84D0, "GL_TEXTURE16", - }, - { - 0x84D1, "GL_TEXTURE17", - }, - { - 0x93D1, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR", - }, - { - 0x84DF, "GL_TEXTURE31", - }, - { - 0x8B97, "GL_PALETTE8_R5_G6_B5_OES", - }, - { - 0x84DD, "GL_TEXTURE29", - }, - { - 0x84DE, "GL_TEXTURE30", - }, - { - 0x84DB, "GL_TEXTURE27", - }, - { - 0x84DC, "GL_TEXTURE28", - }, - { - 0x6002, "GL_TEXTURE_POOL_UNMANAGED_CHROMIUM", - }, - { - 0x84DA, "GL_TEXTURE26", - }, - { - 0x8242, "GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR", - }, - { - 0x8243, "GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR", - }, - { - 0x8244, "GL_DEBUG_CALLBACK_FUNCTION_KHR", - }, - { - 0x8245, "GL_DEBUG_CALLBACK_USER_PARAM_KHR", - }, - { - 0x8246, "GL_DEBUG_SOURCE_API_KHR", - }, - { - 0x8247, "GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR", - }, - { - 0x8248, "GL_DEBUG_SOURCE_SHADER_COMPILER_KHR", - }, - { - 0x8249, "GL_DEBUG_SOURCE_THIRD_PARTY_KHR", - }, - { - 0x88ED, "GL_PIXEL_PACK_BUFFER_BINDING", - }, - { - 0x8B94, "GL_PALETTE4_RGB5_A1_OES", - }, - { - 0x94F4, "GL_PERFQUERY_COUNTER_RAW_INTEL", - }, - { - 0x823C, "GL_RG32UI", - }, - { - 0x8A29, "GL_UNIFORM_BUFFER_START", - }, - { - 0x8A28, "GL_UNIFORM_BUFFER_BINDING", - }, - { - 0x92BE, "GL_PRIMITIVE_BOUNDING_BOX_EXT", - }, - { - 0x8645, "GL_VERTEX_ATTRIB_ARRAY_POINTER", - }, - { - 0x8865, "GL_CURRENT_QUERY_EXT", - }, - { - 0x8E5B, "GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES", - }, - { - 0x8E5C, "GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES", - }, - { - 0x8E5D, "GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES", - }, - { - 0x906A, "GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT", - }, - { - 0x906F, "GL_RGB10_A2UI", - }, - { - 0x8E72, "GL_PATCH_VERTICES_EXT", - }, - { - 0x8BD3, "GL_TEXTURE_HEIGHT_QCOM", - }, - { - 0x87FA, "GL_3DC_XY_AMD", - }, - { - 0x84C4, "GL_TEXTURE4", - }, - { - 0x821C, "GL_MINOR_VERSION", - }, - { - 0x8E8A, "GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT", - }, - { - 0x85B5, "GL_VERTEX_ARRAY_BINDING_OES", - }, - { - 0x8253, "GL_GUILTY_CONTEXT_RESET_KHR", - }, - { - 0x8D6B, "GL_MAX_ELEMENT_INDEX", - }, - { - 0x8D6C, "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT", - }, - { - 0x92A1, "GL_CONTRAST_NV", - }, - { - 0x8252, "GL_LOSE_CONTEXT_ON_RESET_KHR", - }, - { - 0x8C4C, "GL_COMPRESSED_SRGB_S3TC_DXT1_NV", - }, - { - 0x8C4E, "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV", - }, - { - 0x8251, "GL_DEBUG_TYPE_OTHER_KHR", - }, - { - 0x8C4F, "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV", - }, - { - 0x9309, "GL_REFERENCED_BY_GEOMETRY_SHADER_EXT", - }, - { - 0x93E9, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES", - }, - { - 0x93E8, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES", - }, - { - 0x8C43, "GL_SRGB8_ALPHA8_EXT", - }, - { - 0x8C42, "GL_SRGB_ALPHA_EXT", - }, - { - 0x8C45, "GL_SLUMINANCE8_ALPHA8_NV", - }, - { - 0x8C44, "GL_SLUMINANCE_ALPHA_NV", - }, - { - 0x8C47, "GL_SLUMINANCE8_NV", - }, - { - 0x8C46, "GL_SLUMINANCE_NV", - }, - { - 0x93E1, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES", - }, - { - 0x93E0, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES", - }, - { - 0x93E3, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES", - }, - { - 0x93E2, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES", - }, - { - 0x93E5, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES", - }, - { - 0x93E4, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES", - }, - { - 0x93E7, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES", - }, - { - 0x93E6, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES", - }, - { - 0x8D68, "GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES", - }, - { - 0x8E82, "GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT", - }, - { - 0x8E81, "GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT", - }, - { - 0x85BB, "GL_UNSIGNED_SHORT_8_8_REV_APPLE", - }, - { - 0x8E87, "GL_TESS_EVALUATION_SHADER_EXT", - }, - { - 0x8E86, "GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT", - }, - { - 0x8E85, "GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT", - }, - { - 0x8E84, "GL_MAX_TESS_PATCH_COMPONENTS_EXT", - }, - { - 0x8D61, "GL_HALF_FLOAT_OES", - }, - { - 0x8D62, "GL_RGB565", - }, - { - 0x8E88, "GL_TESS_CONTROL_SHADER_EXT", - }, - { - 0x8D64, "GL_ETC1_RGB8_OES", - }, - { - 0x8D65, "GL_TEXTURE_EXTERNAL_OES", - }, - { - 0x8D66, "GL_SAMPLER_EXTERNAL_OES", - }, - { - 0x8D67, "GL_TEXTURE_BINDING_EXTERNAL_OES", - }, - { - 0x10000000, "GL_MULTISAMPLE_BUFFER_BIT4_QCOM", - }, - { - 0x04000000, "GL_MULTISAMPLE_BUFFER_BIT2_QCOM", - }, - { - 0x90D7, "GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT", - }, - { - 0x90D9, "GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT", - }, - { - 0x90D8, "GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT", - }, - { - 0x8CEE, "GL_COLOR_ATTACHMENT14_EXT", - }, - { - 0x8DC7, "GL_UNSIGNED_INT_VEC3", - }, - { - 0x1701, "GL_PATH_PROJECTION_CHROMIUM", - }, - { - 0x2800, "GL_TEXTURE_MAG_FILTER", - }, - { - 0x2801, "GL_TEXTURE_MIN_FILTER", - }, - { - 0x2802, "GL_TEXTURE_WRAP_S", - }, - { - 0x2803, "GL_TEXTURE_WRAP_T", - }, - { - 0x8DCB, "GL_INT_SAMPLER_3D", - }, - { - 0x3007, "GL_CLIP_DISTANCE7_APPLE", - }, - { - 0x2703, "GL_LINEAR_MIPMAP_LINEAR", - }, - { - 0x3005, "GL_CLIP_DISTANCE5_APPLE", - }, - { - 0x3004, "GL_CLIP_DISTANCE4_APPLE", - }, - { - 0x8B98, "GL_PALETTE8_RGBA4_OES", - }, - { - 0x3002, "GL_CLIP_DISTANCE2_APPLE", - }, - { - 0x3001, "GL_CLIP_DISTANCE1_APPLE", - }, - { - 0x2702, "GL_NEAREST_MIPMAP_LINEAR", - }, - { - 0x1F03, "GL_EXTENSIONS", - }, - { - 0x1F02, "GL_VERSION", - }, - { - 0x1F01, "GL_RENDERER", - }, - { - 0x1F00, "GL_VENDOR", - }, - { - 0x9247, "GL_OVERLAY_TRANSFORM_FLIP_VERTICAL_CHROMIUM", - }, - { - 0x2701, "GL_LINEAR_MIPMAP_NEAREST", - }, - { - 0x9245, "GL_OVERLAY_TRANSFORM_NONE_CHROMIUM", - }, - { - 0x92B4, "GL_INVERT_OVG_NV", - }, - { - 0x9249, "GL_OVERLAY_TRANSFORM_ROTATE_180_CHROMIUM", - }, - { - 0x0B94, "GL_STENCIL_FAIL", - }, - { - 0x8B4A, "GL_MAX_VERTEX_UNIFORM_COMPONENTS", - }, - { - 0x8B4B, "GL_MAX_VARYING_COMPONENTS", - }, - { - 0x8B4C, "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS", - }, - { - 0x8B4D, "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS", - }, - { - 0x8B4F, "GL_SHADER_TYPE", - }, - { - 0x9122, "GL_MAX_VERTEX_OUTPUT_COMPONENTS", - }, - { - 0x9123, "GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT", - }, - { - 0x83FB, "GL_PERFQUERY_WAIT_INTEL", - }, - { - 0x9121, "GL_BUFFER_MAP_OFFSET", - }, - { - 0x00004000, "GL_COLOR_BUFFER_BIT", - }, - { - 0x9125, "GL_MAX_FRAGMENT_INPUT_COMPONENTS", - }, - { - 0x00000010, "GL_TESS_EVALUATION_SHADER_BIT_EXT", - }, - { - 0x8834, "GL_DRAW_BUFFER15_EXT", - }, - { - 0x8833, "GL_DRAW_BUFFER14_EXT", - }, - { - 0x8832, "GL_DRAW_BUFFER13_EXT", - }, - { - 0x8831, "GL_DRAW_BUFFER12_EXT", - }, - { - 0x8830, "GL_DRAW_BUFFER11_EXT", - }, - { - 0x8DC5, "GL_SAMPLER_CUBE_SHADOW_NV", - }, - { - 0x94FF, "GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL", - }, - { - 0x94FE, "GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL", - }, - { - 0x94FD, "GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL", - }, - { - 0x94FC, "GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL", - }, - { - 0x94FB, "GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL", - }, - { - 0x93B8, "GL_COMPRESSED_RGBA_ASTC_10x5_KHR", - }, - { - 0x8B65, "GL_FLOAT_MAT2x3_NV", - }, - { - 0x9241, "GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM", - }, - { - 0x00010000, "GL_STENCIL_BUFFER_BIT0_QCOM", - }, - { - 0x83FA, "GL_PERFQUERY_FLUSH_INTEL", - }, - { - 0x0D03, "GL_PACK_SKIP_ROWS", - }, - { - 0x84F3, "GL_FENCE_STATUS_NV", - }, - { - 0x88E6, "GL_STATIC_COPY", - }, - { - 0x0B93, "GL_STENCIL_VALUE_MASK", - }, - { - 0x0B92, "GL_STENCIL_FUNC", - }, - { - 0x0B91, "GL_STENCIL_CLEAR_VALUE", - }, - { - 0x883D, "GL_BLEND_EQUATION_ALPHA", - }, - { - 0x0B97, "GL_STENCIL_REF", - }, - { - 0x0B96, "GL_STENCIL_PASS_DEPTH_PASS", - }, - { - 0x0B95, "GL_STENCIL_PASS_DEPTH_FAIL", - }, - { - 0x2700, "GL_NEAREST_MIPMAP_NEAREST", - }, - { - 0x94F5, "GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL", - }, - { - 0x0B98, "GL_STENCIL_WRITEMASK", - }, - { - 0x94F3, "GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL", - }, - { - 0x94F2, "GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL", - }, - { - 0x94F1, "GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL", - }, - { - 0x94F0, "GL_PERFQUERY_COUNTER_EVENT_INTEL", - }, - { - 0x8B40, "GL_PROGRAM_OBJECT_EXT", - }, - { - 0x1004, "GL_TEXTURE_BORDER_COLOR_EXT", - }, - { - 0x8A2D, "GL_MAX_FRAGMENT_UNIFORM_BLOCKS", - }, - { - 0x8B48, "GL_SHADER_OBJECT_EXT", - }, - { - 0x8B49, "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS", - }, - { - 0x813A, "GL_TEXTURE_MIN_LOD", - }, - { - 0x8DE1, "GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT", - }, - { - 0x8DE0, "GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT", - }, - { - 0x924C, "GL_MOUSE_POSITION_CHROMIUM", - }, - { - 0x924B, "GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM", - }, - { - 0x924A, "GL_OVERLAY_TRANSFORM_ROTATE_270_CHROMIUM", - }, - { - 0x8A2F, "GL_MAX_UNIFORM_BUFFER_BINDINGS", - }, - { - 0x20000000, "GL_MULTISAMPLE_BUFFER_BIT5_QCOM", - }, - { - 64, "GL_MAILBOX_SIZE_CHROMIUM", - }, - { - 0x0DE1, "GL_TEXTURE_2D", - }, - { - 0x8A2C, "GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT", - }, - { - 0x80C9, "GL_BLEND_SRC_RGB", - }, - { - 0x80C8, "GL_BLEND_DST_RGB", - }, - { - 0x912F, "GL_TEXTURE_IMMUTABLE_FORMAT_EXT", - }, - { - 0x8A2B, "GL_MAX_VERTEX_UNIFORM_BLOCKS", - }, - { - 0x88EC, "GL_PIXEL_UNPACK_BUFFER", - }, - { - 0x8D8F, "GL_RGB8I", - }, - { - 0x8059, "GL_RGB10_A2_EXT", - }, - { - 0x8058, "GL_RGBA8_OES", - }, - { - 0x8B93, "GL_PALETTE4_RGBA4_OES", - }, - { - 0x88EB, "GL_PIXEL_PACK_BUFFER", - }, - { - 0x8E83, "GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT", - }, - { - 0x8051, "GL_RGB8_OES", - }, - { - 0x8CAD, "GL_DEPTH32F_STENCIL8", - }, - { - 0x8052, "GL_RGB10_EXT", - }, - { - 0x8CAB, "GL_RENDERBUFFER_SAMPLES_ANGLE", - }, - { - 0x8CAC, "GL_DEPTH_COMPONENT32F", - }, - { - 0x8057, "GL_RGB5_A1", - }, - { - 0x8056, "GL_RGBA4", - }, - { - 0x8232, "GL_R8UI", - }, - { - 0x150A, "GL_INVERT", - }, - { - 0x01000000, "GL_MULTISAMPLE_BUFFER_BIT0_QCOM", - }, - { - 0x78ED, "GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM", - }, - { - 0x78EE, "GL_PIXEL_PACK_TRANSFER_BUFFER_BINDING_CHROMIUM", - }, - { - 0x6001, "GL_TEXTURE_POOL_MANAGED_CHROMIUM", - }, - { - 0x0B45, "GL_CULL_FACE_MODE", - }, - { - 0x8B92, "GL_PALETTE4_R5_G6_B5_OES", - }, - { - 0x00100000, "GL_STENCIL_BUFFER_BIT4_QCOM", - }, - { - 0x8E4E, "GL_LAST_VERTEX_CONVENTION_EXT", - }, - { - 0x8E4D, "GL_FIRST_VERTEX_CONVENTION_EXT", - }, - { - 0x8E24, "GL_TRANSFORM_FEEDBACK_ACTIVE", - }, - { - 0x8E45, "GL_TEXTURE_SWIZZLE_A", - }, - { - 0x8E44, "GL_TEXTURE_SWIZZLE_B", - }, - { - 0x8E43, "GL_TEXTURE_SWIZZLE_G", - }, - { - 0x8E42, "GL_TEXTURE_SWIZZLE_R", - }, - { - 0x8D20, "GL_STENCIL_ATTACHMENT", - }, - { - 0x8B91, "GL_PALETTE4_RGBA8_OES", - }, - { - 0x00000200, "GL_DEPTH_BUFFER_BIT1_QCOM", - }, - { - 0x00008000, "GL_COVERAGE_BUFFER_BIT_NV", - }, - { - 0x1506, "GL_XOR_NV", - }, - { - 0x8CA8, "GL_READ_FRAMEBUFFER_ANGLE", - }, - { - 0x8CA9, "GL_DRAW_FRAMEBUFFER_ANGLE", - }, - { - 0x8CA6, "GL_FRAMEBUFFER_BINDING", - }, - { - 0x8CA7, "GL_RENDERBUFFER_BINDING", - }, - { - 0x8CA4, "GL_STENCIL_BACK_VALUE_MASK", - }, - { - 0x8CA5, "GL_STENCIL_BACK_WRITEMASK", - }, - { - 0x8B90, "GL_PALETTE4_RGB8_OES", - }, - { - 0x8CA3, "GL_STENCIL_BACK_REF", - }, - { - 0x80E8, "GL_MAX_ELEMENTS_VERTICES", - }, - { - 0x80CB, "GL_BLEND_SRC_ALPHA", - }, - { - 0x80CA, "GL_BLEND_DST_ALPHA", - }, - { - 0x8CE7, "GL_COLOR_ATTACHMENT7_EXT", - }, - { - 0x93B0, "GL_COMPRESSED_RGBA_ASTC_4x4_KHR", - }, - { - 0x93B1, "GL_COMPRESSED_RGBA_ASTC_5x4_KHR", - }, - { - 0x93B2, "GL_COMPRESSED_RGBA_ASTC_5x5_KHR", - }, - { - 0x93B3, "GL_COMPRESSED_RGBA_ASTC_6x5_KHR", - }, - { - 0x93B4, "GL_COMPRESSED_RGBA_ASTC_6x6_KHR", - }, - { - 0x93B5, "GL_COMPRESSED_RGBA_ASTC_8x5_KHR", - }, - { - 0x93B6, "GL_COMPRESSED_RGBA_ASTC_8x6_KHR", - }, - { - 0x93B7, "GL_COMPRESSED_RGBA_ASTC_8x8_KHR", - }, - { - 0x8CD6, "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT", - }, - { - 0x93B9, "GL_COMPRESSED_RGBA_ASTC_10x6_KHR", - }, - { - 0x80E9, "GL_MAX_ELEMENTS_INDICES", - }, - { - 0x8CE5, "GL_COLOR_ATTACHMENT5_EXT", - }, - { - 0x8C84, "GL_TRANSFORM_FEEDBACK_BUFFER_START", - }, - { - 0x8DC2, "GL_SAMPLER_BUFFER_EXT", - }, - { - 0x8C36, "GL_SAMPLE_SHADING_OES", - }, - { - 0x8C37, "GL_MIN_SAMPLE_SHADING_VALUE_OES", - }, - { - 0x8F97, "GL_RGBA8_SNORM", - }, - { - 0x8CE9, "GL_COLOR_ATTACHMENT9_EXT", - }, - { - 0x8DAD, "GL_FLOAT_32_UNSIGNED_INT_24_8_REV", - }, - { - 0x8B96, "GL_PALETTE8_RGBA8_OES", - }, - { - 0x8872, "GL_MAX_TEXTURE_IMAGE_UNITS", - }, - { - 0x8DC6, "GL_UNSIGNED_INT_VEC2", - }, - { - 0x8905, "GL_MAX_PROGRAM_TEXEL_OFFSET", - }, - { - 0x8508, "GL_DECR_WRAP", - }, - { - 0x92AD, "GL_HSL_HUE_KHR", - }, - { - 0x92AE, "GL_HSL_SATURATION_KHR", - }, - { - 0x92AF, "GL_HSL_COLOR_KHR", - }, - { - 0x8BD4, "GL_TEXTURE_DEPTH_QCOM", - }, - { - 0x8DC4, "GL_SAMPLER_2D_ARRAY_SHADOW_NV", - }, - { - 0x8507, "GL_INCR_WRAP", - }, - { - 0x82FC, "GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR", - }, - { - 0x8895, "GL_ELEMENT_ARRAY_BUFFER_BINDING", - }, - { - 0x8894, "GL_ARRAY_BUFFER_BINDING", - }, - { - 0x92A3, "GL_INVERT_RGB_NV", - }, - { - 0x905F, "GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT", - }, - { - 0x92A5, "GL_LINEARBURN_NV", - }, - { - 0x8893, "GL_ELEMENT_ARRAY_BUFFER", - }, - { - 0x8892, "GL_ARRAY_BUFFER", - }, - { - 0x92A8, "GL_PINLIGHT_NV", - }, - { - 0x92A9, "GL_HARDMIX_NV", - }, - { - 0x9112, "GL_OBJECT_TYPE_APPLE", - }, - { - 0x90CC, "GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT", - }, - { - 0x90CD, "GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT", - }, - { - 0x919F, "GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT", - }, - { - 0x919E, "GL_TEXTURE_BUFFER_SIZE_EXT", - }, - { - 0x919D, "GL_TEXTURE_BUFFER_OFFSET_EXT", - }, - { - 0x8BD8, "GL_TEXTURE_IMAGE_VALID_QCOM", - }, - { - 0x9278, "GL_COMPRESSED_RGBA8_ETC2_EAC", - }, - { - 0x9279, "GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", - }, - { - 0x8DA7, "GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT", - }, - { - 0x9272, "GL_COMPRESSED_RG11_EAC", - }, - { - 0x8DA8, "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT", - }, - { - 0x9270, "GL_COMPRESSED_R11_EAC", - }, - { - 0x9271, "GL_COMPRESSED_SIGNED_R11_EAC", - }, - { - 0x9276, "GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", - }, - { - 0x887F, "GL_GEOMETRY_SHADER_INVOCATIONS_EXT", - }, - { - 0x8A3B, "GL_UNIFORM_OFFSET", - }, - { - 0x9275, "GL_COMPRESSED_SRGB8_ETC2", - }, - { - 0x84D5, "GL_TEXTURE21", - }, - { - 0x8C3A, "GL_R11F_G11F_B10F_APPLE", - }, - { - 0x8C3B, "GL_UNSIGNED_INT_10F_11F_11F_REV_APPLE", - }, - { - 0x8C3D, "GL_RGB9_E5_APPLE", - }, - { - 0x8C3E, "GL_UNSIGNED_INT_5_9_9_9_REV_APPLE", - }, - { - 0x9287, "GL_DST_NV", - }, - { - 0x93BA, "GL_COMPRESSED_RGBA_ASTC_10x8_KHR", - }, - { - 0x9285, "GL_BLEND_ADVANCED_COHERENT_KHR", - }, - { - 0x93BC, "GL_COMPRESSED_RGBA_ASTC_12x10_KHR", - }, - { - 0x93BD, "GL_COMPRESSED_RGBA_ASTC_12x12_KHR", - }, - { - 0x84E8, "GL_MAX_RENDERBUFFER_SIZE", - }, - { - 0x9281, "GL_BLEND_OVERLAP_NV", - }, - { - 0x9280, "GL_BLEND_PREMULTIPLIED_SRC_NV", - }, - { - 0x00002000, "GL_DEPTH_BUFFER_BIT5_QCOM", - }, - { - 0x8370, "GL_MIRRORED_REPEAT", - }, - { - 0x84E0, "GL_ACTIVE_TEXTURE", - }, - { - 0x8800, "GL_STENCIL_BACK_FUNC", - }, - { - 0x8801, "GL_STENCIL_BACK_FAIL", - }, - { - 0x0D33, "GL_MAX_TEXTURE_SIZE", - }, - { - 0x0D32, "GL_MAX_CLIP_DISTANCES_APPLE", - }, - { - 0x8624, "GL_VERTEX_ATTRIB_ARRAY_STRIDE", - }, - { - 0x8625, "GL_VERTEX_ATTRIB_ARRAY_TYPE", - }, - { - 0x8622, "GL_VERTEX_ATTRIB_ARRAY_ENABLED", - }, - { - 0x8623, "GL_VERTEX_ATTRIB_ARRAY_SIZE", - }, - { - 0x8DB9, "GL_FRAMEBUFFER_SRGB_EXT", - }, - { - 0x9307, "GL_REFERENCED_BY_TESS_CONTROL_SHADER_EXT", - }, - { - 0x8259, "GL_ACTIVE_PROGRAM_EXT", - }, - { - 0x8258, "GL_PROGRAM_SEPARABLE_EXT", - }, - { - 0x8257, "GL_PROGRAM_BINARY_RETRIEVABLE_HINT", - }, - { - 0x8256, "GL_RESET_NOTIFICATION_STRATEGY_KHR", - }, - { - 0x8255, "GL_UNKNOWN_CONTEXT_RESET_KHR", - }, - { - 0x8254, "GL_INNOCENT_CONTEXT_RESET_KHR", - }, - { - 0x1100, "GL_DONT_CARE", - }, - { - 0x1101, "GL_FASTEST", - }, - { - 0x1102, "GL_NICEST", - }, - { - 0x8250, "GL_DEBUG_TYPE_PERFORMANCE_KHR", - }, - { - 0x8CEB, "GL_COLOR_ATTACHMENT11_EXT", - }, - { - 0x8CEC, "GL_COLOR_ATTACHMENT12_EXT", - }, - { - 0x0408, "GL_FRONT_AND_BACK", - }, - { - 0x8CEA, "GL_COLOR_ATTACHMENT10_EXT", - }, - { - 0x8CEF, "GL_COLOR_ATTACHMENT15_EXT", - }, - { - 0x8CED, "GL_COLOR_ATTACHMENT13_EXT", - }, - { - 0x8829, "GL_DRAW_BUFFER4_EXT", - }, - { - 0x0404, "GL_FRONT", - }, - { - 0x0405, "GL_BACK", - }, - { - 0x88E1, "GL_STREAM_READ", - }, - { - 0x88E0, "GL_STREAM_DRAW", - }, - { - 0x88E2, "GL_STREAM_COPY", - }, - { - 0x88E5, "GL_STATIC_READ", - }, - { - 0x88E4, "GL_STATIC_DRAW", - }, - { - 0x93C6, "GL_COMPRESSED_RGBA_ASTC_5x5x5_OES", - }, - { - 0x88E9, "GL_DYNAMIC_READ", - }, - { - 0x88E8, "GL_DYNAMIC_DRAW", - }, - { - 0x9291, "GL_PLUS_NV", - }, - { - 0x8CAA, "GL_READ_FRAMEBUFFER_BINDING_ANGLE", - }, - { - 0x93C5, "GL_COMPRESSED_RGBA_ASTC_5x5x4_OES", - }, - { - 0x40000000, "GL_MULTISAMPLE_BUFFER_BIT6_QCOM", - }, - { - 0x88EA, "GL_DYNAMIC_COPY", - }, - { - 0x9116, "GL_SYNC_FENCE_APPLE", - }, - { - 0x93C4, "GL_COMPRESSED_RGBA_ASTC_5x4x4_OES", - }, - { - 0x88EE, "GL_ETC1_SRGB8_NV", - }, - { - 0x78EC, "GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM", - }, - { - 0x88EF, "GL_PIXEL_UNPACK_BUFFER_BINDING", - }, - { - 0x93C3, "GL_COMPRESSED_RGBA_ASTC_4x4x4_OES", - }, - { - 0x00000800, "GL_DEPTH_BUFFER_BIT3_QCOM", - }, - { - 0x1903, "GL_RED_EXT", - }, - { - 0x93C2, "GL_COMPRESSED_RGBA_ASTC_4x4x3_OES", - }, - { - 0x8CE2, "GL_COLOR_ATTACHMENT2_EXT", - }, - { - 0x8BC1, "GL_COUNTER_RANGE_AMD", - }, - { - 0x8CE0, "GL_COLOR_ATTACHMENT0", - }, - { - 0x8CE1, "GL_COLOR_ATTACHMENT1_EXT", - }, - { - 0x8CE6, "GL_COLOR_ATTACHMENT6_EXT", - }, - { - 0x93C1, "GL_COMPRESSED_RGBA_ASTC_4x3x3_OES", - }, - { - 0x8A1F, "GL_RGB_422_APPLE", - }, - { - 0x93DC, "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR", - }, - { - 0x9292, "GL_PLUS_DARKER_NV", - }, - { - 0x8CE8, "GL_COLOR_ATTACHMENT8_EXT", - }, - { - 0x93C0, "GL_COMPRESSED_RGBA_ASTC_3x3x3_OES", - }, - { - 0x0C23, "GL_COLOR_WRITEMASK", - }, - { - 0x0C22, "GL_COLOR_CLEAR_VALUE", - }, - { - 0x8A11, "GL_UNIFORM_BUFFER", - }, - { - 0x8823, "GL_WRITEONLY_RENDERING_QCOM", - }, - { - 0x8824, "GL_MAX_DRAW_BUFFERS_EXT", - }, - { - 0x825E, "GL_LAYER_PROVOKING_VERTEX_EXT", - }, - { - 0x825A, "GL_PROGRAM_PIPELINE_BINDING_EXT", - }, - { - 0x1909, "GL_LUMINANCE", - }, - { - 0x0D3A, "GL_MAX_VIEWPORT_DIMS", - }, - { - 0x8B53, "GL_INT_VEC2", - }, - { - 0x8826, "GL_DRAW_BUFFER1_EXT", - }, - { - 0x809E, "GL_SAMPLE_ALPHA_TO_COVERAGE", - }, - { - 0x8BC0, "GL_COUNTER_TYPE_AMD", - }, - { - 0x8BC3, "GL_PERCENTAGE_AMD", - }, - { - 0x8BC2, "GL_UNSIGNED_INT64_AMD", - }, - { - 0x8BC5, "GL_PERFMON_RESULT_SIZE_AMD", - }, - { - 0x8BC4, "GL_PERFMON_RESULT_AVAILABLE_AMD", - }, - { - 0x8BC6, "GL_PERFMON_RESULT_AMD", - }, -}; - -const GLEnums::EnumToString* const GLEnums::enum_to_string_table_ = - enum_to_string_table; -const size_t GLEnums::enum_to_string_table_len_ = - sizeof(enum_to_string_table) / sizeof(enum_to_string_table[0]); diff --git a/ui/gl/gl_export.h b/ui/gl/gl_export.h deleted file mode 100644 index 5c30b182e..000000000 --- a/ui/gl/gl_export.h +++ /dev/null @@ -1,29 +0,0 @@ -// 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 UI_GL_GL_EXPORT_H_ -#define UI_GL_GL_EXPORT_H_ - -#if defined(COMPONENT_BUILD) -#if defined(WIN32) - -#if defined(GL_IMPLEMENTATION) -#define GL_EXPORT __declspec(dllexport) -#else -#define GL_EXPORT __declspec(dllimport) -#endif // defined(GL_IMPLEMENTATION) - -#else // defined(WIN32) -#if defined(GL_IMPLEMENTATION) -#define GL_EXPORT __attribute__((visibility("default"))) -#else -#define GL_EXPORT -#endif -#endif - -#else // defined(COMPONENT_BUILD) -#define GL_EXPORT -#endif - -#endif // UI_GL_GL_EXPORT_H_ diff --git a/ui/gl/gl_gl_api_implementation.cc b/ui/gl/gl_gl_api_implementation.cc deleted file mode 100644 index bffa64e56..000000000 --- a/ui/gl/gl_gl_api_implementation.cc +++ /dev/null @@ -1,541 +0,0 @@ -// 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 "ui/gl/gl_gl_api_implementation.h" - -#include -#include - -#include "base/command_line.h" -#include "base/strings/string_split.h" -#include "base/strings/string_util.h" -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_state_restorer.h" -#include "ui/gl/gl_surface.h" -#include "ui/gl/gl_switches.h" -#include "ui/gl/gl_version_info.h" - -namespace gfx { - -// The GL Api being used. This could be g_real_gl or gl_trace_gl -static GLApi* g_gl = NULL; -// A GL Api that calls directly into the driver. -static RealGLApi* g_real_gl = NULL; -// A GL Api that does nothing but warn about illegal GL calls without a context -// current. -static NoContextGLApi* g_no_context_gl = NULL; -// A GL Api that calls TRACE and then calls another GL api. -static TraceGLApi* g_trace_gl = NULL; -// GL version used when initializing dynamic bindings. -static GLVersionInfo* g_version_info = NULL; - -namespace { - -static inline GLenum GetInternalFormat(GLenum internal_format) { - if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { - if (internal_format == GL_BGRA_EXT || internal_format == GL_BGRA8_EXT) - return GL_RGBA8; - } - return internal_format; -} - -// TODO(epenner): Could the above function be merged into this and removed? -static inline GLenum GetTexInternalFormat(GLenum internal_format, - GLenum format, - GLenum type) { - GLenum gl_internal_format = GetInternalFormat(internal_format); - - // g_version_info must be initialized when this function is bound. - DCHECK(gfx::g_version_info); - if (gfx::g_version_info->is_es3) { - if (format == GL_RED_EXT) { - switch (type) { - case GL_UNSIGNED_BYTE: - gl_internal_format = GL_R8_EXT; - break; - case GL_HALF_FLOAT_OES: - gl_internal_format = GL_R16F_EXT; - break; - case GL_FLOAT: - gl_internal_format = GL_R32F_EXT; - break; - default: - NOTREACHED(); - break; - } - return gl_internal_format; - } else if (format == GL_RG_EXT) { - switch (type) { - case GL_UNSIGNED_BYTE: - gl_internal_format = GL_RG8_EXT; - break; - case GL_HALF_FLOAT_OES: - gl_internal_format = GL_RG16F_EXT; - break; - case GL_FLOAT: - gl_internal_format = GL_RG32F_EXT; - break; - default: - NOTREACHED(); - break; - } - return gl_internal_format; - } - } - - if (type == GL_FLOAT && gfx::g_version_info->is_angle && - gfx::g_version_info->is_es && gfx::g_version_info->major_version == 2) { - // It's possible that the texture is using a sized internal format, and - // ANGLE exposing GLES2 API doesn't support those. - // TODO(oetuaho@nvidia.com): Remove these conversions once ANGLE has the - // support. - // http://code.google.com/p/angleproject/issues/detail?id=556 - switch (format) { - case GL_RGBA: - gl_internal_format = GL_RGBA; - break; - case GL_RGB: - gl_internal_format = GL_RGB; - break; - default: - break; - } - } - - if (gfx::g_version_info->is_es) - return gl_internal_format; - - if (type == GL_FLOAT) { - switch (format) { - case GL_RGBA: - gl_internal_format = GL_RGBA32F_ARB; - break; - case GL_RGB: - gl_internal_format = GL_RGB32F_ARB; - break; - case GL_LUMINANCE_ALPHA: - gl_internal_format = GL_LUMINANCE_ALPHA32F_ARB; - break; - case GL_LUMINANCE: - gl_internal_format = GL_LUMINANCE32F_ARB; - break; - case GL_ALPHA: - gl_internal_format = GL_ALPHA32F_ARB; - break; - default: - NOTREACHED(); - break; - } - } else if (type == GL_HALF_FLOAT_OES) { - switch (format) { - case GL_RGBA: - gl_internal_format = GL_RGBA16F_ARB; - break; - case GL_RGB: - gl_internal_format = GL_RGB16F_ARB; - break; - case GL_LUMINANCE_ALPHA: - gl_internal_format = GL_LUMINANCE_ALPHA16F_ARB; - break; - case GL_LUMINANCE: - gl_internal_format = GL_LUMINANCE16F_ARB; - break; - case GL_ALPHA: - gl_internal_format = GL_ALPHA16F_ARB; - break; - default: - NOTREACHED(); - break; - } - } - return gl_internal_format; -} - -static inline GLenum GetTexType(GLenum type) { - if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { - if (type == GL_HALF_FLOAT_OES) - return GL_HALF_FLOAT_ARB; - } - return type; -} - -static void GL_BINDING_CALL CustomTexImage2D( - GLenum target, GLint level, GLint internalformat, - GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, - const void* pixels) { - GLenum gl_internal_format = GetTexInternalFormat( - internalformat, format, type); - GLenum gl_type = GetTexType(type); - g_driver_gl.orig_fn.glTexImage2DFn( - target, level, gl_internal_format, width, height, border, format, gl_type, - pixels); -} - -static void GL_BINDING_CALL CustomTexSubImage2D( - GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, - GLsizei height, GLenum format, GLenum type, const void* pixels) { - GLenum gl_type = GetTexType(type); - g_driver_gl.orig_fn.glTexSubImage2DFn( - target, level, xoffset, yoffset, width, height, format, gl_type, pixels); -} - -static void GL_BINDING_CALL CustomTexStorage2DEXT( - GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, - GLsizei height) { - GLenum gl_internal_format = GetInternalFormat(internalformat); - g_driver_gl.orig_fn.glTexStorage2DEXTFn( - target, levels, gl_internal_format, width, height); -} - -static void GL_BINDING_CALL CustomRenderbufferStorageEXT( - GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { - GLenum gl_internal_format = GetInternalFormat(internalformat); - g_driver_gl.orig_fn.glRenderbufferStorageEXTFn( - target, gl_internal_format, width, height); -} - -// The ANGLE and IMG variants of glRenderbufferStorageMultisample currently do -// not support BGRA render buffers so only the EXT one is customized. If -// GL_CHROMIUM_renderbuffer_format_BGRA8888 support is added to ANGLE then the -// ANGLE version should also be customized. -static void GL_BINDING_CALL CustomRenderbufferStorageMultisampleEXT( - GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, - GLsizei height) { - GLenum gl_internal_format = GetInternalFormat(internalformat); - g_driver_gl.orig_fn.glRenderbufferStorageMultisampleEXTFn( - target, samples, gl_internal_format, width, height); -} - -} // anonymous namespace - -void DriverGL::InitializeCustomDynamicBindings(GLContext* context) { - InitializeDynamicBindings(context); - - DCHECK(orig_fn.glTexImage2DFn == NULL); - orig_fn.glTexImage2DFn = fn.glTexImage2DFn; - fn.glTexImage2DFn = - reinterpret_cast(CustomTexImage2D); - - DCHECK(orig_fn.glTexSubImage2DFn == NULL); - orig_fn.glTexSubImage2DFn = fn.glTexSubImage2DFn; - fn.glTexSubImage2DFn = - reinterpret_cast(CustomTexSubImage2D); - - DCHECK(orig_fn.glTexStorage2DEXTFn == NULL); - orig_fn.glTexStorage2DEXTFn = fn.glTexStorage2DEXTFn; - fn.glTexStorage2DEXTFn = - reinterpret_cast(CustomTexStorage2DEXT); - - DCHECK(orig_fn.glRenderbufferStorageEXTFn == NULL); - orig_fn.glRenderbufferStorageEXTFn = fn.glRenderbufferStorageEXTFn; - fn.glRenderbufferStorageEXTFn = - reinterpret_cast( - CustomRenderbufferStorageEXT); - - DCHECK(orig_fn.glRenderbufferStorageMultisampleEXTFn == NULL); - orig_fn.glRenderbufferStorageMultisampleEXTFn = - fn.glRenderbufferStorageMultisampleEXTFn; - fn.glRenderbufferStorageMultisampleEXTFn = - reinterpret_cast( - CustomRenderbufferStorageMultisampleEXT); -} - -static void GL_BINDING_CALL NullDrawClearFn(GLbitfield mask) { - if (!g_driver_gl.null_draw_bindings_enabled) - g_driver_gl.orig_fn.glClearFn(mask); -} - -static void GL_BINDING_CALL -NullDrawDrawArraysFn(GLenum mode, GLint first, GLsizei count) { - if (!g_driver_gl.null_draw_bindings_enabled) - g_driver_gl.orig_fn.glDrawArraysFn(mode, first, count); -} - -static void GL_BINDING_CALL NullDrawDrawElementsFn(GLenum mode, - GLsizei count, - GLenum type, - const void* indices) { - if (!g_driver_gl.null_draw_bindings_enabled) - g_driver_gl.orig_fn.glDrawElementsFn(mode, count, type, indices); -} - -void DriverGL::InitializeNullDrawBindings() { - DCHECK(orig_fn.glClearFn == NULL); - orig_fn.glClearFn = fn.glClearFn; - fn.glClearFn = NullDrawClearFn; - - DCHECK(orig_fn.glDrawArraysFn == NULL); - orig_fn.glDrawArraysFn = fn.glDrawArraysFn; - fn.glDrawArraysFn = NullDrawDrawArraysFn; - - DCHECK(orig_fn.glDrawElementsFn == NULL); - orig_fn.glDrawElementsFn = fn.glDrawElementsFn; - fn.glDrawElementsFn = NullDrawDrawElementsFn; - - null_draw_bindings_enabled = true; -} - -bool DriverGL::HasInitializedNullDrawBindings() { - return orig_fn.glClearFn != NULL && orig_fn.glDrawArraysFn != NULL && - orig_fn.glDrawElementsFn != NULL; -} - -bool DriverGL::SetNullDrawBindingsEnabled(bool enabled) { - DCHECK(orig_fn.glClearFn != NULL); - DCHECK(orig_fn.glDrawArraysFn != NULL); - DCHECK(orig_fn.glDrawElementsFn != NULL); - - bool before = null_draw_bindings_enabled; - null_draw_bindings_enabled = enabled; - return before; -} - -void InitializeStaticGLBindingsGL() { - g_current_gl_context_tls = new base::ThreadLocalPointer; - g_driver_gl.InitializeStaticBindings(); - if (!g_real_gl) { - g_real_gl = new RealGLApi(); - g_trace_gl = new TraceGLApi(g_real_gl); - g_no_context_gl = new NoContextGLApi(); - } - g_real_gl->Initialize(&g_driver_gl); - g_gl = g_real_gl; - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableGPUServiceTracing)) { - g_gl = g_trace_gl; - } - SetGLToRealGLApi(); -} - -GLApi* GetCurrentGLApi() { - return g_current_gl_context_tls->Get(); -} - -void SetGLApi(GLApi* api) { - g_current_gl_context_tls->Set(api); -} - -void SetGLToRealGLApi() { - SetGLApi(g_gl); -} - -void SetGLApiToNoContext() { - SetGLApi(g_no_context_gl); -} - -const GLVersionInfo* GetGLVersionInfo() { - return g_version_info; -} - -void InitializeDynamicGLBindingsGL(GLContext* context) { - g_driver_gl.InitializeCustomDynamicBindings(context); - DCHECK(context && context->IsCurrent(NULL) && !g_version_info); - g_version_info = new GLVersionInfo(context->GetGLVersion().c_str(), - context->GetGLRenderer().c_str()); -} - -void InitializeDebugGLBindingsGL() { - g_driver_gl.InitializeDebugBindings(); -} - -void InitializeNullDrawGLBindingsGL() { - g_driver_gl.InitializeNullDrawBindings(); -} - -bool HasInitializedNullDrawGLBindingsGL() { - return g_driver_gl.HasInitializedNullDrawBindings(); -} - -bool SetNullDrawGLBindingsEnabledGL(bool enabled) { - return g_driver_gl.SetNullDrawBindingsEnabled(enabled); -} - -void ClearGLBindingsGL() { - if (g_real_gl) { - delete g_real_gl; - g_real_gl = NULL; - } - if (g_trace_gl) { - delete g_trace_gl; - g_trace_gl = NULL; - } - if (g_no_context_gl) { - delete g_no_context_gl; - g_no_context_gl = NULL; - } - g_gl = NULL; - g_driver_gl.ClearBindings(); - if (g_current_gl_context_tls) { - delete g_current_gl_context_tls; - g_current_gl_context_tls = NULL; - } - if (g_version_info) { - delete g_version_info; - g_version_info = NULL; - } -} - -GLApi::GLApi() { -} - -GLApi::~GLApi() { - if (GetCurrentGLApi() == this) - SetGLApi(NULL); -} - -GLApiBase::GLApiBase() - : driver_(NULL) { -} - -GLApiBase::~GLApiBase() { -} - -void GLApiBase::InitializeBase(DriverGL* driver) { - driver_ = driver; -} - -RealGLApi::RealGLApi() { -} - -RealGLApi::~RealGLApi() { -} - -void RealGLApi::Initialize(DriverGL* driver) { - InitializeBase(driver); -} - -void RealGLApi::glFlushFn() { - GLApiBase::glFlushFn(); -} - -void RealGLApi::glFinishFn() { - GLApiBase::glFinishFn(); -} - -TraceGLApi::~TraceGLApi() { -} - -NoContextGLApi::NoContextGLApi() { -} - -NoContextGLApi::~NoContextGLApi() { -} - -VirtualGLApi::VirtualGLApi() - : real_context_(NULL), - current_context_(NULL) { -} - -VirtualGLApi::~VirtualGLApi() { -} - -void VirtualGLApi::Initialize(DriverGL* driver, GLContext* real_context) { - InitializeBase(driver); - real_context_ = real_context; - - DCHECK(real_context->IsCurrent(NULL)); - std::string ext_string( - reinterpret_cast(driver_->fn.glGetStringFn(GL_EXTENSIONS))); - std::vector ext = base::SplitString( - ext_string, " ", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); - - std::vector::iterator it; - // We can't support GL_EXT_occlusion_query_boolean which is - // based on GL_ARB_occlusion_query without a lot of work virtualizing - // queries. - it = std::find(ext.begin(), ext.end(), "GL_EXT_occlusion_query_boolean"); - if (it != ext.end()) - ext.erase(it); - - extensions_ = base::JoinString(ext, " "); -} - -bool VirtualGLApi::MakeCurrent(GLContext* virtual_context, GLSurface* surface) { - bool switched_contexts = g_current_gl_context_tls->Get() != this; - GLSurface* current_surface = GLSurface::GetCurrent(); - if (switched_contexts || surface != current_surface) { - // MakeCurrent 'lite' path that avoids potentially expensive MakeCurrent() - // calls if the GLSurface uses the same underlying surface or renders to - // an FBO. - if (switched_contexts || !current_surface || - !virtual_context->IsCurrent(surface)) { - if (!real_context_->MakeCurrent(surface)) { - return false; - } - } - } - - bool state_dirtied_externally = real_context_->GetStateWasDirtiedExternally(); - real_context_->SetStateWasDirtiedExternally(false); - - DCHECK_EQ(real_context_, GLContext::GetRealCurrent()); - DCHECK(real_context_->IsCurrent(NULL)); - DCHECK(virtual_context->IsCurrent(surface)); - - if (state_dirtied_externally || switched_contexts || - virtual_context != current_context_) { -#if DCHECK_IS_ON() - GLenum error = glGetErrorFn(); - // Accepting a context loss error here enables using debug mode to work on - // context loss handling in virtual context mode. - // There should be no other errors from the previous context leaking into - // the new context. - DCHECK(error == GL_NO_ERROR || error == GL_CONTEXT_LOST_KHR); -#endif - - // Set all state that is different from the real state - GLApi* temp = GetCurrentGLApi(); - SetGLToRealGLApi(); - if (virtual_context->GetGLStateRestorer()->IsInitialized()) { - virtual_context->GetGLStateRestorer()->RestoreState( - (current_context_ && !state_dirtied_externally && !switched_contexts) - ? current_context_->GetGLStateRestorer() - : NULL); - } - SetGLApi(temp); - current_context_ = virtual_context; - } - SetGLApi(this); - - virtual_context->SetCurrent(surface); - if (!surface->OnMakeCurrent(virtual_context)) { - LOG(ERROR) << "Could not make GLSurface current."; - return false; - } - return true; -} - -void VirtualGLApi::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { - if (current_context_ == virtual_context) - current_context_ = NULL; -} - -const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { - switch (name) { - case GL_EXTENSIONS: - return reinterpret_cast(extensions_.c_str()); - default: - return driver_->fn.glGetStringFn(name); - } -} - -void VirtualGLApi::glFlushFn() { - GLApiBase::glFlushFn(); -} - -void VirtualGLApi::glFinishFn() { - GLApiBase::glFinishFn(); -} - -ScopedSetGLToRealGLApi::ScopedSetGLToRealGLApi() - : old_gl_api_(GetCurrentGLApi()) { - SetGLToRealGLApi(); -} - -ScopedSetGLToRealGLApi::~ScopedSetGLToRealGLApi() { - SetGLApi(old_gl_api_); -} - -} // namespace gfx diff --git a/ui/gl/gl_gl_api_implementation.h b/ui/gl/gl_gl_api_implementation.h deleted file mode 100644 index d4086006b..000000000 --- a/ui/gl/gl_gl_api_implementation.h +++ /dev/null @@ -1,131 +0,0 @@ -// 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 UI_GL_GL_GL_API_IMPLEMENTATION_H_ -#define UI_GL_GL_GL_API_IMPLEMENTATION_H_ - -#include "base/compiler_specific.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_export.h" - -namespace gpu { -namespace gles2 { -class GLES2Decoder; -} -} -namespace gfx { - -class GLContext; -class GLSurface; -struct GLVersionInfo; - -void InitializeStaticGLBindingsGL(); -void InitializeDynamicGLBindingsGL(GLContext* context); -void InitializeDebugGLBindingsGL(); -void InitializeNullDrawGLBindingsGL(); -// TODO(danakj): Remove this when all test suites are using null-draw. -bool HasInitializedNullDrawGLBindingsGL(); -bool SetNullDrawGLBindingsEnabledGL(bool enabled); -void ClearGLBindingsGL(); -void SetGLToRealGLApi(); -void SetGLApi(GLApi* api); -void SetGLApiToNoContext(); -const GLVersionInfo* GetGLVersionInfo(); - -class GLApiBase : public GLApi { - public: - // Include the auto-generated part of this class. We split this because - // it means we can easily edit the non-auto generated parts right here in - // this file instead of having to edit some template or the code generator. - #include "gl_bindings_api_autogen_gl.h" - - protected: - GLApiBase(); - ~GLApiBase() override; - void InitializeBase(DriverGL* driver); - - DriverGL* driver_; -}; - -// Implemenents the GL API by calling directly into the driver. -class RealGLApi : public GLApiBase { - public: - RealGLApi(); - ~RealGLApi() override; - void Initialize(DriverGL* driver); - - private: - void glFinishFn() override; - void glFlushFn() override; -}; - -// Inserts a TRACE for every GL call. -class TraceGLApi : public GLApi { - public: - TraceGLApi(GLApi* gl_api) : gl_api_(gl_api) { } - ~TraceGLApi() override; - - // Include the auto-generated part of this class. We split this because - // it means we can easily edit the non-auto generated parts right here in - // this file instead of having to edit some template or the code generator. - #include "gl_bindings_api_autogen_gl.h" - - private: - GLApi* gl_api_; -}; - -// Catches incorrect usage when GL calls are made without a current context. -class NoContextGLApi : public GLApi { - public: - NoContextGLApi(); - ~NoContextGLApi() override; - - // Include the auto-generated part of this class. We split this because - // it means we can easily edit the non-auto generated parts right here in - // this file instead of having to edit some template or the code generator. - #include "gl_bindings_api_autogen_gl.h" -}; - -// Implementents the GL API using co-operative state restoring. -// Assumes there is only one real GL context and that multiple virtual contexts -// are implemented above it. Restores the needed state from the current context. -class VirtualGLApi : public GLApiBase { - public: - VirtualGLApi(); - ~VirtualGLApi() override; - void Initialize(DriverGL* driver, GLContext* real_context); - - // Sets the current virutal context. - bool MakeCurrent(GLContext* virtual_context, GLSurface* surface); - - void OnReleaseVirtuallyCurrent(GLContext* virtual_context); - -private: - // Overridden functions from GLApiBase - const GLubyte* glGetStringFn(GLenum name) override; - void glFinishFn() override; - void glFlushFn() override; - - // The real context we're running on. - GLContext* real_context_; - - // The current virtual context. - GLContext* current_context_; - - // The supported extensions being advertised for this virtual context. - std::string extensions_; -}; - -class GL_EXPORT ScopedSetGLToRealGLApi { - public: - ScopedSetGLToRealGLApi(); - ~ScopedSetGLToRealGLApi(); - - private: - GLApi* old_gl_api_; -}; - -} // namespace gfx - -#endif // UI_GL_GL_GL_API_IMPLEMENTATION_H_ diff --git a/ui/gl/gl_implementation.cc b/ui/gl/gl_implementation.cc deleted file mode 100644 index 0cadbac20..000000000 --- a/ui/gl/gl_implementation.cc +++ /dev/null @@ -1,150 +0,0 @@ -// 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 "ui/gl/gl_implementation.h" - -#include -#include - -#include "base/at_exit.h" -#include "base/command_line.h" -#include "base/logging.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_gl_api_implementation.h" - -namespace gfx { - -namespace { - -const struct { - const char* name; - GLImplementation implementation; -} kGLImplementationNamePairs[] = { - { kGLImplementationDesktopName, kGLImplementationDesktopGL }, - { kGLImplementationOSMesaName, kGLImplementationOSMesaGL }, - { kGLImplementationEGLName, kGLImplementationEGLGLES2 }, - { kGLImplementationMockName, kGLImplementationMockGL } -}; - -typedef std::vector LibraryArray; - -GLImplementation g_gl_implementation = kGLImplementationNone; -LibraryArray* g_libraries; -GLGetProcAddressProc g_get_proc_address; - -void CleanupNativeLibraries(void* unused) { - if (g_libraries) { - // We do not call base::UnloadNativeLibrary() for these libraries as - // unloading libGL without closing X display is not allowed. See - // crbug.com/250813 for details. - delete g_libraries; - g_libraries = NULL; - } -} - -} - -base::ThreadLocalPointer* g_current_gl_context_tls = NULL; -OSMESAApi* g_current_osmesa_context; - -#if defined(OS_ANDROID) - -EGLApi* g_current_egl_context; - -#endif - -GLImplementation GetNamedGLImplementation(const std::string& name) { - for (size_t i = 0; i < arraysize(kGLImplementationNamePairs); ++i) { - if (name == kGLImplementationNamePairs[i].name) - return kGLImplementationNamePairs[i].implementation; - } - - return kGLImplementationNone; -} - -const char* GetGLImplementationName(GLImplementation implementation) { - for (size_t i = 0; i < arraysize(kGLImplementationNamePairs); ++i) { - if (implementation == kGLImplementationNamePairs[i].implementation) - return kGLImplementationNamePairs[i].name; - } - - return "unknown"; -} - -void SetGLImplementation(GLImplementation implementation) { - g_gl_implementation = implementation; -} - -GLImplementation GetGLImplementation() { - return g_gl_implementation; -} - -bool HasDesktopGLFeatures() { - return kGLImplementationDesktopGL == g_gl_implementation || - kGLImplementationOSMesaGL == g_gl_implementation || - kGLImplementationAppleGL == g_gl_implementation; -} - -void AddGLNativeLibrary(base::NativeLibrary library) { - DCHECK(library); - - if (!g_libraries) { - g_libraries = new LibraryArray; - base::AtExitManager::RegisterCallback(CleanupNativeLibraries, NULL); - } - - g_libraries->push_back(library); -} - -void UnloadGLNativeLibraries() { - CleanupNativeLibraries(NULL); -} - -void SetGLGetProcAddressProc(GLGetProcAddressProc proc) { - DCHECK(proc); - g_get_proc_address = proc; -} - -void* GetGLProcAddress(const char* name) { - DCHECK(g_gl_implementation != kGLImplementationNone); - - if (g_libraries) { - for (size_t i = 0; i < g_libraries->size(); ++i) { - void* proc = base::GetFunctionPointerFromNativeLibrary((*g_libraries)[i], - name); - if (proc) - return proc; - } - } - if (g_get_proc_address) { - void* proc = g_get_proc_address(name); - if (proc) - return proc; - } - - return NULL; -} - -void InitializeNullDrawGLBindings() { - // This is platform independent, so it does not need to live in a platform - // specific implementation file. - InitializeNullDrawGLBindingsGL(); -} - -bool HasInitializedNullDrawGLBindings() { - return HasInitializedNullDrawGLBindingsGL(); -} - -DisableNullDrawGLBindings::DisableNullDrawGLBindings() { - initial_enabled_ = SetNullDrawGLBindingsEnabledGL(false); -} - -DisableNullDrawGLBindings::~DisableNullDrawGLBindings() { - SetNullDrawGLBindingsEnabledGL(initial_enabled_); -} - -GLWindowSystemBindingInfo::GLWindowSystemBindingInfo() - : direct_rendering(true) {} - -} // namespace gfx diff --git a/ui/gl/gl_implementation.h b/ui/gl/gl_implementation.h deleted file mode 100644 index 2bfb293ad..000000000 --- a/ui/gl/gl_implementation.h +++ /dev/null @@ -1,114 +0,0 @@ -// 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 UI_GL_GL_IMPLEMENTATION_H_ -#define UI_GL_GL_IMPLEMENTATION_H_ - -#include -#include - -#include "base/native_library.h" -#include "build/build_config.h" -#include "ui/gl/gl_export.h" -#include "ui/gl/gl_switches.h" - -namespace gfx { - -class GLContext; - -// The GL implementation currently in use. -enum GLImplementation { - kGLImplementationNone, - kGLImplementationDesktopGL, - kGLImplementationOSMesaGL, - kGLImplementationAppleGL, - kGLImplementationEGLGLES2, - kGLImplementationMockGL -}; - -struct GL_EXPORT GLWindowSystemBindingInfo { - GLWindowSystemBindingInfo(); - std::string vendor; - std::string version; - std::string extensions; - bool direct_rendering; -}; - -void GetAllowedGLImplementations(std::vector* impls); - -typedef void* (*GLGetProcAddressProc)(const char* name); - -// Initialize a particular GL implementation. -GL_EXPORT bool InitializeStaticGLBindings(GLImplementation implementation); - -// Initialize function bindings that depend on the context for a GL -// implementation. -GL_EXPORT bool InitializeDynamicGLBindings(GLImplementation implementation, - GLContext* context); - -// Initialize Debug logging wrappers for GL bindings. -void InitializeDebugGLBindings(); - -// Initialize stub methods for drawing operations in the GL bindings. The -// null draw bindings default to enabled, so that draw operations do nothing. -void InitializeNullDrawGLBindings(); - -// TODO(danakj): Remove this when all test suites are using null-draw. -GL_EXPORT bool HasInitializedNullDrawGLBindings(); - -// Once initialized, instantiating this turns the stub methods for drawing -// operations off allowing drawing will occur while the object is alive. -class GL_EXPORT DisableNullDrawGLBindings { - public: - DisableNullDrawGLBindings(); - ~DisableNullDrawGLBindings(); - - private: - bool initial_enabled_; -}; - -GL_EXPORT void ClearGLBindings(); - -// Set the current GL implementation. -GL_EXPORT void SetGLImplementation(GLImplementation implementation); - -// Get the current GL implementation. -GL_EXPORT GLImplementation GetGLImplementation(); - -// Does the underlying GL support all features from Desktop GL 2.0 that were -// removed from the ES 2.0 spec without requiring specific extension strings. -GL_EXPORT bool HasDesktopGLFeatures(); - -// Get the GL implementation with a given name. -GLImplementation GetNamedGLImplementation(const std::string& name); - -// Get the name of a GL implementation. -const char* GetGLImplementationName(GLImplementation implementation); - -// Add a native library to those searched for GL entry points. -void AddGLNativeLibrary(base::NativeLibrary library); - -// Unloads all native libraries. -void UnloadGLNativeLibraries(); - -// Set an additional function that will be called to find GL entry points. -// Exported so that tests may set the function used in the mock implementation. -GL_EXPORT void SetGLGetProcAddressProc(GLGetProcAddressProc proc); - -// Find an entry point in the current GL implementation. Note that the function -// may return a non-null pointer to something else than the GL function if an -// unsupported function is queried. Spec-compliant eglGetProcAddress and -// glxGetProcAddress are allowed to return garbage for unsupported functions, -// and when querying functions from the EGL library supplied by Android, it may -// return a function that prints a log message about the function being -// unsupported. -void* GetGLProcAddress(const char* name); - -// Return information about the GL window system binding implementation (e.g., -// EGL, GLX, WGL). Returns true if the information was retrieved successfully. -GL_EXPORT bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info); - -} // namespace gfx - -#endif // UI_GL_GL_IMPLEMENTATION_H_ diff --git a/ui/gl/gl_implementation_android.cc b/ui/gl/gl_implementation_android.cc deleted file mode 100644 index 176cf289a..000000000 --- a/ui/gl/gl_implementation_android.cc +++ /dev/null @@ -1,145 +0,0 @@ -// 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/base_paths.h" -#include "base/command_line.h" -#include "base/files/file_path.h" -#include "base/logging.h" -#include "base/native_library.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_context_stub_with_extensions.h" -#include "ui/gl/gl_egl_api_implementation.h" -#include "ui/gl/gl_gl_api_implementation.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_implementation_osmesa.h" -#include "ui/gl/gl_osmesa_api_implementation.h" - -namespace gfx { - -namespace { - -void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) { - glClearDepthf(static_cast(depth)); -} - -void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near, - GLclampd z_far) { - glDepthRangef(static_cast(z_near), static_cast(z_far)); -} - -} // namespace - -void GetAllowedGLImplementations(std::vector* impls) { - impls->push_back(kGLImplementationEGLGLES2); - impls->push_back(kGLImplementationOSMesaGL); -} - -bool InitializeStaticGLBindings(GLImplementation implementation) { - // Prevent reinitialization with a different implementation. Once the gpu - // unit tests have initialized with kGLImplementationMock, we don't want to - // later switch to another GL implementation. - DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); - - switch (implementation) { - case kGLImplementationEGLGLES2: { - base::NativeLibrary gles_library = - LoadLibraryAndPrintError("libGLESv2.so"); - if (!gles_library) - return false; - base::NativeLibrary egl_library = LoadLibraryAndPrintError("libEGL.so"); - if (!egl_library) { - base::UnloadNativeLibrary(gles_library); - return false; - } - - GLGetProcAddressProc get_proc_address = - reinterpret_cast( - base::GetFunctionPointerFromNativeLibrary( - egl_library, "eglGetProcAddress")); - if (!get_proc_address) { - LOG(ERROR) << "eglGetProcAddress not found."; - base::UnloadNativeLibrary(egl_library); - base::UnloadNativeLibrary(gles_library); - return false; - } - - SetGLGetProcAddressProc(get_proc_address); - AddGLNativeLibrary(egl_library); - AddGLNativeLibrary(gles_library); - SetGLImplementation(kGLImplementationEGLGLES2); - - InitializeStaticGLBindingsGL(); - InitializeStaticGLBindingsEGL(); - - // These two functions take single precision float rather than double - // precision float parameters in GLES. - ::gfx::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf; - ::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef; - break; - } - case kGLImplementationOSMesaGL: - InitializeStaticGLBindingsOSMesaGL(); - break; - case kGLImplementationMockGL: { - SetGLImplementation(kGLImplementationMockGL); - InitializeStaticGLBindingsGL(); - break; - } - default: - NOTIMPLEMENTED() << "InitializeStaticGLBindings on Android"; - return false; - } - - return true; -} - -bool InitializeDynamicGLBindings(GLImplementation implementation, - GLContext* context) { - switch (implementation) { - case kGLImplementationEGLGLES2: - InitializeDynamicGLBindingsGL(context); - break; - case kGLImplementationMockGL: - if (!context) { - scoped_refptr mock_context( - new GLContextStubWithExtensions()); - mock_context->SetGLVersionString("opengl es 3.0"); - InitializeDynamicGLBindingsGL(mock_context.get()); - } else - InitializeDynamicGLBindingsGL(context); - break; - default: - NOTREACHED() << "InitializeDynamicGLBindings on Android"; - return false; - } - - return true; -} - -void InitializeDebugGLBindings() { - InitializeDebugGLBindingsEGL(); - InitializeDebugGLBindingsGL(); - InitializeDebugGLBindingsOSMESA(); -} - -void ClearGLBindings() { - ClearGLBindingsEGL(); - ClearGLBindingsGL(); - ClearGLBindingsOSMESA(); - SetGLImplementation(kGLImplementationNone); - - UnloadGLNativeLibraries(); -} - -bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { - switch (GetGLImplementation()) { - case kGLImplementationEGLGLES2: - return GetGLWindowSystemBindingInfoEGL(info); - default: - return false; - } - return false; -} - -} // namespace gfx diff --git a/ui/gl/gl_implementation_glfw.cc b/ui/gl/gl_implementation_glfw.cc deleted file mode 100644 index bf22f8f57..000000000 --- a/ui/gl/gl_implementation_glfw.cc +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2016 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 - -#include "base/base_paths.h" -#include "base/command_line.h" -#include "base/files/file_path.h" -#include "base/logging.h" -#include "base/native_library.h" -#include "base/path_service.h" -#include "base/threading/thread_restrictions.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_context_stub_with_extensions.h" -#include "ui/gl/gl_gl_api_implementation.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_implementation_osmesa.h" -#include "ui/gl/gl_osmesa_api_implementation.h" - -namespace gfx { - -void GetAllowedGLImplementations(std::vector* impls) { - impls->push_back(kGLImplementationDesktopGL); - impls->push_back(kGLImplementationEGLGLES2); - impls->push_back(kGLImplementationOSMesaGL); -} - -bool InitializeStaticGLBindings(GLImplementation implementation) { - // Prevent reinitialization with a different implementation. Once the gpu - // unit tests have initialized with kGLImplementationMock, we don't want to - // later switch to another GL implementation. - DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); - - switch (implementation) { - case kGLImplementationOSMesaGL: { - base::FilePath module_path; - if (!PathService::Get(base::DIR_MODULE, &module_path)) { - LOG(ERROR) << "PathService::Get failed."; - return false; - } - - base::FilePath library_path = module_path.Append("libosmesa.so"); - base::NativeLibrary library = LoadLibraryAndPrintError(library_path); - if (!library) - return false; - - GLGetProcAddressProc get_proc_address = - reinterpret_cast( - base::GetFunctionPointerFromNativeLibrary(library, - "OSMesaGetProcAddress")); - if (!get_proc_address) { - LOG(ERROR) << "OSMesaGetProcAddress not found."; - base::UnloadNativeLibrary(library); - return false; - } - - SetGLGetProcAddressProc(get_proc_address); - AddGLNativeLibrary(library); - SetGLImplementation(kGLImplementationOSMesaGL); - - InitializeStaticGLBindingsGL(); - InitializeStaticGLBindingsOSMESA(); - break; - } - case kGLImplementationDesktopGL: - case kGLImplementationEGLGLES2: { - SetGLGetProcAddressProc( - reinterpret_cast(glfwGetProcAddress)); - SetGLImplementation(implementation); - - InitializeStaticGLBindingsGL(); - break; - } - case kGLImplementationMockGL: { - SetGLImplementation(kGLImplementationMockGL); - InitializeStaticGLBindingsGL(); - break; - } - default: - return false; - } - - return true; -} - -bool InitializeDynamicGLBindings(GLImplementation implementation, - GLContext* context) { - switch (implementation) { - case kGLImplementationOSMesaGL: - case kGLImplementationDesktopGL: - case kGLImplementationEGLGLES2: - InitializeDynamicGLBindingsGL(context); - break; - case kGLImplementationMockGL: - if (!context) { - scoped_refptr mock_context( - new GLContextStubWithExtensions()); - mock_context->SetGLVersionString("3.0"); - InitializeDynamicGLBindingsGL(mock_context.get()); - } else - InitializeDynamicGLBindingsGL(context); - break; - default: - return false; - } - - return true; -} - -void InitializeDebugGLBindings() { - InitializeDebugGLBindingsGL(); -} - -void ClearGLBindings() { - ClearGLBindingsGL(); - SetGLImplementation(kGLImplementationNone); - - UnloadGLNativeLibraries(); -} - -bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { - return false; -} - -} // namespace gfx diff --git a/ui/gl/gl_implementation_ios.cc b/ui/gl/gl_implementation_ios.cc deleted file mode 100644 index 4b4ac60ef..000000000 --- a/ui/gl/gl_implementation_ios.cc +++ /dev/null @@ -1,81 +0,0 @@ -// 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/base_paths.h" -#include "base/command_line.h" -#include "base/files/file_path.h" -#include "base/logging.h" -#include "base/native_library.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_gl_api_implementation.h" -#include "ui/gl/gl_implementation.h" -#include - -namespace gfx { - -static const char* OpenGLESFrameworkPath = - "/System/Library/Frameworks/OpenGLES.framework/OpenGLES"; - -static void* OpenGLESLibraryHandle(void) { - static void* library_handle = NULL; - if (library_handle == NULL) { - library_handle = dlopen(OpenGLESFrameworkPath, RTLD_NOW); - } - DCHECK(library_handle); - return library_handle; -} - -static void* OpenGLESGetProcAddress(const char* name) { - return dlsym(OpenGLESLibraryHandle(), name); -} - -void GetAllowedGLImplementations(std::vector* impls) { - impls->push_back(kGLImplementationAppleGL); -} - -bool InitializeStaticGLBindings(GLImplementation implementation) { - DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); - - switch (implementation) { - case kGLImplementationAppleGL: - SetGLGetProcAddressProc(&OpenGLESGetProcAddress); - SetGLImplementation(kGLImplementationAppleGL); - InitializeStaticGLBindingsGL(); - - return true; - default: - NOTIMPLEMENTED() << "InitializeStaticGLBindings on iOS"; - return false; - } - - return false; -} - -bool InitializeDynamicGLBindings(GLImplementation implementation, - GLContext* context) { - switch (implementation) { - case kGLImplementationAppleGL: - InitializeDynamicGLBindingsGL(context); - break; - default: - NOTREACHED() << "InitializeDynamicGLBindings on iOS"; - return false; - } - return true; -} - -void InitializeDebugGLBindings() { - DCHECK(false); -} - -void ClearGLBindings() { - DCHECK(false); -} - -bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { - DCHECK(false); - return false; -} - -} // namespace gfx diff --git a/ui/gl/gl_implementation_mac.cc b/ui/gl/gl_implementation_mac.cc deleted file mode 100644 index ae26dff2b..000000000 --- a/ui/gl/gl_implementation_mac.cc +++ /dev/null @@ -1,144 +0,0 @@ -// 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/base_paths.h" -#include "base/command_line.h" -#include "base/files/file_path.h" -#include "base/logging.h" -#include "base/mac/foundation_util.h" -#include "base/native_library.h" -#include "base/path_service.h" -#include "base/threading/thread_restrictions.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_context_stub_with_extensions.h" -#include "ui/gl/gl_gl_api_implementation.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_osmesa_api_implementation.h" - -namespace gfx { -namespace { -const char kOpenGLFrameworkPath[] = - "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL"; -} // namespace - -void GetAllowedGLImplementations(std::vector* impls) { - impls->push_back(kGLImplementationDesktopGL); - impls->push_back(kGLImplementationAppleGL); - impls->push_back(kGLImplementationOSMesaGL); -} - -bool InitializeStaticGLBindings(GLImplementation implementation) { - // Prevent reinitialization with a different implementation. Once the gpu - // unit tests have initialized with kGLImplementationMock, we don't want to - // later switch to another GL implementation. - DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); - - switch (implementation) { - case kGLImplementationOSMesaGL: { - // osmesa.so is located in the build directory. This code path is only - // valid in a developer build environment. - base::FilePath exe_path; - if (!PathService::Get(base::FILE_EXE, &exe_path)) { - LOG(ERROR) << "PathService::Get failed."; - return false; - } - base::FilePath bundle_path = base::mac::GetAppBundlePath(exe_path); - // Some unit test targets depend on osmesa but aren't built as app - // bundles. In that case, the .so is next to the executable. - if (bundle_path.empty()) - bundle_path = exe_path; - base::FilePath build_dir_path = bundle_path.DirName(); - base::FilePath osmesa_path = build_dir_path.Append("osmesa.so"); - - // When using OSMesa, just use OSMesaGetProcAddress to find entry points. - base::NativeLibrary library = base::LoadNativeLibrary(osmesa_path, NULL); - if (!library) { - LOG(ERROR) << "osmesa.so not found at " << osmesa_path.value(); - return false; - } - - GLGetProcAddressProc get_proc_address = - reinterpret_cast( - base::GetFunctionPointerFromNativeLibrary( - library, "OSMesaGetProcAddress")); - if (!get_proc_address) { - LOG(ERROR) << "OSMesaGetProcAddress not found."; - base::UnloadNativeLibrary(library); - return false; - } - - SetGLGetProcAddressProc(get_proc_address); - AddGLNativeLibrary(library); - SetGLImplementation(kGLImplementationOSMesaGL); - - InitializeStaticGLBindingsGL(); - break; - } - case kGLImplementationDesktopGL: - case kGLImplementationAppleGL: { - base::NativeLibrary library = base::LoadNativeLibrary( - base::FilePath(kOpenGLFrameworkPath), NULL); - if (!library) { - LOG(ERROR) << "OpenGL framework not found"; - return false; - } - - AddGLNativeLibrary(library); - SetGLImplementation(implementation); - - InitializeStaticGLBindingsGL(); - break; - } - case kGLImplementationMockGL: { - SetGLImplementation(kGLImplementationMockGL); - InitializeStaticGLBindingsGL(); - break; - } - default: - return false; - } - - return true; -} - -bool InitializeDynamicGLBindings(GLImplementation implementation, - GLContext* context) { - switch (implementation) { - case kGLImplementationOSMesaGL: - case kGLImplementationDesktopGL: - case kGLImplementationAppleGL: - InitializeDynamicGLBindingsGL(context); - break; - case kGLImplementationMockGL: - if (!context) { - scoped_refptr mock_context( - new GLContextStubWithExtensions()); - mock_context->SetGLVersionString("3.0"); - InitializeDynamicGLBindingsGL(mock_context.get()); - } else - InitializeDynamicGLBindingsGL(context); - break; - default: - return false; - } - - return true; -} - -void InitializeDebugGLBindings() { - InitializeDebugGLBindingsGL(); -} - -void ClearGLBindings() { - ClearGLBindingsGL(); - SetGLImplementation(kGLImplementationNone); - - UnloadGLNativeLibraries(); -} - -bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { - return false; -} - -} // namespace gfx diff --git a/ui/gl/gl_implementation_osmesa.cc b/ui/gl/gl_implementation_osmesa.cc deleted file mode 100644 index f3c84fe10..000000000 --- a/ui/gl/gl_implementation_osmesa.cc +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2014 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 "ui/gl/gl_implementation_osmesa.h" - -#include "base/files/file_path.h" -#include "base/logging.h" -#include "base/native_library.h" -#include "base/path_service.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_gl_api_implementation.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_osmesa_api_implementation.h" - -namespace gfx { - -#if defined(OS_LINUX) && !defined(USE_GLFW) -// On Linux, we always use the OSMesa implementation of GL so we hardcode these -// functions here. - -void GetAllowedGLImplementations(std::vector* impls) { - impls->push_back(kGLImplementationOSMesaGL); -} -bool InitializeDynamicGLBindings(GLImplementation implementation, - GLContext* context) { - DCHECK_EQ(implementation, kGLImplementationOSMesaGL); - InitializeDynamicGLBindingsGL(context); - return true; -} - -bool InitializeStaticGLBindings(GLImplementation implementation) { - DCHECK_EQ(implementation, kGLImplementationOSMesaGL); - - return InitializeStaticGLBindingsOSMesaGL(); -} - -void InitializeDebugGLBindings() { - InitializeDebugGLBindingsOSMESA(); -} - -void ClearGLBindings() { - ClearGLBindingsOSMESA(); - SetGLImplementation(kGLImplementationNone); - UnloadGLNativeLibraries(); -} -#endif - -base::NativeLibrary LoadLibraryAndPrintError(const base::FilePath& filename) { - base::NativeLibraryLoadError error; - base::NativeLibrary library = base::LoadNativeLibrary(filename, &error); - if (!library) { - LOG(ERROR) << "Failed to load " << filename.MaybeAsASCII() << ": " - << error.ToString(); - return NULL; - } - return library; -} - -base::NativeLibrary LoadLibraryAndPrintError(const char* filename) { - return LoadLibraryAndPrintError(base::FilePath(filename)); -} - -bool InitializeStaticGLBindingsOSMesaGL() { - base::FilePath module_path; - if (!PathService::Get(base::DIR_MODULE, &module_path)) { - LOG(ERROR) << "PathService::Get failed."; - return false; - } - - base::FilePath library_path = module_path.Append("libosmesa.so"); - base::NativeLibrary library = LoadLibraryAndPrintError(library_path); - if (!library) - return false; - - GLGetProcAddressProc get_proc_address = - reinterpret_cast( - base::GetFunctionPointerFromNativeLibrary(library, - "OSMesaGetProcAddress")); - if (!get_proc_address) { - LOG(ERROR) << "OSMesaGetProcAddress not found."; - base::UnloadNativeLibrary(library); - return false; - } - - SetGLGetProcAddressProc(get_proc_address); - AddGLNativeLibrary(library); - SetGLImplementation(kGLImplementationOSMesaGL); - - InitializeStaticGLBindingsGL(); - InitializeStaticGLBindingsOSMESA(); - return true; -} - -} // namespace gfx diff --git a/ui/gl/gl_implementation_osmesa.h b/ui/gl/gl_implementation_osmesa.h deleted file mode 100644 index 595c24edc..000000000 --- a/ui/gl/gl_implementation_osmesa.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 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 UI_GL_GL_IMPLEMENTATION_OSMESA_ -#define UI_GL_GL_IMPLEMENTATION_OSMESA_ - -#include "base/files/file_path.h" -#include "base/native_library.h" - -namespace gfx { - -bool InitializeStaticGLBindingsOSMesaGL(); -base::NativeLibrary LoadLibraryAndPrintError(const char* filename); -base::NativeLibrary LoadLibraryAndPrintError(const base::FilePath& filename); - -} // namespace gfx - -#endif // UI_GL_GL_IMPLEMENTATION_OSMESA_ diff --git a/ui/gl/gl_mock_autogen_gl.h b/ui/gl/gl_mock_autogen_gl.h deleted file mode 100644 index ff951d8e1..000000000 --- a/ui/gl/gl_mock_autogen_gl.h +++ /dev/null @@ -1,744 +0,0 @@ -// Copyright 2014 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 is auto-generated from -// ui/gl/generate_bindings.py -// It's formatted by clang-format using chromium coding style: -// clang-format -i -style=chromium filename -// DO NOT EDIT! - -MOCK_METHOD1(ActiveTexture, void(GLenum texture)); -MOCK_METHOD2(AttachShader, void(GLuint program, GLuint shader)); -MOCK_METHOD2(BeginQuery, void(GLenum target, GLuint id)); -MOCK_METHOD1(BeginTransformFeedback, void(GLenum primitiveMode)); -MOCK_METHOD3(BindAttribLocation, - void(GLuint program, GLuint index, const char* name)); -MOCK_METHOD2(BindBuffer, void(GLenum target, GLuint buffer)); -MOCK_METHOD3(BindBufferBase, void(GLenum target, GLuint index, GLuint buffer)); -MOCK_METHOD5(BindBufferRange, - void(GLenum target, - GLuint index, - GLuint buffer, - GLintptr offset, - GLsizeiptr size)); -MOCK_METHOD3(BindFragDataLocation, - void(GLuint program, GLuint colorNumber, const char* name)); -MOCK_METHOD4( - BindFragDataLocationIndexed, - void(GLuint program, GLuint colorNumber, GLuint index, const char* name)); -MOCK_METHOD2(BindFramebufferEXT, void(GLenum target, GLuint framebuffer)); -MOCK_METHOD2(BindRenderbufferEXT, void(GLenum target, GLuint renderbuffer)); -MOCK_METHOD2(BindSampler, void(GLuint unit, GLuint sampler)); -MOCK_METHOD2(BindTexture, void(GLenum target, GLuint texture)); -MOCK_METHOD2(BindTransformFeedback, void(GLenum target, GLuint id)); -MOCK_METHOD1(BindVertexArrayOES, void(GLuint array)); -MOCK_METHOD0(BlendBarrierKHR, void()); -MOCK_METHOD4(BlendColor, - void(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)); -MOCK_METHOD1(BlendEquation, void(GLenum mode)); -MOCK_METHOD2(BlendEquationSeparate, void(GLenum modeRGB, GLenum modeAlpha)); -MOCK_METHOD2(BlendFunc, void(GLenum sfactor, GLenum dfactor)); -MOCK_METHOD4( - BlendFuncSeparate, - void(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)); -MOCK_METHOD10(BlitFramebuffer, - void(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter)); -MOCK_METHOD10(BlitFramebufferANGLE, - void(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter)); -MOCK_METHOD10(BlitFramebufferEXT, - void(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter)); -MOCK_METHOD4( - BufferData, - void(GLenum target, GLsizeiptr size, const void* data, GLenum usage)); -MOCK_METHOD4( - BufferSubData, - void(GLenum target, GLintptr offset, GLsizeiptr size, const void* data)); -MOCK_METHOD1(CheckFramebufferStatusEXT, GLenum(GLenum target)); -MOCK_METHOD1(Clear, void(GLbitfield mask)); -MOCK_METHOD4( - ClearBufferfi, - void(GLenum buffer, GLint drawbuffer, const GLfloat depth, GLint stencil)); -MOCK_METHOD3(ClearBufferfv, - void(GLenum buffer, GLint drawbuffer, const GLfloat* value)); -MOCK_METHOD3(ClearBufferiv, - void(GLenum buffer, GLint drawbuffer, const GLint* value)); -MOCK_METHOD3(ClearBufferuiv, - void(GLenum buffer, GLint drawbuffer, const GLuint* value)); -MOCK_METHOD4(ClearColor, - void(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)); -MOCK_METHOD1(ClearDepth, void(GLclampd depth)); -MOCK_METHOD1(ClearDepthf, void(GLclampf depth)); -MOCK_METHOD1(ClearStencil, void(GLint s)); -MOCK_METHOD3(ClientWaitSync, - GLenum(GLsync sync, GLbitfield flags, GLuint64 timeout)); -MOCK_METHOD4( - ColorMask, - void(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)); -MOCK_METHOD1(CompileShader, void(GLuint shader)); -MOCK_METHOD8(CompressedTexImage2D, - void(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const void* data)); -MOCK_METHOD9(CompressedTexImage3D, - void(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLsizei imageSize, - const void* data)); -MOCK_METHOD9(CompressedTexSubImage2D, - void(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const void* data)); -MOCK_METHOD5(CopyBufferSubData, - void(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size)); -MOCK_METHOD8(CopyTexImage2D, - void(GLenum target, - GLint level, - GLenum internalformat, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLint border)); -MOCK_METHOD8(CopyTexSubImage2D, - void(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height)); -MOCK_METHOD9(CopyTexSubImage3D, - void(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height)); -MOCK_METHOD0(CreateProgram, GLuint()); -MOCK_METHOD1(CreateShader, GLuint(GLenum type)); -MOCK_METHOD1(CullFace, void(GLenum mode)); -MOCK_METHOD2(DebugMessageCallbackKHR, - void(GLDEBUGPROCKHR callback, const void* userparam)); -MOCK_METHOD6(DebugMessageControlKHR, - void(GLenum source, - GLenum type, - GLenum severity, - GLsizei count, - const GLuint* ids, - GLboolean enabled)); -MOCK_METHOD6(DebugMessageInsertKHR, - void(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar* buf)); -MOCK_METHOD2(DeleteBuffersARB, void(GLsizei n, const GLuint* buffers)); -MOCK_METHOD2(DeleteFencesAPPLE, void(GLsizei n, const GLuint* fences)); -MOCK_METHOD2(DeleteFencesNV, void(GLsizei n, const GLuint* fences)); -MOCK_METHOD2(DeleteFramebuffersEXT, - void(GLsizei n, const GLuint* framebuffers)); -MOCK_METHOD1(DeleteProgram, void(GLuint program)); -MOCK_METHOD2(DeleteQueries, void(GLsizei n, const GLuint* ids)); -MOCK_METHOD2(DeleteRenderbuffersEXT, - void(GLsizei n, const GLuint* renderbuffers)); -MOCK_METHOD2(DeleteSamplers, void(GLsizei n, const GLuint* samplers)); -MOCK_METHOD1(DeleteShader, void(GLuint shader)); -MOCK_METHOD1(DeleteSync, void(GLsync sync)); -MOCK_METHOD2(DeleteTextures, void(GLsizei n, const GLuint* textures)); -MOCK_METHOD2(DeleteTransformFeedbacks, void(GLsizei n, const GLuint* ids)); -MOCK_METHOD2(DeleteVertexArraysOES, void(GLsizei n, const GLuint* arrays)); -MOCK_METHOD1(DepthFunc, void(GLenum func)); -MOCK_METHOD1(DepthMask, void(GLboolean flag)); -MOCK_METHOD2(DepthRange, void(GLclampd zNear, GLclampd zFar)); -MOCK_METHOD2(DepthRangef, void(GLclampf zNear, GLclampf zFar)); -MOCK_METHOD2(DetachShader, void(GLuint program, GLuint shader)); -MOCK_METHOD1(Disable, void(GLenum cap)); -MOCK_METHOD1(DisableVertexAttribArray, void(GLuint index)); -MOCK_METHOD3(DiscardFramebufferEXT, - void(GLenum target, - GLsizei numAttachments, - const GLenum* attachments)); -MOCK_METHOD3(DrawArrays, void(GLenum mode, GLint first, GLsizei count)); -MOCK_METHOD4(DrawArraysInstancedANGLE, - void(GLenum mode, GLint first, GLsizei count, GLsizei primcount)); -MOCK_METHOD1(DrawBuffer, void(GLenum mode)); -MOCK_METHOD2(DrawBuffersARB, void(GLsizei n, const GLenum* bufs)); -MOCK_METHOD4( - DrawElements, - void(GLenum mode, GLsizei count, GLenum type, const void* indices)); -MOCK_METHOD5(DrawElementsInstancedANGLE, - void(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei primcount)); -MOCK_METHOD6(DrawRangeElements, - void(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices)); -MOCK_METHOD2(EGLImageTargetRenderbufferStorageOES, - void(GLenum target, GLeglImageOES image)); -MOCK_METHOD2(EGLImageTargetTexture2DOES, - void(GLenum target, GLeglImageOES image)); -MOCK_METHOD1(Enable, void(GLenum cap)); -MOCK_METHOD1(EnableVertexAttribArray, void(GLuint index)); -MOCK_METHOD1(EndQuery, void(GLenum target)); -MOCK_METHOD0(EndTransformFeedback, void()); -MOCK_METHOD2(FenceSync, GLsync(GLenum condition, GLbitfield flags)); -MOCK_METHOD0(Finish, void()); -MOCK_METHOD1(FinishFenceAPPLE, void(GLuint fence)); -MOCK_METHOD1(FinishFenceNV, void(GLuint fence)); -MOCK_METHOD0(Flush, void()); -MOCK_METHOD3(FlushMappedBufferRange, - void(GLenum target, GLintptr offset, GLsizeiptr length)); -MOCK_METHOD4(FramebufferRenderbufferEXT, - void(GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer)); -MOCK_METHOD5(FramebufferTexture2DEXT, - void(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level)); -MOCK_METHOD6(FramebufferTexture2DMultisampleEXT, - void(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples)); -MOCK_METHOD6(FramebufferTexture2DMultisampleIMG, - void(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples)); -MOCK_METHOD5(FramebufferTextureLayer, - void(GLenum target, - GLenum attachment, - GLuint texture, - GLint level, - GLint layer)); -MOCK_METHOD1(FrontFace, void(GLenum mode)); -MOCK_METHOD2(GenBuffersARB, void(GLsizei n, GLuint* buffers)); -MOCK_METHOD1(GenerateMipmapEXT, void(GLenum target)); -MOCK_METHOD2(GenFencesAPPLE, void(GLsizei n, GLuint* fences)); -MOCK_METHOD2(GenFencesNV, void(GLsizei n, GLuint* fences)); -MOCK_METHOD2(GenFramebuffersEXT, void(GLsizei n, GLuint* framebuffers)); -MOCK_METHOD2(GenQueries, void(GLsizei n, GLuint* ids)); -MOCK_METHOD2(GenRenderbuffersEXT, void(GLsizei n, GLuint* renderbuffers)); -MOCK_METHOD2(GenSamplers, void(GLsizei n, GLuint* samplers)); -MOCK_METHOD2(GenTextures, void(GLsizei n, GLuint* textures)); -MOCK_METHOD2(GenTransformFeedbacks, void(GLsizei n, GLuint* ids)); -MOCK_METHOD2(GenVertexArraysOES, void(GLsizei n, GLuint* arrays)); -MOCK_METHOD7(GetActiveAttrib, - void(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - char* name)); -MOCK_METHOD7(GetActiveUniform, - void(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - char* name)); -MOCK_METHOD4(GetActiveUniformBlockiv, - void(GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint* params)); -MOCK_METHOD5(GetActiveUniformBlockName, - void(GLuint program, - GLuint uniformBlockIndex, - GLsizei bufSize, - GLsizei* length, - char* uniformBlockName)); -MOCK_METHOD5(GetActiveUniformsiv, - void(GLuint program, - GLsizei uniformCount, - const GLuint* uniformIndices, - GLenum pname, - GLint* params)); -MOCK_METHOD4( - GetAttachedShaders, - void(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)); -MOCK_METHOD2(GetAttribLocation, GLint(GLuint program, const char* name)); -MOCK_METHOD2(GetBooleanv, void(GLenum pname, GLboolean* params)); -MOCK_METHOD3(GetBufferParameteriv, - void(GLenum target, GLenum pname, GLint* params)); -MOCK_METHOD8(GetDebugMessageLogKHR, - GLuint(GLuint count, - GLsizei bufSize, - GLenum* sources, - GLenum* types, - GLuint* ids, - GLenum* severities, - GLsizei* lengths, - GLchar* messageLog)); -MOCK_METHOD0(GetError, GLenum()); -MOCK_METHOD3(GetFenceivNV, void(GLuint fence, GLenum pname, GLint* params)); -MOCK_METHOD2(GetFloatv, void(GLenum pname, GLfloat* params)); -MOCK_METHOD2(GetFragDataLocation, GLint(GLuint program, const char* name)); -MOCK_METHOD4( - GetFramebufferAttachmentParameterivEXT, - void(GLenum target, GLenum attachment, GLenum pname, GLint* params)); -MOCK_METHOD0(GetGraphicsResetStatusARB, GLenum()); -MOCK_METHOD3(GetInteger64i_v, void(GLenum target, GLuint index, GLint64* data)); -MOCK_METHOD2(GetInteger64v, void(GLenum pname, GLint64* params)); -MOCK_METHOD3(GetIntegeri_v, void(GLenum target, GLuint index, GLint* data)); -MOCK_METHOD2(GetIntegerv, void(GLenum pname, GLint* params)); -MOCK_METHOD5(GetInternalformativ, - void(GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLint* params)); -MOCK_METHOD5(GetProgramBinary, - void(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - GLvoid* binary)); -MOCK_METHOD4( - GetProgramInfoLog, - void(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)); -MOCK_METHOD3(GetProgramiv, void(GLuint program, GLenum pname, GLint* params)); -MOCK_METHOD3(GetProgramResourceLocation, - GLint(GLuint program, GLenum programInterface, const char* name)); -MOCK_METHOD3(GetQueryiv, void(GLenum target, GLenum pname, GLint* params)); -MOCK_METHOD3(GetQueryObjecti64v, - void(GLuint id, GLenum pname, GLint64* params)); -MOCK_METHOD3(GetQueryObjectiv, void(GLuint id, GLenum pname, GLint* params)); -MOCK_METHOD3(GetQueryObjectui64v, - void(GLuint id, GLenum pname, GLuint64* params)); -MOCK_METHOD3(GetQueryObjectuiv, void(GLuint id, GLenum pname, GLuint* params)); -MOCK_METHOD3(GetRenderbufferParameterivEXT, - void(GLenum target, GLenum pname, GLint* params)); -MOCK_METHOD3(GetSamplerParameterfv, - void(GLuint sampler, GLenum pname, GLfloat* params)); -MOCK_METHOD3(GetSamplerParameteriv, - void(GLuint sampler, GLenum pname, GLint* params)); -MOCK_METHOD4( - GetShaderInfoLog, - void(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)); -MOCK_METHOD3(GetShaderiv, void(GLuint shader, GLenum pname, GLint* params)); -MOCK_METHOD4(GetShaderPrecisionFormat, - void(GLenum shadertype, - GLenum precisiontype, - GLint* range, - GLint* precision)); -MOCK_METHOD4( - GetShaderSource, - void(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)); -MOCK_METHOD1(GetString, const GLubyte*(GLenum name)); -MOCK_METHOD2(GetStringi, const GLubyte*(GLenum name, GLuint index)); -MOCK_METHOD5(GetSynciv, - void(GLsync sync, - GLenum pname, - GLsizei bufSize, - GLsizei* length, - GLint* values)); -MOCK_METHOD4(GetTexLevelParameterfv, - void(GLenum target, GLint level, GLenum pname, GLfloat* params)); -MOCK_METHOD4(GetTexLevelParameteriv, - void(GLenum target, GLint level, GLenum pname, GLint* params)); -MOCK_METHOD3(GetTexParameterfv, - void(GLenum target, GLenum pname, GLfloat* params)); -MOCK_METHOD3(GetTexParameteriv, - void(GLenum target, GLenum pname, GLint* params)); -MOCK_METHOD7(GetTransformFeedbackVarying, - void(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLsizei* size, - GLenum* type, - char* name)); -MOCK_METHOD4( - GetTranslatedShaderSourceANGLE, - void(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)); -MOCK_METHOD2(GetUniformBlockIndex, - GLuint(GLuint program, const char* uniformBlockName)); -MOCK_METHOD3(GetUniformfv, - void(GLuint program, GLint location, GLfloat* params)); -MOCK_METHOD4(GetUniformIndices, - void(GLuint program, - GLsizei uniformCount, - const char* const* uniformNames, - GLuint* uniformIndices)); -MOCK_METHOD3(GetUniformiv, void(GLuint program, GLint location, GLint* params)); -MOCK_METHOD2(GetUniformLocation, GLint(GLuint program, const char* name)); -MOCK_METHOD3(GetVertexAttribfv, - void(GLuint index, GLenum pname, GLfloat* params)); -MOCK_METHOD3(GetVertexAttribiv, - void(GLuint index, GLenum pname, GLint* params)); -MOCK_METHOD3(GetVertexAttribPointerv, - void(GLuint index, GLenum pname, void** pointer)); -MOCK_METHOD2(Hint, void(GLenum target, GLenum mode)); -MOCK_METHOD2(InsertEventMarkerEXT, void(GLsizei length, const char* marker)); -MOCK_METHOD3(InvalidateFramebuffer, - void(GLenum target, - GLsizei numAttachments, - const GLenum* attachments)); -MOCK_METHOD7(InvalidateSubFramebuffer, - void(GLenum target, - GLsizei numAttachments, - const GLenum* attachments, - GLint x, - GLint y, - GLint width, - GLint height)); -MOCK_METHOD1(IsBuffer, GLboolean(GLuint buffer)); -MOCK_METHOD1(IsEnabled, GLboolean(GLenum cap)); -MOCK_METHOD1(IsFenceAPPLE, GLboolean(GLuint fence)); -MOCK_METHOD1(IsFenceNV, GLboolean(GLuint fence)); -MOCK_METHOD1(IsFramebufferEXT, GLboolean(GLuint framebuffer)); -MOCK_METHOD1(IsProgram, GLboolean(GLuint program)); -MOCK_METHOD1(IsQuery, GLboolean(GLuint query)); -MOCK_METHOD1(IsRenderbufferEXT, GLboolean(GLuint renderbuffer)); -MOCK_METHOD1(IsSampler, GLboolean(GLuint sampler)); -MOCK_METHOD1(IsShader, GLboolean(GLuint shader)); -MOCK_METHOD1(IsSync, GLboolean(GLsync sync)); -MOCK_METHOD1(IsTexture, GLboolean(GLuint texture)); -MOCK_METHOD1(IsTransformFeedback, GLboolean(GLuint id)); -MOCK_METHOD1(IsVertexArrayOES, GLboolean(GLuint array)); -MOCK_METHOD1(LineWidth, void(GLfloat width)); -MOCK_METHOD1(LinkProgram, void(GLuint program)); -MOCK_METHOD2(MapBuffer, void*(GLenum target, GLenum access)); -MOCK_METHOD4(MapBufferRange, - void*(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access)); -MOCK_METHOD2(MatrixLoadfEXT, void(GLenum matrixMode, const GLfloat* m)); -MOCK_METHOD1(MatrixLoadIdentityEXT, void(GLenum matrixMode)); -MOCK_METHOD4( - ObjectLabelKHR, - void(GLenum identifier, GLuint name, GLsizei length, const GLchar* label)); -MOCK_METHOD0(PauseTransformFeedback, void()); -MOCK_METHOD2(PixelStorei, void(GLenum pname, GLint param)); -MOCK_METHOD2(PointParameteri, void(GLenum pname, GLint param)); -MOCK_METHOD2(PolygonOffset, void(GLfloat factor, GLfloat units)); -MOCK_METHOD0(PopDebugGroupKHR, void()); -MOCK_METHOD0(PopGroupMarkerEXT, void()); -MOCK_METHOD4(ProgramBinary, - void(GLuint program, - GLenum binaryFormat, - const GLvoid* binary, - GLsizei length)); -MOCK_METHOD3(ProgramParameteri, - void(GLuint program, GLenum pname, GLint value)); -MOCK_METHOD4( - PushDebugGroupKHR, - void(GLenum source, GLuint id, GLsizei length, const GLchar* message)); -MOCK_METHOD2(PushGroupMarkerEXT, void(GLsizei length, const char* marker)); -MOCK_METHOD2(QueryCounter, void(GLuint id, GLenum target)); -MOCK_METHOD1(ReadBuffer, void(GLenum src)); -MOCK_METHOD7(ReadPixels, - void(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - void* pixels)); -MOCK_METHOD0(ReleaseShaderCompiler, void()); -MOCK_METHOD4( - RenderbufferStorageEXT, - void(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)); -MOCK_METHOD5(RenderbufferStorageMultisample, - void(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height)); -MOCK_METHOD5(RenderbufferStorageMultisampleANGLE, - void(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height)); -MOCK_METHOD5(RenderbufferStorageMultisampleAPPLE, - void(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height)); -MOCK_METHOD5(RenderbufferStorageMultisampleEXT, - void(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height)); -MOCK_METHOD5(RenderbufferStorageMultisampleIMG, - void(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height)); -MOCK_METHOD0(ResolveMultisampleFramebufferAPPLE, void()); -MOCK_METHOD0(ResumeTransformFeedback, void()); -MOCK_METHOD2(SampleCoverage, void(GLclampf value, GLboolean invert)); -MOCK_METHOD3(SamplerParameterf, - void(GLuint sampler, GLenum pname, GLfloat param)); -MOCK_METHOD3(SamplerParameterfv, - void(GLuint sampler, GLenum pname, const GLfloat* params)); -MOCK_METHOD3(SamplerParameteri, - void(GLuint sampler, GLenum pname, GLint param)); -MOCK_METHOD3(SamplerParameteriv, - void(GLuint sampler, GLenum pname, const GLint* params)); -MOCK_METHOD4(Scissor, void(GLint x, GLint y, GLsizei width, GLsizei height)); -MOCK_METHOD1(SetFenceAPPLE, void(GLuint fence)); -MOCK_METHOD2(SetFenceNV, void(GLuint fence, GLenum condition)); -MOCK_METHOD5(ShaderBinary, - void(GLsizei n, - const GLuint* shaders, - GLenum binaryformat, - const void* binary, - GLsizei length)); -MOCK_METHOD4(ShaderSource, - void(GLuint shader, - GLsizei count, - const char* const* str, - const GLint* length)); -MOCK_METHOD3(StencilFunc, void(GLenum func, GLint ref, GLuint mask)); -MOCK_METHOD4(StencilFuncSeparate, - void(GLenum face, GLenum func, GLint ref, GLuint mask)); -MOCK_METHOD1(StencilMask, void(GLuint mask)); -MOCK_METHOD2(StencilMaskSeparate, void(GLenum face, GLuint mask)); -MOCK_METHOD3(StencilOp, void(GLenum fail, GLenum zfail, GLenum zpass)); -MOCK_METHOD4(StencilOpSeparate, - void(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)); -MOCK_METHOD1(TestFenceAPPLE, GLboolean(GLuint fence)); -MOCK_METHOD1(TestFenceNV, GLboolean(GLuint fence)); -MOCK_METHOD9(TexImage2D, - void(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const void* pixels)); -MOCK_METHOD10(TexImage3D, - void(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - const void* pixels)); -MOCK_METHOD3(TexParameterf, void(GLenum target, GLenum pname, GLfloat param)); -MOCK_METHOD3(TexParameterfv, - void(GLenum target, GLenum pname, const GLfloat* params)); -MOCK_METHOD3(TexParameteri, void(GLenum target, GLenum pname, GLint param)); -MOCK_METHOD3(TexParameteriv, - void(GLenum target, GLenum pname, const GLint* params)); -MOCK_METHOD5(TexStorage2DEXT, - void(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height)); -MOCK_METHOD6(TexStorage3D, - void(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth)); -MOCK_METHOD9(TexSubImage2D, - void(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const void* pixels)); -MOCK_METHOD0(TextureBarrierNV, void()); -MOCK_METHOD4(TransformFeedbackVaryings, - void(GLuint program, - GLsizei count, - const char* const* varyings, - GLenum bufferMode)); -MOCK_METHOD2(Uniform1f, void(GLint location, GLfloat x)); -MOCK_METHOD3(Uniform1fv, void(GLint location, GLsizei count, const GLfloat* v)); -MOCK_METHOD2(Uniform1i, void(GLint location, GLint x)); -MOCK_METHOD3(Uniform1iv, void(GLint location, GLsizei count, const GLint* v)); -MOCK_METHOD2(Uniform1ui, void(GLint location, GLuint v0)); -MOCK_METHOD3(Uniform1uiv, void(GLint location, GLsizei count, const GLuint* v)); -MOCK_METHOD3(Uniform2f, void(GLint location, GLfloat x, GLfloat y)); -MOCK_METHOD3(Uniform2fv, void(GLint location, GLsizei count, const GLfloat* v)); -MOCK_METHOD3(Uniform2i, void(GLint location, GLint x, GLint y)); -MOCK_METHOD3(Uniform2iv, void(GLint location, GLsizei count, const GLint* v)); -MOCK_METHOD3(Uniform2ui, void(GLint location, GLuint v0, GLuint v1)); -MOCK_METHOD3(Uniform2uiv, void(GLint location, GLsizei count, const GLuint* v)); -MOCK_METHOD4(Uniform3f, void(GLint location, GLfloat x, GLfloat y, GLfloat z)); -MOCK_METHOD3(Uniform3fv, void(GLint location, GLsizei count, const GLfloat* v)); -MOCK_METHOD4(Uniform3i, void(GLint location, GLint x, GLint y, GLint z)); -MOCK_METHOD3(Uniform3iv, void(GLint location, GLsizei count, const GLint* v)); -MOCK_METHOD4(Uniform3ui, void(GLint location, GLuint v0, GLuint v1, GLuint v2)); -MOCK_METHOD3(Uniform3uiv, void(GLint location, GLsizei count, const GLuint* v)); -MOCK_METHOD5(Uniform4f, - void(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)); -MOCK_METHOD3(Uniform4fv, void(GLint location, GLsizei count, const GLfloat* v)); -MOCK_METHOD5(Uniform4i, - void(GLint location, GLint x, GLint y, GLint z, GLint w)); -MOCK_METHOD3(Uniform4iv, void(GLint location, GLsizei count, const GLint* v)); -MOCK_METHOD5(Uniform4ui, - void(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)); -MOCK_METHOD3(Uniform4uiv, void(GLint location, GLsizei count, const GLuint* v)); -MOCK_METHOD3(UniformBlockBinding, - void(GLuint program, - GLuint uniformBlockIndex, - GLuint uniformBlockBinding)); -MOCK_METHOD4(UniformMatrix2fv, - void(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value)); -MOCK_METHOD4(UniformMatrix2x3fv, - void(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value)); -MOCK_METHOD4(UniformMatrix2x4fv, - void(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value)); -MOCK_METHOD4(UniformMatrix3fv, - void(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value)); -MOCK_METHOD4(UniformMatrix3x2fv, - void(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value)); -MOCK_METHOD4(UniformMatrix3x4fv, - void(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value)); -MOCK_METHOD4(UniformMatrix4fv, - void(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value)); -MOCK_METHOD4(UniformMatrix4x2fv, - void(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value)); -MOCK_METHOD4(UniformMatrix4x3fv, - void(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value)); -MOCK_METHOD1(UnmapBuffer, GLboolean(GLenum target)); -MOCK_METHOD1(UseProgram, void(GLuint program)); -MOCK_METHOD1(ValidateProgram, void(GLuint program)); -MOCK_METHOD2(VertexAttrib1f, void(GLuint indx, GLfloat x)); -MOCK_METHOD2(VertexAttrib1fv, void(GLuint indx, const GLfloat* values)); -MOCK_METHOD3(VertexAttrib2f, void(GLuint indx, GLfloat x, GLfloat y)); -MOCK_METHOD2(VertexAttrib2fv, void(GLuint indx, const GLfloat* values)); -MOCK_METHOD4(VertexAttrib3f, - void(GLuint indx, GLfloat x, GLfloat y, GLfloat z)); -MOCK_METHOD2(VertexAttrib3fv, void(GLuint indx, const GLfloat* values)); -MOCK_METHOD5(VertexAttrib4f, - void(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)); -MOCK_METHOD2(VertexAttrib4fv, void(GLuint indx, const GLfloat* values)); -MOCK_METHOD2(VertexAttribDivisorANGLE, void(GLuint index, GLuint divisor)); -MOCK_METHOD5(VertexAttribI4i, - void(GLuint indx, GLint x, GLint y, GLint z, GLint w)); -MOCK_METHOD2(VertexAttribI4iv, void(GLuint indx, const GLint* values)); -MOCK_METHOD5(VertexAttribI4ui, - void(GLuint indx, GLuint x, GLuint y, GLuint z, GLuint w)); -MOCK_METHOD2(VertexAttribI4uiv, void(GLuint indx, const GLuint* values)); -MOCK_METHOD5(VertexAttribIPointer, - void(GLuint indx, - GLint size, - GLenum type, - GLsizei stride, - const void* ptr)); -MOCK_METHOD6(VertexAttribPointer, - void(GLuint indx, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const void* ptr)); -MOCK_METHOD4(Viewport, void(GLint x, GLint y, GLsizei width, GLsizei height)); -MOCK_METHOD3(WaitSync, GLenum(GLsync sync, GLbitfield flags, GLuint64 timeout)); diff --git a/ui/gl/gl_osmesa_api_implementation.cc b/ui/gl/gl_osmesa_api_implementation.cc deleted file mode 100644 index 4fa33c692..000000000 --- a/ui/gl/gl_osmesa_api_implementation.cc +++ /dev/null @@ -1,65 +0,0 @@ -// 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 "ui/gl/gl_osmesa_api_implementation.h" - -namespace gfx { - -RealOSMESAApi* g_real_osmesa; - -void InitializeStaticGLBindingsOSMESA() { - g_driver_osmesa.InitializeStaticBindings(); - if (!g_real_osmesa) { - g_real_osmesa = new RealOSMESAApi(); - } - g_real_osmesa->Initialize(&g_driver_osmesa); - g_current_osmesa_context = g_real_osmesa; -} - -void InitializeDebugGLBindingsOSMESA() { - g_driver_osmesa.InitializeDebugBindings(); -} - -void ClearGLBindingsOSMESA() { - if (g_real_osmesa) { - delete g_real_osmesa; - g_real_osmesa = NULL; - } - g_current_osmesa_context = NULL; - g_driver_osmesa.ClearBindings(); -} - -OSMESAApi::OSMESAApi() { -} - -OSMESAApi::~OSMESAApi() { -} - -OSMESAApiBase::OSMESAApiBase() - : driver_(NULL) { -} - -OSMESAApiBase::~OSMESAApiBase() { -} - -void OSMESAApiBase::InitializeBase(DriverOSMESA* driver) { - driver_ = driver; -} - -RealOSMESAApi::RealOSMESAApi() { -} - -RealOSMESAApi::~RealOSMESAApi() { -} - -void RealOSMESAApi::Initialize(DriverOSMESA* driver) { - InitializeBase(driver); -} - -TraceOSMESAApi::~TraceOSMESAApi() { -} - -} // namespace gfx - - diff --git a/ui/gl/gl_osmesa_api_implementation.h b/ui/gl/gl_osmesa_api_implementation.h deleted file mode 100644 index c740e1ab8..000000000 --- a/ui/gl/gl_osmesa_api_implementation.h +++ /dev/null @@ -1,62 +0,0 @@ -// 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 UI_GL_GL_OSMESA_API_IMPLEMENTATION_H_ -#define UI_GL_GL_OSMESA_API_IMPLEMENTATION_H_ - -#include "base/compiler_specific.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_export.h" - -namespace gfx { - -class GLContext; - -void InitializeStaticGLBindingsOSMESA(); -void InitializeDebugGLBindingsOSMESA(); -void ClearGLBindingsOSMESA(); - -class GL_EXPORT OSMESAApiBase : public OSMESAApi { - public: - // Include the auto-generated part of this class. We split this because - // it means we can easily edit the non-auto generated parts right here in - // this file instead of having to edit some template or the code generator. - #include "gl_bindings_api_autogen_osmesa.h" - - protected: - OSMESAApiBase(); - ~OSMESAApiBase() override; - void InitializeBase(DriverOSMESA* driver); - - DriverOSMESA* driver_; -}; - -class GL_EXPORT RealOSMESAApi : public OSMESAApiBase { - public: - RealOSMESAApi(); - ~RealOSMESAApi() override; - void Initialize(DriverOSMESA* driver); -}; - -// Inserts a TRACE for every OSMESA call. -class GL_EXPORT TraceOSMESAApi : public OSMESAApi { - public: - TraceOSMESAApi(OSMESAApi* osmesa_api) : osmesa_api_(osmesa_api) { } - ~TraceOSMESAApi() override; - - // Include the auto-generated part of this class. We split this because - // it means we can easily edit the non-auto generated parts right here in - // this file instead of having to edit some template or the code generator. - #include "gl_bindings_api_autogen_osmesa.h" - - private: - OSMESAApi* osmesa_api_; -}; - -} // namespace gfx - -#endif // UI_GL_GL_OSMESA_API_IMPLEMENTATION_H_ - - - diff --git a/ui/gl/gl_share_group.cc b/ui/gl/gl_share_group.cc deleted file mode 100644 index 0ad4a7176..000000000 --- a/ui/gl/gl_share_group.cc +++ /dev/null @@ -1,56 +0,0 @@ -// 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 "ui/gl/gl_share_group.h" - -#include "base/logging.h" -#include "ui/gl/gl_context.h" - -namespace gfx { - -GLShareGroup::GLShareGroup() : shared_context_(NULL) { -} - -void GLShareGroup::AddContext(GLContext* context) { - contexts_.insert(context); -} - -void GLShareGroup::RemoveContext(GLContext* context) { - contexts_.erase(context); - if (shared_context_ == context) - shared_context_ = NULL; -} - -void* GLShareGroup::GetHandle() { - GLContext* context = GetContext(); - if (context) - return context->GetHandle(); - - return NULL; -} - -GLContext* GLShareGroup::GetContext() { - for (ContextSet::iterator it = contexts_.begin(); - it != contexts_.end(); - ++it) { - if ((*it)->GetHandle()) - return *it; - } - - return NULL; -} - -void GLShareGroup::SetSharedContext(GLContext* context) { - DCHECK(contexts_.find(context) != contexts_.end()); - shared_context_ = context; -} - -GLContext* GLShareGroup::GetSharedContext() { - return shared_context_; -} - -GLShareGroup::~GLShareGroup() { -} - -} // namespace gfx diff --git a/ui/gl/gl_share_group.h b/ui/gl/gl_share_group.h deleted file mode 100644 index e069d657e..000000000 --- a/ui/gl/gl_share_group.h +++ /dev/null @@ -1,58 +0,0 @@ -// 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 UI_GL_GL_SHARE_GROUP_H_ -#define UI_GL_GL_SHARE_GROUP_H_ - -#include - -#include "base/basictypes.h" -#include "base/memory/ref_counted.h" -#include "ui/gl/gl_export.h" - -namespace gfx { - -class GLContext; - -// A group of GL contexts that share an ID namespace. -class GL_EXPORT GLShareGroup : public base::RefCounted { - public: - GLShareGroup(); - - // These two should only be called from the constructor and destructor of - // GLContext. - void AddContext(GLContext* context); - void RemoveContext(GLContext* context); - - // Returns a handle to any initialized context in the share group or NULL if - // there are no initialized contexts in the share group. - void* GetHandle(); - - // Returns a pointer to any initialized context in the share group - // or NULL if there are no initialized contexts in the share group. - GLContext* GetContext(); - - // Sets and returns the unique shared GL context. Used for context - // virtualization. - void SetSharedContext(GLContext* context); - GLContext* GetSharedContext(); - - private: - friend class base::RefCounted; - - ~GLShareGroup(); - - // References to GLContext are by raw pointer to avoid a reference count - // cycle. - typedef std::set ContextSet; - ContextSet contexts_; - - GLContext* shared_context_; - - DISALLOW_COPY_AND_ASSIGN(GLShareGroup); -}; - -} // namespace gfx - -#endif // UI_GL_GL_SHARE_GROUP_H_ diff --git a/ui/gl/gl_state_restorer.cc b/ui/gl/gl_state_restorer.cc deleted file mode 100644 index 8bf6f81ec..000000000 --- a/ui/gl/gl_state_restorer.cc +++ /dev/null @@ -1,16 +0,0 @@ -// 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 "ui/gl/gl_state_restorer.h" - -namespace gfx { - -GLStateRestorer::GLStateRestorer() { -} - -GLStateRestorer::~GLStateRestorer() { -} - -} // namespace gfx - diff --git a/ui/gl/gl_state_restorer.h b/ui/gl/gl_state_restorer.h deleted file mode 100644 index 7edc99891..000000000 --- a/ui/gl/gl_state_restorer.h +++ /dev/null @@ -1,31 +0,0 @@ -// 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 UI_GL_GL_STATE_RESTORER_H_ -#define UI_GL_GL_STATE_RESTORER_H_ - -#include "base/basictypes.h" -#include "ui/gl/gl_export.h" - -namespace gfx { - -// An interface for Restoring GL State. -// This will expand over time to provide an more optimizable implementation. -class GL_EXPORT GLStateRestorer { - public: - GLStateRestorer(); - virtual ~GLStateRestorer(); - - virtual bool IsInitialized() = 0; - virtual void RestoreState(const GLStateRestorer* prev_state) = 0; - virtual void RestoreAllTextureUnitBindings() = 0; - virtual void RestoreActiveTextureUnitBinding(unsigned int target) = 0; - virtual void RestoreFramebufferBindings() = 0; - - DISALLOW_COPY_AND_ASSIGN(GLStateRestorer); -}; - -} // namespace gfx - -#endif // UI_GL_GL_STATE_RESTORER_H_ diff --git a/ui/gl/gl_surface.cc b/ui/gl/gl_surface.cc deleted file mode 100644 index 007bcafc4..000000000 --- a/ui/gl/gl_surface.cc +++ /dev/null @@ -1,409 +0,0 @@ -// 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 "ui/gl/gl_surface.h" - -#include -#include - -#include "base/command_line.h" -#include "base/lazy_instance.h" -#include "base/logging.h" -#include "base/threading/thread_local.h" -#include "base/trace_event/trace_event.h" -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_switches.h" - -#if defined(USE_X11) -#include -#endif - -namespace gfx { - -namespace { -base::LazyInstance >::Leaky - current_surface_ = LAZY_INSTANCE_INITIALIZER; -} // namespace - -// static -bool GLSurface::InitializeOneOff(GLImplementation impl) { - DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); - - TRACE_EVENT0("gpu", "GLSurface::InitializeOneOff"); - - std::vector allowed_impls; - GetAllowedGLImplementations(&allowed_impls); - DCHECK(!allowed_impls.empty()); - - base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); - - // The default implementation is always the first one in list. - if (impl == kGLImplementationNone) - impl = allowed_impls[0]; - bool fallback_to_osmesa = false; - if (cmd->HasSwitch(switches::kOverrideUseGLWithOSMesaForTests)) { - impl = kGLImplementationOSMesaGL; - } else if (cmd->HasSwitch(switches::kUseGL)) { - std::string requested_implementation_name = - cmd->GetSwitchValueASCII(switches::kUseGL); - if (requested_implementation_name == "any") { - fallback_to_osmesa = true; - } else if (requested_implementation_name == "swiftshader") { - impl = kGLImplementationEGLGLES2; - } else { - impl = GetNamedGLImplementation(requested_implementation_name); - if (std::find(allowed_impls.begin(), - allowed_impls.end(), - impl) == allowed_impls.end()) { - LOG(ERROR) << "Requested GL implementation is not available."; - return false; - } - } - } - - bool gpu_service_logging = cmd->HasSwitch(switches::kEnableGPUServiceLogging); - bool disable_gl_drawing = cmd->HasSwitch(switches::kDisableGLDrawingForTests); - - return InitializeOneOffImplementation( - impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing); -} - -// static -bool GLSurface::InitializeOneOffImplementation(GLImplementation impl, - bool fallback_to_osmesa, - bool gpu_service_logging, - bool disable_gl_drawing) { - bool initialized = - InitializeStaticGLBindings(impl) && InitializeOneOffInternal(); - if (!initialized && fallback_to_osmesa) { - ClearGLBindings(); - initialized = InitializeStaticGLBindings(kGLImplementationOSMesaGL) && - InitializeOneOffInternal(); - } - if (!initialized) - ClearGLBindings(); - - if (initialized) { - DVLOG(1) << "Using " - << GetGLImplementationName(GetGLImplementation()) - << " GL implementation."; - if (gpu_service_logging) - InitializeDebugGLBindings(); - if (disable_gl_drawing) - InitializeNullDrawGLBindings(); - } - return initialized; -} - -// static -void GLSurface::InitializeOneOffForTests() { - DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); - -#if defined(USE_X11) - XInitThreads(); -#endif - - bool use_osmesa = true; - - // We usually use OSMesa as this works on all bots. The command line can - // override this behaviour to use hardware GL. - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kUseGpuInTests)) - use_osmesa = false; - -#if defined(OS_ANDROID) - // On Android we always use hardware GL. - use_osmesa = false; -#endif - - std::vector allowed_impls; - GetAllowedGLImplementations(&allowed_impls); - DCHECK(!allowed_impls.empty()); - - GLImplementation impl = allowed_impls[0]; - if (use_osmesa) - impl = kGLImplementationOSMesaGL; - - DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) - << "kUseGL has not effect in tests"; - - bool fallback_to_osmesa = false; - bool gpu_service_logging = false; - bool disable_gl_drawing = true; - - CHECK(InitializeOneOffImplementation( - impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing)); -} - -// static -void GLSurface::InitializeOneOffWithMockBindingsForTests() { - DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) - << "kUseGL has not effect in tests"; - - // This method may be called multiple times in the same process to set up - // mock bindings in different ways. - ClearGLBindings(); - - bool fallback_to_osmesa = false; - bool gpu_service_logging = false; - bool disable_gl_drawing = false; - - CHECK(InitializeOneOffImplementation(kGLImplementationMockGL, - fallback_to_osmesa, - gpu_service_logging, - disable_gl_drawing)); -} - -// static -void GLSurface::InitializeDynamicMockBindingsForTests(GLContext* context) { - CHECK(InitializeDynamicGLBindings(kGLImplementationMockGL, context)); -} - -GLSurface::GLSurface(const SurfaceConfiguration requested_configuration) - : surface_configuration_(requested_configuration) { -} - -bool GLSurface::Initialize() { - return true; -} - -void GLSurface::DestroyAndTerminateDisplay() { - Destroy(); -} - -bool GLSurface::Resize(const gfx::Size& size) { - NOTIMPLEMENTED(); - return false; -} - -bool GLSurface::Recreate() { - NOTIMPLEMENTED(); - return false; -} - -bool GLSurface::DeferDraws() { - return false; -} - -bool GLSurface::SupportsPostSubBuffer() { - return false; -} - -unsigned int GLSurface::GetBackingFrameBufferObject() { - return 0; -} - -bool GLSurface::SwapBuffersAsync(const SwapCompletionCallback& callback) { - DCHECK(!IsSurfaceless()); - bool success = SwapBuffers(); - callback.Run(); - return success; -} - -bool GLSurface::PostSubBuffer(int x, int y, int width, int height) { - return false; -} - -bool GLSurface::PostSubBufferAsync(int x, - int y, - int width, - int height, - const SwapCompletionCallback& callback) { - bool success = PostSubBuffer(x, y, width, height); - callback.Run(); - return success; -} - -bool GLSurface::OnMakeCurrent(GLContext* context) { - return true; -} - -void GLSurface::NotifyWasBound() { -} - -bool GLSurface::SetBackbufferAllocation(bool allocated) { - return true; -} - -void GLSurface::SetFrontbufferAllocation(bool allocated) { -} - -void* GLSurface::GetShareHandle() { - NOTIMPLEMENTED(); - return NULL; -} - -void* GLSurface::GetDisplay() { - NOTIMPLEMENTED(); - return NULL; -} - -void* GLSurface::GetConfig() { - NOTIMPLEMENTED(); - return NULL; -} - -unsigned GLSurface::GetFormat() { - NOTIMPLEMENTED(); - return 0; -} - -VSyncProvider* GLSurface::GetVSyncProvider() { - return NULL; -} - -bool GLSurface::ScheduleOverlayPlane(int z_order, - OverlayTransform transform, - GLImage* image, - const Rect& bounds_rect, - const RectF& crop_rect) { - NOTIMPLEMENTED(); - return false; -} - -bool GLSurface::IsSurfaceless() const { - return false; -} - -GLSurface* GLSurface::GetCurrent() { - return current_surface_.Pointer()->Get(); -} - -GLSurface::~GLSurface() { - if (GetCurrent() == this) - SetCurrent(NULL); -} - -void GLSurface::SetCurrent(GLSurface* surface) { - current_surface_.Pointer()->Set(surface); -} - -bool GLSurface::ExtensionsContain(const char* c_extensions, const char* name) { - DCHECK(name); - if (!c_extensions) - return false; - std::string extensions(c_extensions); - extensions += " "; - - std::string delimited_name(name); - delimited_name += " "; - - return extensions.find(delimited_name) != std::string::npos; -} - -void GLSurface::OnSetSwapInterval(int interval) { -} - -GLSurfaceAdapter::GLSurfaceAdapter(GLSurface* surface) - : GLSurface(surface->get_surface_configuration()), surface_(surface) { -} - -bool GLSurfaceAdapter::Initialize() { - return surface_->Initialize(); -} - -void GLSurfaceAdapter::Destroy() { - surface_->Destroy(); -} - -bool GLSurfaceAdapter::Resize(const gfx::Size& size) { - return surface_->Resize(size); -} - -bool GLSurfaceAdapter::Recreate() { - return surface_->Recreate(); -} - -bool GLSurfaceAdapter::DeferDraws() { - return surface_->DeferDraws(); -} - -bool GLSurfaceAdapter::IsOffscreen() { - return surface_->IsOffscreen(); -} - -bool GLSurfaceAdapter::SwapBuffers() { - return surface_->SwapBuffers(); -} - -bool GLSurfaceAdapter::SwapBuffersAsync( - const SwapCompletionCallback& callback) { - return surface_->SwapBuffersAsync(callback); -} - -bool GLSurfaceAdapter::PostSubBuffer(int x, int y, int width, int height) { - return surface_->PostSubBuffer(x, y, width, height); -} - -bool GLSurfaceAdapter::PostSubBufferAsync( - int x, int y, int width, int height, - const SwapCompletionCallback& callback) { - return surface_->PostSubBufferAsync(x, y, width, height, callback); -} - -bool GLSurfaceAdapter::SupportsPostSubBuffer() { - return surface_->SupportsPostSubBuffer(); -} - -gfx::Size GLSurfaceAdapter::GetSize() { - return surface_->GetSize(); -} - -void* GLSurfaceAdapter::GetHandle() { - return surface_->GetHandle(); -} - -unsigned int GLSurfaceAdapter::GetBackingFrameBufferObject() { - return surface_->GetBackingFrameBufferObject(); -} - -bool GLSurfaceAdapter::OnMakeCurrent(GLContext* context) { - return surface_->OnMakeCurrent(context); -} - -bool GLSurfaceAdapter::SetBackbufferAllocation(bool allocated) { - return surface_->SetBackbufferAllocation(allocated); -} - -void GLSurfaceAdapter::SetFrontbufferAllocation(bool allocated) { - surface_->SetFrontbufferAllocation(allocated); -} - -void* GLSurfaceAdapter::GetShareHandle() { - return surface_->GetShareHandle(); -} - -void* GLSurfaceAdapter::GetDisplay() { - return surface_->GetDisplay(); -} - -void* GLSurfaceAdapter::GetConfig() { - return surface_->GetConfig(); -} - -unsigned GLSurfaceAdapter::GetFormat() { - return surface_->GetFormat(); -} - -VSyncProvider* GLSurfaceAdapter::GetVSyncProvider() { - return surface_->GetVSyncProvider(); -} - -bool GLSurfaceAdapter::ScheduleOverlayPlane(int z_order, - OverlayTransform transform, - GLImage* image, - const Rect& bounds_rect, - const RectF& crop_rect) { - return surface_->ScheduleOverlayPlane( - z_order, transform, image, bounds_rect, crop_rect); -} - -bool GLSurfaceAdapter::IsSurfaceless() const { - return surface_->IsSurfaceless(); -} - -GLSurfaceAdapter::~GLSurfaceAdapter() {} - -} // namespace gfx diff --git a/ui/gl/gl_surface.h b/ui/gl/gl_surface.h deleted file mode 100644 index 73c085d4d..000000000 --- a/ui/gl/gl_surface.h +++ /dev/null @@ -1,265 +0,0 @@ -// 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 UI_GL_GL_SURFACE_H_ -#define UI_GL_GL_SURFACE_H_ - -#include - -#include "base/callback.h" -#include "base/memory/ref_counted.h" -#include "build/build_config.h" -#include "ui/gfx/geometry/rect.h" -#include "ui/gfx/geometry/rect_f.h" -#include "ui/gfx/geometry/size.h" -#include "ui/gfx/native_widget_types.h" -#include "ui/gfx/overlay_transform.h" -#include "ui/gl/gl_export.h" -#include "ui/gl/gl_implementation.h" - -namespace gfx { - -class GLContext; -class GLImage; -class VSyncProvider; - -struct SurfaceConfiguration { - uint8_t red_bits = 8; - uint8_t green_bits = 8; - uint8_t blue_bits = 8; - uint8_t alpha_bits = 8; - uint8_t depth_bits = 0; - uint8_t stencil_bits = 0; -}; - -// Encapsulates a surface that can be rendered to with GL, hiding platform -// specific management. -class GL_EXPORT GLSurface : public base::RefCounted { - public: - explicit GLSurface(const gfx::SurfaceConfiguration requested_configuration); - - // (Re)create the surface. TODO(apatrick): This is an ugly hack to allow the - // EGL surface associated to be recreated without destroying the associated - // context. The implementation of this function for other GLSurface derived - // classes is in a pending changelist. - virtual bool Initialize(); - - // Destroys the surface. - virtual void Destroy() = 0; - - // Destroys the surface and terminates its underlying display. This must be - // the last surface which uses the display. - virtual void DestroyAndTerminateDisplay(); - - virtual bool Resize(const gfx::Size& size); - - // Recreate the surface without changing the size. - virtual bool Recreate(); - - // Unschedule the GpuScheduler and return true to abort the processing of - // a GL draw call to this surface and defer it until the GpuScheduler is - // rescheduled. - virtual bool DeferDraws(); - - // Returns true if this surface is offscreen. - virtual bool IsOffscreen() = 0; - - // Swaps front and back buffers. This has no effect for off-screen - // contexts. - virtual bool SwapBuffers() = 0; - - // Get the size of the surface. - virtual gfx::Size GetSize() = 0; - - // Get the underlying platform specific surface "handle". - virtual void* GetHandle() = 0; - - // Returns whether or not the surface supports PostSubBuffer. - virtual bool SupportsPostSubBuffer(); - - // Returns the internal frame buffer object name if the surface is backed by - // FBO. Otherwise returns 0. - virtual unsigned int GetBackingFrameBufferObject(); - - typedef base::Callback SwapCompletionCallback; - // Swaps front and back buffers. This has no effect for off-screen - // contexts. On some platforms, we want to send SwapBufferAck only after the - // surface is displayed on screen. The callback can be used to delay sending - // SwapBufferAck till that data is available. The callback should be run on - // the calling thread (i.e. same thread SwapBuffersAsync is called) - virtual bool SwapBuffersAsync(const SwapCompletionCallback& callback); - - // Copy part of the backbuffer to the frontbuffer. - virtual bool PostSubBuffer(int x, int y, int width, int height); - - // Copy part of the backbuffer to the frontbuffer. On some platforms, we want - // to send SwapBufferAck only after the surface is displayed on screen. The - // callback can be used to delay sending SwapBufferAck till that data is - // available. The callback should be run on the calling thread (i.e. same - // thread PostSubBufferAsync is called) - virtual bool PostSubBufferAsync(int x, - int y, - int width, - int height, - const SwapCompletionCallback& callback); - - // Initialize GL bindings. - static bool InitializeOneOff(GLImplementation = kGLImplementationNone); - - // Unit tests should call these instead of InitializeOneOff() to set up - // GL bindings appropriate for tests. - static void InitializeOneOffForTests(); - static void InitializeOneOffWithMockBindingsForTests(); - static void InitializeDynamicMockBindingsForTests(GLContext* context); - - // Called after a context is made current with this surface. Returns false - // on error. - virtual bool OnMakeCurrent(GLContext* context); - - // Called when the surface is bound as the current framebuffer for the - // current context. - virtual void NotifyWasBound(); - - // Used for explicit buffer management. - virtual bool SetBackbufferAllocation(bool allocated); - virtual void SetFrontbufferAllocation(bool allocated); - - // Get a handle used to share the surface with another process. Returns null - // if this is not possible. - virtual void* GetShareHandle(); - - // Get the platform specific display on which this surface resides, if - // available. - virtual void* GetDisplay(); - - // Get the platfrom specific configuration for this surface, if available. - virtual void* GetConfig(); - - // Get the GL pixel format of the surface, if available. - virtual unsigned GetFormat(); - - // Get access to a helper providing time of recent refresh and period - // of screen refresh. If unavailable, returns NULL. - virtual VSyncProvider* GetVSyncProvider(); - - // Schedule an overlay plane to be shown at swap time. - // |z_order| specifies the stacking order of the plane relative to the - // main framebuffer located at index 0. For the case where there is no - // main framebuffer, overlays may be scheduled at 0, taking its place. - // |transform| specifies how the buffer is to be transformed during - // composition. - // |image| to be presented by the overlay. - // |bounds_rect| specify where it is supposed to be on the screen in pixels. - // |crop_rect| specifies the region within the buffer to be placed inside - // |bounds_rect|. - virtual bool ScheduleOverlayPlane(int z_order, - OverlayTransform transform, - GLImage* image, - const Rect& bounds_rect, - const RectF& crop_rect); - - virtual bool IsSurfaceless() const; - - // Create a GL surface that renders directly to a view. - static scoped_refptr CreateViewGLSurface( - gfx::AcceleratedWidget window, - const gfx::SurfaceConfiguration& requested_configuration); - -#if defined(USE_OZONE) - // Create a GL surface that renders directly into a window with surfaceless - // semantics - there is no default framebuffer and the primary surface must - // be presented as an overlay. If surfaceless mode is not supported or - // enabled it will return a null pointer. - static scoped_refptr CreateSurfacelessViewGLSurface( - gfx::AcceleratedWidget window, - const gfx::SurfaceConfiguration& requested_configuration); -#endif // defined(USE_OZONE) - - // Create a GL surface used for offscreen rendering. - static scoped_refptr CreateOffscreenGLSurface( - const gfx::Size& size, - const gfx::SurfaceConfiguration& requested_configuration); - - static GLSurface* GetCurrent(); - - // Called when the swap interval for the associated context changes. - virtual void OnSetSwapInterval(int interval); - - const gfx::SurfaceConfiguration get_surface_configuration() { - return surface_configuration_; - } - - protected: - virtual ~GLSurface(); - static bool InitializeOneOffImplementation(GLImplementation impl, - bool fallback_to_osmesa, - bool gpu_service_logging, - bool disable_gl_drawing); - static bool InitializeOneOffInternal(); - static void SetCurrent(GLSurface* surface); - - static bool ExtensionsContain(const char* extensions, const char* name); - - private: - friend class base::RefCounted; - friend class GLContext; - - gfx::SurfaceConfiguration surface_configuration_; - - DISALLOW_COPY_AND_ASSIGN(GLSurface); -}; - -// Implementation of GLSurface that forwards all calls through to another -// GLSurface. -class GL_EXPORT GLSurfaceAdapter : public GLSurface { - public: - explicit GLSurfaceAdapter(GLSurface* surface); - - bool Initialize() override; - void Destroy() override; - bool Resize(const gfx::Size& size) override; - bool Recreate() override; - bool DeferDraws() override; - bool IsOffscreen() override; - bool SwapBuffers() override; - bool SwapBuffersAsync(const SwapCompletionCallback& callback) override; - bool PostSubBuffer(int x, int y, int width, int height) override; - bool PostSubBufferAsync(int x, - int y, - int width, - int height, - const SwapCompletionCallback& callback) override; - bool SupportsPostSubBuffer() override; - gfx::Size GetSize() override; - void* GetHandle() override; - unsigned int GetBackingFrameBufferObject() override; - bool OnMakeCurrent(GLContext* context) override; - bool SetBackbufferAllocation(bool allocated) override; - void SetFrontbufferAllocation(bool allocated) override; - void* GetShareHandle() override; - void* GetDisplay() override; - void* GetConfig() override; - unsigned GetFormat() override; - VSyncProvider* GetVSyncProvider() override; - bool ScheduleOverlayPlane(int z_order, - OverlayTransform transform, - GLImage* image, - const Rect& bounds_rect, - const RectF& crop_rect) override; - bool IsSurfaceless() const override; - - GLSurface* surface() const { return surface_.get(); } - - protected: - ~GLSurfaceAdapter() override; - - private: - scoped_refptr surface_; - - DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); -}; - -} // namespace gfx - -#endif // UI_GL_GL_SURFACE_H_ diff --git a/ui/gl/gl_surface_android.cc b/ui/gl/gl_surface_android.cc deleted file mode 100644 index e8f236f2b..000000000 --- a/ui/gl/gl_surface_android.cc +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2014 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 "ui/gl/gl_surface.h" - -#include - -#include "base/logging.h" -#include "base/memory/ref_counted.h" -#include "ui/gfx/native_widget_types.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_surface_egl.h" -#include "ui/gl/gl_surface_osmesa.h" -#include "ui/gl/gl_surface_stub.h" - -namespace gfx { - -// static -bool GLSurface::InitializeOneOffInternal() { - auto implementation = GetGLImplementation(); - switch (implementation) { - case kGLImplementationEGLGLES2: - if (!GLSurfaceEGL::InitializeOneOff()) { - LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; - return false; - } - break; - default: - LOG(ERROR) - << "Unknown GL implementation returned from GetGLImplementation: " - << implementation; - return false; - } - return true; -} - -// static -scoped_refptr GLSurface::CreateViewGLSurface( - gfx::AcceleratedWidget window, - const gfx::SurfaceConfiguration& requested_configuration) { - CHECK_NE(kGLImplementationNone, GetGLImplementation()); - if (GetGLImplementation() == kGLImplementationOSMesaGL) { - scoped_refptr surface( - new GLSurfaceOSMesaHeadless(requested_configuration)); - if (!surface->Initialize()) - return NULL; - return surface; - } - DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); - if (window != kNullAcceleratedWidget) { - scoped_refptr surface = - new NativeViewGLSurfaceEGL(window, requested_configuration); - if (surface->Initialize()) - return surface; - } else { - scoped_refptr surface = - new GLSurfaceStub(requested_configuration); - if (surface->Initialize()) - return surface; - } - return NULL; -} - -// static -scoped_refptr GLSurface::CreateOffscreenGLSurface( - const gfx::Size& size, - const gfx::SurfaceConfiguration& requested_configuration) { - CHECK_NE(kGLImplementationNone, GetGLImplementation()); - switch (GetGLImplementation()) { - case kGLImplementationOSMesaGL: { - scoped_refptr surface(new GLSurfaceOSMesa( - OSMesaSurfaceFormatBGRA, size, requested_configuration)); - if (!surface->Initialize()) - return NULL; - - return surface; - } - case kGLImplementationEGLGLES2: { - scoped_refptr surface; - if (GLSurfaceEGL::IsEGLSurfacelessContextSupported() && - (size.width() == 0 && size.height() == 0)) { - surface = new SurfacelessEGL(size, requested_configuration); - } else { - surface = new PbufferGLSurfaceEGL(size, requested_configuration); - } - - if (!surface->Initialize()) - return NULL; - return surface; - } - default: - NOTREACHED(); - return NULL; - } -} - -EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { - return EGL_DEFAULT_DISPLAY; -} - -} // namespace gfx diff --git a/ui/gl/gl_surface_egl.cc b/ui/gl/gl_surface_egl.cc deleted file mode 100644 index d560a02d8..000000000 --- a/ui/gl/gl_surface_egl.cc +++ /dev/null @@ -1,734 +0,0 @@ -// 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 "ui/gl/gl_surface_egl.h" - -#if defined(OS_ANDROID) -#include -#endif - -#include "base/command_line.h" -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.h" -#include "base/trace_event/trace_event.h" -#include "build/build_config.h" -#include "ui/gfx/geometry/rect.h" -#include "ui/gl/egl_util.h" -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_surface_stub.h" -#include "ui/gl/gl_switches.h" -#include "ui/gl/scoped_make_current.h" -#include "ui/gl/sync_control_vsync_provider.h" - -#if defined(USE_X11) -extern "C" { -#include -} -#endif - -#if defined (USE_OZONE) -#include "ui/ozone/public/surface_factory_ozone.h" -#endif - -#if !defined(EGL_FIXED_SIZE_ANGLE) -#define EGL_FIXED_SIZE_ANGLE 0x3201 -#endif - -#if !defined(EGL_NV_post_sub_buffer) -#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE -#endif - -#if !defined(EGL_OPENGL_ES3_BIT) -#define EGL_OPENGL_ES3_BIT 0x00000040 -#endif - -using ui::GetLastEGLErrorString; - -namespace gfx { - -namespace { - -EGLDisplay g_display; -EGLNativeDisplayType g_native_display_type; - -// In the Cast environment, we need to destroy the EGLNativeDisplayType and -// EGLDisplay returned by the GPU platform when we switch to an external app -// which will temporarily own all screen and GPU resources. -// Even though Chromium is still in the background. -// As such, it must be reinitialized each time we come back to the foreground. -bool g_initialized = false; -int g_num_surfaces = 0; -bool g_terminate_pending = false; - -const char* g_egl_extensions = NULL; -bool g_egl_create_context_robustness_supported = false; -bool g_egl_sync_control_supported = false; -bool g_egl_window_fixed_size_supported = false; -bool g_egl_surfaceless_context_supported = false; - -class EGLSyncControlVSyncProvider - : public gfx::SyncControlVSyncProvider { - public: - explicit EGLSyncControlVSyncProvider(EGLSurface surface) - : SyncControlVSyncProvider(), - surface_(surface) { - } - - ~EGLSyncControlVSyncProvider() override {} - - protected: - bool GetSyncValues(int64* system_time, - int64* media_stream_counter, - int64* swap_buffer_counter) override { - uint64 u_system_time, u_media_stream_counter, u_swap_buffer_counter; - bool result = eglGetSyncValuesCHROMIUM( - g_display, surface_, &u_system_time, - &u_media_stream_counter, &u_swap_buffer_counter) == EGL_TRUE; - if (result) { - *system_time = static_cast(u_system_time); - *media_stream_counter = static_cast(u_media_stream_counter); - *swap_buffer_counter = static_cast(u_swap_buffer_counter); - } - return result; - } - - bool GetMscRate(int32* numerator, int32* denominator) override { - return false; - } - - private: - EGLSurface surface_; - - DISALLOW_COPY_AND_ASSIGN(EGLSyncControlVSyncProvider); -}; - -void DeinitializeEgl() { - if (g_initialized) { - g_initialized = false; - eglTerminate(g_display); - } -} - -} // namespace - -GLSurfaceEGL::GLSurfaceEGL( - const gfx::SurfaceConfiguration requested_configuration) - : GLSurface(requested_configuration) { - ++g_num_surfaces; - if (!g_initialized) { - bool result = GLSurfaceEGL::InitializeOneOff(); - DCHECK(result); - DCHECK(g_initialized); - } -} - -void* GetEGLConfig(const EGLNativeWindowType window, - const gfx::SurfaceConfiguration configuration, - bool allow_window_bit) { - // Choose an EGL configuration. - // On X this is only used for PBuffer surfaces. - EGLConfig config = {0}; - -#if defined(USE_X11) - XWindowAttributes win_attribs; - if (!XGetWindowAttributes(GLSurfaceEGL::GetNativeDisplay(), - window, - &win_attribs)) { - return nullptr; - } -#endif - - EGLint renderable_type = EGL_OPENGL_ES2_BIT; - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableUnsafeES3APIs)) { - renderable_type = EGL_OPENGL_ES3_BIT; - } - EGLint config_attribs[] = { - EGL_BUFFER_SIZE, configuration.alpha_bits + - configuration.red_bits + - configuration.green_bits + - configuration.blue_bits, - EGL_ALPHA_SIZE, configuration.alpha_bits, - EGL_BLUE_SIZE, configuration.blue_bits, - EGL_GREEN_SIZE, configuration.green_bits, - EGL_RED_SIZE, configuration.red_bits, - EGL_DEPTH_SIZE, configuration.depth_bits, - EGL_STENCIL_SIZE, configuration.stencil_bits, - EGL_RENDERABLE_TYPE, renderable_type, - EGL_SURFACE_TYPE, (allow_window_bit ? - (EGL_WINDOW_BIT | EGL_PBUFFER_BIT) : - EGL_PBUFFER_BIT), - EGL_NONE - }; - -#if defined(USE_OZONE) - config_attribs = - ui::SurfaceFactoryOzone::GetInstance()->GetEGLSurfaceProperties( - config_attribs); -#elif defined(USE_X11) - // Try matching the window depth with an alpha channel, - // because we're worried the destination alpha width could - // constrain blending precision. - const int kBufferSizeOffset = 1; - const int kAlphaSizeOffset = 3; - config_attribs[kBufferSizeOffset] = win_attribs.depth; -#endif - - EGLint num_configs; - if (!eglChooseConfig(g_display, - config_attribs, - NULL, - 0, - &num_configs)) { - LOG(ERROR) << "eglChooseConfig failed with error " - << GetLastEGLErrorString(); - return nullptr; - } - - if (!eglChooseConfig(g_display, - config_attribs, - &config, - 1, - &num_configs)) { - LOG(ERROR) << "eglChooseConfig failed with error " - << GetLastEGLErrorString(); - return nullptr; - } - -#if defined(USE_X11) - if (num_configs) { - EGLint config_depth; - if (!eglGetConfigAttrib(g_display, - config, - EGL_BUFFER_SIZE, - &config_depth)) { - LOG(ERROR) << "eglGetConfigAttrib failed with error " - << GetLastEGLErrorString(); - return nullptr; - } - - if (config_depth == win_attribs.depth) { - return config; - } - } - - // Try without an alpha channel. - config_attribs[kAlphaSizeOffset] = 0; - if (!eglChooseConfig(g_display, - config_attribs, - &config, - 1, - &num_configs)) { - LOG(ERROR) << "eglChooseConfig failed with error " - << GetLastEGLErrorString(); - return nullptr; - } -#endif - - if (num_configs == 0) { - LOG(ERROR) << "No suitable EGL configs found."; - return nullptr; - } - - return config; -} - -bool GLSurfaceEGL::InitializeOneOff() { - if (g_initialized) - return true; - - g_native_display_type = GetPlatformDefaultEGLNativeDisplay(); - - g_display = eglGetDisplay(g_native_display_type); - - if (!g_display) { - LOG(ERROR) << "eglGetDisplay failed with error " << GetLastEGLErrorString(); - return false; - } - - if (!eglInitialize(g_display, NULL, NULL)) { - LOG(ERROR) << "eglInitialize failed with error " << GetLastEGLErrorString(); - return false; - } - - g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS); - g_egl_create_context_robustness_supported = - HasEGLExtension("EGL_EXT_create_context_robustness"); - g_egl_sync_control_supported = - HasEGLExtension("EGL_CHROMIUM_sync_control"); - g_egl_window_fixed_size_supported = - HasEGLExtension("EGL_ANGLE_window_fixed_size"); - - // We always succeed beyond this point so set g_initialized here to avoid - // infinite recursion through CreateGLContext and GetDisplay - // if g_egl_surfaceless_context_supported. - g_initialized = true; - g_terminate_pending = false; - - // TODO(oetuaho@nvidia.com): Surfaceless is disabled on Android as a temporary - // workaround, since code written for Android WebView takes different paths - // based on whether GL surface objects have underlying EGL surface handles, - // conflicting with the use of surfaceless. See https://crbug.com/382349 -#if defined(OS_ANDROID) - DCHECK(!g_egl_surfaceless_context_supported); -#else - // Check if SurfacelessEGL is supported. - g_egl_surfaceless_context_supported = - HasEGLExtension("EGL_KHR_surfaceless_context"); - if (g_egl_surfaceless_context_supported) { - // EGL_KHR_surfaceless_context is supported but ensure - // GL_OES_surfaceless_context is also supported. We need a current context - // to query for supported GL extensions. - scoped_refptr surface = new SurfacelessEGL( - Size(1, 1), SurfaceConfiguration()); - scoped_refptr context = GLContext::CreateGLContext( - NULL, surface.get(), PreferIntegratedGpu); - if (!context->MakeCurrent(surface.get())) - g_egl_surfaceless_context_supported = false; - - // Ensure context supports GL_OES_surfaceless_context. - if (g_egl_surfaceless_context_supported) { - g_egl_surfaceless_context_supported = context->HasExtension( - "GL_OES_surfaceless_context"); - context->ReleaseCurrent(surface.get()); - } - } -#endif - - return true; -} - -EGLDisplay GLSurfaceEGL::GetDisplay() { - DCHECK(g_initialized); - return g_display; -} - -// static -EGLDisplay GLSurfaceEGL::GetHardwareDisplay() { - if (!g_initialized) { - bool result = GLSurfaceEGL::InitializeOneOff(); - DCHECK(result); - } - return g_display; -} - -// static -EGLNativeDisplayType GLSurfaceEGL::GetNativeDisplay() { - if (!g_initialized) { - bool result = GLSurfaceEGL::InitializeOneOff(); - DCHECK(result); - } - return g_native_display_type; -} - -const char* GLSurfaceEGL::GetEGLExtensions() { - // No need for InitializeOneOff. Assume that extensions will not change - // after the first initialization. - return g_egl_extensions; -} - -bool GLSurfaceEGL::HasEGLExtension(const char* name) { - return ExtensionsContain(GetEGLExtensions(), name); -} - -bool GLSurfaceEGL::IsCreateContextRobustnessSupported() { - return g_egl_create_context_robustness_supported; -} - -bool GLSurfaceEGL::IsEGLSurfacelessContextSupported() { - return g_egl_surfaceless_context_supported; -} - -void GLSurfaceEGL::DestroyAndTerminateDisplay() { - DCHECK(g_initialized); - DCHECK_EQ(g_num_surfaces, 1); - Destroy(); - g_terminate_pending = true; -} - -GLSurfaceEGL::~GLSurfaceEGL() { - DCHECK_GT(g_num_surfaces, 0) << "Bad surface count"; - if (--g_num_surfaces == 0 && g_terminate_pending) { - DeinitializeEgl(); - g_terminate_pending = false; - } -} - -NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL( - EGLNativeWindowType window, - const gfx::SurfaceConfiguration requested_configuration) - : GLSurfaceEGL(requested_configuration), - window_(window), - surface_(NULL), - supports_post_sub_buffer_(false), - config_(NULL), - size_(1, 1), - swap_interval_(1) { -#if defined(OS_ANDROID) - if (window) - ANativeWindow_acquire(window); -#endif -} - -bool NativeViewGLSurfaceEGL::Initialize() { - return Initialize(nullptr); -} - -bool NativeViewGLSurfaceEGL::Initialize( - scoped_ptr sync_provider) { - DCHECK(!surface_); - - if (!GetDisplay()) { - LOG(ERROR) << "Trying to create surface with invalid display."; - return false; - } - - std::vector egl_window_attributes; - - if (g_egl_window_fixed_size_supported) { - egl_window_attributes.push_back(EGL_FIXED_SIZE_ANGLE); - egl_window_attributes.push_back(EGL_TRUE); - egl_window_attributes.push_back(EGL_WIDTH); - egl_window_attributes.push_back(size_.width()); - egl_window_attributes.push_back(EGL_HEIGHT); - egl_window_attributes.push_back(size_.height()); - } - - if (gfx::g_driver_egl.ext.b_EGL_NV_post_sub_buffer) { - egl_window_attributes.push_back(EGL_POST_SUB_BUFFER_SUPPORTED_NV); - egl_window_attributes.push_back(EGL_TRUE); - } - - egl_window_attributes.push_back(EGL_NONE); - // Create a surface for the native window. - surface_ = eglCreateWindowSurface( - GetDisplay(), GetConfig(), window_, &egl_window_attributes[0]); - - if (!surface_) { - LOG(ERROR) << "eglCreateWindowSurface failed with error " - << GetLastEGLErrorString(); - Destroy(); - return false; - } - - if (gfx::g_driver_egl.ext.b_EGL_NV_post_sub_buffer) { - EGLint surfaceVal; - EGLBoolean retVal = eglQuerySurface( - GetDisplay(), surface_, EGL_POST_SUB_BUFFER_SUPPORTED_NV, &surfaceVal); - supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE; - } - - if (sync_provider) - vsync_provider_.reset(sync_provider.release()); - else if (g_egl_sync_control_supported) - vsync_provider_.reset(new EGLSyncControlVSyncProvider(surface_)); - return true; -} - -void NativeViewGLSurfaceEGL::Destroy() { - if (surface_) { - if (!eglDestroySurface(GetDisplay(), surface_)) { - LOG(ERROR) << "eglDestroySurface failed with error " - << GetLastEGLErrorString(); - } - surface_ = NULL; - } -} - -EGLConfig NativeViewGLSurfaceEGL::GetConfig() { - if (!config_) { - DCHECK(window_); - config_ = GetEGLConfig(window_, this->get_surface_configuration(), true); - } - return config_; -} - -bool NativeViewGLSurfaceEGL::IsOffscreen() { - return false; -} - -bool NativeViewGLSurfaceEGL::SwapBuffers() { - TRACE_EVENT2("gpu", "NativeViewGLSurfaceEGL:RealSwapBuffers", - "width", GetSize().width(), - "height", GetSize().height()); - - if (!eglSwapBuffers(GetDisplay(), surface_)) { - DVLOG(1) << "eglSwapBuffers failed with error " - << GetLastEGLErrorString(); - return false; - } - - return true; -} - -gfx::Size NativeViewGLSurfaceEGL::GetSize() { - EGLint width; - EGLint height; - if (!eglQuerySurface(GetDisplay(), surface_, EGL_WIDTH, &width) || - !eglQuerySurface(GetDisplay(), surface_, EGL_HEIGHT, &height)) { - NOTREACHED() << "eglQuerySurface failed with error " - << GetLastEGLErrorString(); - return gfx::Size(); - } - - return gfx::Size(width, height); -} - -bool NativeViewGLSurfaceEGL::Resize(const gfx::Size& size) { - if (size == GetSize()) - return true; - - size_ = size; - - scoped_ptr scoped_make_current; - GLContext* current_context = GLContext::GetCurrent(); - bool was_current = - current_context && current_context->IsCurrent(this); - if (was_current) { - scoped_make_current.reset( - new ui::ScopedMakeCurrent(current_context, this)); - current_context->ReleaseCurrent(this); - } - - Destroy(); - - if (!Initialize()) { - LOG(ERROR) << "Failed to resize window."; - return false; - } - - return true; -} - -bool NativeViewGLSurfaceEGL::Recreate() { - Destroy(); - if (!Initialize()) { - LOG(ERROR) << "Failed to create surface."; - return false; - } - return true; -} - -EGLSurface NativeViewGLSurfaceEGL::GetHandle() { - return surface_; -} - -bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() { - return supports_post_sub_buffer_; -} - -bool NativeViewGLSurfaceEGL::PostSubBuffer( - int x, int y, int width, int height) { - DCHECK(supports_post_sub_buffer_); - if (!eglPostSubBufferNV(GetDisplay(), surface_, x, y, width, height)) { - DVLOG(1) << "eglPostSubBufferNV failed with error " - << GetLastEGLErrorString(); - return false; - } - return true; -} - -VSyncProvider* NativeViewGLSurfaceEGL::GetVSyncProvider() { - return vsync_provider_.get(); -} - -void NativeViewGLSurfaceEGL::OnSetSwapInterval(int interval) { - swap_interval_ = interval; -} - -NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() { - Destroy(); -#if defined(OS_ANDROID) - if (window_) - ANativeWindow_release(window_); -#endif -} - -PbufferGLSurfaceEGL::PbufferGLSurfaceEGL( - const gfx::Size& size, - const gfx::SurfaceConfiguration requested_configuration) - : GLSurfaceEGL(requested_configuration), - size_(size), - surface_(nullptr), - config_(nullptr) { - // Some implementations of Pbuffer do not support having a 0 size. For such - // cases use a (1, 1) surface. - if (size_.GetArea() == 0) - size_.SetSize(1, 1); -} - -bool PbufferGLSurfaceEGL::Initialize() { - EGLSurface old_surface = surface_; - - EGLDisplay display = GetDisplay(); - if (!display) { - LOG(ERROR) << "Trying to create surface with invalid display."; - return false; - } - - // Allocate the new pbuffer surface before freeing the old one to ensure - // they have different addresses. If they have the same address then a - // future call to MakeCurrent might early out because it appears the current - // context and surface have not changed. - const EGLint pbuffer_attribs[] = { - EGL_WIDTH, size_.width(), - EGL_HEIGHT, size_.height(), - EGL_NONE - }; - - EGLSurface new_surface = eglCreatePbufferSurface(display, - GetConfig(), - pbuffer_attribs); - if (!new_surface) { - LOG(ERROR) << "eglCreatePbufferSurface failed with error " - << GetLastEGLErrorString(); - return false; - } - - if (old_surface) - eglDestroySurface(display, old_surface); - - surface_ = new_surface; - return true; -} - -void PbufferGLSurfaceEGL::Destroy() { - if (surface_) { - if (!eglDestroySurface(GetDisplay(), surface_)) { - LOG(ERROR) << "eglDestroySurface failed with error " - << GetLastEGLErrorString(); - } - surface_ = NULL; - } -} - -EGLConfig PbufferGLSurfaceEGL::GetConfig() { - if (!config_) { - config_ = GetEGLConfig((EGLNativeWindowType)nullptr, - this->get_surface_configuration(), - false); - } - return config_; -} - -bool PbufferGLSurfaceEGL::IsOffscreen() { - return true; -} - -bool PbufferGLSurfaceEGL::SwapBuffers() { - NOTREACHED() << "Attempted to call SwapBuffers on a PbufferGLSurfaceEGL."; - return false; -} - -gfx::Size PbufferGLSurfaceEGL::GetSize() { - return size_; -} - -bool PbufferGLSurfaceEGL::Resize(const gfx::Size& size) { - if (size == size_) - return true; - - scoped_ptr scoped_make_current; - GLContext* current_context = GLContext::GetCurrent(); - bool was_current = - current_context && current_context->IsCurrent(this); - if (was_current) { - scoped_make_current.reset( - new ui::ScopedMakeCurrent(current_context, this)); - } - - size_ = size; - - if (!Initialize()) { - LOG(ERROR) << "Failed to resize pbuffer."; - return false; - } - - return true; -} - -EGLSurface PbufferGLSurfaceEGL::GetHandle() { - return surface_; -} - -void* PbufferGLSurfaceEGL::GetShareHandle() { -#if defined(OS_ANDROID) - NOTREACHED(); - return NULL; -#else - if (!gfx::g_driver_egl.ext.b_EGL_ANGLE_query_surface_pointer) - return NULL; - - if (!gfx::g_driver_egl.ext.b_EGL_ANGLE_surface_d3d_texture_2d_share_handle) - return NULL; - - void* handle; - if (!eglQuerySurfacePointerANGLE(g_display, - GetHandle(), - EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, - &handle)) { - return NULL; - } - - return handle; -#endif -} - -PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { - Destroy(); -} - -SurfacelessEGL::SurfacelessEGL( - const gfx::Size& size, - const gfx::SurfaceConfiguration requested_configuration) - : GLSurfaceEGL(requested_configuration), size_(size) { -} - -bool SurfacelessEGL::Initialize() { - return true; -} - -void SurfacelessEGL::Destroy() { -} - -EGLConfig SurfacelessEGL::GetConfig() { - return NULL; -} - -bool SurfacelessEGL::IsOffscreen() { - return true; -} - -bool SurfacelessEGL::IsSurfaceless() const { - return true; -} - -bool SurfacelessEGL::SwapBuffers() { - LOG(ERROR) << "Attempted to call SwapBuffers with SurfacelessEGL."; - return false; -} - -gfx::Size SurfacelessEGL::GetSize() { - return size_; -} - -bool SurfacelessEGL::Resize(const gfx::Size& size) { - size_ = size; - return true; -} - -EGLSurface SurfacelessEGL::GetHandle() { - return EGL_NO_SURFACE; -} - -void* SurfacelessEGL::GetShareHandle() { - return NULL; -} - -SurfacelessEGL::~SurfacelessEGL() { -} - -} // namespace gfx diff --git a/ui/gl/gl_surface_egl.h b/ui/gl/gl_surface_egl.h deleted file mode 100644 index 9bf2a2d72..000000000 --- a/ui/gl/gl_surface_egl.h +++ /dev/null @@ -1,154 +0,0 @@ -// 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 UI_GL_GL_SURFACE_EGL_H_ -#define UI_GL_GL_SURFACE_EGL_H_ - -#include - -#include "base/compiler_specific.h" -#include "base/time/time.h" -#include "ui/gfx/geometry/size.h" -#include "ui/gfx/vsync_provider.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_surface.h" - -namespace gfx { - -// Get default EGL display for GLSurfaceEGL (differs by platform). -EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay(); - -// Interface for EGL surface. -class GL_EXPORT GLSurfaceEGL : public GLSurface { - public: - explicit GLSurfaceEGL( - const gfx::SurfaceConfiguration requested_configuration); - - // Implement GLSurface. - void DestroyAndTerminateDisplay() override; - EGLDisplay GetDisplay() override; - - static bool InitializeOneOff(); - static EGLDisplay GetHardwareDisplay(); - static EGLNativeDisplayType GetNativeDisplay(); - - // These aren't particularly tied to surfaces, but since we already - // have the static InitializeOneOff here, it's easiest to reuse its - // initialization guards. - static const char* GetEGLExtensions(); - static bool HasEGLExtension(const char* name); - static bool IsCreateContextRobustnessSupported(); - static bool IsEGLSurfacelessContextSupported(); - - protected: - ~GLSurfaceEGL() override; - - private: - DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL); -}; - -// Encapsulates an EGL surface bound to a view. -class GL_EXPORT NativeViewGLSurfaceEGL : public GLSurfaceEGL { - public: - NativeViewGLSurfaceEGL( - EGLNativeWindowType window, - const gfx::SurfaceConfiguration requested_configuration); - - // Implement GLSurface. - EGLConfig GetConfig() override; - bool Initialize() override; - void Destroy() override; - bool Resize(const gfx::Size& size) override; - bool Recreate() override; - bool IsOffscreen() override; - bool SwapBuffers() override; - gfx::Size GetSize() override; - EGLSurface GetHandle() override; - bool SupportsPostSubBuffer() override; - bool PostSubBuffer(int x, int y, int width, int height) override; - VSyncProvider* GetVSyncProvider() override; - - // Create a NativeViewGLSurfaceEGL with an externally provided VSyncProvider. - // Takes ownership of the VSyncProvider. - virtual bool Initialize(scoped_ptr sync_provider); - - protected: - ~NativeViewGLSurfaceEGL() override; - - EGLNativeWindowType window_; - - void OnSetSwapInterval(int interval) override; - - private: - EGLSurface surface_; - bool supports_post_sub_buffer_; - EGLConfig config_; - gfx::Size size_; - - scoped_ptr vsync_provider_; - - int swap_interval_; - - DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGL); -}; - -// Encapsulates a pbuffer EGL surface. -class GL_EXPORT PbufferGLSurfaceEGL : public GLSurfaceEGL { - public: - PbufferGLSurfaceEGL(const gfx::Size& size, - const gfx::SurfaceConfiguration requested_configuration); - - // Implement GLSurface. - EGLConfig GetConfig() override; - bool Initialize() override; - void Destroy() override; - bool IsOffscreen() override; - bool SwapBuffers() override; - gfx::Size GetSize() override; - bool Resize(const gfx::Size& size) override; - EGLSurface GetHandle() override; - void* GetShareHandle() override; - - protected: - ~PbufferGLSurfaceEGL() override; - - private: - gfx::Size size_; - EGLSurface surface_; - EGLConfig config_; - - DISALLOW_COPY_AND_ASSIGN(PbufferGLSurfaceEGL); -}; - -// SurfacelessEGL is used as Offscreen surface when platform supports -// KHR_surfaceless_context and GL_OES_surfaceless_context. This would avoid the -// need to create a dummy EGLsurface in case we render to client API targets. -class GL_EXPORT SurfacelessEGL : public GLSurfaceEGL { - public: - SurfacelessEGL(const gfx::Size& size, - SurfaceConfiguration requested_configuration); - - // Implement GLSurface. - EGLConfig GetConfig() override; - bool Initialize() override; - void Destroy() override; - bool IsOffscreen() override; - bool IsSurfaceless() const override; - bool SwapBuffers() override; - gfx::Size GetSize() override; - bool Resize(const gfx::Size& size) override; - EGLSurface GetHandle() override; - void* GetShareHandle() override; - - protected: - ~SurfacelessEGL() override; - - private: - gfx::Size size_; - DISALLOW_COPY_AND_ASSIGN(SurfacelessEGL); -}; - -} // namespace gfx - -#endif // UI_GL_GL_SURFACE_EGL_H_ diff --git a/ui/gl/gl_surface_glfw.cc b/ui/gl/gl_surface_glfw.cc deleted file mode 100644 index 263e78094..000000000 --- a/ui/gl/gl_surface_glfw.cc +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2016 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 "ui/gl/gl_surface_glfw.h" - -#include - -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_enums.h" -#include "base/logging.h" - -#define WIDGET_AS_VIEW (reinterpret_cast(widget_)) - -namespace gfx { - -GLSurfaceGlfw::GLSurfaceGlfw(gfx::AcceleratedWidget widget, - const gfx::SurfaceConfiguration requested_configuration) - : GLSurface(requested_configuration), - widget_(widget) { -} - -GLSurfaceGlfw::~GLSurfaceGlfw() { - Destroy(); -} - -bool GLSurfaceGlfw::OnMakeCurrent(GLContext* context) { - // The actual "make current" is done in the context. - return true; -} - -bool GLSurfaceGlfw::SwapBuffers() { - glfwSwapBuffers(widget_); - return true; -} - -void GLSurfaceGlfw::Destroy() { - DCHECK(false); -} - -bool GLSurfaceGlfw::IsOffscreen() { - return false; -} - -gfx::Size GLSurfaceGlfw::GetSize() { - int width; - int height; - glfwGetWindowSize(widget_, &width, &height); - return Size(width, height); -} - -void* GLSurfaceGlfw::GetHandle() { - return (void*)widget_; -} - -bool GLSurfaceGlfw::Resize(const gfx::Size& size) { - return true; -} - -bool GLSurface::InitializeOneOffInternal() { - if (!GLSurfaceGlfw::InitializeOneOff()) { - LOG(ERROR) << "GLSurfaceGlfw::InitializeOneOff failed."; - return false; - } - return true; -} - -// static -bool GLSurfaceGlfw::InitializeOneOff() { - return true; -} - -// static -scoped_refptr GLSurface::CreateViewGLSurface( - gfx::AcceleratedWidget window, - const gfx::SurfaceConfiguration& requested_configuration) { - DCHECK(window != kNullAcceleratedWidget); - scoped_refptr surface = - new GLSurfaceGlfw(window, requested_configuration); - - if (!surface->Initialize()) - return NULL; - - return surface; -} - -} // namespace gfx diff --git a/ui/gl/gl_surface_glfw.h b/ui/gl/gl_surface_glfw.h deleted file mode 100644 index b1e77db64..000000000 --- a/ui/gl/gl_surface_glfw.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2016 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 UI_GL_GL_SURFACE_GLFW_H_ -#define UI_GL_GL_SURFACE_GLFW_H_ - -#include "ui/gl/gl_surface.h" - -namespace gfx { - -class GL_EXPORT GLSurfaceGlfw : public GLSurface { - public: - GLSurfaceGlfw(gfx::AcceleratedWidget widget, - const gfx::SurfaceConfiguration requested_configuration); - - static bool InitializeOneOff(); - - static bool HasExtension(const char* name); - static bool IsCreateContextRobustnessSupported(); - - bool SwapBuffers() override; - void Destroy() override; - bool IsOffscreen() override; - gfx::Size GetSize() override; - void* GetHandle() override; - bool Resize(const gfx::Size& size) override; - bool OnMakeCurrent(GLContext* context) override; - - private: - ~GLSurfaceGlfw() override; - - gfx::AcceleratedWidget widget_; - - DISALLOW_COPY_AND_ASSIGN(GLSurfaceGlfw); -}; - -} // namespace gfx - -#endif // UI_GL_GL_SURFACE_GLFW_H_ diff --git a/ui/gl/gl_surface_ios.h b/ui/gl/gl_surface_ios.h deleted file mode 100644 index b60c3aa1d..000000000 --- a/ui/gl/gl_surface_ios.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 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 "ui/gl/gl_surface.h" - -namespace gfx { - -class GL_EXPORT GLSurfaceIOS : public GLSurface { - public: - GLSurfaceIOS(gfx::AcceleratedWidget widget, - const gfx::SurfaceConfiguration requested_configuration); - - bool SwapBuffers() override; - void Destroy() override; - bool IsOffscreen() override; - gfx::Size GetSize() override; - void* GetHandle() override; - bool OnMakeCurrent(GLContext* context) override; - unsigned int GetBackingFrameBufferObject() override; - bool Resize(const gfx::Size& size) override; - - private: - gfx::AcceleratedWidget widget_; - uint32_t framebuffer_; - uint32_t colorbuffer_; - uint32_t depthbuffer_; - uint32_t stencilbuffer_; - uint32_t depth_stencil_packed_buffer_; - Size last_configured_size_; - bool framebuffer_setup_complete_; - - ~GLSurfaceIOS() override; - void SetupFramebufferIfNecessary(); - - DISALLOW_COPY_AND_ASSIGN(GLSurfaceIOS); -}; - -} // namespace gfx diff --git a/ui/gl/gl_surface_ios.mm b/ui/gl/gl_surface_ios.mm deleted file mode 100644 index c4ca982c9..000000000 --- a/ui/gl/gl_surface_ios.mm +++ /dev/null @@ -1,287 +0,0 @@ -// Copyright 2014 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/mac/scoped_nsautorelease_pool.h" -#include "ui/gl/gl_surface_ios.h" -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_enums.h" -#include "base/logging.h" - -#import -#import -#import - -namespace gfx { - -#define WIDGET_AS_LAYER (reinterpret_cast(widget_)) -#define CAST_CONTEXT(c) (reinterpret_cast((c))) - -GLSurfaceIOS::GLSurfaceIOS(gfx::AcceleratedWidget widget, - const gfx::SurfaceConfiguration requested_configuration) - : GLSurface(requested_configuration), - widget_(widget), - framebuffer_(GL_NONE), - colorbuffer_(GL_NONE), - depthbuffer_(GL_NONE), - stencilbuffer_(GL_NONE), - depth_stencil_packed_buffer_(GL_NONE), - last_configured_size_(), - framebuffer_setup_complete_(false) { -} - -GLSurfaceIOS::~GLSurfaceIOS() {} - -#ifndef NDEBUG -static void GLSurfaceIOS_AssertFramebufferCompleteness(void) { - GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); - DLOG_IF(FATAL, status != GL_FRAMEBUFFER_COMPLETE) - << "Framebuffer incomplete on GLSurfaceIOS::MakeCurrent: " - << GLEnums::GetStringEnum(status); -} -#else -#define GLSurfaceIOS_AssertFramebufferCompleteness(...) -#endif - -bool GLSurfaceIOS::OnMakeCurrent(GLContext* context) { - Size new_size = GetSize(); - - if (new_size == last_configured_size_) { - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_); - GLSurfaceIOS_AssertFramebufferCompleteness(); - return true; - } - - base::mac::ScopedNSAutoreleasePool pool; - - SetupFramebufferIfNecessary(); - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_); - - glBindRenderbuffer(GL_RENDERBUFFER, colorbuffer_); - DCHECK(glGetError() == GL_NO_ERROR); - - auto context_handle = context->GetHandle(); - DCHECK(context_handle); - - BOOL res = [CAST_CONTEXT(context_handle) renderbufferStorage:GL_RENDERBUFFER - fromDrawable:WIDGET_AS_LAYER]; - - if (!res) { - return false; - } - - GLint width = 0; - GLint height = 0; - bool rebind_color_buffer = false; - if (depthbuffer_ != GL_NONE - || stencilbuffer_ != GL_NONE - || depth_stencil_packed_buffer_ != GL_NONE) { - // Fetch the dimensions of the color buffer whose backing was just updated - // so that backing of the attachments can be updated - - glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, - &width); - DCHECK(glGetError() == GL_NO_ERROR); - - glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, - &height); - DCHECK(glGetError() == GL_NO_ERROR); - - rebind_color_buffer = true; - } - - if (depth_stencil_packed_buffer_ != GL_NONE) { - glBindRenderbuffer(GL_RENDERBUFFER, depth_stencil_packed_buffer_); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, - width, height); - DCHECK(glGetError() == GL_NO_ERROR); - } - - if (depthbuffer_ != GL_NONE) { - glBindRenderbuffer(GL_RENDERBUFFER, depthbuffer_); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height); - DCHECK(glGetError() == GL_NO_ERROR); - } - - if (stencilbuffer_ != GL_NONE) { - glBindRenderbuffer(GL_RENDERBUFFER, stencilbuffer_); - glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, width, height); - DCHECK(glGetError() == GL_NO_ERROR); - } - - if (rebind_color_buffer) { - glBindRenderbuffer(GL_RENDERBUFFER, colorbuffer_); - DCHECK(glGetError() == GL_NO_ERROR); - } - - last_configured_size_ = new_size; - GLSurfaceIOS_AssertFramebufferCompleteness(); - return true; -} - -void GLSurfaceIOS::SetupFramebufferIfNecessary() { - if (framebuffer_setup_complete_) { - return; - } - - DCHECK(framebuffer_ == GL_NONE); - DCHECK(colorbuffer_ == GL_NONE); - - DCHECK(widget_ != kNullAcceleratedWidget); - DCHECK(glGetError() == GL_NO_ERROR); - - // Generate the framebuffer - - glGenFramebuffers(1, &framebuffer_); - DCHECK(framebuffer_ != GL_NONE); - - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_); - DCHECK(glGetError() == GL_NO_ERROR); - - // Setup color attachment - - glGenRenderbuffers(1, &colorbuffer_); - DCHECK(colorbuffer_ != GL_NONE); - - glBindRenderbuffer(GL_RENDERBUFFER, colorbuffer_); - DCHECK(glGetError() == GL_NO_ERROR); - - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_RENDERBUFFER, colorbuffer_); - DCHECK(glGetError() == GL_NO_ERROR); - - auto config = get_surface_configuration(); - - // On iOS, if both depth and stencil attachments are requested, we are - // required to create a single renderbuffer that acts as both. - - auto requires_packed = (config.depth_bits != 0) && (config.stencil_bits != 0); - - if (requires_packed) { - glGenRenderbuffers(1, &depth_stencil_packed_buffer_); - glBindRenderbuffer(GL_RENDERBUFFER, depth_stencil_packed_buffer_); - DCHECK(depth_stencil_packed_buffer_ != GL_NONE); - - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, - GL_RENDERBUFFER, depth_stencil_packed_buffer_); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, - GL_RENDERBUFFER, depth_stencil_packed_buffer_); - DCHECK(depth_stencil_packed_buffer_ != GL_NONE); - } else { - // Setup the depth attachment if necessary - - if (config.depth_bits != 0) { - glGenRenderbuffers(1, &depthbuffer_); - DCHECK(depthbuffer_ != GL_NONE); - - glBindRenderbuffer(GL_RENDERBUFFER, depthbuffer_); - DCHECK(glGetError() == GL_NO_ERROR); - - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, - GL_RENDERBUFFER, depthbuffer_); - DCHECK(glGetError() == GL_NO_ERROR); - } - - if (config.stencil_bits != 0) { - // Setup the stencil attachment if necessary - - glGenRenderbuffers(1, &stencilbuffer_); - DCHECK(stencilbuffer_ != GL_NONE); - - glBindRenderbuffer(GL_RENDERBUFFER, stencilbuffer_); - DCHECK(glGetError() == GL_NO_ERROR); - - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, - GL_RENDERBUFFER, stencilbuffer_); - DCHECK(glGetError() == GL_NO_ERROR); - } - } - - // The default is RGBA - NSString *drawableColorFormat = kEAGLColorFormatRGBA8; - - if (config.red_bits <= 5 - && config.green_bits <= 6 - && config.blue_bits <= 5 - && config.alpha_bits == 0) { - drawableColorFormat = kEAGLColorFormatRGB565; - } - - WIDGET_AS_LAYER.drawableProperties = @{ - kEAGLDrawablePropertyColorFormat : drawableColorFormat, - kEAGLDrawablePropertyRetainedBacking : @(NO), - }; - - framebuffer_setup_complete_ = true; -} - -bool GLSurfaceIOS::SwapBuffers() { - const GLenum discards[] = { - GL_DEPTH_ATTACHMENT, - GL_STENCIL_ATTACHMENT, - }; - - glDiscardFramebufferEXT(GL_FRAMEBUFFER, sizeof(discards) / sizeof(GLenum), - discards); - - glBindRenderbuffer(GL_RENDERBUFFER, colorbuffer_); - return [[EAGLContext currentContext] presentRenderbuffer:GL_RENDERBUFFER]; -} - -unsigned int GLSurfaceIOS::GetBackingFrameBufferObject() { - return framebuffer_; -} - -bool GLSurfaceIOS::Resize(const gfx::Size& size) { - // The backing layer has already been updated. - return true; -} - -void GLSurfaceIOS::Destroy() { - DCHECK(glGetError() == GL_NO_ERROR); - - glDeleteFramebuffers(1, &framebuffer_); - glDeleteRenderbuffers(1, &colorbuffer_); - // Deletes on GL_NONEs are ignored - glDeleteRenderbuffers(1, &depthbuffer_); - glDeleteRenderbuffers(1, &stencilbuffer_); - glDeleteRenderbuffers(1, &depth_stencil_packed_buffer_); - - DCHECK(glGetError() == GL_NO_ERROR); -} - -bool GLSurfaceIOS::IsOffscreen() { - return widget_ == kNullAcceleratedWidget; -} - -gfx::Size GLSurfaceIOS::GetSize() { - CGSize layer_size = WIDGET_AS_LAYER.bounds.size; - return Size(layer_size.width, layer_size.height); -} - -void* GLSurfaceIOS::GetHandle() { - return (void*)widget_; -} - -bool GLSurface::InitializeOneOffInternal() { - // On EGL, this method is used to perfom one-time initialization tasks like - // initializing the display, setting up config lists, etc. There is no such - // setup on iOS. - return true; -} - -// static -scoped_refptr GLSurface::CreateViewGLSurface( - gfx::AcceleratedWidget window, - const gfx::SurfaceConfiguration& requested_configuration) { - DCHECK(window != kNullAcceleratedWidget); - scoped_refptr surface = - new GLSurfaceIOS(window, requested_configuration); - - if (!surface->Initialize()) - return NULL; - - return surface; -} - -} // namespace gfx diff --git a/ui/gl/gl_surface_mac.h b/ui/gl/gl_surface_mac.h deleted file mode 100644 index 59ee9f505..000000000 --- a/ui/gl/gl_surface_mac.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 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 "ui/gl/gl_surface.h" - -namespace gfx { - -class GL_EXPORT GLSurfaceMac : public GLSurface { - public: - GLSurfaceMac(gfx::AcceleratedWidget widget, - const gfx::SurfaceConfiguration requested_configuration); - - bool SwapBuffers() override; - void Destroy() override; - bool IsOffscreen() override; - gfx::Size GetSize() override; - void* GetHandle() override; - bool Resize(const gfx::Size& size) override; - bool OnMakeCurrent(GLContext* context) override; - - private: - ~GLSurfaceMac() override; - - gfx::AcceleratedWidget widget_; - - DISALLOW_COPY_AND_ASSIGN(GLSurfaceMac); -}; - -} // namespace gfx diff --git a/ui/gl/gl_surface_mac.mm b/ui/gl/gl_surface_mac.mm deleted file mode 100644 index ea981b55d..000000000 --- a/ui/gl/gl_surface_mac.mm +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2014 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 "ui/gl/gl_surface_mac.h" - -#include "base/mac/scoped_nsautorelease_pool.h" -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_enums.h" -#include "base/logging.h" - -#import -#import - -#define WIDGET_AS_VIEW (reinterpret_cast(widget_)) - -namespace gfx { - -GLSurfaceMac::GLSurfaceMac(gfx::AcceleratedWidget widget, - const gfx::SurfaceConfiguration requested_configuration) - : GLSurface(requested_configuration), - widget_(widget) { -} - -GLSurfaceMac::~GLSurfaceMac() { - Destroy(); -} - -bool GLSurfaceMac::OnMakeCurrent(GLContext* context) { - return true; -} - -bool GLSurfaceMac::SwapBuffers() { - [[NSOpenGLContext currentContext] flushBuffer]; - return true; -} - -void GLSurfaceMac::Destroy() { - DCHECK(false); -} - -bool GLSurfaceMac::IsOffscreen() { - return false; -} - -gfx::Size GLSurfaceMac::GetSize() { - auto size = WIDGET_AS_VIEW.bounds.size; - return Size(size.width, size.height); -} - -void* GLSurfaceMac::GetHandle() { - return (void*)widget_; -} - -bool GLSurfaceMac::Resize(const gfx::Size& size) { - // The backing has already been updated. - return true; -} - -bool GLSurface::InitializeOneOffInternal() { - // On EGL, this method is used to perfom one-time initialization tasks like - // initializing the display, setting up config lists, etc. There is no such - // setup on Mac. - return true; -} - -// static -scoped_refptr GLSurface::CreateViewGLSurface( - gfx::AcceleratedWidget window, - const gfx::SurfaceConfiguration& requested_configuration) { - DCHECK(window != kNullAcceleratedWidget); - scoped_refptr surface = - new GLSurfaceMac(window, requested_configuration); - - if (!surface->Initialize()) - return NULL; - - return surface; -} - -} // namespace gfx diff --git a/ui/gl/gl_surface_osmesa.cc b/ui/gl/gl_surface_osmesa.cc deleted file mode 100644 index 2efe12be3..000000000 --- a/ui/gl/gl_surface_osmesa.cc +++ /dev/null @@ -1,139 +0,0 @@ -// 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/logging.h" -#include "base/numerics/safe_math.h" -#include "third_party/mesa/src/include/GL/osmesa.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_surface_osmesa.h" -#include "ui/gl/scoped_make_current.h" - -namespace gfx { - -GLSurfaceOSMesa::GLSurfaceOSMesa( - OSMesaSurfaceFormat format, - const gfx::Size& size, - const gfx::SurfaceConfiguration requested_configuration) - : GLSurface(requested_configuration), size_(size) { - switch (format) { - case OSMesaSurfaceFormatBGRA: - format_ = OSMESA_BGRA; - break; - case OSMesaSurfaceFormatRGBA: - format_ = OSMESA_RGBA; - break; - } - // Implementations of OSMesa surface do not support having a 0 size. In such - // cases use a (1, 1) surface. - if (size_.GetArea() == 0) - size_.SetSize(1, 1); -} - -bool GLSurfaceOSMesa::Initialize() { - return Resize(size_); -} - -void GLSurfaceOSMesa::Destroy() { - buffer_.reset(); -} - -void* GLSurfaceOSMesa::GetConfig() { - // TODO(iansf): Possibly choose a configuration in a manner similar to - // NativeViewGLSurfaceEGL::GetConfig, using the gfx::SurfaceConfiguration - // returned by GLSurface::GetSurfaceConfiguration. - NOTIMPLEMENTED(); - return NULL; -} - -bool GLSurfaceOSMesa::Resize(const gfx::Size& new_size) { - scoped_ptr scoped_make_current; - GLContext* current_context = GLContext::GetCurrent(); - bool was_current = - current_context && current_context->IsCurrent(this); - if (was_current) { - scoped_make_current.reset( - new ui::ScopedMakeCurrent(current_context, this)); - current_context->ReleaseCurrent(this); - } - - // Preserve the old buffer. - scoped_ptr old_buffer(buffer_.release()); - - base::CheckedNumeric checked_size = sizeof(buffer_[0]); - checked_size *= new_size.width(); - checked_size *= new_size.height(); - if (!checked_size.IsValid()) - return false; - - // Allocate a new one. - buffer_.reset(new int32[new_size.GetArea()]); - if (!buffer_.get()) - return false; - - memset(buffer_.get(), 0, new_size.GetArea() * sizeof(buffer_[0])); - - // Copy the old back buffer into the new buffer. - if (old_buffer.get()) { - int copy_width = std::min(size_.width(), new_size.width()); - int copy_height = std::min(size_.height(), new_size.height()); - for (int y = 0; y < copy_height; ++y) { - for (int x = 0; x < copy_width; ++x) { - buffer_[y * new_size.width() + x] = old_buffer[y * size_.width() + x]; - } - } - } - - size_ = new_size; - - return true; -} - -bool GLSurfaceOSMesa::IsOffscreen() { - return true; -} - -bool GLSurfaceOSMesa::SwapBuffers() { - NOTREACHED() << "Should not call SwapBuffers on an GLSurfaceOSMesa."; - return false; -} - -gfx::Size GLSurfaceOSMesa::GetSize() { - return size_; -} - -void* GLSurfaceOSMesa::GetHandle() { - return buffer_.get(); -} - -unsigned GLSurfaceOSMesa::GetFormat() { - return format_; -} - -GLSurfaceOSMesa::~GLSurfaceOSMesa() { - Destroy(); -} - -bool GLSurfaceOSMesaHeadless::IsOffscreen() { return false; } - -bool GLSurfaceOSMesaHeadless::SwapBuffers() { return true; } - -GLSurfaceOSMesaHeadless::GLSurfaceOSMesaHeadless( - const gfx::SurfaceConfiguration requested_configuration) - : GLSurfaceOSMesa(OSMesaSurfaceFormatBGRA, - gfx::Size(1, 1), - requested_configuration) { -} - -void* GLSurfaceOSMesaHeadless::GetConfig() { - // TODO(iansf): Possibly choose a configuration in a manner similar to - // NativeViewGLSurfaceEGL::GetConfig, using the gfx::SurfaceConfiguration - // returned by GLSurface::GetSurfaceConfiguration. - NOTIMPLEMENTED(); - return NULL; -} - -GLSurfaceOSMesaHeadless::~GLSurfaceOSMesaHeadless() { Destroy(); } - -} // namespace gfx diff --git a/ui/gl/gl_surface_osmesa.h b/ui/gl/gl_surface_osmesa.h deleted file mode 100644 index 7484063f6..000000000 --- a/ui/gl/gl_surface_osmesa.h +++ /dev/null @@ -1,68 +0,0 @@ -// 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 UI_GL_GL_SURFACE_OSMESA_H_ -#define UI_GL_GL_SURFACE_OSMESA_H_ - -#include "base/memory/scoped_ptr.h" -#include "ui/gfx/geometry/size.h" -#include "ui/gl/gl_surface.h" - -namespace gfx { - -enum OSMesaSurfaceFormat { OSMesaSurfaceFormatBGRA, OSMesaSurfaceFormatRGBA }; - -// A surface that the Mesa software renderer draws to. This is actually just a -// buffer in system memory. GetHandle returns a pointer to the buffer. These -// surfaces can be resized and resizing preserves the contents. -class GL_EXPORT GLSurfaceOSMesa : public GLSurface { - public: - GLSurfaceOSMesa(OSMesaSurfaceFormat format, - const gfx::Size& size, - const gfx::SurfaceConfiguration requested_configuration); - - // Implement GLSurface. - bool Initialize() override; - void Destroy() override; - bool Resize(const gfx::Size& new_size) override; - bool IsOffscreen() override; - bool SwapBuffers() override; - gfx::Size GetSize() override; - void* GetHandle() override; - unsigned GetFormat() override; - void* GetConfig() override; - - protected: - ~GLSurfaceOSMesa() override; - - private: - unsigned format_; - gfx::Size size_; - scoped_ptr buffer_; - - DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesa); -}; - -// A thin subclass of |GLSurfaceOSMesa| that can be used in place -// of a native hardware-provided surface when a native surface -// provider is not available. -class GLSurfaceOSMesaHeadless : public GLSurfaceOSMesa { - public: - explicit GLSurfaceOSMesaHeadless( - const gfx::SurfaceConfiguration requested_configuration); - - bool IsOffscreen() override; - bool SwapBuffers() override; - void* GetConfig() override; - - protected: - ~GLSurfaceOSMesaHeadless() override; - - private: - DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesaHeadless); -}; - -} // namespace gfx - -#endif // UI_GL_GL_SURFACE_OSMESA_H_ diff --git a/ui/gl/gl_surface_osmesa_x11.cc b/ui/gl/gl_surface_osmesa_x11.cc deleted file mode 100644 index 5992071ac..000000000 --- a/ui/gl/gl_surface_osmesa_x11.cc +++ /dev/null @@ -1,218 +0,0 @@ -// 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 "ui/gl/gl_surface_osmesa_x11.h" - -#include - -#include "base/logging.h" -#include "base/message_loop/message_loop.h" -#include "base/trace_event/trace_event.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_surface_egl.h" - -namespace gfx { - -// static -bool GLSurface::InitializeOneOffInternal() { - if (!NativeViewGLSurfaceOSMesa::InitializeOneOff()) { - LOG(ERROR) << "NativeViewGLSurfaceOSMesa::InitializeOneOff failed."; - return false; - } - return true; -} - -// static -bool NativeViewGLSurfaceOSMesa::InitializeOneOff() { - static bool initialized = false; - if (initialized) - return true; - - if (!GetXDisplay()) { - LOG(ERROR) << "XOpenDisplay failed."; - return false; - } - - initialized = true; - return true; -} - -scoped_refptr GLSurface::CreateViewGLSurface( - gfx::AcceleratedWidget window, - const gfx::SurfaceConfiguration& requested_configuration) { - TRACE_EVENT0("gpu", "GLSurface::CreateViewGLSurface"); - scoped_refptr surface( - new NativeViewGLSurfaceOSMesa(window, requested_configuration)); - if (!surface->Initialize()) - return NULL; - - return surface; -} - -scoped_refptr GLSurface::CreateOffscreenGLSurface( - const gfx::Size& size, - const gfx::SurfaceConfiguration& requested_configuration) { - TRACE_EVENT0("gpu", "GLSurface::CreateOffscreenGLSurface"); - scoped_refptr surface(new GLSurfaceOSMesa( - OSMesaSurfaceFormatRGBA, size, requested_configuration)); - if (!surface->Initialize()) - return NULL; - - return surface; -} - -NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa( - AcceleratedWidget window, - const SurfaceConfiguration& requested_configuration) - : GLSurfaceOSMesa(OSMesaSurfaceFormatBGRA, - Size(1, 1), - requested_configuration), - xdisplay_(GetXDisplay()), - window_graphics_context_(0), - window_(window), - pixmap_graphics_context_(0), - pixmap_(0) { - DCHECK(xdisplay_); - DCHECK(window_); -} - -bool NativeViewGLSurfaceOSMesa::Initialize() { - if (!GLSurfaceOSMesa::Initialize()) - return false; - - window_graphics_context_ = XCreateGC(xdisplay_, window_, 0, NULL); - if (!window_graphics_context_) { - LOG(ERROR) << "XCreateGC failed."; - Destroy(); - return false; - } - - return true; -} - -void NativeViewGLSurfaceOSMesa::Destroy() { - if (pixmap_graphics_context_) { - XFreeGC(xdisplay_, pixmap_graphics_context_); - pixmap_graphics_context_ = NULL; - } - - if (pixmap_) { - XFreePixmap(xdisplay_, pixmap_); - pixmap_ = 0; - } - - if (window_graphics_context_) { - XFreeGC(xdisplay_, window_graphics_context_); - window_graphics_context_ = NULL; - } - - XSync(xdisplay_, False); -} - -bool NativeViewGLSurfaceOSMesa::Resize(const Size& new_size) { - if (!GLSurfaceOSMesa::Resize(new_size)) - return false; - - XWindowAttributes attributes; - if (!XGetWindowAttributes(xdisplay_, window_, &attributes)) { - LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << "."; - return false; - } - - // Destroy the previous pixmap and graphics context. - if (pixmap_graphics_context_) { - XFreeGC(xdisplay_, pixmap_graphics_context_); - pixmap_graphics_context_ = NULL; - } - if (pixmap_) { - XFreePixmap(xdisplay_, pixmap_); - pixmap_ = 0; - } - - // Recreate a pixmap to hold the frame. - pixmap_ = XCreatePixmap(xdisplay_, window_, new_size.width(), - new_size.height(), attributes.depth); - if (!pixmap_) { - LOG(ERROR) << "XCreatePixmap failed."; - return false; - } - - // Recreate a graphics context for the pixmap. - pixmap_graphics_context_ = XCreateGC(xdisplay_, pixmap_, 0, NULL); - if (!pixmap_graphics_context_) { - LOG(ERROR) << "XCreateGC failed"; - return false; - } - - return true; -} - -bool NativeViewGLSurfaceOSMesa::IsOffscreen() { - return false; -} - -bool NativeViewGLSurfaceOSMesa::SwapBuffers() { - TRACE_EVENT2("gpu", "NativeViewGLSurfaceOSMesa:RealSwapBuffers", "width", - GetSize().width(), "height", GetSize().height()); - - Size size = GetSize(); - - XWindowAttributes attributes; - if (!XGetWindowAttributes(xdisplay_, window_, &attributes)) { - LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << "."; - return false; - } - - // Copy the frame into the pixmap. - PutARGBImage(xdisplay_, attributes.visual, attributes.depth, pixmap_, - pixmap_graphics_context_, static_cast(GetHandle()), - size.width(), size.height()); - - // Copy the pixmap to the window. - XCopyArea(xdisplay_, pixmap_, window_, window_graphics_context_, 0, 0, - size.width(), size.height(), 0, 0); - - return true; -} - -bool NativeViewGLSurfaceOSMesa::SupportsPostSubBuffer() { - return true; -} - -bool NativeViewGLSurfaceOSMesa::PostSubBuffer(int x, - int y, - int width, - int height) { - Size size = GetSize(); - - // Move (0,0) from lower-left to upper-left - y = size.height() - y - height; - - XWindowAttributes attributes; - if (!XGetWindowAttributes(xdisplay_, window_, &attributes)) { - LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << "."; - return false; - } - - // Copy the frame into the pixmap. - PutARGBImage(xdisplay_, attributes.visual, attributes.depth, pixmap_, - pixmap_graphics_context_, static_cast(GetHandle()), - size.width(), size.height(), x, y, x, y, width, height); - - // Copy the pixmap to the window. - XCopyArea(xdisplay_, pixmap_, window_, window_graphics_context_, x, y, width, - height, x, y); - - return true; -} - -NativeViewGLSurfaceOSMesa::~NativeViewGLSurfaceOSMesa() { - Destroy(); -} - -EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { - return gfx::GetXDisplay(); -} -} diff --git a/ui/gl/gl_surface_osmesa_x11.h b/ui/gl/gl_surface_osmesa_x11.h deleted file mode 100644 index ba28309a6..000000000 --- a/ui/gl/gl_surface_osmesa_x11.h +++ /dev/null @@ -1,51 +0,0 @@ -// 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. - -#ifndef UI_GL_GL_SURFACE_OSMESA_X11_H_ -#define UI_GL_GL_SURFACE_OSMESA_X11_H_ - -#include - -#include "ui/gfx/native_widget_types.h" -#include "ui/gfx/x/x11_types.h" -#include "ui/gl/gl_surface.h" -#include "ui/gl/gl_surface_osmesa.h" - -namespace gfx { - -// This OSMesa GL surface can use XLib to swap the contents of the buffer to a -// view. -class NativeViewGLSurfaceOSMesa : public GLSurfaceOSMesa { - public: - NativeViewGLSurfaceOSMesa( - AcceleratedWidget window, - const SurfaceConfiguration& requested_configuration); - - static bool InitializeOneOff(); - - // Implement a subset of GLSurface. - bool Initialize() override; - void Destroy() override; - bool Resize(const Size& new_size) override; - bool IsOffscreen() override; - bool SwapBuffers() override; - bool SupportsPostSubBuffer() override; - bool PostSubBuffer(int x, int y, int width, int height) override; - - protected: - ~NativeViewGLSurfaceOSMesa() override; - - private: - XDisplay* xdisplay_; - GC window_graphics_context_; - AcceleratedWidget window_; - GC pixmap_graphics_context_; - EGLNativePixmapType pixmap_; - - DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceOSMesa); -}; - -} // namespace gfx - -#endif // UI_GL_GL_SURFACE_OSMESA_X11_H_ diff --git a/ui/gl/gl_surface_stub.cc b/ui/gl/gl_surface_stub.cc deleted file mode 100644 index 70230fc7c..000000000 --- a/ui/gl/gl_surface_stub.cc +++ /dev/null @@ -1,35 +0,0 @@ -// 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 "ui/gl/gl_surface_stub.h" - -namespace gfx { - -GLSurfaceStub::GLSurfaceStub( - const gfx::SurfaceConfiguration requested_configuration) - : GLSurface(requested_configuration) { -} - -void GLSurfaceStub::Destroy() { -} - -bool GLSurfaceStub::IsOffscreen() { - return false; -} - -bool GLSurfaceStub::SwapBuffers() { - return true; -} - -gfx::Size GLSurfaceStub::GetSize() { - return size_; -} - -void* GLSurfaceStub::GetHandle() { - return NULL; -} - -GLSurfaceStub::~GLSurfaceStub() {} - -} // namespace gfx diff --git a/ui/gl/gl_surface_stub.h b/ui/gl/gl_surface_stub.h deleted file mode 100644 index f35e716b3..000000000 --- a/ui/gl/gl_surface_stub.h +++ /dev/null @@ -1,36 +0,0 @@ -// 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 UI_GL_GL_SURFACE_STUB_H_ -#define UI_GL_GL_SURFACE_STUB_H_ - -#include "ui/gl/gl_surface.h" - -namespace gfx { - -// A GLSurface that does nothing for unit tests. -class GL_EXPORT GLSurfaceStub : public GLSurface { - public: - explicit GLSurfaceStub( - const gfx::SurfaceConfiguration requested_configuration); - - void SetSize(const gfx::Size& size) { size_ = size; } - - // Implement GLSurface. - void Destroy() override; - bool IsOffscreen() override; - bool SwapBuffers() override; - gfx::Size GetSize() override; - void* GetHandle() override; - - protected: - ~GLSurfaceStub() override; - - private: - gfx::Size size_; -}; - -} // namespace gfx - -#endif // UI_GL_GL_SURFACE_STUB_H_ diff --git a/ui/gl/gl_switches.cc b/ui/gl/gl_switches.cc deleted file mode 100644 index 881715636..000000000 --- a/ui/gl/gl_switches.cc +++ /dev/null @@ -1,90 +0,0 @@ -// 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 "ui/gl/gl_switches.h" -#include "base/basictypes.h" - -namespace gfx { - -const char kGLImplementationDesktopName[] = "desktop"; -const char kGLImplementationOSMesaName[] = "osmesa"; -const char kGLImplementationAppleName[] = "apple"; -const char kGLImplementationEGLName[] = "egl"; -const char kGLImplementationSwiftShaderName[] = "swiftshader"; -const char kGLImplementationMockName[] = "mock"; - -} // namespace gfx - -namespace switches { - -// Disables use of D3D11. -const char kDisableD3D11[] = "disable-d3d11"; - -// Stop the GPU from synchronizing on the vsync before presenting. -const char kDisableGpuVsync[] = "disable-gpu-vsync"; - -// Turns on GPU logging (debug build only). -const char kEnableGPUServiceLogging[] = "enable-gpu-service-logging"; - -// Turns on calling TRACE for every GL call. -const char kEnableGPUServiceTracing[] = "enable-gpu-service-tracing"; - -// Select which implementation of GL the GPU process should use. Options are: -// desktop: whatever desktop OpenGL the user has installed (Linux and Mac -// default). -// egl: whatever EGL / GLES2 the user has installed (Windows default - actually -// ANGLE). -// osmesa: The OSMesa software renderer. -const char kUseGL[] = "use-gl"; - -const char kSwiftShaderPath[] = "swiftshader-path"; - -// Inform Chrome that a GPU context will not be lost in power saving mode, -// screen saving mode, etc. Note that this flag does not ensure that a GPU -// context will never be lost in any situations, say, a GPU reset. -const char kGpuNoContextLost[] = "gpu-no-context-lost"; - -// Indicates whether the dual GPU switching is supported or not. -const char kSupportsDualGpus[] = "supports-dual-gpus"; - -// Flag used for Linux tests: for desktop GL bindings, try to load this GL -// library first, but fall back to regular library if loading fails. -const char kTestGLLib[] = "test-gl-lib"; - -// Use hardware gpu, if available, for tests. -const char kUseGpuInTests[] = "use-gpu-in-tests"; - -// On Windows only: use the WARP software rasterizer in the GPU process. -const char kUseWarp[] = "use-warp"; - -// Enable OpenGL ES 3 APIs without proper service side validation. -const char kEnableUnsafeES3APIs[] = "enable-unsafe-es3-apis"; - -// Disables GL drawing operations which produce pixel output. With this -// the GL output will not be correct but tests will run faster. -const char kDisableGLDrawingForTests[] = "disable-gl-drawing-for-tests"; - -// Forces the use of OSMesa instead of hardware gpu. -const char kOverrideUseGLWithOSMesaForTests[] = - "override-use-gl-with-osmesa-for-tests"; - -// This is the list of switches passed from this file that are passed from the -// GpuProcessHost to the GPU Process. Add your switch to this list if you need -// to read it in the GPU process, else don't add it. -const char* kGLSwitchesCopiedFromGpuProcessHost[] = { - kDisableGpuVsync, - kDisableD3D11, - kEnableGPUServiceLogging, - kEnableGPUServiceTracing, - kEnableUnsafeES3APIs, - kGpuNoContextLost, - kDisableGLDrawingForTests, - kOverrideUseGLWithOSMesaForTests, - kUseWarp, -}; -const int kGLSwitchesCopiedFromGpuProcessHostNumSwitches = - arraysize(kGLSwitchesCopiedFromGpuProcessHost); - -} // namespace switches - diff --git a/ui/gl/gl_switches.h b/ui/gl/gl_switches.h deleted file mode 100644 index 0715ad9ae..000000000 --- a/ui/gl/gl_switches.h +++ /dev/null @@ -1,50 +0,0 @@ -// 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 UI_GL_GL_SWITCHES_H_ -#define UI_GL_GL_SWITCHES_H_ - -// Defines all the command-line switches used by ui/gl. - -#include "ui/gl/gl_export.h" - -namespace gfx { - -// The GL implementation names that can be passed to --use-gl. -GL_EXPORT extern const char kGLImplementationDesktopName[]; -GL_EXPORT extern const char kGLImplementationOSMesaName[]; -GL_EXPORT extern const char kGLImplementationAppleName[]; -GL_EXPORT extern const char kGLImplementationEGLName[]; -GL_EXPORT extern const char kGLImplementationSwiftShaderName[]; -extern const char kGLImplementationMockName[]; - -} // namespace gfx - -namespace switches { - -GL_EXPORT extern const char kDisableD3D11[]; -GL_EXPORT extern const char kDisableGpuVsync[]; -GL_EXPORT extern const char kEnableGPUServiceLogging[]; -GL_EXPORT extern const char kEnableGPUServiceTracing[]; -GL_EXPORT extern const char kGpuNoContextLost[]; - -GL_EXPORT extern const char kSupportsDualGpus[]; - -GL_EXPORT extern const char kUseGL[]; -GL_EXPORT extern const char kSwiftShaderPath[]; -GL_EXPORT extern const char kTestGLLib[]; -GL_EXPORT extern const char kUseGpuInTests[]; -GL_EXPORT extern const char kUseWarp[]; -GL_EXPORT extern const char kEnableUnsafeES3APIs[]; - -// These flags are used by the test harness code, not passed in by users. -GL_EXPORT extern const char kDisableGLDrawingForTests[]; -GL_EXPORT extern const char kOverrideUseGLWithOSMesaForTests[]; - -GL_EXPORT extern const char* kGLSwitchesCopiedFromGpuProcessHost[]; -GL_EXPORT extern const int kGLSwitchesCopiedFromGpuProcessHostNumSwitches; - -} // namespace switches - -#endif // UI_GL_GL_SWITCHES_H_ diff --git a/ui/gl/gl_version_info.cc b/ui/gl/gl_version_info.cc deleted file mode 100644 index 02409694f..000000000 --- a/ui/gl/gl_version_info.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 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 "ui/gl/gl_version_info.h" - -#include "base/strings/string_number_conversions.h" -#include "base/strings/string_tokenizer.h" -#include "base/strings/string_util.h" - -namespace gfx { - -GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str) - : is_es(false), - is_angle(false), - major_version(0), - minor_version(0), - is_es3(false) { - if (version_str) { - std::string lstr(base::StringToLowerASCII(std::string(version_str))); - is_es = (lstr.length() > 12) && (lstr.substr(0, 9) == "opengl es"); - if (is_es) - lstr = lstr.substr(10, 3); - base::StringTokenizer tokenizer(lstr.begin(), lstr.end(), "."); - unsigned major, minor; - if (tokenizer.GetNext() && - base::StringToUint(tokenizer.token_piece(), &major)) { - major_version = major; - if (tokenizer.GetNext() && - base::StringToUint(tokenizer.token_piece(), &minor)) { - minor_version = minor; - } - } - if (is_es && major_version == 3) - is_es3 = true; - } - if (renderer_str) { - is_angle = base::StartsWithASCII(renderer_str, "ANGLE", true); - } -} - -} // namespace gfx diff --git a/ui/gl/gl_version_info.h b/ui/gl/gl_version_info.h deleted file mode 100644 index 96944758f..000000000 --- a/ui/gl/gl_version_info.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2014 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 UI_GL_GL_VERSION_INFO_H_ -#define UI_GL_GL_VERSION_INFO_H_ - -#include -#include "base/basictypes.h" -#include "ui/gl/gl_export.h" - -namespace gfx { - -struct GL_EXPORT GLVersionInfo { - GLVersionInfo(const char* version_str, const char* renderer_str); - - bool IsAtLeastGL(unsigned major, unsigned minor) const { - return !is_es && (major_version > major || - (major_version == major && minor_version >= minor)); - } - - bool IsLowerThanGL(unsigned major, unsigned minor) const { - return !is_es && (major_version < major || - (major_version == major && minor_version < minor)); - } - - bool IsAtLeastGLES(unsigned major, unsigned minor) const { - return is_es && (major_version > major || - (major_version == major && minor_version >= minor)); - } - - bool is_es; - bool is_angle; - unsigned major_version; - unsigned minor_version; - bool is_es3; - - private: - DISALLOW_COPY_AND_ASSIGN(GLVersionInfo); -}; - -} // namespace gfx - -#endif // UI_GL_GL_VERSION_INFO_H_ diff --git a/ui/gl/gpu_preference.h b/ui/gl/gpu_preference.h deleted file mode 100644 index 8d0303620..000000000 --- a/ui/gl/gpu_preference.h +++ /dev/null @@ -1,25 +0,0 @@ -// 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 UI_GL_GPU_PREFERENCE_H_ -#define UI_GL_GPU_PREFERENCE_H_ - -namespace gfx { - -// On dual-GPU systems, expresses a preference for using the integrated -// or discrete GPU. On systems that have dual-GPU support (see -// GpuDataManagerImpl), resource sharing only works between -// contexts that are created with the same GPU preference. -// -// This API will likely need to be adjusted as the functionality is -// implemented on more operating systems. -enum GpuPreference { - PreferIntegratedGpu, - PreferDiscreteGpu, - GpuPreferenceLast = PreferDiscreteGpu -}; - -} // namespace gfx - -#endif // UI_GL_GPU_PREFERENCE_H_ diff --git a/ui/gl/gpu_switching_manager.cc b/ui/gl/gpu_switching_manager.cc deleted file mode 100644 index 620de1867..000000000 --- a/ui/gl/gpu_switching_manager.cc +++ /dev/null @@ -1,95 +0,0 @@ -// 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 "ui/gl/gpu_switching_manager.h" - -#include "base/command_line.h" -#include "base/logging.h" -#include "ui/gl/gl_switches.h" - -namespace ui { - -// static -GpuSwitchingManager* GpuSwitchingManager::GetInstance() { - return Singleton::get(); -} - -GpuSwitchingManager::GpuSwitchingManager() - : gpu_switching_option_(gfx::PreferIntegratedGpu), - gpu_switching_option_set_(false), - supports_dual_gpus_(false), - supports_dual_gpus_set_(false), - gpu_count_(0) { -} - -GpuSwitchingManager::~GpuSwitchingManager() { -} - -void GpuSwitchingManager::ForceUseOfIntegratedGpu() { - DCHECK(SupportsDualGpus()); - if (gpu_switching_option_set_) { - DCHECK_EQ(gpu_switching_option_, gfx::PreferIntegratedGpu); - } else { - gpu_switching_option_ = gfx::PreferIntegratedGpu; - gpu_switching_option_set_ = true; - } -} - -void GpuSwitchingManager::ForceUseOfDiscreteGpu() { - DCHECK(SupportsDualGpus()); - if (gpu_switching_option_set_) { - DCHECK_EQ(gpu_switching_option_, gfx::PreferDiscreteGpu); - } else { - gpu_switching_option_ = gfx::PreferDiscreteGpu; - gpu_switching_option_set_ = true; - } -} - -bool GpuSwitchingManager::SupportsDualGpus() { - if (!supports_dual_gpus_set_) { - const base::CommandLine& command_line = - *base::CommandLine::ForCurrentProcess(); - bool flag = false; - if (command_line.HasSwitch(switches::kSupportsDualGpus)) { - // GPU process, flag is passed down from browser process. - std::string flag_string = command_line.GetSwitchValueASCII( - switches::kSupportsDualGpus); - if (flag_string == "true") { - flag = true; - } else if (flag_string == "false") { - flag = false; - } else { - NOTIMPLEMENTED(); - } - } - supports_dual_gpus_ = flag; - supports_dual_gpus_set_ = true; - } - return supports_dual_gpus_; -} - -void GpuSwitchingManager::SetGpuCount(size_t gpu_count) { - gpu_count_ = gpu_count; -} - -void GpuSwitchingManager::AddObserver(GpuSwitchingObserver* observer) { - observer_list_.AddObserver(observer); -} - -void GpuSwitchingManager::RemoveObserver(GpuSwitchingObserver* observer) { - observer_list_.RemoveObserver(observer); -} - -void GpuSwitchingManager::NotifyGpuSwitched() { - FOR_EACH_OBSERVER(GpuSwitchingObserver, observer_list_, OnGpuSwitched()); -} - -gfx::GpuPreference GpuSwitchingManager::AdjustGpuPreference( - gfx::GpuPreference gpu_preference) { - if (!gpu_switching_option_set_) - return gpu_preference; - return gpu_switching_option_; -} - -} // namespace ui diff --git a/ui/gl/gpu_switching_manager.h b/ui/gl/gpu_switching_manager.h deleted file mode 100644 index 7b018533a..000000000 --- a/ui/gl/gpu_switching_manager.h +++ /dev/null @@ -1,74 +0,0 @@ -// 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 UI_GL_GPU_SWITCHING_MANAGER_H_ -#define UI_GL_GPU_SWITCHING_MANAGER_H_ - -#include - -#include "base/memory/singleton.h" -#include "base/observer_list.h" -#include "ui/gl/gl_export.h" -#include "ui/gl/gpu_preference.h" -#include "ui/gl/gpu_switching_observer.h" - -namespace ui { - -class GL_EXPORT GpuSwitchingManager { - public: - // Getter for the singleton. This will return NULL on failure. - static GpuSwitchingManager* GetInstance(); - - // Set the switching option to PreferIntegratedGpu. - void ForceUseOfIntegratedGpu(); - // Set the switching option to PreferDiscreteGpu; switch to discrete GPU - // immediately on Mac where dual GPU switching is supported. - void ForceUseOfDiscreteGpu(); - - // If no GPU is forced, return the original GpuPreference; otherwise, return - // the forced GPU. - gfx::GpuPreference AdjustGpuPreference(gfx::GpuPreference gpu_preference); - - // In the browser process, the value for this flag is computed the first time - // this function is called. - // In the GPU process, the value is passed from the browser process using the - // --supports-dual-gpus commandline switch. - bool SupportsDualGpus(); - - void SetGpuCount(size_t gpu_count); - - void AddObserver(GpuSwitchingObserver* observer); - void RemoveObserver(GpuSwitchingObserver* observer); - - // Called when a GPU switch is noticed by the system. In the browser process - // this is occurs as a result of a system observer. In the GPU process, this - // occurs as a result of an IPC from the browser. The system observer is kept - // in the browser process only so that any workarounds or blacklisting can - // be applied there. - void NotifyGpuSwitched(); - - private: - friend struct DefaultSingletonTraits; - - GpuSwitchingManager(); - virtual ~GpuSwitchingManager(); - - gfx::GpuPreference gpu_switching_option_; - bool gpu_switching_option_set_; - - bool supports_dual_gpus_; - bool supports_dual_gpus_set_; - - size_t gpu_count_; - - struct PlatformSpecific; - - base::ObserverList observer_list_; - - DISALLOW_COPY_AND_ASSIGN(GpuSwitchingManager); -}; - -} // namespace ui - -#endif // UI_GL_GPU_SWITCHING_MANAGER_H_ diff --git a/ui/gl/gpu_switching_observer.h b/ui/gl/gpu_switching_observer.h deleted file mode 100644 index ed85d8a0d..000000000 --- a/ui/gl/gpu_switching_observer.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 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 UI_GL_GPU_SWITCHING_OBSERVER_H_ -#define UI_GL_GPU_SWITCHING_OBSERVER_H_ - -#include "ui/gl/gl_export.h" - -namespace ui { - -class GL_EXPORT GpuSwitchingObserver { - public: - // Called for any observer when the system switches to a different GPU. - virtual void OnGpuSwitched() {}; -}; - -} // namespace ui - -#endif // UI_GL_GPU_SWITCHING_OBSERVER_H_ diff --git a/ui/gl/gpu_timing.cc b/ui/gl/gpu_timing.cc deleted file mode 100644 index e22771767..000000000 --- a/ui/gl/gpu_timing.cc +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright (c) 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 "ui/gl/gpu_timing.h" - -#include "base/time/time.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_version_info.h" - -namespace gfx { - -GPUTiming::GPUTiming(GLContextReal* context) { - DCHECK(context); - const GLVersionInfo* version_info = context->GetVersionInfo(); - DCHECK(version_info); - if (version_info->is_es3 && // glGetInteger64v is supported under ES3. - context->HasExtension("GL_EXT_disjoint_timer_query")) { - timer_type_ = kTimerTypeDisjoint; - } else if (context->HasExtension("GL_ARB_timer_query")) { - timer_type_ = kTimerTypeARB; - } else if (context->HasExtension("GL_EXT_timer_query")) { - timer_type_ = kTimerTypeEXT; - } -} - -GPUTiming::~GPUTiming() { -} - -scoped_refptr GPUTiming::CreateGPUTimingClient() { - return new GPUTimingClient(this); -} - -uint32_t GPUTiming::GetDisjointCount() { - if (timer_type_ == kTimerTypeDisjoint) { - GLint disjoint_value = 0; - glGetIntegerv(GL_GPU_DISJOINT_EXT, &disjoint_value); - if (disjoint_value) { - disjoint_counter_++; - } - } - return disjoint_counter_; -} - -GPUTimer::~GPUTimer() { - // Destroy() must be called before the destructor. - DCHECK(queries_[0] == 0); - DCHECK(queries_[1] == 0); -} - -void GPUTimer::Destroy(bool have_context) { - if (have_context) { - glDeleteQueries(2, queries_); - } - memset(queries_, 0, sizeof(queries_)); -} - -void GPUTimer::Start() { - switch (gpu_timing_client_->gpu_timing_->timer_type_) { - case GPUTiming::kTimerTypeARB: - case GPUTiming::kTimerTypeDisjoint: - // GL_TIMESTAMP and GL_TIMESTAMP_EXT both have the same value. - glQueryCounter(queries_[0], GL_TIMESTAMP); - break; - case GPUTiming::kTimerTypeEXT: - glBeginQuery(GL_TIME_ELAPSED_EXT, queries_[0]); - break; - default: - NOTREACHED(); - } -} - -void GPUTimer::End() { - end_requested_ = true; - DCHECK(gpu_timing_client_->gpu_timing_); - switch (gpu_timing_client_->gpu_timing_->timer_type_) { - case GPUTiming::kTimerTypeARB: - case GPUTiming::kTimerTypeDisjoint: - offset_ = gpu_timing_client_->CalculateTimerOffset(); - glQueryCounter(queries_[1], GL_TIMESTAMP); - break; - case GPUTiming::kTimerTypeEXT: - glEndQuery(GL_TIME_ELAPSED_EXT); - break; - default: - NOTREACHED(); - } -} - -bool GPUTimer::IsAvailable() { - if (!gpu_timing_client_->IsAvailable() || !end_requested_) { - return false; - } - GLint done = 0; - glGetQueryObjectiv(queries_[1] ? queries_[1] : queries_[0], - GL_QUERY_RESULT_AVAILABLE, &done); - return done != 0; -} - -void GPUTimer::GetStartEndTimestamps(int64* start, int64* end) { - DCHECK(start && end); - DCHECK(IsAvailable()); - DCHECK(gpu_timing_client_->gpu_timing_); - DCHECK(gpu_timing_client_->gpu_timing_->timer_type_ != - GPUTiming::kTimerTypeEXT); - GLuint64 begin_stamp = 0; - GLuint64 end_stamp = 0; - // TODO(dsinclair): It's possible for the timer to wrap during the start/end. - // We need to detect if the end is less then the start and correct for the - // wrapping. - glGetQueryObjectui64v(queries_[0], GL_QUERY_RESULT, &begin_stamp); - glGetQueryObjectui64v(queries_[1], GL_QUERY_RESULT, &end_stamp); - - *start = (begin_stamp / base::Time::kNanosecondsPerMicrosecond) + offset_; - *end = (end_stamp / base::Time::kNanosecondsPerMicrosecond) + offset_; -} - -int64 GPUTimer::GetDeltaElapsed() { - DCHECK(gpu_timing_client_->gpu_timing_); - switch (gpu_timing_client_->gpu_timing_->timer_type_) { - case GPUTiming::kTimerTypeARB: - case GPUTiming::kTimerTypeDisjoint: { - int64 start = 0; - int64 end = 0; - GetStartEndTimestamps(&start, &end); - return end - start; - } break; - case GPUTiming::kTimerTypeEXT: { - GLuint64 delta = 0; - glGetQueryObjectui64v(queries_[0], GL_QUERY_RESULT, &delta); - return static_cast(delta / base::Time::kNanosecondsPerMicrosecond); - } break; - default: - NOTREACHED(); - } - return 0; -} - -GPUTimer::GPUTimer(scoped_refptr gpu_timing_client) - : gpu_timing_client_(gpu_timing_client) { - DCHECK(gpu_timing_client_); - memset(queries_, 0, sizeof(queries_)); - int queries = 0; - DCHECK(gpu_timing_client_->gpu_timing_); - switch (gpu_timing_client_->gpu_timing_->timer_type_) { - case GPUTiming::kTimerTypeARB: - case GPUTiming::kTimerTypeDisjoint: - queries = 2; - break; - case GPUTiming::kTimerTypeEXT: - queries = 1; - break; - default: - NOTREACHED(); - } - glGenQueries(queries, queries_); -} - -GPUTimingClient::GPUTimingClient(GPUTiming* gpu_timing) - : gpu_timing_(gpu_timing) { - if (gpu_timing) { - timer_type_ = gpu_timing->GetTimerType(); - disjoint_counter_ = gpu_timing_->GetDisjointCount(); - } -} - -scoped_ptr GPUTimingClient::CreateGPUTimer() { - return make_scoped_ptr(new GPUTimer(this)); -} - -bool GPUTimingClient::IsAvailable() { - return timer_type_ != GPUTiming::kTimerTypeInvalid; -} - -bool GPUTimingClient::IsTimerOffsetAvailable() { - return timer_type_ == GPUTiming::kTimerTypeARB || - timer_type_ == GPUTiming::kTimerTypeDisjoint; -} - -const char* GPUTimingClient::GetTimerTypeName() const { - switch (timer_type_) { - case GPUTiming::kTimerTypeDisjoint: - return "GL_EXT_disjoint_timer_query"; - case GPUTiming::kTimerTypeARB: - return "GL_ARB_timer_query"; - case GPUTiming::kTimerTypeEXT: - return "GL_EXT_timer_query"; - default: - return "Unknown"; - } -} - -bool GPUTimingClient::CheckAndResetTimerErrors() { - if (timer_type_ == GPUTiming::kTimerTypeDisjoint) { - DCHECK(gpu_timing_ != nullptr); - const uint32_t total_disjoint_count = gpu_timing_->GetDisjointCount(); - const bool disjoint_triggered = total_disjoint_count != disjoint_counter_; - disjoint_counter_ = total_disjoint_count; - return disjoint_triggered; - } - return false; -} - -int64 GPUTimingClient::CalculateTimerOffset() { - DCHECK(IsTimerOffsetAvailable()); - if (!offset_valid_) { - GLint64 gl_now = 0; - glGetInteger64v(GL_TIMESTAMP, &gl_now); - int64 now = - cpu_time_for_testing_.is_null() - ? (base::TraceTicks::Now() - base::TraceTicks()).InMicroseconds() - : cpu_time_for_testing_.Run(); - offset_ = now - gl_now / base::Time::kNanosecondsPerMicrosecond; - offset_valid_ = timer_type_ == GPUTiming::kTimerTypeARB; - } - return offset_; -} - -void GPUTimingClient::InvalidateTimerOffset() { - offset_valid_ = false; -} - -void GPUTimingClient::SetCpuTimeForTesting( - const base::Callback& cpu_time) { - cpu_time_for_testing_ = cpu_time; -} - -GPUTimingClient::~GPUTimingClient() { -} - -} // namespace gfx diff --git a/ui/gl/gpu_timing.h b/ui/gl/gpu_timing.h deleted file mode 100644 index 5658097bf..000000000 --- a/ui/gl/gpu_timing.h +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (c) 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. - -#ifndef UI_GL_GPU_TIMING_H_ -#define UI_GL_GPU_TIMING_H_ - -#include "base/callback.h" -#include "base/memory/scoped_ptr.h" -#include "ui/gl/gl_export.h" - -// The gpu_timing classes handles the abstraction of GL GPU Timing extensions -// into a common set of functions. Currently the different timer extensions that -// are supported are EXT_timer_query, ARB_timer_query and -// EXT_disjoint_timer_query. -// -// Explanation of Classes: -// GPUTiming - GPU Timing is a private class which is only owned by the -// underlying GLContextReal class. This class handles any GL Context level -// states which may need to be redistributed to users of GPUTiming. For -// example, there exists only a single disjoint flag for each real GL -// Context. Once the disjoint flag is checked, internally it is reset to -// false. In order to support multiple virtual contexts each checking the -// disjoint flag seperately, GPUTiming is in charge of checking the -// disjoint flag and broadcasting out the disjoint state to all the -// various users of GPUTiming (GPUTimingClient below). -// GPUTimingClient - The GLContextReal holds the GPUTiming class and is the -// factory that creates GPUTimingClient objects. If a user would like to -// obtain various GPU times they would access CreateGPUTimingClient() from -// their GLContext and use the returned object for their timing calls. -// Each virtual context as well as any other classes which need GPU times -// will hold one of these. When they want to time a set of GL commands they -// will create GPUTimer objects. -// GPUTimer - Once a user decides to time something, the user creates a new -// GPUTimer object from a GPUTimingClient and issue Start() and Stop() calls -// around various GL calls. Once IsAvailable() returns true, the GPU times -// will be available through the various time stamp related functions. -// The constructor and destructor of this object handles the actual -// creation and deletion of the GL Queries within GL. - -namespace gfx { - -class GLContextReal; -class GPUTimingClient; - -class GPUTiming { - public: - enum TimerType { - kTimerTypeInvalid = -1, - - kTimerTypeEXT, // EXT_timer_query - kTimerTypeARB, // ARB_timer_query - kTimerTypeDisjoint // EXT_disjoint_timer_query - }; - - TimerType GetTimerType() const { return timer_type_; } - uint32_t GetDisjointCount(); - - private: - friend struct base::DefaultDeleter; - friend class GLContextReal; - friend class GPUTimer; - explicit GPUTiming(GLContextReal* context); - ~GPUTiming(); - - scoped_refptr CreateGPUTimingClient(); - - TimerType timer_type_ = kTimerTypeInvalid; - uint32_t disjoint_counter_ = 0; - DISALLOW_COPY_AND_ASSIGN(GPUTiming); -}; - -// Class to compute the amount of time it takes to fully -// complete a set of GL commands -class GL_EXPORT GPUTimer { - public: - ~GPUTimer(); - - // Destroy the timer object. This must be explicitly called before destroying - // this object. - void Destroy(bool have_context); - - void Start(); - void End(); - bool IsAvailable(); - - void GetStartEndTimestamps(int64* start, int64* end); - int64 GetDeltaElapsed(); - - private: - friend class GPUTimingClient; - - explicit GPUTimer(scoped_refptr gpu_timing_client); - - unsigned int queries_[2]; - int64 offset_ = 0; - bool end_requested_ = false; - scoped_refptr gpu_timing_client_; - - DISALLOW_COPY_AND_ASSIGN(GPUTimer); -}; - -// GPUTimingClient contains all the gl timing logic that is not specific -// to a single GPUTimer. -class GL_EXPORT GPUTimingClient - : public base::RefCounted { - public: - explicit GPUTimingClient(GPUTiming* gpu_timing = nullptr); - - scoped_ptr CreateGPUTimer(); - bool IsAvailable(); - bool IsTimerOffsetAvailable(); - - const char* GetTimerTypeName() const; - - // CheckAndResetTimerErrors has to be called before reading timestamps - // from GPUTimers instances and after making sure all the timers - // were available. - // If the returned value is false, all the previous timers should be - // discarded. - bool CheckAndResetTimerErrors(); - - // Returns the offset between the current gpu time and the cpu time. - int64 CalculateTimerOffset(); - void InvalidateTimerOffset(); - - void SetCpuTimeForTesting(const base::Callback& cpu_time); - - private: - friend class base::RefCounted; - friend class GPUTimer; - friend class GPUTiming; - - virtual ~GPUTimingClient(); - - GPUTiming* gpu_timing_; - GPUTiming::TimerType timer_type_ = GPUTiming::kTimerTypeInvalid; - int64 offset_ = 0; // offset cache when timer_type_ == kTimerTypeARB - uint32_t disjoint_counter_ = 0; - bool offset_valid_ = false; - base::Callback cpu_time_for_testing_; - - DISALLOW_COPY_AND_ASSIGN(GPUTimingClient); -}; - -} // namespace gfx - -#endif // UI_GL_GPU_TIMING_H_ diff --git a/ui/gl/scoped_binders.cc b/ui/gl/scoped_binders.cc deleted file mode 100644 index bb2b29010..000000000 --- a/ui/gl/scoped_binders.cc +++ /dev/null @@ -1,68 +0,0 @@ -// 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 "ui/gl/scoped_binders.h" -#include "ui/gl/gl_bindings.h" -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_state_restorer.h" - -namespace gfx { - -ScopedFrameBufferBinder::ScopedFrameBufferBinder(unsigned int fbo) - : state_restorer_(!GLContext::GetCurrent() - ? NULL - : GLContext::GetCurrent()->GetGLStateRestorer()), - old_fbo_(-1) { - if (!state_restorer_) - glGetIntegerv(GL_FRAMEBUFFER_BINDING, &old_fbo_); - glBindFramebufferEXT(GL_FRAMEBUFFER, fbo); -} - -ScopedFrameBufferBinder::~ScopedFrameBufferBinder() { - if (state_restorer_) { - DCHECK(!!GLContext::GetCurrent()); - DCHECK_EQ(state_restorer_, GLContext::GetCurrent()->GetGLStateRestorer()); - state_restorer_->RestoreFramebufferBindings(); - } else { - glBindFramebufferEXT(GL_FRAMEBUFFER, old_fbo_); - } -} - -ScopedTextureBinder::ScopedTextureBinder(unsigned int target, unsigned int id) - : state_restorer_(!GLContext::GetCurrent() - ? NULL - : GLContext::GetCurrent()->GetGLStateRestorer()), - target_(target), - old_id_(-1) { - if (!state_restorer_) { - GLenum target_getter = 0; - switch (target) { - case GL_TEXTURE_2D: - target_getter = GL_TEXTURE_BINDING_2D; - break; - case GL_TEXTURE_CUBE_MAP: - target_getter = GL_TEXTURE_BINDING_CUBE_MAP; - break; - case GL_TEXTURE_EXTERNAL_OES: - target_getter = GL_TEXTURE_BINDING_EXTERNAL_OES; - break; - default: - NOTIMPLEMENTED() << "Target not part of OpenGL ES 2.0 spec."; - } - glGetIntegerv(target_getter, &old_id_); - } - glBindTexture(target_, id); -} - -ScopedTextureBinder::~ScopedTextureBinder() { - if (state_restorer_) { - DCHECK(!!GLContext::GetCurrent()); - DCHECK_EQ(state_restorer_, GLContext::GetCurrent()->GetGLStateRestorer()); - state_restorer_->RestoreActiveTextureUnitBinding(target_); - } else { - glBindTexture(target_, old_id_); - } -} - -} // namespace gfx diff --git a/ui/gl/scoped_binders.h b/ui/gl/scoped_binders.h deleted file mode 100644 index dab7b3155..000000000 --- a/ui/gl/scoped_binders.h +++ /dev/null @@ -1,50 +0,0 @@ -// 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 UI_GL_SCOPED_BINDERS_H_ -#define UI_GL_SCOPED_BINDERS_H_ - -#include "base/basictypes.h" -#include "ui/gl/gl_export.h" - -namespace gfx { -class GLStateRestorer; - -class GL_EXPORT ScopedFrameBufferBinder { - public: - explicit ScopedFrameBufferBinder(unsigned int fbo); - ~ScopedFrameBufferBinder(); - - private: - // Whenever possible we prefer to use the current GLContext's - // GLStateRestorer to maximize driver compabitility. - GLStateRestorer* state_restorer_; - - // Failing that we use GL calls to save and restore state. - int old_fbo_; - - DISALLOW_COPY_AND_ASSIGN(ScopedFrameBufferBinder); -}; - - -class GL_EXPORT ScopedTextureBinder { - public: - ScopedTextureBinder(unsigned int target, unsigned int id); - ~ScopedTextureBinder(); - - private: - // Whenever possible we prefer to use the current GLContext's - // GLStateRestorer to maximize driver compabitility. - GLStateRestorer* state_restorer_; - - // Failing that we use GL calls to save and restore state. - int target_; - int old_id_; - - DISALLOW_COPY_AND_ASSIGN(ScopedTextureBinder); -}; - -} // namespace gfx - -#endif // UI_GL_SCOPED_BINDERS_H_ diff --git a/ui/gl/scoped_make_current.cc b/ui/gl/scoped_make_current.cc deleted file mode 100644 index c89724a7f..000000000 --- a/ui/gl/scoped_make_current.cc +++ /dev/null @@ -1,38 +0,0 @@ -// 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 "ui/gl/scoped_make_current.h" - -#include "base/logging.h" -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_surface.h" - -namespace ui { - -ScopedMakeCurrent::ScopedMakeCurrent(gfx::GLContext* context, - gfx::GLSurface* surface) - : previous_context_(gfx::GLContext::GetCurrent()), - previous_surface_(gfx::GLSurface::GetCurrent()), - context_(context), - surface_(surface), - succeeded_(false) { - DCHECK(context); - DCHECK(surface); - succeeded_ = context->MakeCurrent(surface); -} - -ScopedMakeCurrent::~ScopedMakeCurrent() { - if (previous_context_.get()) { - DCHECK(previous_surface_.get()); - previous_context_->MakeCurrent(previous_surface_.get()); - } else { - context_->ReleaseCurrent(surface_.get()); - } -} - -bool ScopedMakeCurrent::Succeeded() const { - return succeeded_; -} - -} // namespace ui diff --git a/ui/gl/scoped_make_current.h b/ui/gl/scoped_make_current.h deleted file mode 100644 index 59f34d76b..000000000 --- a/ui/gl/scoped_make_current.h +++ /dev/null @@ -1,38 +0,0 @@ -// 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 UI_GL_SCOPED_MAKE_CURRENT_H_ -#define UI_GL_SCOPED_MAKE_CURRENT_H_ - -#include "base/basictypes.h" -#include "base/memory/ref_counted.h" -#include "ui/gl/gl_export.h" - -namespace gfx { -class GLContext; -class GLSurface; -} - -namespace ui { - -class GL_EXPORT ScopedMakeCurrent { - public: - ScopedMakeCurrent(gfx::GLContext* context, gfx::GLSurface* surface); - ~ScopedMakeCurrent(); - - bool Succeeded() const; - - private: - scoped_refptr previous_context_; - scoped_refptr previous_surface_; - scoped_refptr context_; - scoped_refptr surface_; - bool succeeded_; - - DISALLOW_COPY_AND_ASSIGN(ScopedMakeCurrent); -}; - -} // namespace ui - -#endif // UI_GL_SCOPED_MAKE_CURRENT_H_ diff --git a/ui/gl/sync_control_vsync_provider.cc b/ui/gl/sync_control_vsync_provider.cc deleted file mode 100644 index 66d3734f5..000000000 --- a/ui/gl/sync_control_vsync_provider.cc +++ /dev/null @@ -1,157 +0,0 @@ -// 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. - -#include "ui/gl/sync_control_vsync_provider.h" - -#include - -#include "base/logging.h" -#include "base/time/time.h" - -#if defined(OS_LINUX) -// These constants define a reasonable range for a calculated refresh interval. -// Calculating refreshes out of this range will be considered a fatal error. -const int64 kMinVsyncIntervalUs = base::Time::kMicrosecondsPerSecond / 400; -const int64 kMaxVsyncIntervalUs = base::Time::kMicrosecondsPerSecond / 10; - -// How much noise we'll tolerate between successive computed intervals before -// we think the latest computed interval is invalid (noisey due to -// monitor configuration change, moving a window between monitors, etc.). -const double kRelativeIntervalDifferenceThreshold = 0.05; -#endif - -namespace gfx { - -SyncControlVSyncProvider::SyncControlVSyncProvider() - : VSyncProvider(), last_media_stream_counter_(0), invalid_msc_(false) { - // On platforms where we can't get an accurate reading on the refresh - // rate we fall back to the assumption that we're displaying 60 frames - // per second. - last_good_interval_ = base::TimeDelta::FromSeconds(1) / 60; -} - -SyncControlVSyncProvider::~SyncControlVSyncProvider() {} - -void SyncControlVSyncProvider::GetVSyncParameters( - const UpdateVSyncCallback& callback) { -#if defined(OS_LINUX) - base::TimeTicks timebase; - - // The actual clock used for the system time returned by glXGetSyncValuesOML - // is unspecified. In practice, the clock used is likely to be either - // CLOCK_REALTIME or CLOCK_MONOTONIC, so we compare the returned time to the - // current time according to both clocks, and assume that the returned time - // was produced by the clock whose current time is closest to it, subject - // to the restriction that the returned time must not be in the future - // (since it is the time of a vblank that has already occurred). - int64 system_time; - int64 media_stream_counter; - int64 swap_buffer_counter; - if (!GetSyncValues(&system_time, &media_stream_counter, &swap_buffer_counter)) - return; - - // Both Intel and Mali drivers will return TRUE for GetSyncValues - // but a value of 0 for MSC if they cannot access the CRTC data structure - // associated with the surface. crbug.com/231945 - bool prev_invalid_msc = invalid_msc_; - invalid_msc_ = (media_stream_counter == 0); - if (invalid_msc_) { - LOG_IF(ERROR, !prev_invalid_msc) << "glXGetSyncValuesOML " - "should not return TRUE with a media stream counter of 0."; - return; - } - - struct timespec real_time; - struct timespec monotonic_time; - clock_gettime(CLOCK_REALTIME, &real_time); - clock_gettime(CLOCK_MONOTONIC, &monotonic_time); - - int64 real_time_in_microseconds = - real_time.tv_sec * base::Time::kMicrosecondsPerSecond + - real_time.tv_nsec / base::Time::kNanosecondsPerMicrosecond; - int64 monotonic_time_in_microseconds = - monotonic_time.tv_sec * base::Time::kMicrosecondsPerSecond + - monotonic_time.tv_nsec / base::Time::kNanosecondsPerMicrosecond; - - // We need the time according to CLOCK_MONOTONIC, so if we've been given - // a time from CLOCK_REALTIME, we need to convert. - bool time_conversion_needed = - llabs(system_time - real_time_in_microseconds) < - llabs(system_time - monotonic_time_in_microseconds); - - if (time_conversion_needed) - system_time += monotonic_time_in_microseconds - real_time_in_microseconds; - - // Return if |system_time| is more than 1 frames in the future. - int64 interval_in_microseconds = last_good_interval_.InMicroseconds(); - if (system_time > monotonic_time_in_microseconds + interval_in_microseconds) - return; - - // If |system_time| is slightly in the future, adjust it to the previous - // frame and use the last frame counter to prevent issues in the callback. - if (system_time > monotonic_time_in_microseconds) { - system_time -= interval_in_microseconds; - media_stream_counter--; - } - if (monotonic_time_in_microseconds - system_time > - base::Time::kMicrosecondsPerSecond) - return; - - timebase = base::TimeTicks::FromInternalValue(system_time); - - // Only need the previous calculated interval for our filtering. - while (last_computed_intervals_.size() > 1) - last_computed_intervals_.pop(); - - int32 numerator, denominator; - if (GetMscRate(&numerator, &denominator)) { - last_computed_intervals_.push(base::TimeDelta::FromSeconds(denominator) / - numerator); - } else if (!last_timebase_.is_null()) { - base::TimeDelta timebase_diff = timebase - last_timebase_; - int64 counter_diff = media_stream_counter - last_media_stream_counter_; - if (counter_diff > 0 && timebase > last_timebase_) - last_computed_intervals_.push(timebase_diff / counter_diff); - } - - if (last_computed_intervals_.size() == 2) { - const base::TimeDelta& old_interval = last_computed_intervals_.front(); - const base::TimeDelta& new_interval = last_computed_intervals_.back(); - - double relative_change = - fabs(old_interval.InMillisecondsF() - new_interval.InMillisecondsF()) / - new_interval.InMillisecondsF(); - if (relative_change < kRelativeIntervalDifferenceThreshold) { - if (new_interval.InMicroseconds() < kMinVsyncIntervalUs || - new_interval.InMicroseconds() > kMaxVsyncIntervalUs) { -#if defined(USE_ASH) - // On ash platforms (ChromeOS essentially), the real refresh interval is - // queried from XRandR, regardless of the value calculated here, and - // this value is overriden by ui::CompositorVSyncManager. The log - // should not be fatal in this case. Reconsider all this when XRandR - // support is added to non-ash platforms. - // http://crbug.com/340851 - LOG(ERROR) -#else - LOG(FATAL) -#endif // USE_ASH - << "Calculated bogus refresh interval=" - << new_interval.InMicroseconds() - << " us., last_timebase_=" << last_timebase_.ToInternalValue() - << " us., timebase=" << timebase.ToInternalValue() - << " us., last_media_stream_counter_=" << last_media_stream_counter_ - << ", media_stream_counter=" << media_stream_counter; - } else { - last_good_interval_ = new_interval; - } - } - } - - last_timebase_ = timebase; - last_media_stream_counter_ = media_stream_counter; - callback.Run(timebase, last_good_interval_); -#endif // defined(OS_LINUX) -} - -} // namespace gfx diff --git a/ui/gl/sync_control_vsync_provider.h b/ui/gl/sync_control_vsync_provider.h deleted file mode 100644 index 302980d3d..000000000 --- a/ui/gl/sync_control_vsync_provider.h +++ /dev/null @@ -1,47 +0,0 @@ -// 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. - -#ifndef UI_GL_SYNC_CONTROL_VSYNC_PROVIDER_H_ -#define UI_GL_SYNC_CONTROL_VSYNC_PROVIDER_H_ - -#include - -#include "ui/gfx/vsync_provider.h" - -namespace gfx { - -// Base class for providers based on extensions like GLX_OML_sync_control and -// EGL_CHROMIUM_sync_control. -class SyncControlVSyncProvider : public VSyncProvider { - public: - SyncControlVSyncProvider(); - ~SyncControlVSyncProvider() override; - - void GetVSyncParameters(const UpdateVSyncCallback& callback) override; - - protected: - virtual bool GetSyncValues(int64* system_time, - int64* media_stream_counter, - int64* swap_buffer_counter) = 0; - - virtual bool GetMscRate(int32* numerator, int32* denominator) = 0; - - private: - base::TimeTicks last_timebase_; - uint64 last_media_stream_counter_; - base::TimeDelta last_good_interval_; - bool invalid_msc_; - - // A short history of the last few computed intervals. - // We use this to filter out the noise in the computation resulting - // from configuration change (monitor reconfiguration, moving windows - // between monitors, suspend and resume, etc.). - std::queue last_computed_intervals_; - - DISALLOW_COPY_AND_ASSIGN(SyncControlVSyncProvider); -}; - -} // namespace gfx - -#endif // UI_GL_SYNC_CONTROL_VSYNC_PROVIDER_H_