diff options
Diffstat (limited to 'opengl/libagl/copybit.cpp')
-rwxr-xr-x[-rw-r--r--] | opengl/libagl/copybit.cpp | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/opengl/libagl/copybit.cpp b/opengl/libagl/copybit.cpp index 67d1ce7..f78adca 100644..100755 --- a/opengl/libagl/copybit.cpp +++ b/opengl/libagl/copybit.cpp @@ -48,11 +48,24 @@ static void textureToCopyBitImage( const GGLSurface* surface, int32_t opFormat, android_native_buffer_t* buffer, copybit_image_t* img) { + uint32_t vstride = 0; + if (opFormat == COPYBIT_FORMAT_YCbCr_422_SP || + opFormat == COPYBIT_FORMAT_YCbCr_420_SP || + opFormat == COPYBIT_FORMAT_YCrCb_420_SP) { + // NOTE: this static_cast is really not safe b/c we can't know for + // sure the buffer passed is of the right type. + // However, since we do this only for YUV formats, we should be safe + // since only SurfaceFlinger makes use of them. + GraphicBuffer* graphicBuffer = static_cast<GraphicBuffer*>(buffer); + vstride = graphicBuffer->getVerticalStride(); + } + img->w = surface->stride; - img->h = surface->height; + img->h = vstride ? vstride : surface->height; img->format = opFormat; img->base = surface->data; img->handle = (native_handle_t *)buffer->handle; + img->padding = surface->stride - surface->width; } struct clipRectRegion : public copybit_region_t { @@ -87,6 +100,9 @@ static bool supportedCopybitsFormat(int format) { case COPYBIT_FORMAT_BGRA_8888: case COPYBIT_FORMAT_RGBA_5551: case COPYBIT_FORMAT_RGBA_4444: + case COPYBIT_FORMAT_YCbCr_422_SP: + case COPYBIT_FORMAT_YCbCr_420_SP: + case COPYBIT_FORMAT_YCrCb_420_SP: return true; default: return false; @@ -531,16 +547,16 @@ bool drawTriangleFanWithCopybit_impl(ogles_context_t* c, GLint first, GLsizei co // at this point, we know we are dealing with a rectangle, so we // only need to consider 3 vertices for computing the jacobians - const int dx01 = v1.x - v0.x; - const int dx02 = v2.x - v0.x; - const int dy01 = v1.y - v0.y; - const int dy02 = v2.y - v0.y; - const int ds01 = t1.S - t0.S; - const int ds02 = t2.S - t0.S; - const int dt01 = t1.T - t0.T; - const int dt02 = t2.T - t0.T; - const int area = dx01*dy02 - dy01*dx02; - int dsdx, dsdy, dtdx, dtdy; + const long long dx01 = v1.x - v0.x; + const long long dx02 = v2.x - v0.x; + const long long dy01 = v1.y - v0.y; + const long long dy02 = v2.y - v0.y; + const long long ds01 = t1.S - t0.S; + const long long ds02 = t2.S - t0.S; + const long long dt01 = t1.T - t0.T; + const long long dt02 = t2.T - t0.T; + const long long area = dx01*dy02 - dy01*dx02; + long long dsdx, dsdy, dtdx, dtdy; if (area >= 0) { dsdx = ds01*dy02 - ds02*dy01; dtdx = dt01*dy02 - dt02*dy01; |