The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright 2007 The Android Open Source Project |
| 4 | ** |
| 5 | ** Licensed under the Apache License Version 2.0(the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
Mathias Agopian | dff8e58 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 18 | #define LOG_TAG "FramebufferNativeWindow" |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | |
| 20 | #include <stdlib.h> |
| 21 | #include <stdio.h> |
| 22 | #include <string.h> |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 23 | #include <errno.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | |
| 25 | #include <cutils/log.h> |
| 26 | #include <cutils/atomic.h> |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 27 | #include <utils/threads.h> |
Mathias Agopian | 6693f23 | 2009-08-06 20:46:44 -0700 | [diff] [blame] | 28 | #include <utils/RefBase.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | #include <ui/Rect.h> |
Mathias Agopian | dff8e58 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 31 | #include <ui/FramebufferNativeWindow.h> |
Mathias Agopian | 04262e9 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 32 | #include <ui/GraphicLog.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | |
| 34 | #include <EGL/egl.h> |
| 35 | |
| 36 | #include <pixelflinger/format.h> |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 37 | #include <pixelflinger/pixelflinger.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 39 | #include <hardware/hardware.h> |
| 40 | #include <hardware/gralloc.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | |
Mathias Agopian | b51e18d | 2009-05-05 18:21:32 -0700 | [diff] [blame] | 42 | #include <private/ui/android_natives_priv.h> |
| 43 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | // ---------------------------------------------------------------------------- |
| 45 | namespace android { |
| 46 | // ---------------------------------------------------------------------------- |
| 47 | |
Mathias Agopian | ac2523b | 2009-05-05 18:11:11 -0700 | [diff] [blame] | 48 | class NativeBuffer |
| 49 | : public EGLNativeBase< |
Iliyan Malchev | b2a153a | 2011-05-01 11:33:26 -0700 | [diff] [blame] | 50 | ANativeWindowBuffer, |
Mathias Agopian | ac2523b | 2009-05-05 18:11:11 -0700 | [diff] [blame] | 51 | NativeBuffer, |
| 52 | LightRefBase<NativeBuffer> > |
| 53 | { |
| 54 | public: |
| 55 | NativeBuffer(int w, int h, int f, int u) : BASE() { |
Iliyan Malchev | b2a153a | 2011-05-01 11:33:26 -0700 | [diff] [blame] | 56 | ANativeWindowBuffer::width = w; |
| 57 | ANativeWindowBuffer::height = h; |
| 58 | ANativeWindowBuffer::format = f; |
| 59 | ANativeWindowBuffer::usage = u; |
Mathias Agopian | ac2523b | 2009-05-05 18:11:11 -0700 | [diff] [blame] | 60 | } |
| 61 | private: |
| 62 | friend class LightRefBase<NativeBuffer>; |
| 63 | ~NativeBuffer() { }; // this class cannot be overloaded |
| 64 | }; |
| 65 | |
| 66 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 67 | /* |
| 68 | * This implements the (main) framebuffer management. This class is used |
| 69 | * mostly by SurfaceFlinger, but also by command line GL application. |
| 70 | * |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 71 | * In fact this is an implementation of ANativeWindow on top of |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 72 | * the framebuffer. |
| 73 | * |
| 74 | * Currently it is pretty simple, it manages only two buffers (the front and |
| 75 | * back buffer). |
| 76 | * |
| 77 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 78 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 79 | FramebufferNativeWindow::FramebufferNativeWindow() |
Mathias Agopian | 97b8056 | 2009-05-07 17:40:23 -0700 | [diff] [blame] | 80 | : BASE(), fbDev(0), grDev(0), mUpdateOnDemand(false) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | { |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 82 | hw_module_t const* module; |
| 83 | if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) { |
| 84 | int stride; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 85 | int err; |
Rodrigo Obregon | 8404343 | 2010-11-03 15:16:18 -0500 | [diff] [blame] | 86 | int i; |
Mathias Agopian | 6693f23 | 2009-08-06 20:46:44 -0700 | [diff] [blame] | 87 | err = framebuffer_open(module, &fbDev); |
Steve Block | c6aacce | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 88 | ALOGE_IF(err, "couldn't open framebuffer HAL (%s)", strerror(-err)); |
Mathias Agopian | 6693f23 | 2009-08-06 20:46:44 -0700 | [diff] [blame] | 89 | |
| 90 | err = gralloc_open(module, &grDev); |
Steve Block | c6aacce | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 91 | ALOGE_IF(err, "couldn't open gralloc HAL (%s)", strerror(-err)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 92 | |
Mathias Agopian | 6693f23 | 2009-08-06 20:46:44 -0700 | [diff] [blame] | 93 | // bail out if we can't initialize the modules |
| 94 | if (!fbDev || !grDev) |
| 95 | return; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 96 | |
Mathias Agopian | 97b8056 | 2009-05-07 17:40:23 -0700 | [diff] [blame] | 97 | mUpdateOnDemand = (fbDev->setUpdateRect != 0); |
| 98 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 99 | // initialize the buffer FIFO |
Rodrigo Obregon | 8404343 | 2010-11-03 15:16:18 -0500 | [diff] [blame] | 100 | mNumBuffers = NUM_FRAME_BUFFERS; |
| 101 | mNumFreeBuffers = NUM_FRAME_BUFFERS; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 102 | mBufferHead = mNumBuffers-1; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 103 | |
Rodrigo Obregon | 8404343 | 2010-11-03 15:16:18 -0500 | [diff] [blame] | 104 | for (i = 0; i < mNumBuffers; i++) |
| 105 | { |
| 106 | buffers[i] = new NativeBuffer( |
| 107 | fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB); |
| 108 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 109 | |
Rodrigo Obregon | 8404343 | 2010-11-03 15:16:18 -0500 | [diff] [blame] | 110 | for (i = 0; i < mNumBuffers; i++) |
| 111 | { |
| 112 | err = grDev->alloc(grDev, |
| 113 | fbDev->width, fbDev->height, fbDev->format, |
| 114 | GRALLOC_USAGE_HW_FB, &buffers[i]->handle, &buffers[i]->stride); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 115 | |
Steve Block | c6aacce | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 116 | ALOGE_IF(err, "fb buffer %d allocation failed w=%d, h=%d, err=%s", |
Rodrigo Obregon | 8404343 | 2010-11-03 15:16:18 -0500 | [diff] [blame] | 117 | i, fbDev->width, fbDev->height, strerror(-err)); |
| 118 | |
| 119 | if (err) |
| 120 | { |
| 121 | mNumBuffers = i; |
| 122 | mNumFreeBuffers = i; |
| 123 | mBufferHead = mNumBuffers-1; |
| 124 | break; |
| 125 | } |
| 126 | } |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 127 | |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 128 | const_cast<uint32_t&>(ANativeWindow::flags) = fbDev->flags; |
| 129 | const_cast<float&>(ANativeWindow::xdpi) = fbDev->xdpi; |
| 130 | const_cast<float&>(ANativeWindow::ydpi) = fbDev->ydpi; |
| 131 | const_cast<int&>(ANativeWindow::minSwapInterval) = |
Marco Nelissen | e613468 | 2009-09-23 10:54:36 -0700 | [diff] [blame] | 132 | fbDev->minSwapInterval; |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 133 | const_cast<int&>(ANativeWindow::maxSwapInterval) = |
Marco Nelissen | e613468 | 2009-09-23 10:54:36 -0700 | [diff] [blame] | 134 | fbDev->maxSwapInterval; |
| 135 | } else { |
Steve Block | c6aacce | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 136 | ALOGE("Couldn't get gralloc module"); |
Marco Nelissen | e613468 | 2009-09-23 10:54:36 -0700 | [diff] [blame] | 137 | } |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 138 | |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 139 | ANativeWindow::setSwapInterval = setSwapInterval; |
| 140 | ANativeWindow::dequeueBuffer = dequeueBuffer; |
| 141 | ANativeWindow::lockBuffer = lockBuffer; |
| 142 | ANativeWindow::queueBuffer = queueBuffer; |
| 143 | ANativeWindow::query = query; |
| 144 | ANativeWindow::perform = perform; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 145 | } |
| 146 | |
Mathias Agopian | 6693f23 | 2009-08-06 20:46:44 -0700 | [diff] [blame] | 147 | FramebufferNativeWindow::~FramebufferNativeWindow() |
| 148 | { |
| 149 | if (grDev) { |
| 150 | if (buffers[0] != NULL) |
| 151 | grDev->free(grDev, buffers[0]->handle); |
| 152 | if (buffers[1] != NULL) |
| 153 | grDev->free(grDev, buffers[1]->handle); |
| 154 | gralloc_close(grDev); |
| 155 | } |
| 156 | |
| 157 | if (fbDev) { |
| 158 | framebuffer_close(fbDev); |
| 159 | } |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 160 | } |
| 161 | |
Mathias Agopian | 97b8056 | 2009-05-07 17:40:23 -0700 | [diff] [blame] | 162 | status_t FramebufferNativeWindow::setUpdateRectangle(const Rect& r) |
| 163 | { |
| 164 | if (!mUpdateOnDemand) { |
| 165 | return INVALID_OPERATION; |
| 166 | } |
| 167 | return fbDev->setUpdateRect(fbDev, r.left, r.top, r.width(), r.height()); |
| 168 | } |
| 169 | |
Mathias Agopian | b1a1874 | 2009-09-17 16:18:16 -0700 | [diff] [blame] | 170 | status_t FramebufferNativeWindow::compositionComplete() |
| 171 | { |
| 172 | if (fbDev->compositionComplete) { |
| 173 | return fbDev->compositionComplete(fbDev); |
| 174 | } |
| 175 | return INVALID_OPERATION; |
| 176 | } |
| 177 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 178 | int FramebufferNativeWindow::setSwapInterval( |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 179 | ANativeWindow* window, int interval) |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 180 | { |
| 181 | framebuffer_device_t* fb = getSelf(window)->fbDev; |
| 182 | return fb->setSwapInterval(fb, interval); |
| 183 | } |
| 184 | |
Erik Gilling | 94720d7 | 2010-12-01 16:38:01 -0800 | [diff] [blame] | 185 | void FramebufferNativeWindow::dump(String8& result) { |
| 186 | if (fbDev->common.version >= 1 && fbDev->dump) { |
| 187 | const size_t SIZE = 4096; |
| 188 | char buffer[SIZE]; |
| 189 | |
| 190 | fbDev->dump(fbDev, buffer, SIZE); |
| 191 | result.append(buffer); |
| 192 | } |
| 193 | } |
| 194 | |
Mathias Agopian | 04262e9 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 195 | // only for debugging / logging |
| 196 | int FramebufferNativeWindow::getCurrentBufferIndex() const |
| 197 | { |
| 198 | Mutex::Autolock _l(mutex); |
| 199 | const int index = mCurrentBufferIndex; |
| 200 | return index; |
| 201 | } |
| 202 | |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 203 | int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window, |
Iliyan Malchev | b2a153a | 2011-05-01 11:33:26 -0700 | [diff] [blame] | 204 | ANativeWindowBuffer** buffer) |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 205 | { |
| 206 | FramebufferNativeWindow* self = getSelf(window); |
| 207 | Mutex::Autolock _l(self->mutex); |
| 208 | framebuffer_device_t* fb = self->fbDev; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 209 | |
Mathias Agopian | 04262e9 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 210 | int index = self->mBufferHead++; |
| 211 | if (self->mBufferHead >= self->mNumBuffers) |
| 212 | self->mBufferHead = 0; |
| 213 | |
| 214 | GraphicLog& logger(GraphicLog::getInstance()); |
| 215 | logger.log(GraphicLog::SF_FB_DEQUEUE_BEFORE, index); |
| 216 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 217 | // wait for a free buffer |
| 218 | while (!self->mNumFreeBuffers) { |
| 219 | self->mCondition.wait(self->mutex); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 220 | } |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 221 | // get this buffer |
| 222 | self->mNumFreeBuffers--; |
Mathias Agopian | 04262e9 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 223 | self->mCurrentBufferIndex = index; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 224 | |
| 225 | *buffer = self->buffers[index].get(); |
| 226 | |
Mathias Agopian | 04262e9 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 227 | logger.log(GraphicLog::SF_FB_DEQUEUE_AFTER, index); |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 228 | return 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 229 | } |
| 230 | |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 231 | int FramebufferNativeWindow::lockBuffer(ANativeWindow* window, |
Iliyan Malchev | b2a153a | 2011-05-01 11:33:26 -0700 | [diff] [blame] | 232 | ANativeWindowBuffer* buffer) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 233 | { |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 234 | FramebufferNativeWindow* self = getSelf(window); |
| 235 | Mutex::Autolock _l(self->mutex); |
| 236 | |
Mathias Agopian | 04262e9 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 237 | const int index = self->mCurrentBufferIndex; |
| 238 | GraphicLog& logger(GraphicLog::getInstance()); |
| 239 | logger.log(GraphicLog::SF_FB_LOCK_BEFORE, index); |
| 240 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 241 | // wait that the buffer we're locking is not front anymore |
| 242 | while (self->front == buffer) { |
| 243 | self->mCondition.wait(self->mutex); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 244 | } |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 245 | |
Mathias Agopian | 04262e9 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 246 | logger.log(GraphicLog::SF_FB_LOCK_AFTER, index); |
| 247 | |
Mathias Agopian | dff8e58 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 248 | return NO_ERROR; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 249 | } |
| 250 | |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 251 | int FramebufferNativeWindow::queueBuffer(ANativeWindow* window, |
Iliyan Malchev | b2a153a | 2011-05-01 11:33:26 -0700 | [diff] [blame] | 252 | ANativeWindowBuffer* buffer) |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 253 | { |
| 254 | FramebufferNativeWindow* self = getSelf(window); |
| 255 | Mutex::Autolock _l(self->mutex); |
| 256 | framebuffer_device_t* fb = self->fbDev; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 257 | buffer_handle_t handle = static_cast<NativeBuffer*>(buffer)->handle; |
Mathias Agopian | 04262e9 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 258 | |
| 259 | const int index = self->mCurrentBufferIndex; |
| 260 | GraphicLog& logger(GraphicLog::getInstance()); |
| 261 | logger.log(GraphicLog::SF_FB_POST_BEFORE, index); |
| 262 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 263 | int res = fb->post(fb, handle); |
Mathias Agopian | 04262e9 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 264 | |
| 265 | logger.log(GraphicLog::SF_FB_POST_AFTER, index); |
| 266 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 267 | self->front = static_cast<NativeBuffer*>(buffer); |
| 268 | self->mNumFreeBuffers++; |
| 269 | self->mCondition.broadcast(); |
| 270 | return res; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 271 | } |
| 272 | |
Iliyan Malchev | 4d7c1ce | 2011-04-14 16:54:38 -0700 | [diff] [blame] | 273 | int FramebufferNativeWindow::query(const ANativeWindow* window, |
Mathias Agopian | 5b5c914 | 2009-07-30 18:14:56 -0700 | [diff] [blame] | 274 | int what, int* value) |
| 275 | { |
Iliyan Malchev | 4d7c1ce | 2011-04-14 16:54:38 -0700 | [diff] [blame] | 276 | const FramebufferNativeWindow* self = getSelf(window); |
Mathias Agopian | 5b5c914 | 2009-07-30 18:14:56 -0700 | [diff] [blame] | 277 | Mutex::Autolock _l(self->mutex); |
| 278 | framebuffer_device_t* fb = self->fbDev; |
| 279 | switch (what) { |
| 280 | case NATIVE_WINDOW_WIDTH: |
| 281 | *value = fb->width; |
| 282 | return NO_ERROR; |
| 283 | case NATIVE_WINDOW_HEIGHT: |
| 284 | *value = fb->height; |
| 285 | return NO_ERROR; |
Mathias Agopian | 25ec00f | 2009-08-06 16:04:29 -0700 | [diff] [blame] | 286 | case NATIVE_WINDOW_FORMAT: |
| 287 | *value = fb->format; |
| 288 | return NO_ERROR; |
Jamie Gennis | c4ca7c5 | 2011-03-14 15:00:06 -0700 | [diff] [blame] | 289 | case NATIVE_WINDOW_CONCRETE_TYPE: |
| 290 | *value = NATIVE_WINDOW_FRAMEBUFFER; |
| 291 | return NO_ERROR; |
Mathias Agopian | f07b8a3 | 2011-07-19 15:24:46 -0700 | [diff] [blame] | 292 | case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER: |
| 293 | *value = 0; |
| 294 | return NO_ERROR; |
| 295 | case NATIVE_WINDOW_DEFAULT_WIDTH: |
| 296 | *value = fb->width; |
| 297 | return NO_ERROR; |
| 298 | case NATIVE_WINDOW_DEFAULT_HEIGHT: |
| 299 | *value = fb->height; |
| 300 | return NO_ERROR; |
| 301 | case NATIVE_WINDOW_TRANSFORM_HINT: |
| 302 | *value = 0; |
| 303 | return NO_ERROR; |
Mathias Agopian | 5b5c914 | 2009-07-30 18:14:56 -0700 | [diff] [blame] | 304 | } |
Mathias Agopian | 6693f23 | 2009-08-06 20:46:44 -0700 | [diff] [blame] | 305 | *value = 0; |
Mathias Agopian | 5b5c914 | 2009-07-30 18:14:56 -0700 | [diff] [blame] | 306 | return BAD_VALUE; |
| 307 | } |
| 308 | |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 309 | int FramebufferNativeWindow::perform(ANativeWindow* window, |
Mathias Agopian | 5cec474 | 2009-08-11 22:34:02 -0700 | [diff] [blame] | 310 | int operation, ...) |
| 311 | { |
| 312 | switch (operation) { |
Mathias Agopian | 2f7540e | 2010-03-11 15:06:54 -0800 | [diff] [blame] | 313 | case NATIVE_WINDOW_CONNECT: |
| 314 | case NATIVE_WINDOW_DISCONNECT: |
Mathias Agopian | 45b63dd | 2011-07-21 14:50:29 -0700 | [diff] [blame] | 315 | case NATIVE_WINDOW_SET_USAGE: |
Mathias Agopian | 09d7ed7 | 2011-07-13 15:24:42 -0700 | [diff] [blame] | 316 | case NATIVE_WINDOW_SET_BUFFERS_GEOMETRY: |
Mathias Agopian | 09d7ed7 | 2011-07-13 15:24:42 -0700 | [diff] [blame] | 317 | case NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS: |
Mathias Agopian | 09d7ed7 | 2011-07-13 15:24:42 -0700 | [diff] [blame] | 318 | case NATIVE_WINDOW_SET_BUFFERS_FORMAT: |
Mathias Agopian | 45b63dd | 2011-07-21 14:50:29 -0700 | [diff] [blame] | 319 | case NATIVE_WINDOW_SET_BUFFERS_TRANSFORM: |
Mathias Agopian | 982d2da | 2011-07-29 17:55:48 -0700 | [diff] [blame] | 320 | case NATIVE_WINDOW_API_CONNECT: |
| 321 | case NATIVE_WINDOW_API_DISCONNECT: |
Mathias Agopian | 45b63dd | 2011-07-21 14:50:29 -0700 | [diff] [blame] | 322 | // TODO: we should implement these |
Mathias Agopian | 09d7ed7 | 2011-07-13 15:24:42 -0700 | [diff] [blame] | 323 | return NO_ERROR; |
Mathias Agopian | 45b63dd | 2011-07-21 14:50:29 -0700 | [diff] [blame] | 324 | |
| 325 | case NATIVE_WINDOW_LOCK: |
| 326 | case NATIVE_WINDOW_UNLOCK_AND_POST: |
| 327 | case NATIVE_WINDOW_SET_CROP: |
| 328 | case NATIVE_WINDOW_SET_BUFFER_COUNT: |
| 329 | case NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP: |
Mathias Agopian | 09d7ed7 | 2011-07-13 15:24:42 -0700 | [diff] [blame] | 330 | case NATIVE_WINDOW_SET_SCALING_MODE: |
| 331 | return INVALID_OPERATION; |
Mathias Agopian | 5cec474 | 2009-08-11 22:34:02 -0700 | [diff] [blame] | 332 | } |
Mathias Agopian | 09d7ed7 | 2011-07-13 15:24:42 -0700 | [diff] [blame] | 333 | return NAME_NOT_FOUND; |
Mathias Agopian | 5cec474 | 2009-08-11 22:34:02 -0700 | [diff] [blame] | 334 | } |
| 335 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 336 | // ---------------------------------------------------------------------------- |
| 337 | }; // namespace android |
| 338 | // ---------------------------------------------------------------------------- |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 339 | |
Mathias Agopian | 6693f23 | 2009-08-06 20:46:44 -0700 | [diff] [blame] | 340 | using namespace android; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 341 | |
| 342 | EGLNativeWindowType android_createDisplaySurface(void) |
| 343 | { |
Mathias Agopian | 6693f23 | 2009-08-06 20:46:44 -0700 | [diff] [blame] | 344 | FramebufferNativeWindow* w; |
| 345 | w = new FramebufferNativeWindow(); |
| 346 | if (w->getDevice() == NULL) { |
| 347 | // get a ref so it can be destroyed when we exit this block |
| 348 | sp<FramebufferNativeWindow> ref(w); |
| 349 | return NULL; |
| 350 | } |
| 351 | return (EGLNativeWindowType)w; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 352 | } |