diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-29 04:16:17 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-29 04:16:17 +0000 |
commit | 41de2282baf73691595bb4e411603c9c08e0d055 (patch) | |
tree | 78fb84d6c79b941a34c7c9f9fd4dc31d5cc945d1 /cc | |
parent | afcade6dd7ada5e53fa96e325268dc3986b29332 (diff) | |
download | chromium_src-41de2282baf73691595bb4e411603c9c08e0d055.zip chromium_src-41de2282baf73691595bb4e411603c9c08e0d055.tar.gz chromium_src-41de2282baf73691595bb4e411603c9c08e0d055.tar.bz2 |
Pass context capabilities via cc::ContextProvider instead of gl string
This migrates cc to checking for context capabilities through a struct
provided by the ContextProvider instead of parsing out the GL_EXTENSIONS
string manually. This is a very minor performance win, since we don't
parse the string multiple times. More importantly, this centralizes
capability testing into one place and breaks cc's dependency on
WebString.
The implementation of ContextCapabilities() in content still parses out
the extensions string from the context, but we can route this data in
more directly in a follow-up.
BUG=279518
Review URL: https://chromiumcodereview.appspot.com/23466003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220186 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/cc.gyp | 5 | ||||
-rw-r--r-- | cc/debug/test_context_provider.cc | 12 | ||||
-rw-r--r-- | cc/debug/test_context_provider.h | 1 | ||||
-rw-r--r-- | cc/debug/test_web_graphics_context_3d.cc | 24 | ||||
-rw-r--r-- | cc/debug/test_web_graphics_context_3d.h | 18 | ||||
-rw-r--r-- | cc/output/context_provider.cc | 26 | ||||
-rw-r--r-- | cc/output/context_provider.h | 23 | ||||
-rw-r--r-- | cc/output/delegating_renderer.cc | 39 | ||||
-rw-r--r-- | cc/output/gl_renderer.cc | 28 | ||||
-rw-r--r-- | cc/output/gl_renderer_unittest.cc | 54 | ||||
-rw-r--r-- | cc/output/output_surface.cc | 16 | ||||
-rw-r--r-- | cc/resources/resource_provider.cc | 26 | ||||
-rw-r--r-- | cc/resources/resource_update_controller_unittest.cc | 12 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 67 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest.cc | 7 |
15 files changed, 149 insertions, 209 deletions
@@ -14,11 +14,11 @@ '<(DEPTH)/base/base.gyp:base', '<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', '<(DEPTH)/gpu/gpu.gyp:gpu', - '<(DEPTH)/skia/skia.gyp:skia', '<(DEPTH)/media/media.gyp:media', + '<(DEPTH)/skia/skia.gyp:skia', + '<(DEPTH)/third_party/WebKit/public/blink.gyp:blink_minimal', '<(DEPTH)/ui/gl/gl.gyp:gl', '<(DEPTH)/ui/ui.gyp:ui', - '<(DEPTH)/third_party/WebKit/public/blink.gyp:blink_minimal', ], 'defines': [ 'CC_IMPLEMENTATION=1', @@ -185,6 +185,7 @@ 'output/compositor_frame_ack.h', 'output/compositor_frame_metadata.cc', 'output/compositor_frame_metadata.h', + 'output/context_provider.cc', 'output/context_provider.h', 'output/copy_output_request.cc', 'output/copy_output_request.h', diff --git a/cc/debug/test_context_provider.cc b/cc/debug/test_context_provider.cc index 613ef53..0d6fc01 100644 --- a/cc/debug/test_context_provider.cc +++ b/cc/debug/test_context_provider.cc @@ -4,9 +4,13 @@ #include "cc/debug/test_context_provider.h" +#include <set> +#include <vector> + #include "base/bind.h" #include "base/callback_helpers.h" #include "base/logging.h" +#include "base/strings/string_split.h" #include "cc/debug/test_web_graphics_context_3d.h" namespace cc { @@ -122,6 +126,14 @@ bool TestContextProvider::BindToCurrentThread() { return true; } +ContextProvider::Capabilities TestContextProvider::ContextCapabilities() { + DCHECK(context3d_); + DCHECK(bound_); + DCHECK(context_thread_checker_.CalledOnValidThread()); + + return context3d_->test_capabilities(); +} + WebKit::WebGraphicsContext3D* TestContextProvider::Context3d() { DCHECK(context3d_); DCHECK(bound_); diff --git a/cc/debug/test_context_provider.h b/cc/debug/test_context_provider.h index af3e599..0be90af 100644 --- a/cc/debug/test_context_provider.h +++ b/cc/debug/test_context_provider.h @@ -30,6 +30,7 @@ class CC_EXPORT TestContextProvider scoped_ptr<TestWebGraphicsContext3D> context); virtual bool BindToCurrentThread() OVERRIDE; + virtual Capabilities ContextCapabilities() OVERRIDE; virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE; virtual class GrContext* GrContext() OVERRIDE; virtual void VerifyContexts() OVERRIDE; diff --git a/cc/debug/test_web_graphics_context_3d.cc b/cc/debug/test_web_graphics_context_3d.cc index 11d1ed8..1d19b23 100644 --- a/cc/debug/test_web_graphics_context_3d.cc +++ b/cc/debug/test_web_graphics_context_3d.cc @@ -61,9 +61,6 @@ scoped_ptr<TestWebGraphicsContext3D> TestWebGraphicsContext3D::Create() { TestWebGraphicsContext3D::TestWebGraphicsContext3D() : FakeWebGraphicsContext3D(), context_id_(s_context_id++), - support_swapbuffers_complete_callback_(true), - have_extension_io_surface_(false), - have_extension_egl_image_(false), times_make_current_succeeds_(-1), times_bind_texture_succeeds_(-1), times_end_query_succeeds_(-1), @@ -79,6 +76,7 @@ TestWebGraphicsContext3D::TestWebGraphicsContext3D() bound_buffer_(0), weak_ptr_factory_(this) { CreateNamespace(); + test_capabilities_.swapbuffers_complete_callback = true; } TestWebGraphicsContext3D::TestWebGraphicsContext3D( @@ -86,9 +84,6 @@ TestWebGraphicsContext3D::TestWebGraphicsContext3D( : FakeWebGraphicsContext3D(), context_id_(s_context_id++), attributes_(attributes), - support_swapbuffers_complete_callback_(true), - have_extension_io_surface_(false), - have_extension_egl_image_(false), times_make_current_succeeds_(-1), times_bind_texture_succeeds_(-1), times_end_query_succeeds_(-1), @@ -104,6 +99,7 @@ TestWebGraphicsContext3D::TestWebGraphicsContext3D( bound_buffer_(0), weak_ptr_factory_(this) { CreateNamespace(); + test_capabilities_.swapbuffers_complete_callback = true; } void TestWebGraphicsContext3D::CreateNamespace() { @@ -175,19 +171,7 @@ WebGraphicsContext3D::Attributes } WebKit::WebString TestWebGraphicsContext3D::getString(WGC3Denum name) { - std::string string; - - if (support_swapbuffers_complete_callback_) - string += "GL_CHROMIUM_swapbuffers_complete_callback"; - - if (name == GL_EXTENSIONS) { - if (have_extension_io_surface_) - string += " GL_CHROMIUM_iosurface GL_ARB_texture_rectangle"; - if (have_extension_egl_image_) - string += " GL_OES_EGL_image_external"; - } - - return WebKit::WebString::fromUTF8(string.c_str()); + return WebKit::WebString(); } WGC3Dint TestWebGraphicsContext3D::getUniformLocation( @@ -427,7 +411,7 @@ void TestWebGraphicsContext3D::signalQuery( void TestWebGraphicsContext3D::setSwapBuffersCompleteCallbackCHROMIUM( WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback) { - if (support_swapbuffers_complete_callback_) + if (test_capabilities_.swapbuffers_complete_callback) swap_buffers_callback_ = callback; } diff --git a/cc/debug/test_web_graphics_context_3d.h b/cc/debug/test_web_graphics_context_3d.h index 5910d03..1c5ceb1 100644 --- a/cc/debug/test_web_graphics_context_3d.h +++ b/cc/debug/test_web_graphics_context_3d.h @@ -17,6 +17,7 @@ #include "cc/base/cc_export.h" #include "cc/base/scoped_ptr_hash_map.h" #include "cc/debug/fake_web_graphics_context_3d.h" +#include "cc/output/context_provider.h" #include "third_party/khronos/GLES2/gl2.h" namespace cc { @@ -141,6 +142,10 @@ class CC_EXPORT TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { WebKit::WGC3Denum access); virtual void unmapImageCHROMIUM(WebKit::WGC3Duint image_id); + const ContextProvider::Capabilities& test_capabilities() const { + return test_capabilities_; + } + // When set, MakeCurrent() will fail after this many times. void set_times_make_current_succeeds(int times) { times_make_current_succeeds_ = times; @@ -174,13 +179,16 @@ class CC_EXPORT TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { void ResetUsedTextures() { used_textures_.clear(); } void set_support_swapbuffers_complete_callback(bool support) { - support_swapbuffers_complete_callback_ = support; + test_capabilities_.swapbuffers_complete_callback = support; } void set_have_extension_io_surface(bool have) { - have_extension_io_surface_ = have; + test_capabilities_.iosurface = have; } void set_have_extension_egl_image(bool have) { - have_extension_egl_image_ = have; + test_capabilities_.egl_image_external = have; + } + void set_have_post_sub_buffer(bool have) { + test_capabilities_.post_sub_buffer = have; } // When this context is lost, all contexts in its share group are also lost. @@ -247,9 +255,7 @@ class CC_EXPORT TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { unsigned context_id_; Attributes attributes_; - bool support_swapbuffers_complete_callback_; - bool have_extension_io_surface_; - bool have_extension_egl_image_; + ContextProvider::Capabilities test_capabilities_; int times_make_current_succeeds_; int times_bind_texture_succeeds_; int times_end_query_succeeds_; diff --git a/cc/output/context_provider.cc b/cc/output/context_provider.cc new file mode 100644 index 0000000..fb6d8e6 --- /dev/null +++ b/cc/output/context_provider.cc @@ -0,0 +1,26 @@ +// 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 "cc/output/context_provider.h" + +namespace cc { + +ContextProvider::Capabilities::Capabilities() + : bind_uniform_location(false), + discard_backbuffer(false), + egl_image_external(false), + fast_npot_mo8_textures(false), + iosurface(false), + map_image(false), + map_sub(false), + post_sub_buffer(false), + set_visibility(false), + shallow_flush(false), + swapbuffers_complete_callback(false), + texture_format_bgra8888(false), + texture_rectangle(false), + texture_storage(false), + texture_usage(false) {} + +} // namespace cc diff --git a/cc/output/context_provider.h b/cc/output/context_provider.h index 7d61763..3aae7eb 100644 --- a/cc/output/context_provider.h +++ b/cc/output/context_provider.h @@ -7,6 +7,7 @@ #include "base/callback.h" #include "base/memory/ref_counted.h" +#include "cc/base/cc_export.h" class GrContext; namespace WebKit { class WebGraphicsContext3D; } @@ -25,6 +26,28 @@ class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> { virtual WebKit::WebGraphicsContext3D* Context3d() = 0; virtual class GrContext* GrContext() = 0; + struct Capabilities { + bool bind_uniform_location; + bool discard_backbuffer; + bool egl_image_external; + bool fast_npot_mo8_textures; + bool iosurface; + bool map_image; + bool map_sub; + bool post_sub_buffer; + bool set_visibility; + bool shallow_flush; + bool swapbuffers_complete_callback; + bool texture_format_bgra8888; + bool texture_rectangle; + bool texture_storage; + bool texture_usage; + + CC_EXPORT Capabilities(); + }; + // Returns the capabilities of the currently bound 3d context. + virtual Capabilities ContextCapabilities() = 0; + // Ask the provider to check if the contexts are valid or lost. If they are, // this should invalidate the provider so that it can be replaced with a new // one. diff --git a/cc/output/delegating_renderer.cc b/cc/output/delegating_renderer.cc index eae6f30..799ca83 100644 --- a/cc/output/delegating_renderer.cc +++ b/cc/output/delegating_renderer.cc @@ -75,41 +75,14 @@ bool DelegatingRenderer::Initialize() { context3d); context3d->pushGroupMarkerEXT(unique_context_name.c_str()); - std::string extensions_string = - UTF16ToASCII(context3d->getString(GL_EXTENSIONS)); - - std::vector<std::string> extensions; - base::SplitString(extensions_string, ' ', &extensions); - - // TODO(danakj): We need non-GPU-specific paths for these things. This - // renderer shouldn't need to use context3d extensions directly. - bool has_set_visibility = false; - bool has_io_surface = false; - bool has_arb_texture_rect = false; - bool has_egl_image = false; - bool has_map_image = false; - for (size_t i = 0; i < extensions.size(); ++i) { - if (extensions[i] == "GL_CHROMIUM_set_visibility") { - has_set_visibility = true; - } else if (extensions[i] == "GL_CHROMIUM_iosurface") { - has_io_surface = true; - } else if (extensions[i] == "GL_ARB_texture_rectangle") { - has_arb_texture_rect = true; - } else if (extensions[i] == "GL_OES_EGL_image_external") { - has_egl_image = true; - } else if (extensions[i] == "GL_CHROMIUM_map_image") { - has_map_image = true; - } - } - - if (has_io_surface) - DCHECK(has_arb_texture_rect); - - capabilities_.using_set_visibility = has_set_visibility; + const ContextProvider::Capabilities& caps = + output_surface_->context_provider()->ContextCapabilities(); - capabilities_.using_egl_image = has_egl_image; + DCHECK(!caps.iosurface || caps.texture_rectangle); - capabilities_.using_map_image = has_map_image; + capabilities_.using_set_visibility = caps.set_visibility; + capabilities_.using_egl_image = caps.egl_image_external; + capabilities_.using_map_image = caps.map_image; return true; } diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc index e35b697..ac8c2c6 100644 --- a/cc/output/gl_renderer.cc +++ b/cc/output/gl_renderer.cc @@ -176,25 +176,18 @@ bool GLRenderer::Initialize() { context_); context_->pushGroupMarkerEXT(unique_context_name.c_str()); - std::string extensions_string = - UTF16ToASCII(context_->getString(GL_EXTENSIONS)); - std::vector<std::string> extensions_list; - base::SplitString(extensions_string, ' ', &extensions_list); - std::set<std::string> extensions(extensions_list.begin(), - extensions_list.end()); + ContextProvider::Capabilities context_caps = + output_surface_->context_provider()->ContextCapabilities(); capabilities_.using_partial_swap = Settings().partial_swap_enabled && - extensions.count("GL_CHROMIUM_post_sub_buffer"); + context_caps.post_sub_buffer; - capabilities_.using_set_visibility = - extensions.count("GL_CHROMIUM_set_visibility") > 0; + capabilities_.using_set_visibility = context_caps.set_visibility; - if (extensions.count("GL_CHROMIUM_iosurface") > 0) - DCHECK_GT(extensions.count("GL_ARB_texture_rectangle"), 0u); + DCHECK(!context_caps.iosurface || context_caps.texture_rectangle); - capabilities_.using_egl_image = - extensions.count("GL_OES_EGL_image_external") > 0; + capabilities_.using_egl_image = context_caps.egl_image_external; capabilities_.max_texture_size = resource_provider_->max_texture_size(); capabilities_.best_texture_format = resource_provider_->best_texture_format(); @@ -204,17 +197,14 @@ bool GLRenderer::Initialize() { // Check for texture fast paths. Currently we always use MO8 textures, // so we only need to avoid POT textures if we have an NPOT fast-path. - capabilities_.avoid_pow2_textures = - extensions.count("GL_CHROMIUM_fast_NPOT_MO8_textures") > 0; + capabilities_.avoid_pow2_textures = context_caps.fast_npot_mo8_textures; capabilities_.using_offscreen_context3d = true; capabilities_.using_map_image = - extensions.count("GL_CHROMIUM_map_image") > 0 && - Settings().use_map_image; + Settings().use_map_image && context_caps.map_image; - is_using_bind_uniform_ = - extensions.count("GL_CHROMIUM_bind_uniform_location") > 0; + is_using_bind_uniform_ = context_caps.bind_uniform_location; if (!InitializeSharedObjects()) return false; diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc index c71ba35..c12bbfe 100644 --- a/cc/output/gl_renderer_unittest.cc +++ b/cc/output/gl_renderer_unittest.cc @@ -117,19 +117,16 @@ TEST_F(GLRendererShaderPixelTest, AllShadersCompile) { TestShaders(); } class FrameCountingContext : public TestWebGraphicsContext3D { public: - FrameCountingContext() : frame_(0) {} + FrameCountingContext() + : frame_(0) { + test_capabilities_.set_visibility = true; + test_capabilities_.discard_backbuffer = true; + } // WebGraphicsContext3D methods. // This method would normally do a glSwapBuffers under the hood. virtual void prepareTexture() { frame_++; } - virtual WebString getString(WebKit::WGC3Denum name) { - if (name == GL_EXTENSIONS) - return WebString( - "GL_CHROMIUM_set_visibility GL_CHROMIUM_gpu_memory_manager " - "GL_CHROMIUM_discard_backbuffer"); - return WebString(); - } // Methods added for test. int frame_count() { return frame_; } @@ -571,11 +568,7 @@ class ForbidSynchronousCallContext : public TestWebGraphicsContext3D { } virtual WebString getString(WGC3Denum name) { - // We allow querying the extension string. - // TODO(enne): It'd be better to check that we only do this before starting - // any other expensive work (like starting a compilation) - if (name != GL_EXTENSIONS) - ADD_FAILURE(); + ADD_FAILURE() << name; return WebString(); } @@ -776,7 +769,10 @@ class VisibilityChangeIsLastCallTrackingContext : public TestWebGraphicsContext3D { public: VisibilityChangeIsLastCallTrackingContext() - : last_call_was_set_visibility_(false) {} + : last_call_was_set_visibility_(false) { + test_capabilities_.set_visibility = true; + test_capabilities_.discard_backbuffer = true; + } // WebGraphicsContext3D methods. virtual void setVisibilityCHROMIUM(bool visible) { @@ -805,15 +801,6 @@ class VisibilityChangeIsLastCallTrackingContext last_call_was_set_visibility_ = false; } - // This method would normally do a glSwapBuffers under the hood. - virtual WebString getString(WebKit::WGC3Denum name) { - if (name == GL_EXTENSIONS) - return WebString( - "GL_CHROMIUM_set_visibility GL_CHROMIUM_gpu_memory_manager " - "GL_CHROMIUM_discard_backbuffer"); - return WebString(); - } - // Methods added for test. bool last_call_was_set_visibility() const { return last_call_was_set_visibility_; @@ -855,12 +842,9 @@ TEST(GLRendererTest2, VisibilityChangeIsLastCall) { class TextureStateTrackingContext : public TestWebGraphicsContext3D { public: - TextureStateTrackingContext() : active_texture_(GL_INVALID_ENUM) {} - - virtual WebString getString(WGC3Denum name) { - if (name == GL_EXTENSIONS) - return WebString("GL_OES_EGL_image_external"); - return WebString(); + TextureStateTrackingContext() + : active_texture_(GL_INVALID_ENUM) { + test_capabilities_.egl_image_external = true; } MOCK_METHOD3(texParameteri, @@ -1452,6 +1436,11 @@ TEST_F(GLRendererShaderTest, DrawSolidColorShader) { class OutputSurfaceMockContext : public TestWebGraphicsContext3D { public: + OutputSurfaceMockContext() { + test_capabilities_.discard_backbuffer = true; + test_capabilities_.post_sub_buffer = true; + } + // Specifically override methods even if they are unused (used in conjunction // with StrictMock). We need to make sure that GLRenderer does not issue // framebuffer-related GL calls directly. Instead these are supposed to go @@ -1467,13 +1456,6 @@ class OutputSurfaceMockContext : public TestWebGraphicsContext3D { WGC3Dsizei count, WGC3Denum type, WGC3Dintptr offset)); - - virtual WebString getString(WebKit::WGC3Denum name) { - if (name == GL_EXTENSIONS) - return WebString( - "GL_CHROMIUM_post_sub_buffer GL_CHROMIUM_discard_backbuffer"); - return WebString(); - } }; class MockOutputSurface : public OutputSurface { diff --git a/cc/output/output_surface.cc b/cc/output/output_surface.cc index f085d49..19683b2 100644 --- a/cc/output/output_surface.cc +++ b/cc/output/output_surface.cc @@ -287,17 +287,11 @@ void OutputSurface::SetUpContext3d() { DCHECK(context_provider_); DCHECK(client_); - WebKit::WebGraphicsContext3D* context3d = context_provider_->Context3d(); - - string extensions_string = - UTF16ToASCII(context3d->getString(GL_EXTENSIONS)); - vector<string> extensions_list; - base::SplitString(extensions_string, ' ', &extensions_list); - set<string> extensions(extensions_list.begin(), extensions_list.end()); - has_gl_discard_backbuffer_ = - extensions.count("GL_CHROMIUM_discard_backbuffer") > 0; - has_swap_buffers_complete_callback_ = - extensions.count("GL_CHROMIUM_swapbuffers_complete_callback") > 0; + const ContextProvider::Capabilities& caps = + context_provider_->ContextCapabilities(); + + has_gl_discard_backbuffer_ = caps.discard_backbuffer; + has_swap_buffers_complete_callback_ = caps.swapbuffers_complete_callback; context_provider_->SetLostContextCallback( base::Bind(&OutputSurface::DidLoseOutputSurface, diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc index 57a1806..9779a54 100644 --- a/cc/resources/resource_provider.cc +++ b/cc/resources/resource_provider.cc @@ -709,24 +709,14 @@ bool ResourceProvider::InitializeGL() { default_resource_type_ = GLTexture; - std::string extensions_string = - UTF16ToASCII(context3d->getString(GL_EXTENSIONS)); - std::vector<std::string> extensions; - base::SplitString(extensions_string, ' ', &extensions); - bool use_map_sub = false; - bool use_bgra = false; - for (size_t i = 0; i < extensions.size(); ++i) { - if (extensions[i] == "GL_EXT_texture_storage") - use_texture_storage_ext_ = true; - else if (extensions[i] == "GL_ANGLE_texture_usage") - use_texture_usage_hint_ = true; - else if (extensions[i] == "GL_CHROMIUM_map_sub") - use_map_sub = true; - else if (extensions[i] == "GL_CHROMIUM_shallow_flush") - use_shallow_flush_ = true; - else if (extensions[i] == "GL_EXT_texture_format_BGRA8888") - use_bgra = true; - } + const ContextProvider::Capabilities& caps = + output_surface_->context_provider()->ContextCapabilities(); + + bool use_map_sub = caps.map_sub; + bool use_bgra = caps.texture_format_bgra8888; + use_texture_storage_ext_ = caps.texture_storage; + use_shallow_flush_ = caps.shallow_flush; + use_texture_usage_hint_ = caps.texture_usage; texture_uploader_ = TextureUploader::Create(context3d, use_map_sub, use_shallow_flush_); diff --git a/cc/resources/resource_update_controller_unittest.cc b/cc/resources/resource_update_controller_unittest.cc index e7c59bf..ccbfadd 100644 --- a/cc/resources/resource_update_controller_unittest.cc +++ b/cc/resources/resource_update_controller_unittest.cc @@ -35,8 +35,9 @@ class ResourceUpdateControllerTest; class WebGraphicsContext3DForUploadTest : public TestWebGraphicsContext3D { public: explicit WebGraphicsContext3DForUploadTest(ResourceUpdateControllerTest* test) - : test_(test), - support_shallow_flush_(true) {} + : test_(test) { + test_capabilities_.shallow_flush = true; + } virtual void flush(void) OVERRIDE; virtual void shallowFlushCHROMIUM(void) OVERRIDE; @@ -52,12 +53,6 @@ class WebGraphicsContext3DForUploadTest : public TestWebGraphicsContext3D { const void* pixels) OVERRIDE; virtual GrGLInterface* onCreateGrGLInterface() OVERRIDE { return NULL; } - virtual WebString getString(WGC3Denum name) OVERRIDE { - if (support_shallow_flush_) - return WebString("GL_CHROMIUM_shallow_flush"); - return WebString(""); - } - virtual void getQueryObjectuivEXT( WebGLId id, WGC3Denum pname, @@ -65,7 +60,6 @@ class WebGraphicsContext3DForUploadTest : public TestWebGraphicsContext3D { private: ResourceUpdateControllerTest* test_; - bool support_shallow_flush_; }; class ResourceUpdateControllerTest : public Test { diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 669b5a8..dc9899d 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -3131,7 +3131,11 @@ TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { class SwapTrackerContext : public TestWebGraphicsContext3D { public: - SwapTrackerContext() : last_update_type_(NoUpdate) {} + SwapTrackerContext() + : last_update_type_(NoUpdate) { + test_capabilities_.post_sub_buffer = true; + test_capabilities_.set_visibility = true; + } virtual void prepareTexture() OVERRIDE { update_rect_ = gfx::Rect(width_, height_); @@ -3144,15 +3148,6 @@ class SwapTrackerContext : public TestWebGraphicsContext3D { last_update_type_ = PostSubBuffer; } - virtual WebKit::WebString getString(WebKit::WGC3Denum name) OVERRIDE { - if (name == GL_EXTENSIONS) { - return WebKit::WebString( - "GL_CHROMIUM_post_sub_buffer GL_CHROMIUM_set_visibility"); - } - - return WebKit::WebString(); - } - gfx::Rect update_rect() const { return update_rect_; } enum UpdateType { @@ -3327,7 +3322,6 @@ class MockContext : public TestWebGraphicsContext3D { WebKit::WGC3Dsizei count, WebKit::WGC3Denum type, WebKit::WGC3Dintptr offset)); - MOCK_METHOD1(getString, WebKit::WebString(WebKit::WGC3Denum name)); MOCK_METHOD0(getRequestableExtensionsCHROMIUM, WebKit::WebString()); MOCK_METHOD1(enable, void(WebKit::WGC3Denum cap)); MOCK_METHOD1(disable, void(WebKit::WGC3Denum cap)); @@ -3344,6 +3338,8 @@ class MockContextHarness { public: explicit MockContextHarness(MockContext* context) : context_(context) { + context_->set_have_post_sub_buffer(true); + // Catch "uninteresting" calls EXPECT_CALL(*context_, useProgram(_)) .Times(0); @@ -3358,19 +3354,6 @@ class MockContextHarness { EXPECT_CALL(*context_, uniform4f(_, _, _, _, _)) .WillRepeatedly(Return()); - // Any other strings are empty - EXPECT_CALL(*context_, getString(_)) - .WillRepeatedly(Return(WebKit::WebString())); - - // Support for partial swap, if needed - EXPECT_CALL(*context_, getString(GL_EXTENSIONS)) - .WillRepeatedly(Return( - WebKit::WebString("GL_CHROMIUM_post_sub_buffer"))); - - EXPECT_CALL(*context_, getRequestableExtensionsCHROMIUM()) - .WillRepeatedly(Return( - WebKit::WebString("GL_CHROMIUM_post_sub_buffer"))); - // Any un-sanctioned calls to enable() are OK EXPECT_CALL(*context_, enable(_)) .WillRepeatedly(Return()); @@ -3487,14 +3470,8 @@ TEST_F(LayerTreeHostImplTest, PartialSwap) { class PartialSwapContext : public TestWebGraphicsContext3D { public: - virtual WebKit::WebString getString(WebKit::WGC3Denum name) OVERRIDE { - if (name == GL_EXTENSIONS) - return WebKit::WebString("GL_CHROMIUM_post_sub_buffer"); - return WebKit::WebString(); - } - - virtual WebKit::WebString getRequestableExtensionsCHROMIUM() OVERRIDE { - return WebKit::WebString("GL_CHROMIUM_post_sub_buffer"); + PartialSwapContext() { + test_capabilities_.post_sub_buffer = true; } // Unlimited texture size. @@ -3630,7 +3607,10 @@ class TrackingWebGraphicsContext3D : public TestWebGraphicsContext3D { public: TrackingWebGraphicsContext3D() : TestWebGraphicsContext3D(), - num_textures_(0) {} + num_textures_(0) { + test_capabilities_.iosurface = true; + test_capabilities_.texture_rectangle = true; + } virtual WebKit::WebGLId createTexture() OVERRIDE { WebKit::WebGLId id = TestWebGraphicsContext3D::createTexture(); @@ -3648,15 +3628,6 @@ class TrackingWebGraphicsContext3D : public TestWebGraphicsContext3D { --num_textures_; } - virtual WebKit::WebString getString(WebKit::WGC3Denum name) OVERRIDE { - if (name == GL_EXTENSIONS) { - return WebKit::WebString( - "GL_CHROMIUM_iosurface GL_ARB_texture_rectangle"); - } - - return WebKit::WebString(); - } - unsigned num_textures() const { return num_textures_; } private: @@ -6326,15 +6297,6 @@ TEST_F(LayerTreeHostImplTestDeferredInitialize, Fails_OffscreenContext) { EXPECT_TRUE(did_lose_output_surface_); } -class ContextThatDoesNotSupportMemoryManagmentExtensions - : public TestWebGraphicsContext3D { - public: - // WebGraphicsContext3D methods. - virtual WebKit::WebString getString(WebKit::WGC3Denum name) { - return WebKit::WebString(); - } -}; - // Checks that we have a non-0 default allocation if we pass a context that // doesn't support memory management extensions. TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { @@ -6345,8 +6307,7 @@ TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { &stats_instrumentation_); scoped_ptr<OutputSurface> output_surface( - FakeOutputSurface::Create3d(scoped_ptr<TestWebGraphicsContext3D>( - new ContextThatDoesNotSupportMemoryManagmentExtensions))); + FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create())); host_impl_->InitializeRenderer(output_surface.Pass()); EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes()); } diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index fda3911..0102a10 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -2364,6 +2364,11 @@ SINGLE_THREAD_TEST_F(LayerTreeHostTestChangeLayerPropertiesInPaintContents); class MockIOSurfaceWebGraphicsContext3D : public TestWebGraphicsContext3D { public: + MockIOSurfaceWebGraphicsContext3D() { + test_capabilities_.iosurface = true; + test_capabilities_.texture_rectangle = true; + } + virtual WebKit::WebGLId createTexture() OVERRIDE { return 1; } @@ -2395,8 +2400,6 @@ class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest { new MockIOSurfaceWebGraphicsContext3D); mock_context_ = mock_context_owned.get(); - mock_context_->set_have_extension_io_surface(true); - scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( mock_context_owned.PassAs<TestWebGraphicsContext3D>())); return output_surface.Pass(); |