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 UI_OZONE_PLATFORM_DRI_GPU_PLATFORM_SUPPORT_HOST_GBM_H_ 6#define UI_OZONE_PLATFORM_DRI_GPU_PLATFORM_SUPPORT_HOST_GBM_H_ 7 8#include <queue> 9#include <vector> 10 11#include "base/observer_list.h" 12#include "ui/gfx/native_widget_types.h" 13#include "ui/ozone/platform/dri/hardware_cursor_delegate.h" 14#include "ui/ozone/public/gpu_platform_support_host.h" 15 16class SkBitmap; 17 18namespace gfx { 19class Point; 20} 21 22namespace ui { 23 24class ChannelObserver; 25 26class GpuPlatformSupportHostGbm : public GpuPlatformSupportHost, 27 public HardwareCursorDelegate, 28 public IPC::Sender { 29 public: 30 GpuPlatformSupportHostGbm(); 31 virtual ~GpuPlatformSupportHostGbm(); 32 33 bool IsConnected() const; 34 35 void RegisterHandler(GpuPlatformSupportHost* handler); 36 void UnregisterHandler(GpuPlatformSupportHost* handler); 37 38 void AddChannelObserver(ChannelObserver* observer); 39 void RemoveChannelObserver(ChannelObserver* observer); 40 41 // GpuPlatformSupportHost: 42 virtual void OnChannelEstablished(int host_id, IPC::Sender* sender) OVERRIDE; 43 virtual void OnChannelDestroyed(int host_id) OVERRIDE; 44 45 // IPC::Listener: 46 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 47 48 // IPC::Sender: 49 virtual bool Send(IPC::Message* message) OVERRIDE; 50 51 // HardwareCursorDelegate: 52 virtual void SetHardwareCursor(gfx::AcceleratedWidget widget, 53 const std::vector<SkBitmap>& bitmaps, 54 const gfx::Point& location, 55 int frame_delay_ms) OVERRIDE; 56 virtual void MoveHardwareCursor(gfx::AcceleratedWidget widget, 57 const gfx::Point& location) OVERRIDE; 58 59 private: 60 int host_id_; 61 IPC::Sender* sender_; 62 std::vector<GpuPlatformSupportHost*> handlers_; 63 // If messages are sent before the channel is created, store the messages and 64 // delay sending them until the channel is created. These messages are stored 65 // in |queued_messaged_|. 66 std::queue<IPC::Message*> queued_messages_; 67 ObserverList<ChannelObserver> channel_observers_; 68}; 69 70} // namespace ui 71 72#endif // UI_OZONE_GPU_GPU_PLATFORM_SUPPORT_HOST_GBM_H_ 73