diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-08 03:39:29 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-08 03:39:29 +0000 |
commit | ea9d8f2728ab88307a58b8bb5e7b690a55f75862 (patch) | |
tree | 5689bbe76da521d88fa89dc530c0113511e69ed3 /cc | |
parent | dc8ccb32e130f3d707a108f549609aeea550a957 (diff) | |
download | chromium_src-ea9d8f2728ab88307a58b8bb5e7b690a55f75862.zip chromium_src-ea9d8f2728ab88307a58b8bb5e7b690a55f75862.tar.gz chromium_src-ea9d8f2728ab88307a58b8bb5e7b690a55f75862.tar.bz2 |
Add the DelegatingRenderer class with its initialize path.
It's a skeleton class that can be initialized so that we can test with it.
Tests:
LayerTreeHostTest.PartialUpdatesWithDelegatingRendererAndGLContent
LayerTreeHostTest.PartialUpdatesWithDelegatingRendererAndSoftwareContent
LayerTreeHostImplTest.partialSwapReceivesDamageRect
R=piman
BUG=146080
Review URL: https://codereview.chromium.org/11464007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171927 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/cc.gyp | 2 | ||||
-rw-r--r-- | cc/delegating_renderer.cc | 186 | ||||
-rw-r--r-- | cc/delegating_renderer.h | 87 | ||||
-rw-r--r-- | cc/gl_renderer.cc | 5 | ||||
-rw-r--r-- | cc/layer_tree_host_impl.cc | 5 | ||||
-rw-r--r-- | cc/layer_tree_host_impl_unittest.cc | 44 | ||||
-rw-r--r-- | cc/layer_tree_host_unittest.cc | 39 | ||||
-rw-r--r-- | cc/resource_provider.cc | 7 | ||||
-rw-r--r-- | cc/resource_provider.h | 2 | ||||
-rw-r--r-- | cc/software_renderer.cc | 4 | ||||
-rw-r--r-- | cc/test/fake_layer_tree_host_client.cc | 6 | ||||
-rw-r--r-- | cc/test/fake_layer_tree_host_client.h | 4 | ||||
-rw-r--r-- | cc/test/fake_output_surface.cc | 6 | ||||
-rw-r--r-- | cc/test/fake_output_surface.h | 20 |
14 files changed, 393 insertions, 24 deletions
@@ -46,6 +46,8 @@ 'delegated_renderer_layer.h', 'delegated_renderer_layer_impl.cc', 'delegated_renderer_layer_impl.h', + 'delegating_renderer.cc', + 'delegating_renderer.h', 'direct_renderer.cc', 'direct_renderer.h', 'draw_properties.h', diff --git a/cc/delegating_renderer.cc b/cc/delegating_renderer.cc new file mode 100644 index 0000000..fb76922 --- /dev/null +++ b/cc/delegating_renderer.cc @@ -0,0 +1,186 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "cc/delegating_renderer.h" + +#include <set> +#include <string> +#include <vector> + +#include "base/debug/trace_event.h" +#include "base/string_split.h" +#include "base/string_util.h" +#include "cc/checkerboard_draw_quad.h" +#include "cc/compositor_frame_ack.h" +#include "cc/debug_border_draw_quad.h" +#include "cc/render_pass.h" +#include "cc/render_pass_draw_quad.h" +#include "cc/resource_provider.h" +#include "cc/solid_color_draw_quad.h" +#include "cc/texture_draw_quad.h" +#include "cc/tile_draw_quad.h" +#include "cc/yuv_video_draw_quad.h" +#include "third_party/khronos/GLES2/gl2ext.h" + +using WebKit::WebGraphicsContext3D; + +namespace cc { + +scoped_ptr<DelegatingRenderer> DelegatingRenderer::Create( + RendererClient* client, ResourceProvider* resource_provider) { + scoped_ptr<DelegatingRenderer> renderer( + new DelegatingRenderer(client, resource_provider)); + if (!renderer->Initialize()) + return scoped_ptr<DelegatingRenderer>(); + return renderer.Pass(); +} + +DelegatingRenderer::DelegatingRenderer( + RendererClient* client, ResourceProvider* resource_provider) + : Renderer(client), + resource_provider_(resource_provider), + visible_(true) { + DCHECK(resource_provider_); +} + +bool DelegatingRenderer::Initialize() { + capabilities_.usingPartialSwap = false; + // TODO(danakj): Throttling - we may want to only allow 1 outstanding frame, + // but the parent compositor may pipeline for us. + // TODO(danakj): Can we use this in single-thread mode? + capabilities_.usingSwapCompleteCallback = true; + capabilities_.maxTextureSize = resource_provider_->maxTextureSize(); + capabilities_.bestTextureFormat = resource_provider_->bestTextureFormat(); + capabilities_.allowPartialTextureUpdates = false; + + WebGraphicsContext3D* context3d = resource_provider_->graphicsContext3D(); + + if (!context3d) { + // Software compositing. + return true; + } + + if (!context3d->makeContextCurrent()) + return false; + + context3d->setContextLostCallback(this); + context3d->pushGroupMarkerEXT("CompositorContext"); + + std::string extensionsString = + UTF16ToASCII(context3d->getString(GL_EXTENSIONS)); + + std::vector<std::string> extensions; + base::SplitString(extensionsString, ' ', &extensions); + + // TODO(danakj): We need non-GPU-specific paths for these things. This + // renderer shouldn't need to use context3d extensions directly. + bool hasReadBGRA = true; + bool hasSetVisibility = true; + bool hasIOSurface = true; + bool hasARBTextureRect = true; + bool hasGpuMemoryManager = true; + bool hasEGLImage = true; + for (size_t i = 0; i < extensions.size(); ++i) { + if (extensions[i] == "GL_EXT_read_format_bgra") + hasReadBGRA = true; + else if (extensions[i] == "GL_CHROMIUM_set_visibility") + hasSetVisibility = true; + else if (extensions[i] == "GL_CHROMIUM_iosurface") + hasIOSurface = true; + else if (extensions[i] == "GL_ARB_texture_rectangle") + hasARBTextureRect = true; + else if (extensions[i] == "GL_CHROMIUM_gpu_memory_manager") + hasGpuMemoryManager = true; + else if (extensions[i] == "GL_OES_EGL_image_external") + hasEGLImage = true; + } + + if (hasIOSurface) + DCHECK(hasARBTextureRect); + + capabilities_.usingAcceleratedPainting = + settings().acceleratePainting && + capabilities_.bestTextureFormat == GL_BGRA_EXT && + hasReadBGRA; + + // TODO(piman): loop visibility to GPU process? + capabilities_.usingSetVisibility = hasSetVisibility; + + // TODO(danakj): Support GpuMemoryManager. + capabilities_.usingGpuMemoryManager = false; + + capabilities_.usingEglImage = hasEGLImage; + + return true; +} + +DelegatingRenderer::~DelegatingRenderer() { + WebGraphicsContext3D* context3d = resource_provider_->graphicsContext3D(); + if (context3d) + context3d->setContextLostCallback(NULL); +} + +const RendererCapabilities& DelegatingRenderer::capabilities() const { + return capabilities_; +} + +void DelegatingRenderer::drawFrame(RenderPassList& render_passes_in_draw_order, + RenderPassIdHashMap& render_passes_by_id) { + TRACE_EVENT0("cc", "DelegatingRenderer::drawFrame"); + NOTIMPLEMENTED(); +} + +bool DelegatingRenderer::swapBuffers() { + return true; +} + +void DelegatingRenderer::getFramebufferPixels(void *pixels, + const gfx::Rect& rect) { + NOTIMPLEMENTED(); +} + +void DelegatingRenderer::receiveCompositorFrameAck( + const CompositorFrameAck& ack) { + resource_provider_->receiveFromParent(ack.resources); + m_client->onSwapBuffersComplete(); +} + + +bool DelegatingRenderer::isContextLost() { + WebGraphicsContext3D* context3d = resource_provider_->graphicsContext3D(); + if (!context3d) + return false; + return context3d->getGraphicsResetStatusARB() != GL_NO_ERROR; +} + +void DelegatingRenderer::setVisible(bool visible) { + visible_ = visible; +} + +void DelegatingRenderer::onContextLost() { + m_client->didLoseOutputSurface(); +} + +} // namespace cc diff --git a/cc/delegating_renderer.h b/cc/delegating_renderer.h new file mode 100644 index 0000000..aa20354 --- /dev/null +++ b/cc/delegating_renderer.h @@ -0,0 +1,87 @@ + /* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef CC_DELEGATING_RENDERER_H_ +#define CC_DELEGATING_RENDERER_H_ + +#include "base/memory/scoped_ptr.h" +#include "cc/cc_export.h" +#include "cc/renderer.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h" + +namespace cc { + +class ResourceProvider; + +class CC_EXPORT DelegatingRenderer : + public Renderer, + public NON_EXPORTED_BASE( + WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback) +{ + public: + static scoped_ptr<DelegatingRenderer> Create( + RendererClient* client, ResourceProvider* resource_provider); + virtual ~DelegatingRenderer(); + + virtual const RendererCapabilities& capabilities() const OVERRIDE; + + virtual void drawFrame(RenderPassList& render_passes_in_draw_order, + RenderPassIdHashMap& render_passes_by_id) OVERRIDE; + + virtual void finish() OVERRIDE {} + + virtual bool swapBuffers() OVERRIDE; + + virtual void getFramebufferPixels(void *pixels, + const gfx::Rect& rect) OVERRIDE; + + virtual void receiveCompositorFrameAck(const CompositorFrameAck&) OVERRIDE; + + virtual bool isContextLost() OVERRIDE; + + virtual void setVisible(bool) OVERRIDE; + + virtual void sendManagedMemoryStats(size_t bytes_visible, + size_t bytes_visible_and_nearby, + size_t bytes_allocated) OVERRIDE {} + + // WebGraphicsContext3D::WebGraphicsContextLostCallback implementation. + virtual void onContextLost() OVERRIDE; + +private: + DelegatingRenderer(RendererClient* client, + ResourceProvider* resource_provider); + bool Initialize(); + + ResourceProvider* resource_provider_; + RendererCapabilities capabilities_; + bool visible_; + + DISALLOW_COPY_AND_ASSIGN(DelegatingRenderer); +}; + +} // namespace cc + +#endif // CC_DELEGATING_RENDERER_H_ diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc index e9a76c1..a40dd3a 100644 --- a/cc/gl_renderer.cc +++ b/cc/gl_renderer.cc @@ -13,7 +13,6 @@ #include "cc/geometry_binding.h" #include "cc/layer_quad.h" #include "cc/math_util.h" -#include "cc/platform_color.h" #include "cc/priority_calculator.h" #include "cc/proxy.h" #include "cc/render_pass.h" @@ -123,8 +122,8 @@ bool GLRenderer::initialize() m_capabilities.usingEglImage = extensions.count("GL_OES_EGL_image_external"); - GLC(m_context, m_context->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_capabilities.maxTextureSize)); - m_capabilities.bestTextureFormat = PlatformColor::bestTextureFormat(m_context, extensions.count("GL_EXT_texture_format_BGRA8888")); + m_capabilities.maxTextureSize = m_resourceProvider->maxTextureSize(); + m_capabilities.bestTextureFormat = m_resourceProvider->bestTextureFormat(); // The updater can access textures while the GLRenderer is using them. m_capabilities.allowPartialTextureUpdates = true; diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc index 2372ca3..da778a9 100644 --- a/cc/layer_tree_host_impl.cc +++ b/cc/layer_tree_host_impl.cc @@ -13,6 +13,7 @@ #include "cc/damage_tracker.h" #include "cc/debug_rect_history.h" #include "cc/delay_based_time_source.h" +#include "cc/delegating_renderer.h" #include "cc/frame_rate_counter.h" #include "cc/gl_renderer.h" #include "cc/heads_up_display_layer_impl.h" @@ -975,7 +976,9 @@ bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<OutputSurface> outputSurfa if (m_settings.implSidePainting) m_tileManager.reset(new TileManager(this, resourceProvider.get(), m_settings.numRasterThreads)); - if (outputSurface->Context3D()) + if (outputSurface->Capabilities().has_parent_compositor) + m_renderer = DelegatingRenderer::Create(this, resourceProvider.get()); + else if (outputSurface->Context3D()) m_renderer = GLRenderer::create(this, resourceProvider.get()); else if (outputSurface->SoftwareDevice()) m_renderer = SoftwareRenderer::create(this, resourceProvider.get(), outputSurface->SoftwareDevice()); diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc index 965cfb9..7e9f281 100644 --- a/cc/layer_tree_host_impl_unittest.cc +++ b/cc/layer_tree_host_impl_unittest.cc @@ -207,10 +207,7 @@ public: void pinchZoomPanViewportAndScrollBoundaryTest(const float deviceScaleFactor); protected: - scoped_ptr<OutputSurface> createOutputSurface() - { - return FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<OutputSurface>(); - } + virtual scoped_ptr<OutputSurface> createOutputSurface() { return createFakeOutputSurface(); } FakeProxy m_proxy; DebugScopedSetImplThread m_alwaysImplThread; @@ -4892,6 +4889,45 @@ TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca pinchZoomPanViewportAndScrollBoundaryTest(2); } +class LayerTreeHostImplTestWithDelegatingRenderer : public LayerTreeHostImplTest { +protected: + virtual scoped_ptr<OutputSurface> createOutputSurface() + { + // Creates an output surface with a parent to use a delegating renderer. + WebKit::WebGraphicsContext3D::Attributes attrs; + return FakeOutputSurface::CreateDelegating3d(WebKit::CompositorFakeWebGraphicsContext3D::create(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); + } + + void drawFrameAndTestDamage(const gfx::RectF& expectedDamage) { + LayerTreeHostImpl::FrameData frame; + EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); + ASSERT_EQ(1u, frame.renderPasses.size()); + + // Verify the damage rect for the root render pass. + const RenderPass* rootRenderPass = frame.renderPasses.back(); + EXPECT_RECT_EQ(expectedDamage, rootRenderPass->damage_rect); + + // Verify the root layer's quad is generated and not being culled. + ASSERT_EQ(1u, rootRenderPass->quad_list.size()); + gfx::Rect expectedVisibleRect(m_hostImpl->rootLayer()->contentBounds()); + EXPECT_RECT_EQ(expectedVisibleRect, rootRenderPass->quad_list[0]->visible_rect); + + m_hostImpl->drawLayers(frame); + m_hostImpl->didDrawAllLayers(frame); + } +}; + +TEST_P(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) +{ + // Draw a frame. In the first frame, the entire viewport should be damaged. + gfx::Rect fullFrameDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); + drawFrameAndTestDamage(fullFrameDamage); + + // The second frame should have no damage, but the quads should still be generated. + gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); + drawFrameAndTestDamage(noDamage); +} + INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, LayerTreeHostImplTest, ::testing::Values(false, true)); diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc index a1fbce3..87d47e0 100644 --- a/cc/layer_tree_host_unittest.cc +++ b/cc/layer_tree_host_unittest.cc @@ -2960,11 +2960,6 @@ public: m_children.push_back(ContentLayerWithUpdateTracking::create(&m_client)); } - virtual scoped_ptr<OutputSurface> createOutputSurface() - { - return FakeOutputSurface::Create3d(CompositorFakeWebGraphicsContext3DWithEndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes()).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); - } - virtual void beginTest() { m_layerTreeHost->setRootLayer(m_parent); @@ -3335,7 +3330,8 @@ TEST(LayerTreeHostTest, LimitPartialUpdates) TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { bool useSoftwareRendering = false; - FakeLayerImplTreeHostClient client(useSoftwareRendering); + bool useDelegatingRenderer = false; + FakeLayerImplTreeHostClient client(useSoftwareRendering, useDelegatingRenderer); LayerTreeSettings settings; settings.maxPartialTextureUpdates = 4; @@ -3348,7 +3344,8 @@ TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { bool useSoftwareRendering = true; - FakeLayerImplTreeHostClient client(useSoftwareRendering); + bool useDelegatingRenderer = false; + FakeLayerImplTreeHostClient client(useSoftwareRendering, useDelegatingRenderer); LayerTreeSettings settings; settings.maxPartialTextureUpdates = 4; @@ -3358,5 +3355,33 @@ TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) EXPECT_EQ(4u, host->settings().maxPartialTextureUpdates); } +TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) +{ + bool useSoftwareRendering = false; + bool useDelegatingRenderer = true; + FakeLayerImplTreeHostClient client(useSoftwareRendering, useDelegatingRenderer); + + LayerTreeSettings settings; + settings.maxPartialTextureUpdates = 4; + + scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, scoped_ptr<Thread>()); + EXPECT_TRUE(host->initializeRendererIfNeeded()); + EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); +} + +TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndSoftwareContent) +{ + bool useSoftwareRendering = true; + bool useDelegatingRenderer = true; + FakeLayerImplTreeHostClient client(useSoftwareRendering, useDelegatingRenderer); + + LayerTreeSettings settings; + settings.maxPartialTextureUpdates = 4; + + scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, scoped_ptr<Thread>()); + EXPECT_TRUE(host->initializeRendererIfNeeded()); + EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); +} + } // namespace } // namespace cc diff --git a/cc/resource_provider.cc b/cc/resource_provider.cc index bf6bd8b..2cd7b4c 100644 --- a/cc/resource_provider.cc +++ b/cc/resource_provider.cc @@ -12,6 +12,7 @@ #include "base/string_split.h" #include "base/string_util.h" #include "cc/gl_renderer.h" // For the GLC() macro. +#include "cc/platform_color.h" #include "cc/texture_uploader.h" #include "cc/transferable_resource.h" #include "third_party/khronos/GLES2/gl2.h" @@ -499,6 +500,7 @@ ResourceProvider::ResourceProvider(OutputSurface* context) , m_useTextureUsageHint(false) , m_useShallowFlush(false) , m_maxTextureSize(0) + , m_bestTextureFormat(0) { } @@ -508,6 +510,7 @@ bool ResourceProvider::initialize() WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); if (!context3d) { m_maxTextureSize = INT_MAX / 2; + m_bestTextureFormat = GL_RGBA; return true; } if (!context3d->makeContextCurrent()) @@ -518,6 +521,7 @@ bool ResourceProvider::initialize() base::SplitString(extensionsString, ' ', &extensions); bool useMapSub = false; bool useBindUniform = false; + bool useBGRA = false; for (size_t i = 0; i < extensions.size(); ++i) { if (extensions[i] == "GL_EXT_texture_storage") m_useTextureStorageExt = true; @@ -529,12 +533,15 @@ bool ResourceProvider::initialize() m_useShallowFlush = true; else if (extensions[i] == "GL_CHROMIUM_bind_uniform_location") useBindUniform = true; + else if (extensions[i] == "GL_EXT_texture_format_BGRA8888") + useBGRA = true; } m_textureCopier = AcceleratedTextureCopier::create(context3d, useBindUniform); m_textureUploader = TextureUploader::create(context3d, useMapSub, m_useShallowFlush); GLC(context3d, context3d->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize)); + m_bestTextureFormat = PlatformColor::bestTextureFormat(context3d, useBGRA); return true; } diff --git a/cc/resource_provider.h b/cc/resource_provider.h index 860c6ca..730d9b4 100644 --- a/cc/resource_provider.h +++ b/cc/resource_provider.h @@ -53,6 +53,7 @@ public: WebKit::WebGraphicsContext3D* graphicsContext3D(); TextureCopier* textureCopier() const { return m_textureCopier.get(); } int maxTextureSize() const { return m_maxTextureSize; } + GLenum bestTextureFormat() const { return m_bestTextureFormat; } unsigned numResources() const { return m_resources.size(); } // Checks whether a resource is in use by a consumer. @@ -289,6 +290,7 @@ private: scoped_ptr<TextureUploader> m_textureUploader; scoped_ptr<AcceleratedTextureCopier> m_textureCopier; int m_maxTextureSize; + GLenum m_bestTextureFormat; base::ThreadChecker m_threadChecker; diff --git a/cc/software_renderer.cc b/cc/software_renderer.cc index 632f335..87b6fbf 100644 --- a/cc/software_renderer.cc +++ b/cc/software_renderer.cc @@ -65,8 +65,8 @@ SoftwareRenderer::SoftwareRenderer(RendererClient* client, ResourceProvider* res { m_resourceProvider->setDefaultResourceType(ResourceProvider::Bitmap); - m_capabilities.maxTextureSize = INT_MAX; - m_capabilities.bestTextureFormat = GL_RGBA; + m_capabilities.maxTextureSize = m_resourceProvider->maxTextureSize(); + m_capabilities.bestTextureFormat = m_resourceProvider->bestTextureFormat(); m_capabilities.usingSetVisibility = true; // The updater can access bitmaps while the SoftwareRenderer is using them. m_capabilities.allowPartialTextureUpdates = true; diff --git a/cc/test/fake_layer_tree_host_client.cc b/cc/test/fake_layer_tree_host_client.cc index ff312f6..a34f800 100644 --- a/cc/test/fake_layer_tree_host_client.cc +++ b/cc/test/fake_layer_tree_host_client.cc @@ -9,10 +9,16 @@ namespace cc { scoped_ptr<OutputSurface> FakeLayerImplTreeHostClient::createOutputSurface() { if (m_useSoftwareRendering) { + if (m_useDelegatingRenderer) + return FakeOutputSurface::CreateDelegatingSoftware(make_scoped_ptr(new FakeSoftwareOutputDevice).PassAs<SoftwareOutputDevice>()).PassAs<OutputSurface>(); + return FakeOutputSurface::CreateSoftware(make_scoped_ptr(new FakeSoftwareOutputDevice).PassAs<SoftwareOutputDevice>()).PassAs<OutputSurface>(); } WebKit::WebGraphicsContext3D::Attributes attrs; + if (m_useDelegatingRenderer) + return FakeOutputSurface::CreateDelegating3d(WebKit::CompositorFakeWebGraphicsContext3D::create(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); + return FakeOutputSurface::Create3d(WebKit::CompositorFakeWebGraphicsContext3D::create(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); } diff --git a/cc/test/fake_layer_tree_host_client.h b/cc/test/fake_layer_tree_host_client.h index 4cd9df3..9e5cdfcb 100644 --- a/cc/test/fake_layer_tree_host_client.h +++ b/cc/test/fake_layer_tree_host_client.h @@ -15,8 +15,9 @@ namespace cc { class FakeLayerImplTreeHostClient : public LayerTreeHostClient { public: - FakeLayerImplTreeHostClient(bool useSoftwareRendering = false) + FakeLayerImplTreeHostClient(bool useSoftwareRendering = false, bool useDelegatingRenderer = false) : m_useSoftwareRendering(useSoftwareRendering) + , m_useDelegatingRenderer(useDelegatingRenderer) { } @@ -41,6 +42,7 @@ public: private: bool m_useSoftwareRendering; + bool m_useDelegatingRenderer; }; } diff --git a/cc/test/fake_output_surface.cc b/cc/test/fake_output_surface.cc index 6d1e972..a312041 100644 --- a/cc/test/fake_output_surface.cc +++ b/cc/test/fake_output_surface.cc @@ -7,13 +7,15 @@ namespace cc { FakeOutputSurface::FakeOutputSurface( - scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { + scoped_ptr<WebKit::WebGraphicsContext3D> context3d, bool has_parent) { context3d_ = context3d.Pass(); + capabilities_.has_parent_compositor = has_parent; } FakeOutputSurface::FakeOutputSurface( - scoped_ptr<SoftwareOutputDevice> software_device) { + scoped_ptr<SoftwareOutputDevice> software_device, bool has_parent) { software_device_ = software_device.Pass(); + capabilities_.has_parent_compositor = has_parent; } FakeOutputSurface::~FakeOutputSurface() {} diff --git a/cc/test/fake_output_surface.h b/cc/test/fake_output_surface.h index 1150b05..f21e058 100644 --- a/cc/test/fake_output_surface.h +++ b/cc/test/fake_output_surface.h @@ -20,12 +20,24 @@ class FakeOutputSurface : public OutputSurface { static inline scoped_ptr<FakeOutputSurface> Create3d( scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { - return make_scoped_ptr(new FakeOutputSurface(context3d.Pass())); + return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false)); } static inline scoped_ptr<FakeOutputSurface> CreateSoftware( scoped_ptr<SoftwareOutputDevice> software_device) { - return make_scoped_ptr(new FakeOutputSurface(software_device.Pass())); + return make_scoped_ptr( + new FakeOutputSurface(software_device.Pass(), false)); + } + + static inline scoped_ptr<FakeOutputSurface> CreateDelegating3d( + scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { + return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true)); + } + + static inline scoped_ptr<FakeOutputSurface> CreateDelegatingSoftware( + scoped_ptr<SoftwareOutputDevice> software_device) { + return make_scoped_ptr( + new FakeOutputSurface(software_device.Pass(), true)); } virtual bool BindToClient(OutputSurfaceClient* client) OVERRIDE; @@ -39,9 +51,9 @@ class FakeOutputSurface : public OutputSurface { private: explicit FakeOutputSurface( - scoped_ptr<WebKit::WebGraphicsContext3D> context3d); + scoped_ptr<WebKit::WebGraphicsContext3D> context3d, bool has_parent); explicit FakeOutputSurface( - scoped_ptr<SoftwareOutputDevice> software_device); + scoped_ptr<SoftwareOutputDevice> software_device, bool has_parent); scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; scoped_ptr<SoftwareOutputDevice> software_device_; |