Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <stdint.h> |
| 18 | #include <sys/types.h> |
| 19 | |
| 20 | #include <gui/IDisplayEventConnection.h> |
| 21 | #include <gui/BitTube.h> |
| 22 | #include <gui/DisplayEventReceiver.h> |
| 23 | |
| 24 | #include <utils/Errors.h> |
| 25 | |
| 26 | #include "SurfaceFlinger.h" |
| 27 | #include "DisplayEventConnection.h" |
| 28 | |
| 29 | // --------------------------------------------------------------------------- |
| 30 | |
| 31 | namespace android { |
| 32 | |
| 33 | // --------------------------------------------------------------------------- |
| 34 | |
| 35 | DisplayEventConnection::DisplayEventConnection( |
| 36 | const sp<SurfaceFlinger>& flinger) |
| 37 | : mFlinger(flinger), mChannel(new BitTube()) |
| 38 | { |
| 39 | } |
| 40 | |
| 41 | DisplayEventConnection::~DisplayEventConnection() { |
| 42 | mFlinger->cleanupDisplayEventConnection(this); |
| 43 | } |
| 44 | |
| 45 | void DisplayEventConnection::onFirstRef() { |
| 46 | // nothing to do here for now. |
| 47 | } |
| 48 | |
| 49 | sp<BitTube> DisplayEventConnection::getDataChannel() const { |
| 50 | return mChannel; |
| 51 | } |
| 52 | |
| 53 | status_t DisplayEventConnection::postEvent(const DisplayEventReceiver::Event& event) |
| 54 | { |
| 55 | ssize_t size = mChannel->write(&event, sizeof(DisplayEventReceiver::Event)); |
| 56 | return size < 0 ? status_t(size) : status_t(NO_ERROR); |
| 57 | } |
| 58 | |
| 59 | |
| 60 | // --------------------------------------------------------------------------- |
| 61 | |
| 62 | }; // namespace android |