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