summaryrefslogtreecommitdiffstats
path: root/ppapi/shared_impl
diff options
context:
space:
mode:
authorpenghuang@chromium.org <penghuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-16 14:20:26 +0000
committerpenghuang@chromium.org <penghuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-16 14:20:26 +0000
commitc44620b2cb57378a518ee97427e7c3d319507c8d (patch)
treeccc8f088aab4dc3758fc71de6b9eca133e3637c9 /ppapi/shared_impl
parentd765198b19590e158a609cc34c29af39b6cd9e9d (diff)
downloadchromium_src-c44620b2cb57378a518ee97427e7c3d319507c8d.zip
chromium_src-c44620b2cb57378a518ee97427e7c3d319507c8d.tar.gz
chromium_src-c44620b2cb57378a518ee97427e7c3d319507c8d.tar.bz2
[PPAPI] Compositor API implementation.
Implement the compositor API which allows a plugin to combine different sources of visual data efficiently, such as PPB_ImageData and OpengGL texture. API Proposal http://goo.gl/V7xcu3 BUG=374383 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=277208 Review URL: https://codereview.chromium.org/298023004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277422 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/shared_impl')
-rw-r--r--ppapi/shared_impl/compositor_layer_data.cc36
-rw-r--r--ppapi/shared_impl/compositor_layer_data.h119
2 files changed, 155 insertions, 0 deletions
diff --git a/ppapi/shared_impl/compositor_layer_data.cc b/ppapi/shared_impl/compositor_layer_data.cc
new file mode 100644
index 0000000..a4b51d37
--- /dev/null
+++ b/ppapi/shared_impl/compositor_layer_data.cc
@@ -0,0 +1,36 @@
+// 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 "ppapi/shared_impl/compositor_layer_data.h"
+
+namespace ppapi {
+
+namespace {
+
+template<typename T>
+void Copy(scoped_ptr<T>* a, const scoped_ptr<T>& b) {
+ if (b) {
+ if (!(*a))
+ a->reset(new T());
+ **a = *b;
+ } else {
+ a->reset();
+ }
+}
+
+} // namespace
+
+const CompositorLayerData& CompositorLayerData::operator=(
+ const CompositorLayerData& other) {
+ DCHECK(other.is_null() || other.is_valid());
+
+ common = other.common;
+ Copy(&color, other.color);
+ Copy(&texture, other.texture);
+ Copy(&image, other.image);
+
+ return *this;
+}
+
+} // namespace ppapi
diff --git a/ppapi/shared_impl/compositor_layer_data.h b/ppapi/shared_impl/compositor_layer_data.h
new file mode 100644
index 0000000..b51fcd7
--- /dev/null
+++ b/ppapi/shared_impl/compositor_layer_data.h
@@ -0,0 +1,119 @@
+// 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 PPAPI_SHARED_IMPL_COMPOSITOR_LAYER_DATA_H_
+#define PPAPI_SHARED_IMPL_COMPOSITOR_LAYER_DATA_H_
+
+#include <string.h>
+
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "gpu/command_buffer/common/mailbox.h"
+#include "ppapi/c/ppb_compositor_layer.h"
+#include "ppapi/shared_impl/host_resource.h"
+#include "ppapi/shared_impl/ppapi_shared_export.h"
+
+namespace ppapi {
+
+struct PPAPI_SHARED_EXPORT CompositorLayerData {
+
+ struct Transform {
+ Transform() {
+ matrix[0] = 1.0f;
+ matrix[1] = 0.0f;
+ matrix[2] = 0.0f;
+ matrix[3] = 0.0f;
+ matrix[4] = 0.0f;
+ matrix[5] = 1.0f;
+ matrix[6] = 0.0f;
+ matrix[7] = 0.0f;
+ matrix[8] = 0.0f;
+ matrix[9] = 0.0f;
+ matrix[10] = 1.0f;
+ matrix[11] = 0.0f;
+ matrix[12] = 0.0f;
+ matrix[13] = 0.0f;
+ matrix[14] = 0.0f;
+ matrix[15] = 1.0f;
+ }
+
+ float matrix[16];
+ };
+
+ struct LayerCommon {
+ LayerCommon()
+ : size(PP_MakeSize(0, 0)),
+ clip_rect(PP_MakeRectFromXYWH(0, 0, 0, 0)),
+ blend_mode(PP_BLENDMODE_SRC_OVER),
+ opacity(1.0f),
+ resource_id(0) {
+ }
+
+ PP_Size size;
+ PP_Rect clip_rect;
+ Transform transform;
+ PP_BlendMode blend_mode;
+ float opacity;
+ uint32_t resource_id;
+ };
+
+ struct ColorLayer {
+ ColorLayer() : red(0.0f), green(0.0f), blue(0.0f), alpha(0.0f) {}
+
+ float red;
+ float green;
+ float blue;
+ float alpha;
+ };
+
+ struct ImageLayer {
+ ImageLayer()
+ : resource(0),
+ source_rect(PP_MakeFloatRectFromXYWH(0.0f, 0.0f, 0.0f, 0.0f)) {}
+
+ PP_Resource resource;
+ PP_FloatRect source_rect;
+ };
+
+ struct TextureLayer {
+ TextureLayer()
+ : sync_point(0),
+ source_rect(PP_MakeFloatRectFromXYWH(0.0f, 0.0f, 1.0f, 1.0f)),
+ premult_alpha(true) {}
+
+ gpu::Mailbox mailbox;
+ uint32_t sync_point;
+ PP_FloatRect source_rect;
+ bool premult_alpha;
+ };
+
+ CompositorLayerData() {}
+
+ CompositorLayerData(const CompositorLayerData& other) {
+ *this = other;
+ }
+
+ bool is_null() const {
+ return !(color || texture || image);
+ }
+
+ bool is_valid() const {
+ int i = 0;
+ if (color) ++i;
+ if (texture) ++i;
+ if (image) ++i;
+ return i == 1;
+ }
+
+ const CompositorLayerData& operator=(const CompositorLayerData& other);
+
+ LayerCommon common;
+ scoped_ptr<ColorLayer> color;
+ scoped_ptr<TextureLayer> texture;
+ scoped_ptr<ImageLayer> image;
+};
+
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_COMPOSITOR_LAYER_DATA_H_