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. 4 5#ifndef PPAPI_PROXY_COMPOSITOR_RESOURCE_H_ 6#define PPAPI_PROXY_COMPOSITOR_RESOURCE_H_ 7 8#include <map> 9 10#include "ppapi/proxy/compositor_layer_resource.h" 11#include "ppapi/proxy/plugin_resource.h" 12#include "ppapi/proxy/ppapi_proxy_export.h" 13#include "ppapi/shared_impl/proxy_lock.h" 14#include "ppapi/thunk/ppb_compositor_api.h" 15 16namespace ppapi { 17namespace proxy { 18 19class PPAPI_PROXY_EXPORT CompositorResource 20 : public PluginResource, 21 public thunk::PPB_Compositor_API { 22 public: 23 CompositorResource(Connection connection, 24 PP_Instance instance); 25 26 bool IsInProgress() const; 27 28 int32_t GenerateResourceId() const; 29 30 private: 31 virtual ~CompositorResource(); 32 33 // Resource overrides: 34 virtual thunk::PPB_Compositor_API* AsPPB_Compositor_API() OVERRIDE; 35 36 // PluginResource overrides: 37 virtual void OnReplyReceived(const ResourceMessageReplyParams& params, 38 const IPC::Message& msg) OVERRIDE; 39 40 // thunk::PPB_Compositor_API overrides: 41 virtual PP_Resource AddLayer() OVERRIDE; 42 virtual int32_t CommitLayers( 43 const scoped_refptr<TrackedCallback>& callback) OVERRIDE; 44 virtual int32_t ResetLayers() OVERRIDE; 45 46 // IPC msg handlers: 47 void OnPluginMsgCommitLayersReply(const ResourceMessageReplyParams& params); 48 void OnPluginMsgReleaseResource( 49 const ResourceMessageReplyParams& params, 50 int32_t id, 51 uint32_t sync_point, 52 bool is_lost); 53 54 void ResetLayersInternal(bool is_aborted); 55 56 // Callback for CommitLayers(). 57 scoped_refptr<TrackedCallback> commit_callback_; 58 59 // True if layers_ has been reset by ResetLayers(). 60 bool layer_reset_; 61 62 // Layer stack. 63 typedef std::vector<scoped_refptr<CompositorLayerResource> > LayerList; 64 LayerList layers_; 65 66 // Release callback map for texture and image. 67 typedef CompositorLayerResource::ReleaseCallback ReleaseCallback; 68 typedef std::map<int32_t, ReleaseCallback> ReleaseCallbackMap; 69 ReleaseCallbackMap release_callback_map_; 70 71 // The last resource id for texture or image. 72 mutable int32_t last_resource_id_; 73 74 DISALLOW_COPY_AND_ASSIGN(CompositorResource); 75}; 76 77} // namespace proxy 78} // namespace ppapi 79 80#endif // PPAPI_PROXY_COMPOSITOR_RESOURCE_H_ 81