diff options
author | John Reck <jreck@google.com> | 2015-06-09 22:30:12 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-09 22:32:33 +0000 |
commit | 475c545fa8ea0d87bc3704ae3c0bf73bb060dcb8 (patch) | |
tree | 33ff6bfdf1e1589ef5f4552713a478a7a3a4cde2 /libs/hwui | |
parent | 31ed2044e2907954b32148c06b131d3069b1c8ca (diff) | |
parent | 37b0824a46157b7e169ad7ec33a46e89c851884c (diff) | |
download | frameworks_base-475c545fa8ea0d87bc3704ae3c0bf73bb060dcb8.zip frameworks_base-475c545fa8ea0d87bc3704ae3c0bf73bb060dcb8.tar.gz frameworks_base-475c545fa8ea0d87bc3704ae3c0bf73bb060dcb8.tar.bz2 |
Merge "Upload bitmaps in SkShader* safely" into mnc-dev
Diffstat (limited to 'libs/hwui')
-rw-r--r-- | libs/hwui/DisplayListCanvas.cpp | 21 | ||||
-rw-r--r-- | libs/hwui/DisplayListCanvas.h | 2 | ||||
-rwxr-xr-x | libs/hwui/OpenGLRenderer.h | 16 |
3 files changed, 23 insertions, 16 deletions
diff --git a/libs/hwui/DisplayListCanvas.cpp b/libs/hwui/DisplayListCanvas.cpp index cbb6fd5..900a621 100644 --- a/libs/hwui/DisplayListCanvas.cpp +++ b/libs/hwui/DisplayListCanvas.cpp @@ -352,6 +352,7 @@ void DisplayListCanvas::drawRoundRect( mDisplayListData->ref(rx); mDisplayListData->ref(ry); mDisplayListData->ref(paint); + refBitmapsInShader(paint->value.getShader()); addDrawOp(new (alloc()) DrawRoundRectPropsOp(&left->value, &top->value, &right->value, &bottom->value, &rx->value, &ry->value, &paint->value)); } @@ -366,6 +367,7 @@ void DisplayListCanvas::drawCircle(CanvasPropertyPrimitive* x, CanvasPropertyPri mDisplayListData->ref(y); mDisplayListData->ref(radius); mDisplayListData->ref(paint); + refBitmapsInShader(paint->value.getShader()); addDrawOp(new (alloc()) DrawCirclePropsOp(&x->value, &y->value, &radius->value, &paint->value)); } @@ -565,5 +567,24 @@ size_t DisplayListCanvas::addRenderNodeOp(DrawRenderNodeOp* op) { return opIndex; } +void DisplayListCanvas::refBitmapsInShader(const SkShader* shader) { + if (!shader) return; + + // If this paint has an SkShader that has an SkBitmap add + // it to the bitmap pile + SkBitmap bitmap; + SkShader::TileMode xy[2]; + if (shader->asABitmap(&bitmap, nullptr, xy) == SkShader::kDefault_BitmapType) { + refBitmap(bitmap); + return; + } + SkShader::ComposeRec rec; + if (shader->asACompose(&rec)) { + refBitmapsInShader(rec.fShaderA); + refBitmapsInShader(rec.fShaderB); + return; + } +} + }; // namespace uirenderer }; // namespace android diff --git a/libs/hwui/DisplayListCanvas.h b/libs/hwui/DisplayListCanvas.h index d997ef4..edfda62 100644 --- a/libs/hwui/DisplayListCanvas.h +++ b/libs/hwui/DisplayListCanvas.h @@ -263,6 +263,7 @@ private: size_t addDrawOp(DrawOp* op); size_t addRenderNodeOp(DrawRenderNodeOp* op); + void refBitmapsInShader(const SkShader* shader); template<class T> inline const T* refBuffer(const T* srcBuffer, int32_t count) { @@ -311,6 +312,7 @@ private: // replaceValueFor() performs an add if the entry doesn't exist mPaintMap.replaceValueFor(key, cachedPaint); + refBitmapsInShader(cachedPaint->getShader()); } return cachedPaint; diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index 29fbf0c..5850dc6 100755 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -524,22 +524,6 @@ protected: inline float getLayerAlpha(const Layer* layer) const; /** - * Safely retrieves the ColorFilter from the given Paint. If the paint is - * null then null is returned. - */ - static inline SkColorFilter* getColorFilter(const SkPaint* paint) { - return paint ? paint->getColorFilter() : nullptr; - } - - /** - * Safely retrieves the Shader from the given Paint. If the paint is - * null then null is returned. - */ - static inline const SkShader* getShader(const SkPaint* paint) { - return paint ? paint->getShader() : nullptr; - } - - /** * Set to true to suppress error checks at the end of a frame. */ virtual bool suppressErrorChecks() const { |