Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2482)

Unified Diff: cc/CCDelegatingRenderer.cpp

Issue 10915298: Add CCDelegatingRenderer, and corresponding IPCs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/CCDelegatingRenderer.h ('k') | cc/CCDrawQuad.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/CCDelegatingRenderer.cpp
diff --git a/cc/CCDelegatingRenderer.cpp b/cc/CCDelegatingRenderer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0fff63586d15a6af419e81667dcf2cc2ed55c083
--- /dev/null
+++ b/cc/CCDelegatingRenderer.cpp
@@ -0,0 +1,237 @@
+/*
+ * 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 "config.h"
+#include "cc/CCDelegatingRenderer.h"
+
+#include <set>
+#include <string>
+#include <vector>
+
+#include "cc/CCCheckerboardDrawQuad.h"
+#include "cc/CCDebugBorderDrawQuad.h"
+#include "cc/CCRenderPass.h"
+#include "cc/CCRenderPassDrawQuad.h"
+#include "cc/CCResourceProvider.h"
+#include "cc/CCSolidColorDrawQuad.h"
+#include "cc/CCTextureDrawQuad.h"
+#include "cc/CCTileDrawQuad.h"
+#include "cc/CCYUVVideoDrawQuad.h"
+#include "cc/compositor_frame.h"
+#include "CCSettings.h"
+#include "PlatformColor.h"
+#include "TraceEvent.h"
+#include <public/WebFloatRect.h>
+#include <public/WebRect.h>
+#include <public/WebSize.h>
+#include <wtf/text/StringHash.h>
+#include "base/string_split.h"
+#include "base/string_util.h"
+
+using namespace WebKit;
+
+namespace cc {
+
+namespace {
+
+void CollectResourcesInDrawQuad(const CCDrawQuad* quad, CCResourceProvider::ResourceIdArray* resources) {
+ switch (quad->material()) {
+ case CCDrawQuad::Invalid:
+ NOTREACHED();
+ break;
+ case CCDrawQuad::Checkerboard:
+ case CCDrawQuad::DebugBorder:
+ case CCDrawQuad::SolidColor:
+ break;
+ case CCDrawQuad::IOSurfaceContent:
+ // TODO(piman): convert to CCTextureDrawQuad?
+ NOTIMPLEMENTED();
+ break;
+ case CCDrawQuad::RenderPass:
+ resources->append(CCRenderPassDrawQuad::materialCast(quad)->maskResourceId());
+ break;
+ case CCDrawQuad::TextureContent:
+ resources->append(CCTextureDrawQuad::materialCast(quad)->resourceId());
+ break;
+ case CCDrawQuad::TiledContent:
+ resources->append(CCTileDrawQuad::materialCast(quad)->resourceId());
+ break;
+ case CCDrawQuad::YUVVideoContent: {
+ const CCYUVVideoDrawQuad* yuvQuad = CCYUVVideoDrawQuad::materialCast(quad);
+ resources->append(yuvQuad->yPlane().resourceId);
+ resources->append(yuvQuad->uPlane().resourceId);
+ resources->append(yuvQuad->vPlane().resourceId);
+ }
+ case CCDrawQuad::StreamVideoContent:
+ // TODO(piman): convert to CCTextureDrawQuad?
+ NOTIMPLEMENTED();
+ break;
+ }
+}
+
+void CollectResourcesInRenderPass(CCRenderPass* pass, CCResourceProvider::ResourceIdArray* resources) {
+ const CCQuadList& quadList = pass->quadList();
+ for (CCQuadList::const_iterator it = quadList.begin(); it != quadList.end(); ++it)
+ CollectResourcesInDrawQuad(*it, resources);
+}
+
+} // anonymous namespace
+
+
+PassOwnPtr<CCDelegatingRenderer> CCDelegatingRenderer::create(CCRendererClient* client, CCResourceProvider* resourceProvider)
+{
+ OwnPtr<CCDelegatingRenderer> renderer(adoptPtr(new CCDelegatingRenderer(client, resourceProvider)));
+ if (!renderer->initialize())
+ return nullptr;
+ return renderer.release();
+}
+
+CCDelegatingRenderer::CCDelegatingRenderer(CCRendererClient* client, CCResourceProvider* resourceProvider)
+ : CCRenderer(client)
+ , m_resourceProvider(resourceProvider)
+ , m_visible(true)
+{
+ ASSERT(m_resourceProvider);
+}
+
+bool CCDelegatingRenderer::initialize()
+{
+ m_capabilities.usingPartialSwap = CCSettings::partialSwapEnabled();
+ // FIXME: Throttling - we may want to only allow 1 outstanding frame (the
+ // parent compositor can pipeline for us).
+ m_capabilities.usingSwapCompleteCallback = true;
+ m_capabilities.maxTextureSize = m_resourceProvider->maxTextureSize();
+
+ WebGraphicsContext3D* context = m_resourceProvider->graphicsContext3D();
+ bool supportsBGRA = false;
+ if (context) {
+ if (!context->makeContextCurrent())
+ return false;
+
+ context->setContextLostCallback(this);
+ context->pushGroupMarkerEXT("CompositorContext");
+
+ std::string extensionsString = UTF16ToASCII(context->getString(GraphicsContext3D::EXTENSIONS));
+ std::vector<std::string> extensionsList;
+ base::SplitString(extensionsString, ' ', &extensionsList);
+ std::set<std::string> extensions(extensionsList.begin(), extensionsList.end());
+
+ if (settings().acceleratePainting && extensions.count("GL_EXT_texture_format_BGRA8888")
+ && extensions.count("GL_EXT_read_format_bgra"))
+ m_capabilities.usingAcceleratedPainting = true;
+ else
+ m_capabilities.usingAcceleratedPainting = false;
+
+ // FIXME: loop visibility to GPU process?
+ m_capabilities.usingSetVisibility = extensions.count("GL_CHROMIUM_set_visibility");
+
+ if (extensions.count("GL_CHROMIUM_iosurface"))
+ ASSERT(extensions.count("GL_ARB_texture_rectangle"));
+
+ m_capabilities.usingGpuMemoryManager = extensions.count("GL_CHROMIUM_gpu_memory_manager");
+ // FIXME: doesn't belong here.
+ /*
+ if (m_capabilities.usingGpuMemoryManager)
+ context->setMemoryAllocationChangedCallbackCHROMIUM(this);
+ */
+
+ m_capabilities.usingEglImage = extensions.count("GL_OES_EGL_image_external");
+ supportsBGRA = extensions.count("GL_EXT_texture_format_BGRA8888");
+ }
+
+ m_capabilities.bestTextureFormat = PlatformColor::bestTextureFormat(context, supportsBGRA);
+ m_capabilities.allowPartialTextureUpdates = false;
+
+ return true;
+}
+
+CCDelegatingRenderer::~CCDelegatingRenderer()
+{
+ ASSERT(CCProxy::isImplThread());
+ WebGraphicsContext3D* context = m_resourceProvider->graphicsContext3D();
+ if (context)
+ context->setContextLostCallback(0);
+}
+
+const RendererCapabilities& CCDelegatingRenderer::capabilities() const
+{
+ return m_capabilities;
+}
+
+void CCDelegatingRenderer::drawFrame(const CCRenderPassList& renderPassesInDrawOrder, const CCRenderPassIdHashMap&)
+{
+ TRACE_EVENT0("cc", "CCDelegatingRenderer::drawFrame");
+ WebCompositorOutputSurface* outputSurface = m_resourceProvider->context();
+ ASSERT(outputSurface);
+ CompositorFrame frame;
+ frame.size.SetSize(viewportWidth(), viewportHeight());
+ frame.render_passes.reserve(renderPassesInDrawOrder.size());
+ CCResourceProvider::ResourceIdArray resources;
+ for (CCRenderPassList::const_iterator it = renderPassesInDrawOrder.begin(); it != renderPassesInDrawOrder.end(); ++it) {
+ frame.render_passes.push_back(*it);
+ CollectResourcesInRenderPass(*it, &resources);
+ }
+ m_resourceProvider->prepareSendToParent(resources, &frame.resources);
+
+ outputSurface->sendFrameToParentCompositor(frame);
+}
+
+bool CCDelegatingRenderer::swapBuffers()
+{
+ return true;
+}
+
+void CCDelegatingRenderer::getFramebufferPixels(void *pixels, const IntRect&)
+{
+ // FIXME
+}
+
+bool CCDelegatingRenderer::isContextLost()
+{
+ WebGraphicsContext3D* context = m_resourceProvider->graphicsContext3D();
+ if (!context)
+ return false;
+ return (context->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR);
+}
+
+void CCDelegatingRenderer::onSendFrameToParentCompositorAck(const CompositorFrameAck& ack)
+{
+ m_resourceProvider->receiveFromParent(ack.resources);
+ m_client->onSwapBuffersComplete();
+}
+
+void CCDelegatingRenderer::setVisible(bool visible)
+{
+ if (m_visible == visible)
+ return;
+ m_visible = visible;
+}
+
+void CCDelegatingRenderer::onContextLost()
+{
+ m_client->didLoseContext();
+}
+
+}
« no previous file with comments | « cc/CCDelegatingRenderer.h ('k') | cc/CCDrawQuad.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698