The Android Open Source Project | edbf3b6 | 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 | 0926f50 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 18 | #define LOG_TAG "FramebufferNativeWindow" |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | |
| 20 | #include <stdlib.h> |
| 21 | #include <stdio.h> |
| 22 | #include <string.h> |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 23 | #include <errno.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | |
| 25 | #include <cutils/log.h> |
| 26 | #include <cutils/atomic.h> |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 27 | #include <utils/threads.h> |
Mathias Agopian | 42db9dc | 2009-08-06 20:46:44 -0700 | [diff] [blame] | 28 | #include <utils/RefBase.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | |
Mathias Agopian | 5f2165f | 2012-02-24 18:25:41 -0800 | [diff] [blame] | 30 | #include <ui/ANativeObjectBase.h> |
Mathias Agopian | 0926f50 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 31 | #include <ui/FramebufferNativeWindow.h> |
Mathias Agopian | 5f2165f | 2012-02-24 18:25:41 -0800 | [diff] [blame] | 32 | #include <ui/Rect.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | |
| 34 | #include <EGL/egl.h> |
| 35 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 36 | #include <hardware/hardware.h> |
| 37 | #include <hardware/gralloc.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | |
| 39 | // ---------------------------------------------------------------------------- |
| 40 | namespace android { |
| 41 | // ---------------------------------------------------------------------------- |
| 42 | |
Mathias Agopian | 7189c00 | 2009-05-05 18:11:11 -0700 | [diff] [blame] | 43 | class NativeBuffer |
Mathias Agopian | 5f2165f | 2012-02-24 18:25:41 -0800 | [diff] [blame] | 44 | : public ANativeObjectBase< |
Iliyan Malchev | 697526b | 2011-05-01 11:33:26 -0700 | [diff] [blame] | 45 | ANativeWindowBuffer, |
Mathias Agopian | 7189c00 | 2009-05-05 18:11:11 -0700 | [diff] [blame] | 46 | NativeBuffer, |
| 47 | LightRefBase<NativeBuffer> > |
| 48 | { |
| 49 | public: |
| 50 | NativeBuffer(int w, int h, int f, int u) : BASE() { |
Iliyan Malchev | 697526b | 2011-05-01 11:33:26 -0700 | [diff] [blame] | 51 | ANativeWindowBuffer::width = w; |
| 52 | ANativeWindowBuffer::height = h; |
| 53 | ANativeWindowBuffer::format = f; |
| 54 | ANativeWindowBuffer::usage = u; |
Mathias Agopian | 7189c00 | 2009-05-05 18:11:11 -0700 | [diff] [blame] | 55 | } |
| 56 | private: |
| 57 | friend class LightRefBase<NativeBuffer>; |
| 58 | ~NativeBuffer() { }; // this class cannot be overloaded |
| 59 | }; |
| 60 | |
| 61 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 62 | /* |
| 63 | * This implements the (main) framebuffer management. This class is used |
| 64 | * mostly by SurfaceFlinger, but also by command line GL application. |
| 65 | * |
Dianne Hackborn | 4b5e91e | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 66 | * In fact this is an implementation of ANativeWindow on top of |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 67 | * the framebuffer. |
| 68 | * |
| 69 | * Currently it is pretty simple, it manages only two buffers (the front and |
| 70 | * back buffer). |
| 71 | * |
| 72 | */ |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 73 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 74 | FramebufferNativeWindow::FramebufferNativeWindow() |
Mathias Agopian | 1e16b13 | 2009-05-07 17:40:23 -0700 | [diff] [blame] | 75 | : BASE(), fbDev(0), grDev(0), mUpdateOnDemand(false) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | { |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 77 | hw_module_t const* module; |
| 78 | if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) { |
| 79 | int stride; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 80 | int err; |
Rodrigo Obregon | 71484f2 | 2010-11-03 15:16:18 -0500 | [diff] [blame] | 81 | int i; |
Mathias Agopian | 42db9dc | 2009-08-06 20:46:44 -0700 | [diff] [blame] | 82 | err = framebuffer_open(module, &fbDev); |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 83 | ALOGE_IF(err, "couldn't open framebuffer HAL (%s)", strerror(-err)); |
Mathias Agopian | 42db9dc | 2009-08-06 20:46:44 -0700 | [diff] [blame] | 84 | |
| 85 | err = gralloc_open(module, &grDev); |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 86 | ALOGE_IF(err, "couldn't open gralloc HAL (%s)", strerror(-err)); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 87 | |
Mathias Agopian | 42db9dc | 2009-08-06 20:46:44 -0700 | [diff] [blame] | 88 | // bail out if we can't initialize the modules |
| 89 | if (!fbDev || !grDev) |
| 90 | return; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 91 | |
Mathias Agopian | 1e16b13 | 2009-05-07 17:40:23 -0700 | [diff] [blame] | 92 | mUpdateOnDemand = (fbDev->setUpdateRect != 0); |
| 93 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 94 | // initialize the buffer FIFO |
Rodrigo Obregon | 71484f2 | 2010-11-03 15:16:18 -0500 | [diff] [blame] | 95 | mNumBuffers = NUM_FRAME_BUFFERS; |
| 96 | mNumFreeBuffers = NUM_FRAME_BUFFERS; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 97 | mBufferHead = mNumBuffers-1; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 98 | |
Dima Zavin | c6cd27c | 2012-02-22 14:37:57 -0800 | [diff] [blame] | 99 | /* |
| 100 | * This does not actually change the framebuffer format. It merely |
| 101 | * fakes this format to surfaceflinger so that when it creates |
| 102 | * framebuffer surfaces it will use this format. It's really a giant |
| 103 | * HACK to allow interworking with buggy gralloc+GPU driver |
| 104 | * implementations. You should *NEVER* need to set this for shipping |
| 105 | * devices. |
| 106 | */ |
| 107 | #ifdef FRAMEBUFFER_FORCE_FORMAT |
| 108 | *((uint32_t *)&fbDev->format) = FRAMEBUFFER_FORCE_FORMAT; |
| 109 | #endif |
| 110 | |
Rodrigo Obregon | 71484f2 | 2010-11-03 15:16:18 -0500 | [diff] [blame] | 111 | for (i = 0; i < mNumBuffers; i++) |
| 112 | { |
| 113 | buffers[i] = new NativeBuffer( |
| 114 | fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB); |
| 115 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 116 | |
Rodrigo Obregon | 71484f2 | 2010-11-03 15:16:18 -0500 | [diff] [blame] | 117 | for (i = 0; i < mNumBuffers; i++) |
| 118 | { |
| 119 | err = grDev->alloc(grDev, |
| 120 | fbDev->width, fbDev->height, fbDev->format, |
| 121 | GRALLOC_USAGE_HW_FB, &buffers[i]->handle, &buffers[i]->stride); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 122 | |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 123 | ALOGE_IF(err, "fb buffer %d allocation failed w=%d, h=%d, err=%s", |
Rodrigo Obregon | 71484f2 | 2010-11-03 15:16:18 -0500 | [diff] [blame] | 124 | i, fbDev->width, fbDev->height, strerror(-err)); |
| 125 | |
| 126 | if (err) |
| 127 | { |
| 128 | mNumBuffers = i; |
| 129 | mNumFreeBuffers = i; |
| 130 | mBufferHead = mNumBuffers-1; |
| 131 | break; |
| 132 | } |
| 133 | } |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 134 | |
Dianne Hackborn | 4b5e91e | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 135 | const_cast<uint32_t&>(ANativeWindow::flags) = fbDev->flags; |
| 136 | const_cast<float&>(ANativeWindow::xdpi) = fbDev->xdpi; |
| 137 | const_cast<float&>(ANativeWindow::ydpi) = fbDev->ydpi; |
| 138 | const_cast<int&>(ANativeWindow::minSwapInterval) = |
Marco Nelissen | a455793 | 2009-09-23 10:54:36 -0700 | [diff] [blame] | 139 | fbDev->minSwapInterval; |
Dianne Hackborn | 4b5e91e | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 140 | const_cast<int&>(ANativeWindow::maxSwapInterval) = |
Marco Nelissen | a455793 | 2009-09-23 10:54:36 -0700 | [diff] [blame] | 141 | fbDev->maxSwapInterval; |
| 142 | } else { |
Steve Block | e6f43dd | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 143 | ALOGE("Couldn't get gralloc module"); |
Marco Nelissen | a455793 | 2009-09-23 10:54:36 -0700 | [diff] [blame] | 144 | } |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 145 | |
Dianne Hackborn | 4b5e91e | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 146 | ANativeWindow::setSwapInterval = setSwapInterval; |
| 147 | ANativeWindow::dequeueBuffer = dequeueBuffer; |
| 148 | ANativeWindow::lockBuffer = lockBuffer; |
| 149 | ANativeWindow::queueBuffer = queueBuffer; |
| 150 | ANativeWindow::query = query; |
| 151 | ANativeWindow::perform = perform; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 152 | } |
| 153 | |
Mathias Agopian | 42db9dc | 2009-08-06 20:46:44 -0700 | [diff] [blame] | 154 | FramebufferNativeWindow::~FramebufferNativeWindow() |
| 155 | { |
| 156 | if (grDev) { |
| 157 | if (buffers[0] != NULL) |
| 158 | grDev->free(grDev, buffers[0]->handle); |
| 159 | if (buffers[1] != NULL) |
| 160 | grDev->free(grDev, buffers[1]->handle); |
| 161 | gralloc_close(grDev); |
| 162 | } |
| 163 | |
| 164 | if (fbDev) { |
| 165 | framebuffer_close(fbDev); |
| 166 | } |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 167 | } |
| 168 | |
Mathias Agopian | 1e16b13 | 2009-05-07 17:40:23 -0700 | [diff] [blame] | 169 | status_t FramebufferNativeWindow::setUpdateRectangle(const Rect& r) |
| 170 | { |
| 171 | if (!mUpdateOnDemand) { |
| 172 | return INVALID_OPERATION; |
| 173 | } |
| 174 | return fbDev->setUpdateRect(fbDev, r.left, r.top, r.width(), r.height()); |
| 175 | } |
| 176 | |
Mathias Agopian | 74faca2 | 2009-09-17 16:18:16 -0700 | [diff] [blame] | 177 | status_t FramebufferNativeWindow::compositionComplete() |
| 178 | { |
| 179 | if (fbDev->compositionComplete) { |
| 180 | return fbDev->compositionComplete(fbDev); |
| 181 | } |
| 182 | return INVALID_OPERATION; |
| 183 | } |
| 184 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 185 | int FramebufferNativeWindow::setSwapInterval( |
Dianne Hackborn | 4b5e91e | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 186 | ANativeWindow* window, int interval) |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 187 | { |
| 188 | framebuffer_device_t* fb = getSelf(window)->fbDev; |
| 189 | return fb->setSwapInterval(fb, interval); |
| 190 | } |
| 191 | |
Erik Gilling | 1d21a9c | 2010-12-01 16:38:01 -0800 | [diff] [blame] | 192 | void FramebufferNativeWindow::dump(String8& result) { |
| 193 | if (fbDev->common.version >= 1 && fbDev->dump) { |
| 194 | const size_t SIZE = 4096; |
| 195 | char buffer[SIZE]; |
| 196 | |
| 197 | fbDev->dump(fbDev, buffer, SIZE); |
| 198 | result.append(buffer); |
| 199 | } |
| 200 | } |
| 201 | |
Mathias Agopian | 35b48d1 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 202 | // only for debugging / logging |
| 203 | int FramebufferNativeWindow::getCurrentBufferIndex() const |
| 204 | { |
| 205 | Mutex::Autolock _l(mutex); |
| 206 | const int index = mCurrentBufferIndex; |
| 207 | return index; |
| 208 | } |
| 209 | |
Dianne Hackborn | 4b5e91e | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 210 | int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window, |
Iliyan Malchev | 697526b | 2011-05-01 11:33:26 -0700 | [diff] [blame] | 211 | ANativeWindowBuffer** buffer) |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 212 | { |
| 213 | FramebufferNativeWindow* self = getSelf(window); |
| 214 | Mutex::Autolock _l(self->mutex); |
| 215 | framebuffer_device_t* fb = self->fbDev; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 216 | |
Mathias Agopian | 35b48d1 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 217 | int index = self->mBufferHead++; |
| 218 | if (self->mBufferHead >= self->mNumBuffers) |
| 219 | self->mBufferHead = 0; |
| 220 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 221 | // wait for a free buffer |
| 222 | while (!self->mNumFreeBuffers) { |
| 223 | self->mCondition.wait(self->mutex); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 224 | } |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 225 | // get this buffer |
| 226 | self->mNumFreeBuffers--; |
Mathias Agopian | 35b48d1 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 227 | self->mCurrentBufferIndex = index; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 228 | |
| 229 | *buffer = self->buffers[index].get(); |
| 230 | |
| 231 | return 0; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 232 | } |
| 233 | |
Dianne Hackborn | 4b5e91e | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 234 | int FramebufferNativeWindow::lockBuffer(ANativeWindow* window, |
Iliyan Malchev | 697526b | 2011-05-01 11:33:26 -0700 | [diff] [blame] | 235 | ANativeWindowBuffer* buffer) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 236 | { |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 237 | FramebufferNativeWindow* self = getSelf(window); |
| 238 | Mutex::Autolock _l(self->mutex); |
| 239 | |
Mathias Agopian | 35b48d1 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 240 | const int index = self->mCurrentBufferIndex; |
Mathias Agopian | 35b48d1 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 241 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 242 | // wait that the buffer we're locking is not front anymore |
| 243 | while (self->front == buffer) { |
| 244 | self->mCondition.wait(self->mutex); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 245 | } |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 246 | |
Mathias Agopian | 0926f50 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 247 | return NO_ERROR; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 248 | } |
| 249 | |
Dianne Hackborn | 4b5e91e | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 250 | int FramebufferNativeWindow::queueBuffer(ANativeWindow* window, |
Iliyan Malchev | 697526b | 2011-05-01 11:33:26 -0700 | [diff] [blame] | 251 | ANativeWindowBuffer* buffer) |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 252 | { |
| 253 | FramebufferNativeWindow* self = getSelf(window); |
| 254 | Mutex::Autolock _l(self->mutex); |
| 255 | framebuffer_device_t* fb = self->fbDev; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 256 | buffer_handle_t handle = static_cast<NativeBuffer*>(buffer)->handle; |
Mathias Agopian | 35b48d1 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 257 | |
| 258 | const int index = self->mCurrentBufferIndex; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 259 | int res = fb->post(fb, handle); |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 260 | self->front = static_cast<NativeBuffer*>(buffer); |
| 261 | self->mNumFreeBuffers++; |
| 262 | self->mCondition.broadcast(); |
| 263 | return res; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 264 | } |
| 265 | |
Iliyan Malchev | 41abd67 | 2011-04-14 16:54:38 -0700 | [diff] [blame] | 266 | int FramebufferNativeWindow::query(const ANativeWindow* window, |
Mathias Agopian | cb6b904 | 2009-07-30 18:14:56 -0700 | [diff] [blame] | 267 | int what, int* value) |
| 268 | { |
Iliyan Malchev | 41abd67 | 2011-04-14 16:54:38 -0700 | [diff] [blame] | 269 | const FramebufferNativeWindow* self = getSelf(window); |
Mathias Agopian | cb6b904 | 2009-07-30 18:14:56 -0700 | [diff] [blame] | 270 | Mutex::Autolock _l(self->mutex); |
| 271 | framebuffer_device_t* fb = self->fbDev; |
| 272 | switch (what) { |
| 273 | case NATIVE_WINDOW_WIDTH: |
| 274 | *value = fb->width; |
| 275 | return NO_ERROR; |
| 276 | case NATIVE_WINDOW_HEIGHT: |
| 277 | *value = fb->height; |
| 278 | return NO_ERROR; |
Mathias Agopian | 6b1f410 | 2009-08-06 16:04:29 -0700 | [diff] [blame] | 279 | case NATIVE_WINDOW_FORMAT: |
| 280 | *value = fb->format; |
| 281 | return NO_ERROR; |
Jamie Gennis | 391bbe2 | 2011-03-14 15:00:06 -0700 | [diff] [blame] | 282 | case NATIVE_WINDOW_CONCRETE_TYPE: |
| 283 | *value = NATIVE_WINDOW_FRAMEBUFFER; |
| 284 | return NO_ERROR; |
Mathias Agopian | 97c602c | 2011-07-19 15:24:46 -0700 | [diff] [blame] | 285 | case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER: |
| 286 | *value = 0; |
| 287 | return NO_ERROR; |
| 288 | case NATIVE_WINDOW_DEFAULT_WIDTH: |
| 289 | *value = fb->width; |
| 290 | return NO_ERROR; |
| 291 | case NATIVE_WINDOW_DEFAULT_HEIGHT: |
| 292 | *value = fb->height; |
| 293 | return NO_ERROR; |
| 294 | case NATIVE_WINDOW_TRANSFORM_HINT: |
| 295 | *value = 0; |
| 296 | return NO_ERROR; |
Mathias Agopian | cb6b904 | 2009-07-30 18:14:56 -0700 | [diff] [blame] | 297 | } |
Mathias Agopian | 42db9dc | 2009-08-06 20:46:44 -0700 | [diff] [blame] | 298 | *value = 0; |
Mathias Agopian | cb6b904 | 2009-07-30 18:14:56 -0700 | [diff] [blame] | 299 | return BAD_VALUE; |
| 300 | } |
| 301 | |
Dianne Hackborn | 4b5e91e | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 302 | int FramebufferNativeWindow::perform(ANativeWindow* window, |
Mathias Agopian | 5221271 | 2009-08-11 22:34:02 -0700 | [diff] [blame] | 303 | int operation, ...) |
| 304 | { |
| 305 | switch (operation) { |
Mathias Agopian | 55fa251 | 2010-03-11 15:06:54 -0800 | [diff] [blame] | 306 | case NATIVE_WINDOW_CONNECT: |
| 307 | case NATIVE_WINDOW_DISCONNECT: |
Mathias Agopian | bb66c9b | 2011-07-21 14:50:29 -0700 | [diff] [blame] | 308 | case NATIVE_WINDOW_SET_USAGE: |
Mathias Agopian | 7734ebf | 2011-07-13 15:24:42 -0700 | [diff] [blame] | 309 | case NATIVE_WINDOW_SET_BUFFERS_GEOMETRY: |
Mathias Agopian | 7734ebf | 2011-07-13 15:24:42 -0700 | [diff] [blame] | 310 | case NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS: |
Mathias Agopian | 7734ebf | 2011-07-13 15:24:42 -0700 | [diff] [blame] | 311 | case NATIVE_WINDOW_SET_BUFFERS_FORMAT: |
Mathias Agopian | bb66c9b | 2011-07-21 14:50:29 -0700 | [diff] [blame] | 312 | case NATIVE_WINDOW_SET_BUFFERS_TRANSFORM: |
Mathias Agopian | 81a6335 | 2011-07-29 17:55:48 -0700 | [diff] [blame] | 313 | case NATIVE_WINDOW_API_CONNECT: |
| 314 | case NATIVE_WINDOW_API_DISCONNECT: |
Mathias Agopian | bb66c9b | 2011-07-21 14:50:29 -0700 | [diff] [blame] | 315 | // TODO: we should implement these |
Mathias Agopian | 7734ebf | 2011-07-13 15:24:42 -0700 | [diff] [blame] | 316 | return NO_ERROR; |
Mathias Agopian | bb66c9b | 2011-07-21 14:50:29 -0700 | [diff] [blame] | 317 | |
| 318 | case NATIVE_WINDOW_LOCK: |
| 319 | case NATIVE_WINDOW_UNLOCK_AND_POST: |
| 320 | case NATIVE_WINDOW_SET_CROP: |
| 321 | case NATIVE_WINDOW_SET_BUFFER_COUNT: |
| 322 | case NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP: |
Mathias Agopian | 7734ebf | 2011-07-13 15:24:42 -0700 | [diff] [blame] | 323 | case NATIVE_WINDOW_SET_SCALING_MODE: |
| 324 | return INVALID_OPERATION; |
Mathias Agopian | 5221271 | 2009-08-11 22:34:02 -0700 | [diff] [blame] | 325 | } |
Mathias Agopian | 7734ebf | 2011-07-13 15:24:42 -0700 | [diff] [blame] | 326 | return NAME_NOT_FOUND; |
Mathias Agopian | 5221271 | 2009-08-11 22:34:02 -0700 | [diff] [blame] | 327 | } |
| 328 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 329 | // ---------------------------------------------------------------------------- |
| 330 | }; // namespace android |
| 331 | // ---------------------------------------------------------------------------- |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 332 | |
Mathias Agopian | 42db9dc | 2009-08-06 20:46:44 -0700 | [diff] [blame] | 333 | using namespace android; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 334 | |
| 335 | EGLNativeWindowType android_createDisplaySurface(void) |
| 336 | { |
Mathias Agopian | 42db9dc | 2009-08-06 20:46:44 -0700 | [diff] [blame] | 337 | FramebufferNativeWindow* w; |
| 338 | w = new FramebufferNativeWindow(); |
| 339 | if (w->getDevice() == NULL) { |
| 340 | // get a ref so it can be destroyed when we exit this block |
| 341 | sp<FramebufferNativeWindow> ref(w); |
| 342 | return NULL; |
| 343 | } |
| 344 | return (EGLNativeWindowType)w; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 345 | } |