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 | |
Mathias Agopian | 841cde5 | 2012-03-01 15:44:37 -0800 | [diff] [blame] | 17 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
| 18 | |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 19 | #include <stdint.h> |
| 20 | #include <sys/types.h> |
| 21 | |
Mathias Agopian | a4cb35a | 2012-08-20 20:07:34 -0700 | [diff] [blame] | 22 | #include <cutils/compiler.h> |
| 23 | |
Mathias Agopian | cb9732a | 2012-04-03 17:48:03 -0700 | [diff] [blame] | 24 | #include <gui/BitTube.h> |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 25 | #include <gui/IDisplayEventConnection.h> |
| 26 | #include <gui/DisplayEventReceiver.h> |
| 27 | |
| 28 | #include <utils/Errors.h> |
Mathias Agopian | 921e6ac | 2012-07-23 23:11:29 -0700 | [diff] [blame] | 29 | #include <utils/String8.h> |
Mathias Agopian | 841cde5 | 2012-03-01 15:44:37 -0800 | [diff] [blame] | 30 | #include <utils/Trace.h> |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 31 | |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 32 | #include "EventThread.h" |
| 33 | #include "SurfaceFlinger.h" |
| 34 | |
| 35 | // --------------------------------------------------------------------------- |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 36 | namespace android { |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 37 | // --------------------------------------------------------------------------- |
| 38 | |
| 39 | EventThread::EventThread(const sp<SurfaceFlinger>& flinger) |
Mathias Agopian | 8630320 | 2012-07-24 22:46:10 -0700 | [diff] [blame] | 40 | : mFlinger(flinger), |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 41 | mVSyncTimestamp(0), |
Mathias Agopian | 22ffb11 | 2012-04-10 21:04:02 -0700 | [diff] [blame] | 42 | mUseSoftwareVSync(false), |
Mathias Agopian | 10125f0 | 2012-08-17 15:06:02 -0700 | [diff] [blame] | 43 | mVSyncCount(0), |
Mathias Agopian | 921e6ac | 2012-07-23 23:11:29 -0700 | [diff] [blame] | 44 | mDebugVsyncEnabled(false) { |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | void EventThread::onFirstRef() { |
| 48 | run("EventThread", PRIORITY_URGENT_DISPLAY + PRIORITY_MORE_FAVORABLE); |
| 49 | } |
| 50 | |
Mathias Agopian | cb9732a | 2012-04-03 17:48:03 -0700 | [diff] [blame] | 51 | sp<EventThread::Connection> EventThread::createEventConnection() const { |
| 52 | return new Connection(const_cast<EventThread*>(this)); |
Mathias Agopian | 8aedd47 | 2012-01-24 16:39:14 -0800 | [diff] [blame] | 53 | } |
| 54 | |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 55 | status_t EventThread::registerDisplayEventConnection( |
Mathias Agopian | cb9732a | 2012-04-03 17:48:03 -0700 | [diff] [blame] | 56 | const sp<EventThread::Connection>& connection) { |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 57 | Mutex::Autolock _l(mLock); |
Mathias Agopian | cb9732a | 2012-04-03 17:48:03 -0700 | [diff] [blame] | 58 | mDisplayEventConnections.add(connection); |
Mathias Agopian | 7d88647 | 2012-06-14 23:39:35 -0700 | [diff] [blame] | 59 | mCondition.broadcast(); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 60 | return NO_ERROR; |
| 61 | } |
| 62 | |
| 63 | status_t EventThread::unregisterDisplayEventConnection( |
Mathias Agopian | cb9732a | 2012-04-03 17:48:03 -0700 | [diff] [blame] | 64 | const wp<EventThread::Connection>& connection) { |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 65 | Mutex::Autolock _l(mLock); |
Mathias Agopian | cb9732a | 2012-04-03 17:48:03 -0700 | [diff] [blame] | 66 | mDisplayEventConnections.remove(connection); |
Mathias Agopian | 7d88647 | 2012-06-14 23:39:35 -0700 | [diff] [blame] | 67 | mCondition.broadcast(); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 68 | return NO_ERROR; |
| 69 | } |
| 70 | |
Mathias Agopian | 478ae5e | 2011-12-06 17:22:19 -0800 | [diff] [blame] | 71 | void EventThread::removeDisplayEventConnection( |
Mathias Agopian | cb9732a | 2012-04-03 17:48:03 -0700 | [diff] [blame] | 72 | const wp<EventThread::Connection>& connection) { |
Mathias Agopian | 2374866 | 2011-12-05 14:33:34 -0800 | [diff] [blame] | 73 | Mutex::Autolock _l(mLock); |
Mathias Agopian | cb9732a | 2012-04-03 17:48:03 -0700 | [diff] [blame] | 74 | mDisplayEventConnections.remove(connection); |
Mathias Agopian | 478ae5e | 2011-12-06 17:22:19 -0800 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | void EventThread::setVsyncRate(uint32_t count, |
Mathias Agopian | cb9732a | 2012-04-03 17:48:03 -0700 | [diff] [blame] | 78 | const sp<EventThread::Connection>& connection) { |
Mathias Agopian | 478ae5e | 2011-12-06 17:22:19 -0800 | [diff] [blame] | 79 | if (int32_t(count) >= 0) { // server must protect against bad params |
| 80 | Mutex::Autolock _l(mLock); |
Mathias Agopian | cb9732a | 2012-04-03 17:48:03 -0700 | [diff] [blame] | 81 | const int32_t new_count = (count == 0) ? -1 : count; |
| 82 | if (connection->count != new_count) { |
| 83 | connection->count = new_count; |
Mathias Agopian | 7d88647 | 2012-06-14 23:39:35 -0700 | [diff] [blame] | 84 | mCondition.broadcast(); |
Mathias Agopian | 478ae5e | 2011-12-06 17:22:19 -0800 | [diff] [blame] | 85 | } |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | void EventThread::requestNextVsync( |
Mathias Agopian | cb9732a | 2012-04-03 17:48:03 -0700 | [diff] [blame] | 90 | const sp<EventThread::Connection>& connection) { |
Mathias Agopian | 478ae5e | 2011-12-06 17:22:19 -0800 | [diff] [blame] | 91 | Mutex::Autolock _l(mLock); |
Mathias Agopian | cb9732a | 2012-04-03 17:48:03 -0700 | [diff] [blame] | 92 | if (connection->count < 0) { |
| 93 | connection->count = 0; |
Mathias Agopian | 7d88647 | 2012-06-14 23:39:35 -0700 | [diff] [blame] | 94 | mCondition.broadcast(); |
Mathias Agopian | 478ae5e | 2011-12-06 17:22:19 -0800 | [diff] [blame] | 95 | } |
Mathias Agopian | 2374866 | 2011-12-05 14:33:34 -0800 | [diff] [blame] | 96 | } |
| 97 | |
Mathias Agopian | 22ffb11 | 2012-04-10 21:04:02 -0700 | [diff] [blame] | 98 | void EventThread::onScreenReleased() { |
| 99 | Mutex::Autolock _l(mLock); |
Mathias Agopian | 22ffb11 | 2012-04-10 21:04:02 -0700 | [diff] [blame] | 100 | if (!mUseSoftwareVSync) { |
Mathias Agopian | 7d88647 | 2012-06-14 23:39:35 -0700 | [diff] [blame] | 101 | // disable reliance on h/w vsync |
| 102 | mUseSoftwareVSync = true; |
| 103 | mCondition.broadcast(); |
Mathias Agopian | 22ffb11 | 2012-04-10 21:04:02 -0700 | [diff] [blame] | 104 | } |
Mathias Agopian | 22ffb11 | 2012-04-10 21:04:02 -0700 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | void EventThread::onScreenAcquired() { |
| 108 | Mutex::Autolock _l(mLock); |
Mathias Agopian | 7d88647 | 2012-06-14 23:39:35 -0700 | [diff] [blame] | 109 | if (mUseSoftwareVSync) { |
| 110 | // resume use of h/w vsync |
| 111 | mUseSoftwareVSync = false; |
| 112 | mCondition.broadcast(); |
| 113 | } |
Mathias Agopian | 22ffb11 | 2012-04-10 21:04:02 -0700 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 117 | void EventThread::onVSyncReceived(int, nsecs_t timestamp) { |
| 118 | Mutex::Autolock _l(mLock); |
| 119 | mVSyncTimestamp = timestamp; |
Mathias Agopian | 10125f0 | 2012-08-17 15:06:02 -0700 | [diff] [blame] | 120 | mVSyncCount++; |
Mathias Agopian | 7d88647 | 2012-06-14 23:39:35 -0700 | [diff] [blame] | 121 | mCondition.broadcast(); |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 122 | } |
| 123 | |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 124 | bool EventThread::threadLoop() { |
| 125 | |
| 126 | nsecs_t timestamp; |
Mathias Agopian | 10125f0 | 2012-08-17 15:06:02 -0700 | [diff] [blame] | 127 | size_t vsyncCount; |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 128 | DisplayEventReceiver::Event vsync; |
Mathias Agopian | 10125f0 | 2012-08-17 15:06:02 -0700 | [diff] [blame] | 129 | Vector< sp<EventThread::Connection> > activeConnections; |
Mathias Agopian | a4cb35a | 2012-08-20 20:07:34 -0700 | [diff] [blame] | 130 | Vector< sp<EventThread::Connection> > signalConnections; |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 131 | |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 132 | do { |
Mathias Agopian | a4cb35a | 2012-08-20 20:07:34 -0700 | [diff] [blame] | 133 | // release our references |
| 134 | signalConnections.clear(); |
| 135 | activeConnections.clear(); |
| 136 | |
Mathias Agopian | 2374866 | 2011-12-05 14:33:34 -0800 | [diff] [blame] | 137 | Mutex::Autolock _l(mLock); |
Mathias Agopian | a4cb35a | 2012-08-20 20:07:34 -0700 | [diff] [blame] | 138 | |
Mathias Agopian | 10125f0 | 2012-08-17 15:06:02 -0700 | [diff] [blame] | 139 | // latch VSYNC event if any |
Mathias Agopian | a4cb35a | 2012-08-20 20:07:34 -0700 | [diff] [blame] | 140 | bool waitForVSync = false; |
| 141 | vsyncCount = mVSyncCount; |
Mathias Agopian | 10125f0 | 2012-08-17 15:06:02 -0700 | [diff] [blame] | 142 | timestamp = mVSyncTimestamp; |
| 143 | mVSyncTimestamp = 0; |
Mathias Agopian | 478ae5e | 2011-12-06 17:22:19 -0800 | [diff] [blame] | 144 | |
Mathias Agopian | a4cb35a | 2012-08-20 20:07:34 -0700 | [diff] [blame] | 145 | // find out connections waiting for VSYNC events |
Mathias Agopian | 10125f0 | 2012-08-17 15:06:02 -0700 | [diff] [blame] | 146 | size_t count = mDisplayEventConnections.size(); |
| 147 | for (size_t i=0 ; i<count ; i++) { |
| 148 | sp<Connection> connection(mDisplayEventConnections[i].promote()); |
| 149 | if (connection != NULL) { |
| 150 | activeConnections.add(connection); |
| 151 | if (connection->count >= 0) { |
Mathias Agopian | a4cb35a | 2012-08-20 20:07:34 -0700 | [diff] [blame] | 152 | // we need vsync events because at least |
| 153 | // one connection is waiting for it |
| 154 | waitForVSync = true; |
| 155 | if (connection->count == 0) { |
| 156 | // fired this time around |
| 157 | if (timestamp) { |
| 158 | // only "consume" this event if we're going to |
| 159 | // report it |
| 160 | connection->count = -1; |
| 161 | } |
| 162 | signalConnections.add(connection); |
| 163 | } else if (connection->count == 1 || |
| 164 | (vsyncCount % connection->count) == 0) { |
| 165 | // continuous event, and time to report it |
| 166 | signalConnections.add(connection); |
| 167 | } |
Mathias Agopian | 616c0cd | 2012-01-12 16:13:54 -0800 | [diff] [blame] | 168 | } |
Mathias Agopian | a72d0db | 2012-01-09 18:19:18 -0800 | [diff] [blame] | 169 | } |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 170 | } |
Mathias Agopian | 10125f0 | 2012-08-17 15:06:02 -0700 | [diff] [blame] | 171 | |
| 172 | if (timestamp) { |
Mathias Agopian | a4cb35a | 2012-08-20 20:07:34 -0700 | [diff] [blame] | 173 | // we have a vsync event we can dispatch |
| 174 | if (!waitForVSync) { |
Mathias Agopian | 10125f0 | 2012-08-17 15:06:02 -0700 | [diff] [blame] | 175 | // we received a VSYNC but we have no clients |
| 176 | // don't report it, and disable VSYNC events |
| 177 | disableVSyncLocked(); |
| 178 | } else { |
| 179 | // report VSYNC event |
| 180 | break; |
| 181 | } |
| 182 | } else { |
| 183 | // never disable VSYNC events immediately, instead |
| 184 | // we'll wait to receive the event and we'll |
| 185 | // reevaluate whether we need to dispatch it and/or |
| 186 | // disable VSYNC events then. |
Mathias Agopian | a4cb35a | 2012-08-20 20:07:34 -0700 | [diff] [blame] | 187 | if (waitForVSync) { |
Mathias Agopian | 10125f0 | 2012-08-17 15:06:02 -0700 | [diff] [blame] | 188 | // enable |
| 189 | enableVSyncLocked(); |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | // wait for something to happen |
Mathias Agopian | a4cb35a | 2012-08-20 20:07:34 -0700 | [diff] [blame] | 194 | if (CC_UNLIKELY(mUseSoftwareVSync && waitForVSync)) { |
Mathias Agopian | 10125f0 | 2012-08-17 15:06:02 -0700 | [diff] [blame] | 195 | // h/w vsync cannot be used (screen is off), so we use |
| 196 | // a timeout instead. it doesn't matter how imprecise this |
| 197 | // is, we just need to make sure to serve the clients |
| 198 | if (mCondition.waitRelative(mLock, ms2ns(16)) == TIMED_OUT) { |
| 199 | mVSyncTimestamp = systemTime(SYSTEM_TIME_MONOTONIC); |
| 200 | mVSyncCount++; |
| 201 | } |
| 202 | } else { |
Mathias Agopian | a4cb35a | 2012-08-20 20:07:34 -0700 | [diff] [blame] | 203 | if (!timestamp || signalConnections.isEmpty()) { |
| 204 | // This is where we spend most of our time, waiting |
| 205 | // for a vsync events and registered clients |
| 206 | mCondition.wait(mLock); |
| 207 | } |
Mathias Agopian | 10125f0 | 2012-08-17 15:06:02 -0700 | [diff] [blame] | 208 | } |
Mathias Agopian | a4cb35a | 2012-08-20 20:07:34 -0700 | [diff] [blame] | 209 | } while (!timestamp || signalConnections.isEmpty()); |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 210 | |
| 211 | // dispatch vsync events to listeners... |
| 212 | vsync.header.type = DisplayEventReceiver::DISPLAY_EVENT_VSYNC; |
| 213 | vsync.header.timestamp = timestamp; |
Mathias Agopian | 10125f0 | 2012-08-17 15:06:02 -0700 | [diff] [blame] | 214 | vsync.vsync.count = vsyncCount; |
Mathias Agopian | 2374866 | 2011-12-05 14:33:34 -0800 | [diff] [blame] | 215 | |
Mathias Agopian | a4cb35a | 2012-08-20 20:07:34 -0700 | [diff] [blame] | 216 | const size_t count = signalConnections.size(); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 217 | for (size_t i=0 ; i<count ; i++) { |
Mathias Agopian | a4cb35a | 2012-08-20 20:07:34 -0700 | [diff] [blame] | 218 | const sp<Connection>& conn(signalConnections[i]); |
Mathias Agopian | 10125f0 | 2012-08-17 15:06:02 -0700 | [diff] [blame] | 219 | // now see if we still need to report this VSYNC event |
Mathias Agopian | a4cb35a | 2012-08-20 20:07:34 -0700 | [diff] [blame] | 220 | status_t err = conn->postEvent(vsync); |
| 221 | if (err == -EAGAIN || err == -EWOULDBLOCK) { |
| 222 | // The destination doesn't accept events anymore, it's probably |
| 223 | // full. For now, we just drop the events on the floor. |
| 224 | // Note that some events cannot be dropped and would have to be |
| 225 | // re-sent later. Right-now we don't have the ability to do |
| 226 | // this, but it doesn't matter for VSYNC. |
| 227 | } else if (err < 0) { |
| 228 | // handle any other error on the pipe as fatal. the only |
| 229 | // reasonable thing to do is to clean-up this connection. |
| 230 | // The most common error we'll get here is -EPIPE. |
| 231 | removeDisplayEventConnection(signalConnections[i]); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 232 | } |
| 233 | } |
| 234 | |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 235 | return true; |
| 236 | } |
| 237 | |
Mathias Agopian | 22ffb11 | 2012-04-10 21:04:02 -0700 | [diff] [blame] | 238 | void EventThread::enableVSyncLocked() { |
| 239 | if (!mUseSoftwareVSync) { |
| 240 | // never enable h/w VSYNC when screen is off |
Mathias Agopian | 8630320 | 2012-07-24 22:46:10 -0700 | [diff] [blame] | 241 | mFlinger->eventControl(SurfaceFlinger::EVENT_VSYNC, true); |
| 242 | mPowerHAL.vsyncHint(true); |
Mathias Agopian | 22ffb11 | 2012-04-10 21:04:02 -0700 | [diff] [blame] | 243 | } |
Mathias Agopian | e2c4f4e | 2012-04-10 18:25:31 -0700 | [diff] [blame] | 244 | mDebugVsyncEnabled = true; |
| 245 | } |
| 246 | |
Mathias Agopian | 22ffb11 | 2012-04-10 21:04:02 -0700 | [diff] [blame] | 247 | void EventThread::disableVSyncLocked() { |
Mathias Agopian | 8630320 | 2012-07-24 22:46:10 -0700 | [diff] [blame] | 248 | mFlinger->eventControl(SurfaceFlinger::EVENT_VSYNC, false); |
| 249 | mPowerHAL.vsyncHint(false); |
Mathias Agopian | e2c4f4e | 2012-04-10 18:25:31 -0700 | [diff] [blame] | 250 | mDebugVsyncEnabled = false; |
| 251 | } |
| 252 | |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 253 | status_t EventThread::readyToRun() { |
Steve Block | a19954a | 2012-01-04 20:05:49 +0000 | [diff] [blame] | 254 | ALOGI("EventThread ready to run."); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 255 | return NO_ERROR; |
| 256 | } |
| 257 | |
| 258 | void EventThread::dump(String8& result, char* buffer, size_t SIZE) const { |
| 259 | Mutex::Autolock _l(mLock); |
Mathias Agopian | e2c4f4e | 2012-04-10 18:25:31 -0700 | [diff] [blame] | 260 | result.appendFormat("VSYNC state: %s\n", |
| 261 | mDebugVsyncEnabled?"enabled":"disabled"); |
Mathias Agopian | 22ffb11 | 2012-04-10 21:04:02 -0700 | [diff] [blame] | 262 | result.appendFormat(" soft-vsync: %s\n", |
| 263 | mUseSoftwareVSync?"enabled":"disabled"); |
Mathias Agopian | e2c4f4e | 2012-04-10 18:25:31 -0700 | [diff] [blame] | 264 | result.appendFormat(" numListeners=%u,\n events-delivered: %u\n", |
Mathias Agopian | 10125f0 | 2012-08-17 15:06:02 -0700 | [diff] [blame] | 265 | mDisplayEventConnections.size(), mVSyncCount); |
Mathias Agopian | e2c4f4e | 2012-04-10 18:25:31 -0700 | [diff] [blame] | 266 | for (size_t i=0 ; i<mDisplayEventConnections.size() ; i++) { |
| 267 | sp<Connection> connection = |
| 268 | mDisplayEventConnections.itemAt(i).promote(); |
| 269 | result.appendFormat(" %p: count=%d\n", |
| 270 | connection.get(), connection!=NULL ? connection->count : 0); |
| 271 | } |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | // --------------------------------------------------------------------------- |
| 275 | |
Mathias Agopian | cb9732a | 2012-04-03 17:48:03 -0700 | [diff] [blame] | 276 | EventThread::Connection::Connection( |
| 277 | const sp<EventThread>& eventThread) |
| 278 | : count(-1), mEventThread(eventThread), mChannel(new BitTube()) |
| 279 | { |
| 280 | } |
| 281 | |
| 282 | EventThread::Connection::~Connection() { |
| 283 | mEventThread->unregisterDisplayEventConnection(this); |
| 284 | } |
| 285 | |
| 286 | void EventThread::Connection::onFirstRef() { |
| 287 | // NOTE: mEventThread doesn't hold a strong reference on us |
| 288 | mEventThread->registerDisplayEventConnection(this); |
| 289 | } |
| 290 | |
| 291 | sp<BitTube> EventThread::Connection::getDataChannel() const { |
| 292 | return mChannel; |
| 293 | } |
| 294 | |
| 295 | void EventThread::Connection::setVsyncRate(uint32_t count) { |
| 296 | mEventThread->setVsyncRate(count, this); |
| 297 | } |
| 298 | |
| 299 | void EventThread::Connection::requestNextVsync() { |
| 300 | mEventThread->requestNextVsync(this); |
| 301 | } |
| 302 | |
| 303 | status_t EventThread::Connection::postEvent( |
| 304 | const DisplayEventReceiver::Event& event) { |
| 305 | ssize_t size = DisplayEventReceiver::sendEvents(mChannel, &event, 1); |
| 306 | return size < 0 ? status_t(size) : status_t(NO_ERROR); |
| 307 | } |
| 308 | |
| 309 | // --------------------------------------------------------------------------- |
| 310 | |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 311 | }; // namespace android |