summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy/image_data.h
blob: fb4a8393667ca759c30ecfbbcc5d02f43daad920 (plain)
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
// Copyright (c) 2010 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_IMAGE_DATA_H_
#define PPAPI_PROXY_IMAGE_DATA_H_

#include "base/shared_memory.h"
#include "ppapi/c/ppb_image_data.h"
#include "ppapi/proxy/plugin_resource.h"
#include "ppapi/proxy/serialized_structs.h"

namespace pp {
namespace proxy {

class ImageData : public PluginResource {
 public:
  ImageData(const PP_ImageDataDesc& desc, ImageHandle handle);
  virtual ~ImageData();

  // Resource overrides.
  virtual ImageData* AsImageData() { return this; }

  void* Map();
  void Unmap();

  const PP_ImageDataDesc& desc() const { return desc_; }

  static const ImageHandle NullHandle;
  static ImageHandle HandleFromInt(int32_t i);

 private:
  PP_ImageDataDesc desc_;
  ImageHandle handle_;

  void* mapped_data_;

  DISALLOW_COPY_AND_ASSIGN(ImageData);
};

}  // namespace proxy
}  // namespace pp

#endif  // PPAPI_PROXY_IMAGE_DATA_H_