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