diff options
Diffstat (limited to 'libs/rs')
-rw-r--r-- | libs/rs/Android.mk | 4 | ||||
-rw-r--r-- | libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs | 5 | ||||
-rw-r--r-- | libs/rs/rs.spec | 10 | ||||
-rw-r--r-- | libs/rs/rsAllocation.cpp | 73 | ||||
-rw-r--r-- | libs/rs/rsAllocation.h | 2 | ||||
-rw-r--r-- | libs/rs/rsContext.cpp | 4 | ||||
-rw-r--r-- | libs/rs/rslib.bc | bin | 716 -> 728 bytes |
7 files changed, 54 insertions, 44 deletions
diff --git a/libs/rs/Android.mk b/libs/rs/Android.mk index c2e58b6..d8d70c6 100644 --- a/libs/rs/Android.mk +++ b/libs/rs/Android.mk @@ -27,6 +27,10 @@ include $(CLEAR_VARS) input_data_file := $(LOCAL_PATH)/rslib.bc slangdata_output_var_name := rs_runtime_lib_bc LOCAL_MODULE := librslib_rt + +LOCAL_PRELINK_MODULE := false +LOCAL_MODULE_CLASS := STATIC_LIBRARIES + LOCAL_MODULE_TAGS := optional include frameworks/compile/slang/SlangData.mk include $(BUILD_STATIC_LIBRARY) diff --git a/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs b/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs index e5900fd..aa4cf2d 100644 --- a/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs +++ b/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs @@ -55,6 +55,9 @@ void setGamma(float g) { gamma = (float3)g; } +//sliao +uchar3 convert2uchar3(float3 xyz); + void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32_t y) { uchar4 *output = (uchar4 *)v_out; const FilterStruct *fs = (const FilterStruct *)usrData; @@ -84,7 +87,7 @@ void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32 temp = pow(temp, (float3)gamma); temp = clamp(temp * outWMinOutB + outBlack, 0.f, 255.f); - output->xyz = convert_uchar3(temp); + output->xyz = convert2uchar3(temp); //output->w = input->w; } diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index 33ac2f0..7e23cec 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -77,12 +77,6 @@ ElementCreate2 { ret RsElement } -AllocationCopyFromBitmap { - param RsAllocation alloc - param const void * data - param size_t dataLen - } - AllocationCopyToBitmap { param RsAllocation alloc param void * data @@ -135,6 +129,10 @@ Allocation2DElementData { param uint32_t bytes } +AllocationGenerateMipmaps { + param RsAllocation va +} + AllocationRead { param RsAllocation va param void * data diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index d6b90e6..2ed7774 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/rsAllocation.cpp @@ -202,6 +202,17 @@ void Allocation::uploadToTexture(const Context *rsc) { rsc->checkError("Allocation::uploadToTexture"); } +void Allocation::update2DTexture(const void *ptr, uint32_t xoff, uint32_t yoff, + uint32_t lod, RsAllocationCubemapFace face, + uint32_t w, uint32_t h) { + GLenum type = mType->getElement()->getComponent().getGLType(); + GLenum format = mType->getElement()->getComponent().getGLFormat(); + GLenum target = (GLenum)getGLTarget(); + glBindTexture(target, mTextureID); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexSubImage2D(GL_TEXTURE_2D, lod, xoff, yoff, w, h, format, type, ptr); +} + void Allocation::upload2DTexture(bool isFirstUpload, const void *ptr) { GLenum type = mType->getElement()->getComponent().getGLType(); GLenum format = mType->getElement()->getComponent().getGLFormat(); @@ -342,30 +353,39 @@ void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t lod, uint32_t lineSize = eSize * w; uint32_t destW = mType->getDimX(); - const uint8_t *src = static_cast<const uint8_t *>(data); - uint8_t *dst = static_cast<uint8_t *>(mPtr); - dst += eSize * (xoff + yoff * destW); + //LOGE("data2d %p, %i %i %i %i %i %i %p %i", this, xoff, yoff, lod, face, w, h, data, sizeBytes); - if ((lineSize * eSize * h) != sizeBytes) { + if ((lineSize * h) != sizeBytes) { + LOGE("Allocation size mismatch, expected %i, got %i", (lineSize * h), sizeBytes); rsAssert(!"Allocation::subData called with mismatched size"); return; } - for (uint32_t line=yoff; line < (yoff+h); line++) { - if (mType->getElement()->getHasReferences()) { - incRefs(src, w); - decRefs(dst, w); + if (mPtr) { + const uint8_t *src = static_cast<const uint8_t *>(data); + uint8_t *dst = static_cast<uint8_t *>(mPtr); + dst += mType->getLODOffset(lod, xoff, yoff); + + //LOGE(" %p %p %i ", dst, src, eSize); + for (uint32_t line=yoff; line < (yoff+h); line++) { + if (mType->getElement()->getHasReferences()) { + incRefs(src, w); + decRefs(dst, w); + } + memcpy(dst, src, lineSize); + src += lineSize; + dst += destW * eSize; } - memcpy(dst, src, lineSize); - src += lineSize; - dst += destW * eSize; + sendDirty(); + mUploadDefered = true; + } else { + update2DTexture(data, xoff, yoff, lod, face, w, h); } - sendDirty(); - mUploadDefered = true; } -void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod, RsAllocationCubemapFace face, - uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes) { +void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff, + uint32_t lod, RsAllocationCubemapFace face, + uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes) { } void Allocation::elementData(Context *rsc, uint32_t x, const void *data, @@ -685,28 +705,9 @@ void rsi_AllocationSyncAll(Context *rsc, RsAllocation va, RsAllocationUsageType a->syncAll(rsc, src); } -void rsi_AllocationCopyFromBitmap(Context *rsc, RsAllocation va, const void *data, size_t dataLen) { +void rsi_AllocationGenerateMipmaps(Context *rsc, RsAllocation va) { Allocation *texAlloc = static_cast<Allocation *>(va); - const Type * t = texAlloc->getType(); - - uint32_t w = t->getDimX(); - uint32_t h = t->getDimY(); - bool genMips = t->getDimLOD(); - size_t s = w * h * t->getElementSizeBytes(); - if (s != dataLen) { - rsc->setError(RS_ERROR_BAD_VALUE, "Bitmap size didn't match allocation size"); - return; - } - - if (texAlloc->getIsScript()) { - memcpy(texAlloc->getPtr(), data, s); - if (genMips) { - rsaAllocationGenerateScriptMips(rsc, texAlloc); - } - } else { - texAlloc->upload2DTexture(false, data); - } - + rsaAllocationGenerateScriptMips(rsc, texAlloc); } void rsi_AllocationCopyToBitmap(Context *rsc, RsAllocation va, void *data, size_t dataLen) { diff --git a/libs/rs/rsAllocation.h b/libs/rs/rsAllocation.h index a8d086e..a160765 100644 --- a/libs/rs/rsAllocation.h +++ b/libs/rs/rsAllocation.h @@ -106,6 +106,8 @@ public: } void upload2DTexture(bool isFirstUpload, const void *ptr); + void update2DTexture(const void *ptr, uint32_t xoff, uint32_t yoff, + uint32_t lod, RsAllocationCubemapFace face, uint32_t w, uint32_t h); protected: ObjectBaseRef<const Type> mType; diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index c5ee7ee..bb38825 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -743,7 +743,9 @@ void Context::setSurface(uint32_t w, uint32_t h, ANativeWindow *sur) { rsAssert(mIsGraphicsContext); EGLBoolean ret; - if (mEGL.mSurface != NULL) { + // WAR: Some drivers fail to handle 0 size surfaces correcntly. + // Use the pbuffer to avoid this pitfall. + if ((mEGL.mSurface != NULL) || (w == 0) || (h == 0)) { ret = eglMakeCurrent(mEGL.mDisplay, mEGL.mSurfaceDefault, mEGL.mSurfaceDefault, mEGL.mContext); checkEglError("eglMakeCurrent", ret); diff --git a/libs/rs/rslib.bc b/libs/rs/rslib.bc Binary files differindex 1897c3b..761e765 100644 --- a/libs/rs/rslib.bc +++ b/libs/rs/rslib.bc |