diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/DisplayListRenderer.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 23 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.h | 14 | ||||
-rw-r--r-- | libs/hwui/font/Font.cpp | 20 |
4 files changed, 34 insertions, 25 deletions
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp index c2ce6ed..2391e80 100644 --- a/libs/hwui/DisplayListRenderer.cpp +++ b/libs/hwui/DisplayListRenderer.cpp @@ -58,7 +58,7 @@ DisplayListData* DisplayListRenderer::finishRecording() { void DisplayListRenderer::setViewport(int width, int height) { // TODO: DisplayListRenderer shouldn't have a projection matrix, as it should never be used - mViewProjMatrix.loadOrtho(0, width, height, 0, -1, 1); + mProjectionMatrix.loadOrtho(0, width, height, 0, -1, 1); initializeViewport(width, height); } diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 5a977c8..20b038d 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -171,7 +171,7 @@ void OpenGLRenderer::setViewport(int width, int height) { } void OpenGLRenderer::initViewport(int width, int height) { - mViewProjMatrix.loadOrtho(0, width, height, 0, -1, 1); + mProjectionMatrix.loadOrtho(0, width, height, 0, -1, 1); initializeViewport(width, height); } @@ -628,7 +628,7 @@ void OpenGLRenderer::onSnapshotRestored(const Snapshot& removed, const Snapshot& if (restoreOrtho) { const Rect& r = restored.viewport; glViewport(r.left, r.top, r.right, r.bottom); - mViewProjMatrix.load(removed.orthoMatrix); // TODO: should ortho be stored in 'restored'? + mProjectionMatrix.load(removed.orthoMatrix); // TODO: should ortho be stored in 'restored'? } if (restoreClip) { @@ -854,7 +854,7 @@ bool OpenGLRenderer::createFboLayer(Layer* layer, Rect& bounds, Rect& clip) { mSnapshot->resetClip(clip.left, clip.top, clip.right, clip.bottom); mSnapshot->viewport.set(0.0f, 0.0f, bounds.getWidth(), bounds.getHeight()); mSnapshot->height = bounds.getHeight(); - mSnapshot->orthoMatrix.load(mViewProjMatrix); + mSnapshot->orthoMatrix.load(mProjectionMatrix); endTiling(); debugOverdraw(false, false); @@ -884,8 +884,7 @@ bool OpenGLRenderer::createFboLayer(Layer* layer, Rect& bounds, Rect& clip) { // Change the ortho projection glViewport(0, 0, bounds.getWidth(), bounds.getHeight()); - // TODO: determine best way to support 3d drawing within HW layers - mViewProjMatrix.loadOrtho(0.0f, bounds.getWidth(), bounds.getHeight(), 0.0f, -1.0f, 1.0f); + mProjectionMatrix.loadOrtho(0.0f, bounds.getWidth(), bounds.getHeight(), 0.0f, -1.0f, 1.0f); return true; } @@ -1689,17 +1688,17 @@ void OpenGLRenderer::setupDrawDirtyRegionsDisabled() { void OpenGLRenderer::setupDrawModelView(ModelViewMode mode, bool offset, float left, float top, float right, float bottom, bool ignoreTransform) { - mModelView.loadTranslate(left, top, 0.0f); + mModelViewMatrix.loadTranslate(left, top, 0.0f); if (mode == kModelViewMode_TranslateAndScale) { - mModelView.scale(right - left, bottom - top, 1.0f); + mModelViewMatrix.scale(right - left, bottom - top, 1.0f); } bool dirty = right - left > 0.0f && bottom - top > 0.0f; if (!ignoreTransform) { - mCaches.currentProgram->set(mViewProjMatrix, mModelView, *currentTransform(), offset); + mCaches.currentProgram->set(mProjectionMatrix, mModelViewMatrix, *currentTransform(), offset); if (dirty && mTrackDirtyRegions) dirtyLayer(left, top, right, bottom, *currentTransform()); } else { - mCaches.currentProgram->set(mViewProjMatrix, mModelView, mat4::identity(), offset); + mCaches.currentProgram->set(mProjectionMatrix, mModelViewMatrix, mat4::identity(), offset); if (dirty && mTrackDirtyRegions) dirtyLayer(left, top, right, bottom); } } @@ -1724,11 +1723,11 @@ void OpenGLRenderer::setupDrawShaderUniforms(bool ignoreTransform) { // compensate. mat4 modelViewWithoutTransform; modelViewWithoutTransform.loadInverse(*currentTransform()); - modelViewWithoutTransform.multiply(mModelView); - mModelView.load(modelViewWithoutTransform); + modelViewWithoutTransform.multiply(mModelViewMatrix); + mModelViewMatrix.load(modelViewWithoutTransform); } mDrawModifiers.mShader->setupProgram(mCaches.currentProgram, - mModelView, *mSnapshot, &mTextureUnit); + mModelViewMatrix, *mSnapshot, &mTextureUnit); } } diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index 1d46945..4f7f01e 100644 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -930,8 +930,8 @@ private: */ Texture* getTexture(const SkBitmap* bitmap); - // Matrix used for view/projection in shaders - mat4 mViewProjMatrix; + // Ortho matrix used for projection in shaders + mat4 mProjectionMatrix; /** * Model-view matrix used to position/size objects @@ -939,15 +939,15 @@ private: * Stores operation-local modifications to the draw matrix that aren't incorporated into the * currentTransform(). * - * If generated with kModelViewMode_Translate, the mModelView will reflect an x/y offset, + * If generated with kModelViewMode_Translate, mModelViewMatrix will reflect an x/y offset, * e.g. the offset in drawLayer(). If generated with kModelViewMode_TranslateAndScale, - * mModelView will reflect a translation and scale, e.g. the translation and scale required to - * make VBO 0 (a rect of (0,0,1,1)) scaled to match the x,y offset, and width/height of a - * bitmap. + * mModelViewMatrix will reflect a translation and scale, e.g. the translation and scale + * required to make VBO 0 (a rect of (0,0,1,1)) scaled to match the x,y offset, and width/height + * of a bitmap. * * Used as input to SkiaShader transformation. */ - mat4 mModelView; + mat4 mModelViewMatrix; // State used to define the clipping region Rect mTilingClip; diff --git a/libs/hwui/font/Font.cpp b/libs/hwui/font/Font.cpp index d22cb8a..08e9a1a 100644 --- a/libs/hwui/font/Font.cpp +++ b/libs/hwui/font/Font.cpp @@ -214,18 +214,28 @@ void Font::drawCachedGlyphBitmap(CachedGlyphInfo* glyph, int x, int y, uint8_t* int dstY = y + glyph->mBitmapTop; CacheTexture* cacheTexture = glyph->mCacheTexture; + PixelBuffer* pixelBuffer = cacheTexture->getPixelBuffer(); + uint32_t formatSize = PixelBuffer::formatSize(pixelBuffer->getFormat()); uint32_t cacheWidth = cacheTexture->getWidth(); - uint32_t startY = glyph->mStartY * cacheWidth; - uint32_t endY = startY + (glyph->mBitmapHeight * cacheWidth); + uint32_t srcStride = formatSize * cacheWidth; + uint32_t startY = glyph->mStartY * srcStride; + uint32_t endY = startY + (glyph->mBitmapHeight * srcStride); - PixelBuffer* pixelBuffer = cacheTexture->getPixelBuffer(); const uint8_t* cacheBuffer = pixelBuffer->map(); for (uint32_t cacheY = startY, bitmapY = dstY * bitmapWidth; cacheY < endY; - cacheY += cacheWidth, bitmapY += bitmapWidth) { - memcpy(&bitmap[bitmapY + dstX], &cacheBuffer[cacheY + glyph->mStartX], glyph->mBitmapWidth); + cacheY += srcStride, bitmapY += bitmapWidth) { + + if (formatSize == 1) { + memcpy(&bitmap[bitmapY + dstX], &cacheBuffer[cacheY + glyph->mStartX], glyph->mBitmapWidth); + } else { + for (uint32_t i = 0; i < glyph->mBitmapWidth; ++i) { + bitmap[bitmapY + dstX + i] = cacheBuffer[cacheY + (glyph->mStartX + i)*formatSize]; + } + } } + } void Font::drawCachedGlyph(CachedGlyphInfo* glyph, float x, float hOffset, float vOffset, |