OSDN Git Service

Pass the gralloc buffer stride to sw::Surface.
authorNicolas Capens <capn@google.com>
Tue, 24 Nov 2015 20:33:31 +0000 (15:33 -0500)
committerNicolas Capens <capn@google.com>
Thu, 31 Dec 2015 16:46:10 +0000 (16:46 +0000)
Bug 19979104

Change-Id: If9dd668b4b6a1d82b38d1840648cb578e80495bf
Reviewed-on: https://swiftshader-review.googlesource.com/4302
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
src/OpenGL/common/Image.hpp
src/Renderer/Surface.cpp
src/Renderer/Surface.hpp

index f2fc2af..e2402ac 100644 (file)
@@ -54,8 +54,8 @@ public:
                referenceCount = 1;\r
        }\r
 \r
-       Image(Texture *parentTexture, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type)\r
-               : sw::Surface(getParentResource(parentTexture), width, height, depth, SelectInternalFormat(format, type), true, true),\r
+       Image(Texture *parentTexture, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pitchP = 0)\r
+               : sw::Surface(getParentResource(parentTexture), width, height, depth, SelectInternalFormat(format, type), true, true, pitchP),\r
                  width(width), height(height), format(format), type(type), internalFormat(SelectInternalFormat(format, type)), depth(depth),\r
                  parentTexture(parentTexture)\r
        {\r
@@ -182,12 +182,13 @@ public:
        explicit AndroidNativeImage(ANativeWindowBuffer *nativeBuffer)\r
                : egl::Image(0, nativeBuffer->width, nativeBuffer->height, 1,\r
                             GLPixelFormatFromAndroid(nativeBuffer->format),\r
-                            GLPixelTypeFromAndroid(nativeBuffer->format)),\r
+                            GLPixelTypeFromAndroid(nativeBuffer->format),\r
+                            nativeBuffer->stride),\r
                  nativeBuffer(nativeBuffer)\r
-{\r
-    nativeBuffer->common.incRef(&nativeBuffer->common);\r
-    markShared();\r
-}\r
+       {\r
+               nativeBuffer->common.incRef(&nativeBuffer->common);\r
+               markShared();\r
+       }\r
 \r
 private:\r
        ANativeWindowBuffer *nativeBuffer;\r
index a86e3c4..af2c7c9 100644 (file)
@@ -1205,7 +1205,7 @@ namespace sw
                paletteUsed = 0;
        }
 
-       Surface::Surface(Resource *texture, int width, int height, int depth, Format format, bool lockable, bool renderTarget) : lockable(lockable), renderTarget(renderTarget)
+       Surface::Surface(Resource *texture, int width, int height, int depth, Format format, bool lockable, bool renderTarget, int pitchPprovided) : lockable(lockable), renderTarget(renderTarget)
        {
                resource = texture ? texture : new Resource(0);
                hasParent = texture != 0;
@@ -1231,8 +1231,8 @@ namespace sw
                internal.depth = depth;
                internal.format = selectInternalFormat(format);
                internal.bytes = bytes(internal.format);
-               internal.pitchB = pitchB(internal.width, internal.format, renderTarget);
-               internal.pitchP = pitchP(internal.width, internal.format, renderTarget);
+               internal.pitchB = !pitchPprovided ? pitchB(internal.width, internal.format, renderTarget) : pitchPprovided * internal.bytes;
+               internal.pitchP = !pitchPprovided ? pitchP(internal.width, internal.format, renderTarget) : pitchPprovided;
                internal.sliceB = sliceB(internal.width, internal.height, internal.format, renderTarget);
                internal.sliceP = sliceP(internal.width, internal.height, internal.format, renderTarget);
                internal.lock = LOCK_UNLOCKED;
index 9a97f1c..1d81c35 100644 (file)
@@ -237,14 +237,14 @@ namespace sw
                        int sliceP;\r
                        Format format;\r
                        Lock lock;\r
-                       \r
+\r
                        bool dirty;\r
                };\r
 \r
        public:\r
                Surface(int width, int height, int depth, Format format, void *pixels, int pitch, int slice);\r
-               Surface(Resource *texture, int width, int height, int depth, Format format, bool lockable, bool renderTarget);\r
-               \r
+               Surface(Resource *texture, int width, int height, int depth, Format format, bool lockable, bool renderTarget, int pitchP = 0);\r
+\r
                virtual ~Surface();\r
 \r
                inline void *lock(int x, int y, int z, Lock lock, Accessor client, bool internal = false);\r