The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 17 | #include <stdlib.h> |
| 18 | #include <stdint.h> |
| 19 | #include <sys/types.h> |
| 20 | |
| 21 | #include <utils/Errors.h> |
| 22 | #include <utils/Log.h> |
Mathias Agopian | 310f8da | 2009-05-22 01:27:01 -0700 | [diff] [blame] | 23 | #include <binder/IPCThreadState.h> |
| 24 | #include <binder/IServiceManager.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | |
| 26 | #include <GLES/gl.h> |
| 27 | #include <GLES/glext.h> |
| 28 | |
| 29 | #include <hardware/hardware.h> |
| 30 | |
| 31 | #include "clz.h" |
| 32 | #include "LayerBase.h" |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | #include "SurfaceFlinger.h" |
| 34 | #include "DisplayHardware/DisplayHardware.h" |
| 35 | |
| 36 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | namespace android { |
| 38 | |
| 39 | // --------------------------------------------------------------------------- |
| 40 | |
| 41 | const uint32_t LayerBase::typeInfo = 1; |
| 42 | const char* const LayerBase::typeID = "LayerBase"; |
| 43 | |
| 44 | const uint32_t LayerBaseClient::typeInfo = LayerBase::typeInfo | 2; |
| 45 | const char* const LayerBaseClient::typeID = "LayerBaseClient"; |
| 46 | |
| 47 | // --------------------------------------------------------------------------- |
| 48 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | LayerBase::LayerBase(SurfaceFlinger* flinger, DisplayID display) |
| 50 | : dpy(display), contentDirty(false), |
| 51 | mFlinger(flinger), |
| 52 | mTransformed(false), |
Mathias Agopian | a2fe0a2 | 2009-09-23 18:34:53 -0700 | [diff] [blame] | 53 | mUseLinearFiltering(false), |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | mOrientation(0), |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | mTransactionFlags(0), |
| 56 | mPremultipliedAlpha(true), |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | mInvalidate(0) |
| 58 | { |
| 59 | const DisplayHardware& hw(flinger->graphicPlane(0).displayHardware()); |
| 60 | mFlags = hw.getFlags(); |
| 61 | } |
| 62 | |
| 63 | LayerBase::~LayerBase() |
| 64 | { |
| 65 | } |
| 66 | |
| 67 | const GraphicPlane& LayerBase::graphicPlane(int dpy) const |
| 68 | { |
| 69 | return mFlinger->graphicPlane(dpy); |
| 70 | } |
| 71 | |
| 72 | GraphicPlane& LayerBase::graphicPlane(int dpy) |
| 73 | { |
| 74 | return mFlinger->graphicPlane(dpy); |
| 75 | } |
| 76 | |
| 77 | void LayerBase::initStates(uint32_t w, uint32_t h, uint32_t flags) |
| 78 | { |
| 79 | uint32_t layerFlags = 0; |
| 80 | if (flags & ISurfaceComposer::eHidden) |
| 81 | layerFlags = ISurfaceComposer::eLayerHidden; |
| 82 | |
| 83 | if (flags & ISurfaceComposer::eNonPremultiplied) |
| 84 | mPremultipliedAlpha = false; |
| 85 | |
| 86 | mCurrentState.z = 0; |
| 87 | mCurrentState.w = w; |
| 88 | mCurrentState.h = h; |
| 89 | mCurrentState.alpha = 0xFF; |
| 90 | mCurrentState.flags = layerFlags; |
| 91 | mCurrentState.sequence = 0; |
| 92 | mCurrentState.transform.set(0, 0); |
| 93 | |
| 94 | // drawing state & current state are identical |
| 95 | mDrawingState = mCurrentState; |
| 96 | } |
| 97 | |
Mathias Agopian | ba6be54 | 2009-09-29 22:32:36 -0700 | [diff] [blame^] | 98 | void LayerBase::commitTransaction() { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 99 | mDrawingState = mCurrentState; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | } |
| 101 | void LayerBase::forceVisibilityTransaction() { |
| 102 | // this can be called without SurfaceFlinger.mStateLock, but if we |
| 103 | // can atomically increment the sequence number, it doesn't matter. |
| 104 | android_atomic_inc(&mCurrentState.sequence); |
| 105 | requestTransaction(); |
| 106 | } |
| 107 | bool LayerBase::requestTransaction() { |
| 108 | int32_t old = setTransactionFlags(eTransactionNeeded); |
| 109 | return ((old & eTransactionNeeded) == 0); |
| 110 | } |
| 111 | uint32_t LayerBase::getTransactionFlags(uint32_t flags) { |
| 112 | return android_atomic_and(~flags, &mTransactionFlags) & flags; |
| 113 | } |
| 114 | uint32_t LayerBase::setTransactionFlags(uint32_t flags) { |
| 115 | return android_atomic_or(flags, &mTransactionFlags); |
| 116 | } |
| 117 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 118 | bool LayerBase::setPosition(int32_t x, int32_t y) { |
| 119 | if (mCurrentState.transform.tx() == x && mCurrentState.transform.ty() == y) |
| 120 | return false; |
| 121 | mCurrentState.sequence++; |
| 122 | mCurrentState.transform.set(x, y); |
| 123 | requestTransaction(); |
| 124 | return true; |
| 125 | } |
| 126 | bool LayerBase::setLayer(uint32_t z) { |
| 127 | if (mCurrentState.z == z) |
| 128 | return false; |
| 129 | mCurrentState.sequence++; |
| 130 | mCurrentState.z = z; |
| 131 | requestTransaction(); |
| 132 | return true; |
| 133 | } |
| 134 | bool LayerBase::setSize(uint32_t w, uint32_t h) { |
| 135 | if (mCurrentState.w == w && mCurrentState.h == h) |
| 136 | return false; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 137 | mCurrentState.w = w; |
| 138 | mCurrentState.h = h; |
| 139 | requestTransaction(); |
| 140 | return true; |
| 141 | } |
| 142 | bool LayerBase::setAlpha(uint8_t alpha) { |
| 143 | if (mCurrentState.alpha == alpha) |
| 144 | return false; |
| 145 | mCurrentState.sequence++; |
| 146 | mCurrentState.alpha = alpha; |
| 147 | requestTransaction(); |
| 148 | return true; |
| 149 | } |
| 150 | bool LayerBase::setMatrix(const layer_state_t::matrix22_t& matrix) { |
| 151 | // TODO: check the matrix has changed |
| 152 | mCurrentState.sequence++; |
| 153 | mCurrentState.transform.set( |
| 154 | matrix.dsdx, matrix.dsdy, matrix.dtdx, matrix.dtdy); |
| 155 | requestTransaction(); |
| 156 | return true; |
| 157 | } |
| 158 | bool LayerBase::setTransparentRegionHint(const Region& transparent) { |
| 159 | // TODO: check the region has changed |
| 160 | mCurrentState.sequence++; |
| 161 | mCurrentState.transparentRegion = transparent; |
| 162 | requestTransaction(); |
| 163 | return true; |
| 164 | } |
| 165 | bool LayerBase::setFlags(uint8_t flags, uint8_t mask) { |
| 166 | const uint32_t newFlags = (mCurrentState.flags & ~mask) | (flags & mask); |
| 167 | if (mCurrentState.flags == newFlags) |
| 168 | return false; |
| 169 | mCurrentState.sequence++; |
| 170 | mCurrentState.flags = newFlags; |
| 171 | requestTransaction(); |
| 172 | return true; |
| 173 | } |
| 174 | |
| 175 | Rect LayerBase::visibleBounds() const |
| 176 | { |
| 177 | return mTransformedBounds; |
| 178 | } |
| 179 | |
| 180 | void LayerBase::setVisibleRegion(const Region& visibleRegion) { |
| 181 | // always called from main thread |
| 182 | visibleRegionScreen = visibleRegion; |
| 183 | } |
| 184 | |
| 185 | void LayerBase::setCoveredRegion(const Region& coveredRegion) { |
| 186 | // always called from main thread |
| 187 | coveredRegionScreen = coveredRegion; |
| 188 | } |
| 189 | |
| 190 | uint32_t LayerBase::doTransaction(uint32_t flags) |
| 191 | { |
| 192 | const Layer::State& front(drawingState()); |
| 193 | const Layer::State& temp(currentState()); |
| 194 | |
| 195 | if (temp.sequence != front.sequence) { |
| 196 | // invalidate and recompute the visible regions if needed |
| 197 | flags |= eVisibleRegion; |
| 198 | this->contentDirty = true; |
| 199 | } |
Mathias Agopian | a2fe0a2 | 2009-09-23 18:34:53 -0700 | [diff] [blame] | 200 | |
| 201 | if (temp.sequence != front.sequence) { |
| 202 | const bool linearFiltering = mUseLinearFiltering; |
| 203 | mUseLinearFiltering = false; |
| 204 | if (!(mFlags & DisplayHardware::SLOW_CONFIG)) { |
| 205 | // we may use linear filtering, if the matrix scales us |
| 206 | const uint8_t type = temp.transform.getType(); |
| 207 | if (!temp.transform.preserveRects() || (type >= Transform::SCALE)) { |
| 208 | mUseLinearFiltering = true; |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 213 | // Commit the transaction |
Mathias Agopian | ba6be54 | 2009-09-29 22:32:36 -0700 | [diff] [blame^] | 214 | commitTransaction(); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 215 | return flags; |
| 216 | } |
| 217 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 218 | void LayerBase::validateVisibility(const Transform& planeTransform) |
| 219 | { |
| 220 | const Layer::State& s(drawingState()); |
| 221 | const Transform tr(planeTransform * s.transform); |
| 222 | const bool transformed = tr.transformed(); |
| 223 | |
Mathias Agopian | cbb288b | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 224 | uint32_t w = s.w; |
| 225 | uint32_t h = s.h; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 226 | tr.transform(mVertices[0], 0, 0); |
| 227 | tr.transform(mVertices[1], 0, h); |
| 228 | tr.transform(mVertices[2], w, h); |
| 229 | tr.transform(mVertices[3], w, 0); |
| 230 | if (UNLIKELY(transformed)) { |
| 231 | // NOTE: here we could also punt if we have too many rectangles |
| 232 | // in the transparent region |
| 233 | if (tr.preserveRects()) { |
| 234 | // transform the transparent region |
| 235 | transparentRegionScreen = tr.transform(s.transparentRegion); |
| 236 | } else { |
| 237 | // transformation too complex, can't do the transparent region |
| 238 | // optimization. |
| 239 | transparentRegionScreen.clear(); |
| 240 | } |
| 241 | } else { |
| 242 | transparentRegionScreen = s.transparentRegion; |
| 243 | } |
| 244 | |
| 245 | // cache a few things... |
| 246 | mOrientation = tr.getOrientation(); |
| 247 | mTransformedBounds = tr.makeBounds(w, h); |
| 248 | mTransformed = transformed; |
| 249 | mLeft = tr.tx(); |
| 250 | mTop = tr.ty(); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | void LayerBase::lockPageFlip(bool& recomputeVisibleRegions) |
| 254 | { |
| 255 | } |
| 256 | |
| 257 | void LayerBase::unlockPageFlip( |
| 258 | const Transform& planeTransform, Region& outDirtyRegion) |
| 259 | { |
| 260 | if ((android_atomic_and(~1, &mInvalidate)&1) == 1) { |
| 261 | outDirtyRegion.orSelf(visibleRegionScreen); |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | void LayerBase::finishPageFlip() |
| 266 | { |
| 267 | } |
| 268 | |
| 269 | void LayerBase::invalidate() |
| 270 | { |
| 271 | if ((android_atomic_or(1, &mInvalidate)&1) == 0) { |
| 272 | mFlinger->signalEvent(); |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | void LayerBase::drawRegion(const Region& reg) const |
| 277 | { |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 278 | Region::const_iterator it = reg.begin(); |
| 279 | Region::const_iterator const end = reg.end(); |
| 280 | if (it != end) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 281 | Rect r; |
| 282 | const DisplayHardware& hw(graphicPlane(0).displayHardware()); |
| 283 | const int32_t fbWidth = hw.getWidth(); |
| 284 | const int32_t fbHeight = hw.getHeight(); |
| 285 | const GLshort vertices[][2] = { { 0, 0 }, { fbWidth, 0 }, |
| 286 | { fbWidth, fbHeight }, { 0, fbHeight } }; |
| 287 | glVertexPointer(2, GL_SHORT, 0, vertices); |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 288 | while (it != end) { |
| 289 | const Rect& r = *it++; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 290 | const GLint sy = fbHeight - (r.top + r.height()); |
| 291 | glScissor(r.left, sy, r.width(), r.height()); |
| 292 | glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | void LayerBase::draw(const Region& inClip) const |
| 298 | { |
| 299 | // invalidate the region we'll update |
| 300 | Region clip(inClip); // copy-on-write, so no-op most of the time |
| 301 | |
| 302 | // Remove the transparent area from the clipping region |
| 303 | const State& s = drawingState(); |
| 304 | if (LIKELY(!s.transparentRegion.isEmpty())) { |
| 305 | clip.subtract(transparentRegionScreen); |
| 306 | if (clip.isEmpty()) { |
| 307 | // usually this won't happen because this should be taken care of |
| 308 | // by SurfaceFlinger::computeVisibleRegions() |
| 309 | return; |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | // reset GL state |
| 314 | glEnable(GL_SCISSOR_TEST); |
| 315 | |
| 316 | onDraw(clip); |
| 317 | |
| 318 | /* |
| 319 | glDisable(GL_TEXTURE_2D); |
| 320 | glDisable(GL_DITHER); |
| 321 | glEnable(GL_BLEND); |
| 322 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 323 | glColor4x(0, 0x8000, 0, 0x10000); |
| 324 | drawRegion(transparentRegionScreen); |
| 325 | glDisable(GL_BLEND); |
| 326 | */ |
| 327 | } |
| 328 | |
| 329 | GLuint LayerBase::createTexture() const |
| 330 | { |
| 331 | GLuint textureName = -1; |
| 332 | glGenTextures(1, &textureName); |
| 333 | glBindTexture(GL_TEXTURE_2D, textureName); |
| 334 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 335 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
Mathias Agopian | a2fe0a2 | 2009-09-23 18:34:53 -0700 | [diff] [blame] | 336 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 337 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 338 | return textureName; |
| 339 | } |
| 340 | |
Rebecca Schultz Zavin | 29aa74c | 2009-09-01 23:06:45 -0700 | [diff] [blame] | 341 | void LayerBase::clearWithOpenGL(const Region& clip, GLclampx red, |
| 342 | GLclampx green, GLclampx blue, |
| 343 | GLclampx alpha) const |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 344 | { |
| 345 | const DisplayHardware& hw(graphicPlane(0).displayHardware()); |
| 346 | const uint32_t fbHeight = hw.getHeight(); |
Rebecca Schultz Zavin | 29aa74c | 2009-09-01 23:06:45 -0700 | [diff] [blame] | 347 | glColor4x(red,green,blue,alpha); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 348 | glDisable(GL_TEXTURE_2D); |
| 349 | glDisable(GL_BLEND); |
| 350 | glDisable(GL_DITHER); |
Mathias Agopian | 20f6878 | 2009-05-11 00:03:41 -0700 | [diff] [blame] | 351 | |
| 352 | Region::const_iterator it = clip.begin(); |
| 353 | Region::const_iterator const end = clip.end(); |
Mathias Agopian | 95a666b | 2009-09-24 14:57:26 -0700 | [diff] [blame] | 354 | glEnable(GL_SCISSOR_TEST); |
| 355 | glVertexPointer(2, GL_FIXED, 0, mVertices); |
| 356 | while (it != end) { |
| 357 | const Rect& r = *it++; |
| 358 | const GLint sy = fbHeight - (r.top + r.height()); |
| 359 | glScissor(r.left, sy, r.width(), r.height()); |
| 360 | glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 361 | } |
| 362 | } |
| 363 | |
Rebecca Schultz Zavin | 29aa74c | 2009-09-01 23:06:45 -0700 | [diff] [blame] | 364 | void LayerBase::clearWithOpenGL(const Region& clip) const |
| 365 | { |
| 366 | clearWithOpenGL(clip,0,0,0,0); |
| 367 | } |
| 368 | |
Mathias Agopian | 1fed11c | 2009-06-23 18:08:22 -0700 | [diff] [blame] | 369 | void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 370 | { |
| 371 | const DisplayHardware& hw(graphicPlane(0).displayHardware()); |
| 372 | const uint32_t fbHeight = hw.getHeight(); |
| 373 | const State& s(drawingState()); |
Mathias Agopian | 0926f50 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 374 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 375 | // bind our texture |
Mathias Agopian | 1fed11c | 2009-06-23 18:08:22 -0700 | [diff] [blame] | 376 | validateTexture(texture.name); |
| 377 | uint32_t width = texture.width; |
| 378 | uint32_t height = texture.height; |
| 379 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 380 | glEnable(GL_TEXTURE_2D); |
| 381 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 382 | if (UNLIKELY(s.alpha < 0xFF)) { |
| 383 | // We have an alpha-modulation. We need to modulate all |
| 384 | // texture components by alpha because we're always using |
| 385 | // premultiplied alpha. |
| 386 | |
| 387 | // If the texture doesn't have an alpha channel we can |
| 388 | // use REPLACE and switch to non premultiplied alpha |
| 389 | // blending (SRCA/ONE_MINUS_SRCA). |
| 390 | |
| 391 | GLenum env, src; |
| 392 | if (needsBlending()) { |
| 393 | env = GL_MODULATE; |
| 394 | src = mPremultipliedAlpha ? GL_ONE : GL_SRC_ALPHA; |
| 395 | } else { |
| 396 | env = GL_REPLACE; |
| 397 | src = GL_SRC_ALPHA; |
| 398 | } |
| 399 | const GGLfixed alpha = (s.alpha << 16)/255; |
| 400 | glColor4x(alpha, alpha, alpha, alpha); |
| 401 | glEnable(GL_BLEND); |
| 402 | glBlendFunc(src, GL_ONE_MINUS_SRC_ALPHA); |
| 403 | glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, env); |
| 404 | } else { |
| 405 | glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
| 406 | glColor4x(0x10000, 0x10000, 0x10000, 0x10000); |
| 407 | if (needsBlending()) { |
| 408 | GLenum src = mPremultipliedAlpha ? GL_ONE : GL_SRC_ALPHA; |
| 409 | glEnable(GL_BLEND); |
| 410 | glBlendFunc(src, GL_ONE_MINUS_SRC_ALPHA); |
| 411 | } else { |
| 412 | glDisable(GL_BLEND); |
| 413 | } |
| 414 | } |
| 415 | |
Mathias Agopian | 95a666b | 2009-09-24 14:57:26 -0700 | [diff] [blame] | 416 | Region::const_iterator it = clip.begin(); |
| 417 | Region::const_iterator const end = clip.end(); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 418 | if (UNLIKELY(transformed() |
| 419 | || !(mFlags & DisplayHardware::DRAW_TEXTURE_EXTENSION) )) |
| 420 | { |
| 421 | //StopWatch watch("GL transformed"); |
Mathias Agopian | 95a666b | 2009-09-24 14:57:26 -0700 | [diff] [blame] | 422 | const GLfixed texCoords[4][2] = { |
| 423 | { 0, 0 }, |
| 424 | { 0, 0x10000 }, |
| 425 | { 0x10000, 0x10000 }, |
| 426 | { 0x10000, 0 } |
| 427 | }; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 428 | |
Mathias Agopian | 95a666b | 2009-09-24 14:57:26 -0700 | [diff] [blame] | 429 | glMatrixMode(GL_TEXTURE); |
| 430 | glLoadIdentity(); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 431 | |
Mathias Agopian | 95a666b | 2009-09-24 14:57:26 -0700 | [diff] [blame] | 432 | // the texture's source is rotated |
| 433 | if (texture.transform == HAL_TRANSFORM_ROT_90) { |
| 434 | // TODO: handle the other orientations |
| 435 | glTranslatef(0, 1, 0); |
| 436 | glRotatef(-90, 0, 0, 1); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 437 | } |
Mathias Agopian | 95a666b | 2009-09-24 14:57:26 -0700 | [diff] [blame] | 438 | |
| 439 | if (!(mFlags & (DisplayHardware::NPOT_EXTENSION | |
| 440 | DisplayHardware::DIRECT_TEXTURE))) { |
| 441 | // find the smallest power-of-two that will accommodate our surface |
| 442 | GLuint tw = 1 << (31 - clz(width)); |
| 443 | GLuint th = 1 << (31 - clz(height)); |
| 444 | if (tw < width) tw <<= 1; |
| 445 | if (th < height) th <<= 1; |
| 446 | GLfloat ws = GLfloat(width) /tw; |
| 447 | GLfloat hs = GLfloat(height)/th; |
| 448 | glScalef(ws, hs, 1.0f); |
| 449 | } |
| 450 | |
| 451 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
| 452 | glVertexPointer(2, GL_FIXED, 0, mVertices); |
| 453 | glTexCoordPointer(2, GL_FIXED, 0, texCoords); |
| 454 | |
| 455 | while (it != end) { |
| 456 | const Rect& r = *it++; |
| 457 | const GLint sy = fbHeight - (r.top + r.height()); |
| 458 | glScissor(r.left, sy, r.width(), r.height()); |
| 459 | glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
| 460 | } |
| 461 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 462 | } else { |
Mathias Agopian | 95a666b | 2009-09-24 14:57:26 -0700 | [diff] [blame] | 463 | GLint crop[4] = { 0, height, width, -height }; |
| 464 | glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop); |
| 465 | int x = tx(); |
| 466 | int y = ty(); |
| 467 | y = fbHeight - (y + height); |
| 468 | while (it != end) { |
| 469 | const Rect& r = *it++; |
| 470 | const GLint sy = fbHeight - (r.top + r.height()); |
| 471 | glScissor(r.left, sy, r.width(), r.height()); |
| 472 | glDrawTexiOES(x, y, 0, width, height); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 473 | } |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | void LayerBase::validateTexture(GLint textureName) const |
| 478 | { |
| 479 | glBindTexture(GL_TEXTURE_2D, textureName); |
| 480 | // TODO: reload the texture if needed |
| 481 | // this is currently done in loadTexture() below |
Mathias Agopian | a2fe0a2 | 2009-09-23 18:34:53 -0700 | [diff] [blame] | 482 | if (mUseLinearFiltering) { |
| 483 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 484 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 485 | } else { |
| 486 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 487 | glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 488 | } |
Mathias Agopian | 401c257 | 2009-09-23 19:16:27 -0700 | [diff] [blame] | 489 | |
| 490 | if (needsDithering()) { |
| 491 | glEnable(GL_DITHER); |
| 492 | } else { |
| 493 | glDisable(GL_DITHER); |
| 494 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 495 | } |
| 496 | |
Mathias Agopian | 1fed11c | 2009-06-23 18:08:22 -0700 | [diff] [blame] | 497 | void LayerBase::loadTexture(Texture* texture, GLint textureName, |
| 498 | const Region& dirty, const GGLSurface& t) const |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 499 | { |
| 500 | // TODO: defer the actual texture reload until LayerBase::validateTexture |
| 501 | // is called. |
| 502 | |
Mathias Agopian | 1fed11c | 2009-06-23 18:08:22 -0700 | [diff] [blame] | 503 | texture->name = textureName; |
| 504 | GLuint& textureWidth(texture->width); |
| 505 | GLuint& textureHeight(texture->height); |
| 506 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 507 | uint32_t flags = mFlags; |
| 508 | glBindTexture(GL_TEXTURE_2D, textureName); |
| 509 | |
| 510 | GLuint tw = t.width; |
| 511 | GLuint th = t.height; |
| 512 | |
| 513 | /* |
| 514 | * In OpenGL ES we can't specify a stride with glTexImage2D (however, |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 515 | * GL_UNPACK_ALIGNMENT is a limited form of stride). |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 516 | * So if the stride here isn't representable with GL_UNPACK_ALIGNMENT, we |
| 517 | * need to do something reasonable (here creating a bigger texture). |
| 518 | * |
| 519 | * extra pixels = (((stride - width) * pixelsize) / GL_UNPACK_ALIGNMENT); |
| 520 | * |
| 521 | * This situation doesn't happen often, but some h/w have a limitation |
| 522 | * for their framebuffer (eg: must be multiple of 8 pixels), and |
| 523 | * we need to take that into account when using these buffers as |
| 524 | * textures. |
| 525 | * |
| 526 | * This should never be a problem with POT textures |
| 527 | */ |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 528 | |
| 529 | int unpack = __builtin_ctz(t.stride * bytesPerPixel(t.format)); |
| 530 | unpack = 1 << ((unpack > 3) ? 3 : unpack); |
| 531 | glPixelStorei(GL_UNPACK_ALIGNMENT, unpack); |
| 532 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 533 | /* |
| 534 | * round to POT if needed |
| 535 | */ |
| 536 | |
| 537 | GLuint texture_w = tw; |
| 538 | GLuint texture_h = th; |
| 539 | if (!(flags & DisplayHardware::NPOT_EXTENSION)) { |
| 540 | // find the smallest power-of-two that will accommodate our surface |
| 541 | texture_w = 1 << (31 - clz(t.width)); |
| 542 | texture_h = 1 << (31 - clz(t.height)); |
| 543 | if (texture_w < t.width) texture_w <<= 1; |
| 544 | if (texture_h < t.height) texture_h <<= 1; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 545 | } |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 546 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 547 | regular: |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 548 | Rect bounds(dirty.bounds()); |
| 549 | GLvoid* data = 0; |
| 550 | if (texture_w!=textureWidth || texture_h!=textureHeight) { |
| 551 | // texture size changed, we need to create a new one |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 552 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 553 | if (!textureWidth || !textureHeight) { |
| 554 | // this is the first time, load the whole texture |
| 555 | if (texture_w==tw && texture_h==th) { |
| 556 | // we can do it one pass |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 557 | data = t.data; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 558 | } else { |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 559 | // we have to create the texture first because it |
| 560 | // doesn't match the size of the buffer |
| 561 | bounds.set(Rect(tw, th)); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 562 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 563 | } |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 564 | |
| 565 | if (t.format == GGL_PIXEL_FORMAT_RGB_565) { |
| 566 | glTexImage2D(GL_TEXTURE_2D, 0, |
| 567 | GL_RGB, texture_w, texture_h, 0, |
| 568 | GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data); |
| 569 | } else if (t.format == GGL_PIXEL_FORMAT_RGBA_4444) { |
| 570 | glTexImage2D(GL_TEXTURE_2D, 0, |
| 571 | GL_RGBA, texture_w, texture_h, 0, |
| 572 | GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data); |
Mathias Agopian | 816d7d0 | 2009-09-14 18:10:30 -0700 | [diff] [blame] | 573 | } else if (t.format == GGL_PIXEL_FORMAT_RGBA_8888 || |
| 574 | t.format == GGL_PIXEL_FORMAT_RGBX_8888) { |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 575 | glTexImage2D(GL_TEXTURE_2D, 0, |
| 576 | GL_RGBA, texture_w, texture_h, 0, |
| 577 | GL_RGBA, GL_UNSIGNED_BYTE, data); |
| 578 | } else if ( t.format == GGL_PIXEL_FORMAT_YCbCr_422_SP || |
| 579 | t.format == GGL_PIXEL_FORMAT_YCbCr_420_SP) { |
| 580 | // just show the Y plane of YUV buffers |
| 581 | glTexImage2D(GL_TEXTURE_2D, 0, |
| 582 | GL_LUMINANCE, texture_w, texture_h, 0, |
| 583 | GL_LUMINANCE, GL_UNSIGNED_BYTE, data); |
| 584 | } else { |
| 585 | // oops, we don't handle this format! |
| 586 | LOGE("layer %p, texture=%d, using format %d, which is not " |
| 587 | "supported by the GL", this, textureName, t.format); |
| 588 | textureName = -1; |
| 589 | } |
| 590 | textureWidth = texture_w; |
| 591 | textureHeight = texture_h; |
| 592 | } |
| 593 | if (!data && textureName>=0) { |
| 594 | if (t.format == GGL_PIXEL_FORMAT_RGB_565) { |
| 595 | glTexSubImage2D(GL_TEXTURE_2D, 0, |
| 596 | 0, bounds.top, t.width, bounds.height(), |
| 597 | GL_RGB, GL_UNSIGNED_SHORT_5_6_5, |
| 598 | t.data + bounds.top*t.stride*2); |
| 599 | } else if (t.format == GGL_PIXEL_FORMAT_RGBA_4444) { |
| 600 | glTexSubImage2D(GL_TEXTURE_2D, 0, |
| 601 | 0, bounds.top, t.width, bounds.height(), |
| 602 | GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, |
| 603 | t.data + bounds.top*t.stride*2); |
Mathias Agopian | 816d7d0 | 2009-09-14 18:10:30 -0700 | [diff] [blame] | 604 | } else if (t.format == GGL_PIXEL_FORMAT_RGBA_8888 || |
| 605 | t.format == GGL_PIXEL_FORMAT_RGBX_8888) { |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 606 | glTexSubImage2D(GL_TEXTURE_2D, 0, |
| 607 | 0, bounds.top, t.width, bounds.height(), |
| 608 | GL_RGBA, GL_UNSIGNED_BYTE, |
| 609 | t.data + bounds.top*t.stride*4); |
| 610 | } else if ( t.format == GGL_PIXEL_FORMAT_YCbCr_422_SP || |
| 611 | t.format == GGL_PIXEL_FORMAT_YCbCr_420_SP) { |
| 612 | // just show the Y plane of YUV buffers |
| 613 | glTexSubImage2D(GL_TEXTURE_2D, 0, |
| 614 | 0, bounds.top, t.width, bounds.height(), |
| 615 | GL_LUMINANCE, GL_UNSIGNED_BYTE, |
| 616 | t.data + bounds.top*t.stride); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 617 | } |
| 618 | } |
| 619 | } |
| 620 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 621 | // --------------------------------------------------------------------------- |
| 622 | |
Mathias Agopian | 2e12324 | 2009-06-23 20:06:46 -0700 | [diff] [blame] | 623 | int32_t LayerBaseClient::sIdentity = 0; |
| 624 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 625 | LayerBaseClient::LayerBaseClient(SurfaceFlinger* flinger, DisplayID display, |
Mathias Agopian | f9d9327 | 2009-06-19 17:00:27 -0700 | [diff] [blame] | 626 | const sp<Client>& client, int32_t i) |
Mathias Agopian | 48d819a | 2009-09-10 19:41:18 -0700 | [diff] [blame] | 627 | : LayerBase(flinger, display), lcblk(NULL), client(client), |
Mathias Agopian | cbb288b | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 628 | mIndex(i), mIdentity(uint32_t(android_atomic_inc(&sIdentity))) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 629 | { |
Mathias Agopian | 48d819a | 2009-09-10 19:41:18 -0700 | [diff] [blame] | 630 | lcblk = new SharedBufferServer( |
| 631 | client->ctrlblk, i, NUM_BUFFERS, |
| 632 | mIdentity); |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 633 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 634 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 635 | void LayerBaseClient::onFirstRef() |
| 636 | { |
Mathias Agopian | f9d9327 | 2009-06-19 17:00:27 -0700 | [diff] [blame] | 637 | sp<Client> client(this->client.promote()); |
| 638 | if (client != 0) { |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 639 | client->bindLayer(this, mIndex); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 640 | } |
| 641 | } |
| 642 | |
| 643 | LayerBaseClient::~LayerBaseClient() |
| 644 | { |
Mathias Agopian | f9d9327 | 2009-06-19 17:00:27 -0700 | [diff] [blame] | 645 | sp<Client> client(this->client.promote()); |
| 646 | if (client != 0) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 647 | client->free(mIndex); |
| 648 | } |
Mathias Agopian | 48d819a | 2009-09-10 19:41:18 -0700 | [diff] [blame] | 649 | delete lcblk; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 650 | } |
| 651 | |
Mathias Agopian | f9d9327 | 2009-06-19 17:00:27 -0700 | [diff] [blame] | 652 | int32_t LayerBaseClient::serverIndex() const |
| 653 | { |
| 654 | sp<Client> client(this->client.promote()); |
| 655 | if (client != 0) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 656 | return (client->cid<<16)|mIndex; |
| 657 | } |
| 658 | return 0xFFFF0000 | mIndex; |
| 659 | } |
| 660 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 661 | sp<LayerBaseClient::Surface> LayerBaseClient::getSurface() |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 662 | { |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 663 | sp<Surface> s; |
| 664 | Mutex::Autolock _l(mLock); |
| 665 | s = mClientSurface.promote(); |
| 666 | if (s == 0) { |
| 667 | s = createSurface(); |
| 668 | mClientSurface = s; |
| 669 | } |
| 670 | return s; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 671 | } |
| 672 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 673 | sp<LayerBaseClient::Surface> LayerBaseClient::createSurface() const |
| 674 | { |
Mathias Agopian | 9a11206 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 675 | return new Surface(mFlinger, clientIndex(), mIdentity, |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 676 | const_cast<LayerBaseClient *>(this)); |
| 677 | } |
| 678 | |
| 679 | // --------------------------------------------------------------------------- |
| 680 | |
Mathias Agopian | 9a11206 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 681 | LayerBaseClient::Surface::Surface( |
| 682 | const sp<SurfaceFlinger>& flinger, |
| 683 | SurfaceID id, int identity, |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 684 | const sp<LayerBaseClient>& owner) |
Mathias Agopian | 9a11206 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 685 | : mFlinger(flinger), mToken(id), mIdentity(identity), mOwner(owner) |
| 686 | { |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 687 | } |
| 688 | |
| 689 | |
Mathias Agopian | 9a11206 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 690 | LayerBaseClient::Surface::~Surface() |
| 691 | { |
| 692 | /* |
| 693 | * This is a good place to clean-up all client resources |
| 694 | */ |
| 695 | |
| 696 | // destroy client resources |
| 697 | sp<LayerBaseClient> layer = getOwner(); |
| 698 | if (layer != 0) { |
| 699 | mFlinger->destroySurface(layer); |
| 700 | } |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | sp<LayerBaseClient> LayerBaseClient::Surface::getOwner() const { |
| 704 | sp<LayerBaseClient> owner(mOwner.promote()); |
| 705 | return owner; |
| 706 | } |
| 707 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 708 | status_t LayerBaseClient::Surface::onTransact( |
Mathias Agopian | 375f563 | 2009-06-15 18:24:59 -0700 | [diff] [blame] | 709 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 710 | { |
| 711 | switch (code) { |
| 712 | case REGISTER_BUFFERS: |
| 713 | case UNREGISTER_BUFFERS: |
| 714 | case CREATE_OVERLAY: |
| 715 | { |
Mathias Agopian | 375f563 | 2009-06-15 18:24:59 -0700 | [diff] [blame] | 716 | if (!mFlinger->mAccessSurfaceFlinger.checkCalling()) { |
| 717 | IPCThreadState* ipc = IPCThreadState::self(); |
| 718 | const int pid = ipc->getCallingPid(); |
| 719 | const int uid = ipc->getCallingUid(); |
| 720 | LOGE("Permission Denial: " |
| 721 | "can't access SurfaceFlinger pid=%d, uid=%d", pid, uid); |
| 722 | return PERMISSION_DENIED; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 723 | } |
| 724 | } |
| 725 | } |
| 726 | return BnSurface::onTransact(code, data, reply, flags); |
| 727 | } |
| 728 | |
Mathias Agopian | cbb288b | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 729 | sp<SurfaceBuffer> LayerBaseClient::Surface::requestBuffer(int index, int usage) |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 730 | { |
| 731 | return NULL; |
| 732 | } |
| 733 | |
| 734 | status_t LayerBaseClient::Surface::registerBuffers( |
| 735 | const ISurface::BufferHeap& buffers) |
| 736 | { |
| 737 | return INVALID_OPERATION; |
| 738 | } |
| 739 | |
| 740 | void LayerBaseClient::Surface::postBuffer(ssize_t offset) |
| 741 | { |
| 742 | } |
| 743 | |
| 744 | void LayerBaseClient::Surface::unregisterBuffers() |
| 745 | { |
| 746 | } |
| 747 | |
| 748 | sp<OverlayRef> LayerBaseClient::Surface::createOverlay( |
| 749 | uint32_t w, uint32_t h, int32_t format) |
| 750 | { |
| 751 | return NULL; |
| 752 | }; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 753 | |
| 754 | // --------------------------------------------------------------------------- |
| 755 | |
| 756 | }; // namespace android |