Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ppapi / shared_impl / compositor_layer_data.h
blob8cf096ea49b690caaafe97477b9beec66a01a333
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PPAPI_SHARED_IMPL_COMPOSITOR_LAYER_DATA_H_
6 #define PPAPI_SHARED_IMPL_COMPOSITOR_LAYER_DATA_H_
8 #include <string.h>
10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "gpu/command_buffer/common/mailbox.h"
13 #include "ppapi/c/ppb_compositor_layer.h"
14 #include "ppapi/shared_impl/host_resource.h"
15 #include "ppapi/shared_impl/ppapi_shared_export.h"
17 namespace ppapi {
19 struct PPAPI_SHARED_EXPORT CompositorLayerData {
21 struct Transform {
22 Transform() {
23 matrix[0] = 1.0f;
24 matrix[1] = 0.0f;
25 matrix[2] = 0.0f;
26 matrix[3] = 0.0f;
27 matrix[4] = 0.0f;
28 matrix[5] = 1.0f;
29 matrix[6] = 0.0f;
30 matrix[7] = 0.0f;
31 matrix[8] = 0.0f;
32 matrix[9] = 0.0f;
33 matrix[10] = 1.0f;
34 matrix[11] = 0.0f;
35 matrix[12] = 0.0f;
36 matrix[13] = 0.0f;
37 matrix[14] = 0.0f;
38 matrix[15] = 1.0f;
41 float matrix[16];
44 struct LayerCommon {
45 LayerCommon()
46 : size(PP_MakeSize(0, 0)),
47 clip_rect(PP_MakeRectFromXYWH(0, 0, 0, 0)),
48 blend_mode(PP_BLENDMODE_SRC_OVER),
49 opacity(1.0f),
50 resource_id(0) {
53 PP_Size size;
54 PP_Rect clip_rect;
55 Transform transform;
56 PP_BlendMode blend_mode;
57 float opacity;
58 uint32_t resource_id;
61 struct ColorLayer {
62 ColorLayer() : red(0.0f), green(0.0f), blue(0.0f), alpha(0.0f) {}
64 float red;
65 float green;
66 float blue;
67 float alpha;
70 struct ImageLayer {
71 ImageLayer()
72 : resource(0),
73 source_rect(PP_MakeFloatRectFromXYWH(0.0f, 0.0f, 0.0f, 0.0f)) {}
75 PP_Resource resource;
76 PP_FloatRect source_rect;
79 struct TextureLayer {
80 TextureLayer()
81 : target(0),
82 sync_point(0),
83 source_rect(PP_MakeFloatRectFromXYWH(0.0f, 0.0f, 1.0f, 1.0f)),
84 premult_alpha(true) {}
86 gpu::Mailbox mailbox;
87 uint32_t target;
88 uint32_t sync_point;
89 PP_FloatRect source_rect;
90 bool premult_alpha;
93 CompositorLayerData() {}
95 CompositorLayerData(const CompositorLayerData& other) {
96 *this = other;
99 bool is_null() const {
100 return !(color || texture || image);
103 bool is_valid() const {
104 int i = 0;
105 if (color) ++i;
106 if (texture) ++i;
107 if (image) ++i;
108 return i == 1;
111 const CompositorLayerData& operator=(const CompositorLayerData& other);
113 LayerCommon common;
114 scoped_ptr<ColorLayer> color;
115 scoped_ptr<TextureLayer> texture;
116 scoped_ptr<ImageLayer> image;
119 } // namespace ppapi
121 #endif // PPAPI_SHARED_IMPL_COMPOSITOR_LAYER_DATA_H_