File: compositor_layer_resource.h

package info (click to toggle)
chromium-browser 57.0.2987.98-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,637,852 kB
  • ctags: 2,544,394
  • sloc: cpp: 12,815,961; ansic: 3,676,222; python: 1,147,112; asm: 526,608; java: 523,212; xml: 286,794; perl: 92,654; sh: 86,408; objc: 73,271; makefile: 27,698; cs: 18,487; yacc: 13,031; tcl: 12,957; pascal: 4,875; ml: 4,716; lex: 3,904; sql: 3,862; ruby: 1,982; lisp: 1,508; php: 1,368; exp: 404; awk: 325; csh: 117; jsp: 39; sed: 37
file content (113 lines) | stat: -rw-r--r-- 3,519 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// 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_PROXY_COMPOSITOR_LAYER_RESOURCE_H_
#define PPAPI_PROXY_COMPOSITOR_LAYER_RESOURCE_H_

#include <stdint.h>

#include "base/macros.h"
#include "ppapi/c/ppb_compositor_layer.h"
#include "ppapi/proxy/plugin_resource.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
#include "ppapi/shared_impl/compositor_layer_data.h"
#include "ppapi/shared_impl/scoped_pp_resource.h"
#include "ppapi/thunk/ppb_compositor_layer_api.h"

namespace gpu {
struct SyncToken;
}

namespace ppapi {
namespace proxy {

class CompositorResource;

class PPAPI_PROXY_EXPORT CompositorLayerResource
    : public PluginResource,
      public thunk::PPB_CompositorLayer_API {
 public:
  // Release callback for texture or image layer.
  typedef base::Callback<void(int32_t, const gpu::SyncToken&, bool)>
      ReleaseCallback;

  CompositorLayerResource(Connection connection,
                          PP_Instance instance,
                          const CompositorResource* compositor);

  const CompositorLayerData& data() const { return data_; }
  const ReleaseCallback& release_callback() const {
    return release_callback_;
  }
  void ResetReleaseCallback() { release_callback_.Reset(); }
  void Invalidate() { compositor_ = NULL; }

 private:
  enum LayerType {
    TYPE_COLOR,
    TYPE_TEXTURE,
    TYPE_IMAGE,
  };

  ~CompositorLayerResource() override;

  // Resource overrides:
  thunk::PPB_CompositorLayer_API* AsPPB_CompositorLayer_API() override;

  // thunk::PPB_Compositor_API overrides:
  int32_t SetColor(float red,
                   float green,
                   float blue,
                   float alpha,
                   const PP_Size* size) override;
  int32_t SetTexture0_1(
      PP_Resource context,
      uint32_t texture,
      const PP_Size* size,
      const scoped_refptr<ppapi::TrackedCallback>& callback) override;
  int32_t SetTexture(
      PP_Resource context,
      uint32_t target,
      uint32_t texture,
      const PP_Size* size,
      const scoped_refptr<TrackedCallback>& callback) override;
  int32_t SetImage(
      PP_Resource image_data,
      const PP_Size* size,
      const scoped_refptr<TrackedCallback>& callback) override;
  int32_t SetClipRect(const PP_Rect* rect) override;
  int32_t SetTransform(const float matrix[16]) override;
  int32_t SetOpacity(float opacity) override;
  int32_t SetBlendMode(PP_BlendMode mode) override;
  int32_t SetSourceRect(const PP_FloatRect* rect) override;
  int32_t SetPremultipliedAlpha(PP_Bool premult) override;

  bool SetType(LayerType type);
  int32_t CheckForSetTextureAndImage(
      LayerType type,
      const scoped_refptr<TrackedCallback>& release_callback);

  // The CompositorResource which own the layer. The layer is invalidated if
  // compositor_ is NULL.
  const CompositorResource* compositor_;

  // Release callback for uncommitted texture or image. When CommitLayers() on
  // the compositor_ is called, the callback will be copied into a map in the
  // compositor_, and it will be reset to NULL.
  ReleaseCallback release_callback_;

  // Size of texture or image. It is used to verify the rect arg of
  // SetSourceRect().
  PP_FloatSize source_size_;

  // Layer data.
  CompositorLayerData data_;

  DISALLOW_COPY_AND_ASSIGN(CompositorLayerResource);
};

}  // namespace proxy
}  // namespace ppapi

#endif  // PPAPI_PROXY_COMPOSITOR_LAYER_RESOURCE_H_