Merge "Upload bitmaps in SkShader* safely" into mnc-dev
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -523,22 +523,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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user