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

Unified Diff: cc/ipc/cc_render_pass_traits.cc

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/ipc/cc_render_pass_traits.h ('k') | cc/transferable_resource.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/ipc/cc_render_pass_traits.cc
diff --git a/cc/ipc/cc_render_pass_traits.cc b/cc/ipc/cc_render_pass_traits.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fcfd8f378bedc67afeaf67e506e81355a755054c
--- /dev/null
+++ b/cc/ipc/cc_render_pass_traits.cc
@@ -0,0 +1,392 @@
+// 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 "cc/ipc/cc_render_pass_traits.h"
+
+#include "content/common/cc_messages.h"
+#include "cc/compositor_frame.h"
+#include "cc/ipc/cc_param_traits.h"
+
+#undef LOG
+#include "config.h"
+
+#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"
+
+namespace IPC {
+
+void ParamTraits<cc::IntRect>::Write(Message* m, const param_type& p) {
+ WriteParam(m, p.location());
+ WriteParam(m, p.size());
+}
+
+bool ParamTraits<cc::IntRect>::Read(const Message* m,
+ PickleIterator* iter,
+ param_type* p) {
+ WebCore::IntPoint location;
+ WebCore::IntSize size;
+ if (!ReadParam(m, iter, &location) || !ReadParam(m, iter, &size))
+ return false;
+ p->setLocation(location);
+ p->setSize(size);
+ return true;
+}
+
+void ParamTraits<cc::IntRect>::Log(const param_type& p, std::string* l) {
+ // TODO
+}
+
+void ParamTraits<WebCore::IntPoint>::Write(Message* m, const param_type& p) {
+ WriteParam(m, p.x());
+ WriteParam(m, p.y());
+}
+
+bool ParamTraits<WebCore::IntPoint>::Read(const Message* m,
+ PickleIterator* iter,
+ param_type* p) {
+ int x;
+ int y;
+ if (!ReadParam(m, iter, &x) || !ReadParam(m, iter, &y))
+ return false;
+ p->setX(x);
+ p->setY(y);
+ return true;
+}
+
+void ParamTraits<WebCore::IntPoint>::Log(const param_type& p, std::string* l) {
+ // TODO
+}
+
+void ParamTraits<WebCore::IntSize>::Write(Message* m, const param_type& p) {
+ WriteParam(m, p.width());
+ WriteParam(m, p.height());
+}
+
+bool ParamTraits<WebCore::IntSize>::Read(const Message* m,
+ PickleIterator* iter,
+ param_type* p) {
+ int width;
+ int height;
+ if (!ReadParam(m, iter, &width) || !ReadParam(m, iter, &height))
+ return false;
+ p->setWidth(width);
+ p->setHeight(height);
+ return true;
+}
+
+void ParamTraits<WebCore::IntSize>::Log(const param_type& p, std::string* l) {
+ // TODO
+}
+
+void ParamTraits<cc::FloatRect>::Write(Message* m, const param_type& p) {
+ WriteParam(m, p.location());
+ WriteParam(m, p.size());
+}
+
+bool ParamTraits<cc::FloatRect>::Read(const Message* m,
+ PickleIterator* iter,
+ param_type* p) {
+ WebCore::FloatPoint location;
+ WebCore::FloatSize size;
+ if (!ReadParam(m, iter, &location) || !ReadParam(m, iter, &size))
+ return false;
+ p->setLocation(location);
+ p->setSize(size);
+ return true;
+}
+
+void ParamTraits<cc::FloatRect>::Log(const param_type& p, std::string* l) {
+ // TODO
+}
+
+void ParamTraits<WebCore::FloatPoint>::Write(Message* m, const param_type& p) {
+ WriteParam(m, p.x());
+ WriteParam(m, p.y());
+}
+
+bool ParamTraits<WebCore::FloatPoint>::Read(const Message* m,
+ PickleIterator* iter,
+ param_type* p) {
+ float x;
+ float y;
+ if (!ReadParam(m, iter, &x) || !ReadParam(m, iter, &y))
+ return false;
+ p->setX(x);
+ p->setY(y);
+ return true;
+}
+
+void ParamTraits<WebCore::FloatPoint>::Log(const param_type& p, std::string* l) {
+ // TODO
+}
+
+void ParamTraits<WebCore::FloatSize>::Write(Message* m, const param_type& p) {
+ WriteParam(m, p.width());
+ WriteParam(m, p.height());
+}
+
+bool ParamTraits<WebCore::FloatSize>::Read(const Message* m,
+ PickleIterator* iter,
+ param_type* p) {
+ float width;
+ float height;
+ if (!ReadParam(m, iter, &width) || !ReadParam(m, iter, &height))
+ return false;
+ p->setWidth(width);
+ p->setHeight(height);
+ return true;
+}
+
+void ParamTraits<WebCore::FloatSize>::Log(const param_type& p, std::string* l) {
+ // TODO
+}
+
+template<>
+struct ParamTraits<cc::CCDrawQuad> {
+ static void WriteDrawQuad(Message* m, const cc::CCDrawQuad* p);
+ static cc::CCDrawQuad* ReadDrawQuad(const Message* m, PickleIterator* iter, const cc::CCSharedQuadStateList&);
+};
+
+void ParamTraits<cc::CCDrawQuad>::WriteDrawQuad(Message* m, const cc::CCDrawQuad* quad) {
+ m->WriteUInt32(quad->m_material);
+ WriteParam(m, quad->m_sharedQuadStateId);
+ WriteParam(m, quad->m_quadRect);
+ WriteParam(m, quad->m_quadVisibleRect);
+ WriteParam(m, quad->m_quadOpaque);
+ WriteParam(m, quad->m_needsBlending);
+ WriteParam(m, quad->m_opaqueRect);
+ switch (quad->material()) {
+ case cc::CCDrawQuad::Invalid:
+ NOTREACHED();
+ break;
+ case cc::CCDrawQuad::Checkerboard:
+ WriteParam(m, cc::CCCheckerboardDrawQuad::materialCast(quad)->color());
+ break;
+ case cc::CCDrawQuad::SolidColor:
+ WriteParam(m, cc::CCSolidColorDrawQuad::materialCast(quad)->color());
+ break;
+ case cc::CCDrawQuad::TiledContent: {
+ const cc::CCTileDrawQuad* tileQuad = cc::CCTileDrawQuad::materialCast(quad);
+ WriteParam(m, tileQuad->resourceId());
+ WriteParam<WebCore::IntPoint>(m, tileQuad->textureOffset());
+ WriteParam<WebCore::IntSize>(m, tileQuad->textureSize());
+ WriteParam(m, tileQuad->textureFilter());
+ WriteParam(m, tileQuad->swizzleContents());
+ WriteParam(m, tileQuad->leftEdgeAA());
+ WriteParam(m, tileQuad->topEdgeAA());
+ WriteParam(m, tileQuad->rightEdgeAA());
+ WriteParam(m, tileQuad->bottomEdgeAA());
+ break;
+ }
+ case cc::CCDrawQuad::TextureContent: {
+ const cc::CCTextureDrawQuad* textureQuad = cc::CCTextureDrawQuad::materialCast(quad);
+ WriteParam(m, textureQuad->resourceId());
+ WriteParam(m, textureQuad->uvRect());
+ WriteParam(m, textureQuad->premultipliedAlpha());
+ WriteParam(m, textureQuad->flipped());
+ break;
+ }
+ case cc::CCDrawQuad::DebugBorder:
+ case cc::CCDrawQuad::YUVVideoContent:
+ case cc::CCDrawQuad::RenderPass:
+ case cc::CCDrawQuad::IOSurfaceContent:
+ case cc::CCDrawQuad::StreamVideoContent:
+ // TODO
+ break;
+ }
+}
+
+cc::CCDrawQuad* ParamTraits<cc::CCDrawQuad>::ReadDrawQuad(
+ const Message* m,
+ PickleIterator* iter,
+ const cc::CCSharedQuadStateList& sharedQuadList) {
+ unsigned material;
+ int sharedQuadStateId;
+ cc::IntRect quadRect;
+ cc::IntRect quadVisibleRect;
+ bool quadOpaque;
+ bool needsBlending;
+ cc::IntRect opaqueRect;
+ if (!m->ReadUInt32(iter, &material) ||
+ !ReadParam(m, iter, &sharedQuadStateId) ||
+ !ReadParam(m, iter, &quadRect) ||
+ !ReadParam(m, iter, &quadVisibleRect) ||
+ !ReadParam(m, iter, &quadOpaque) ||
+ !ReadParam(m, iter, &needsBlending) ||
+ !ReadParam(m, iter, &opaqueRect))
+ return NULL;
+ scoped_ptr<cc::CCDrawQuad> quad;
+ const cc::CCSharedQuadState* state = NULL;
+ for (cc::CCSharedQuadStateList::const_iterator it = sharedQuadList.begin(); it != sharedQuadList.end(); ++it) {
+ if ((*it)->id == sharedQuadStateId)
+ state = *it;
+ }
+ if (!state)
+ return NULL;
+
+ switch (material) {
+ case cc::CCDrawQuad::Checkerboard:
+ SkColor color;
+ if (!ReadParam(m, iter, &color))
+ return NULL;
+ quad = cc::CCCheckerboardDrawQuad::create(state, quadRect, color).Pass();
+ break;
+ case cc::CCDrawQuad::SolidColor: {
+ SkColor color;
+ if (!ReadParam(m, iter, &color))
+ return NULL;
+ quad = cc::CCSolidColorDrawQuad::create(state, quadRect, color).Pass();
+ break;
+ }
+ case cc::CCDrawQuad::TiledContent: {
+ unsigned resourceId;
+ WebCore::IntPoint textureOffset;
+ WebCore::IntSize textureSize;
+ WebKit::WGC3Dint textureFilter;
+ bool swizzleContents;
+ bool leftEdgeAA;
+ bool topEdgeAA;
+ bool rightEdgeAA;
+ bool bottomEdgeAA;
+
+ if (!ReadParam(m, iter, &resourceId) ||
+ !ReadParam(m, iter, &textureOffset) ||
+ !ReadParam(m, iter, &textureSize) ||
+ !ReadParam(m, iter, &textureFilter) ||
+ !ReadParam(m, iter, &swizzleContents) ||
+ !ReadParam(m, iter, &leftEdgeAA) ||
+ !ReadParam(m, iter, &topEdgeAA) ||
+ !ReadParam(m, iter, &rightEdgeAA) ||
+ !ReadParam(m, iter, &bottomEdgeAA))
+ return NULL;
+ quad = cc::CCTileDrawQuad::create(state, quadRect, opaqueRect, resourceId, textureOffset, textureSize, textureFilter, swizzleContents, leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA).Pass();
+ break;
+ }
+ case cc::CCDrawQuad::TextureContent: {
+ unsigned resourceId;
+ cc::FloatRect uvRect;
+ bool premultipliedAlpha;
+ bool flipped;
+ if (!ReadParam(m, iter, &resourceId) ||
+ !ReadParam(m, iter, &uvRect) ||
+ !ReadParam(m, iter, &premultipliedAlpha) ||
+ !ReadParam(m, iter, &flipped))
+ return NULL;
+ quad = cc::CCTextureDrawQuad::create(state, quadRect, resourceId, premultipliedAlpha, uvRect, flipped).Pass();
+ break;
+ }
+ case cc::CCDrawQuad::DebugBorder:
+ case cc::CCDrawQuad::YUVVideoContent:
+ case cc::CCDrawQuad::RenderPass:
+ case cc::CCDrawQuad::IOSurfaceContent:
+ case cc::CCDrawQuad::StreamVideoContent:
+ // TODO
+ quad = cc::CCCheckerboardDrawQuad::create(state, quadRect, SK_ColorYELLOW).Pass();
+ break;
+ case cc::CCDrawQuad::Invalid:
+ default:
+ NOTREACHED();
+ return NULL;
+ }
+ quad->m_quadVisibleRect = quadVisibleRect;
+ quad->m_quadOpaque = quadOpaque;
+ quad->m_needsBlending = needsBlending;
+ quad->m_opaqueRect = opaqueRect;
+ return quad.release();
+}
+
+void ParamTraits<cc::CCSharedQuadState>::Write(Message* m, const param_type& p) {
+ WriteParam(m, p.id);
+ WriteParam(m, p.quadTransform);
+ WriteParam(m, p.visibleContentRect);
+ WriteParam(m, p.clippedRectInTarget);
+ WriteParam(m, p.opacity);
+ WriteParam(m, p.opaque);
+}
+
+bool ParamTraits<cc::CCSharedQuadState>::Read(const Message* m,
+ PickleIterator* iter,
+ param_type* p) {
+ return ReadParam(m, iter, &p->id) &&
+ ReadParam(m, iter, &p->quadTransform) &&
+ ReadParam(m, iter, &p->visibleContentRect) &&
+ ReadParam(m, iter, &p->clippedRectInTarget) &&
+ ReadParam(m, iter, &p->opacity) &&
+ ReadParam(m, iter, &p->opaque);
+}
+
+void ParamTraits<cc::CCSharedQuadState>::Log(const param_type& p, std::string* l) {
+ // TODO
+}
+
+void ParamTraits<cc::CCRenderPass>::Write(Message* m, const param_type& p) {
+ WriteParam(m, p.m_id.layerId);
+ WriteParam(m, p.m_id.index);
+ WriteParam(m, p.m_sharedQuadStateList.size());
+ WriteParam(m, p.m_quadList.size());
+ WriteParam(m, p.m_transformToRootTarget);
+ WriteParam(m, p.m_outputRect);
+ WriteParam(m, p.m_damageRect);
+ WriteParam(m, p.m_hasTransparentBackground);
+ WriteParam(m, p.m_hasOcclusionFromOutsideTargetSurface);
+ for (size_t i = 0; i < p.m_sharedQuadStateList.size(); ++i)
+ WriteParam(m, *p.m_sharedQuadStateList[i]);
+ for (size_t i = 0; i < p.m_quadList.size(); ++i)
+ ParamTraits<cc::CCDrawQuad>::WriteDrawQuad(m, p.m_quadList[i]);
+ // TODO m_filters, m_backgroundFilters
+}
+
+bool ParamTraits<cc::CCRenderPass>::Read(const Message* m,
+ PickleIterator* iter,
+ param_type* p) {
+ size_t sharedQuadStateListSize;
+ size_t quadListSize;
+ if (!ReadParam(m, iter, &p->m_id.layerId) ||
+ !ReadParam(m, iter, &p->m_id.index) ||
+ !ReadParam(m, iter, &sharedQuadStateListSize) ||
+ !ReadParam(m, iter, &quadListSize) ||
+ !ReadParam(m, iter, &p->m_transformToRootTarget) ||
+ !ReadParam(m, iter, &p->m_outputRect) ||
+ !ReadParam(m, iter, &p->m_damageRect) ||
+ !ReadParam(m, iter, &p->m_hasTransparentBackground) ||
+ !ReadParam(m, iter, &p->m_hasOcclusionFromOutsideTargetSurface))
+ return false;
+ for (size_t i = 0; i < sharedQuadStateListSize; ++i) {
+ scoped_ptr<cc::CCSharedQuadState> state(cc::CCSharedQuadState::create(WebKit::WebTransformationMatrix(), cc::IntRect(), cc::IntRect(), 1.f, true));
+ if (!ReadParam(m, iter, state.get()))
+ return false;
+ p->m_sharedQuadStateList.append(state.Pass());
+ }
+ for (size_t i = 0; i < quadListSize; ++i) {
+ scoped_ptr<cc::CCDrawQuad> quad(ParamTraits<cc::CCDrawQuad>::ReadDrawQuad(m, iter, p->m_sharedQuadStateList));
+ if (!quad.get())
+ return false;
+ p->m_quadList.append(quad.Pass());
+ }
+ // TODO m_filters, m_backgroundFilters
+ return true;
+}
+
+cc::CCRenderPass* ParamTraits<cc::CCRenderPass>::ReadRenderPass(const Message* m,
+ PickleIterator* iter) {
+ cc::CCRenderPass::Id id(1, 1);
+ scoped_ptr<cc::CCRenderPass> render_pass(cc::CCRenderPass::create(id, cc::IntRect(), WebKit::WebTransformationMatrix()));
+ if (!Read(m, iter, render_pass.get())) {
+ return NULL;
+ }
+ return render_pass.release();
+}
+
+void ParamTraits<cc::CCRenderPass>::Log(const param_type& p, std::string* l) {
+ // TODO
+}
+
+} // namespace IPC
« no previous file with comments | « cc/ipc/cc_render_pass_traits.h ('k') | cc/transferable_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698