summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2014-02-21 13:15:32 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-02-21 13:15:33 +0000
commit52382757753b54be7d5ed4c2cc8496cab36192d8 (patch)
tree1cfe47052778d01c68f552166d631c6de0433550 /libs
parent5c79949324066adc536ba563736f8f1f688fef02 (diff)
parent674554fc36932ca50b15bba41ac6f650254d4e72 (diff)
downloadframeworks_base-52382757753b54be7d5ed4c2cc8496cab36192d8.zip
frameworks_base-52382757753b54be7d5ed4c2cc8496cab36192d8.tar.gz
frameworks_base-52382757753b54be7d5ed4c2cc8496cab36192d8.tar.bz2
Merge "Reapply "Refactor setting an SkPaint onto a hwui Layer.""
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/DeferredLayerUpdater.cpp8
-rw-r--r--libs/hwui/DeferredLayerUpdater.h6
-rw-r--r--libs/hwui/Layer.cpp3
-rw-r--r--libs/hwui/Layer.h2
-rw-r--r--libs/hwui/OpenGLRenderer.cpp9
5 files changed, 11 insertions, 17 deletions
diff --git a/libs/hwui/DeferredLayerUpdater.cpp b/libs/hwui/DeferredLayerUpdater.cpp
index efb1298..62f6c76 100644
--- a/libs/hwui/DeferredLayerUpdater.cpp
+++ b/libs/hwui/DeferredLayerUpdater.cpp
@@ -34,21 +34,23 @@ DeferredLayerUpdater::DeferredLayerUpdater(Layer* layer, OpenGLRenderer* rendere
mWidth = mLayer->layer.getWidth();
mHeight = mLayer->layer.getHeight();
mBlend = mLayer->isBlend();
- mColorFilter = mLayer->getColorFilter();
+ mColorFilter = SkSafeRef(mLayer->getColorFilter());
mAlpha = mLayer->getAlpha();
mMode = mLayer->getMode();
mDirtyRect.setEmpty();
}
DeferredLayerUpdater::~DeferredLayerUpdater() {
- setColorFilter(NULL);
+ SkSafeUnref(mColorFilter);
if (mLayer) {
mCaches.resourceCache.decrementRefcount(mLayer);
}
delete mRenderer;
}
-void DeferredLayerUpdater::setColorFilter(SkColorFilter* colorFilter) {
+void DeferredLayerUpdater::setPaint(const SkPaint* paint) {
+ OpenGLRenderer::getAlphaAndModeDirect(paint, &mAlpha, &mMode);
+ SkColorFilter* colorFilter = (paint) ? paint->getColorFilter() : NULL;
SkRefCnt_SafeAssign(mColorFilter, colorFilter);
}
diff --git a/libs/hwui/DeferredLayerUpdater.h b/libs/hwui/DeferredLayerUpdater.h
index 624db2c..65f225c 100644
--- a/libs/hwui/DeferredLayerUpdater.h
+++ b/libs/hwui/DeferredLayerUpdater.h
@@ -75,11 +75,7 @@ public:
ANDROID_API void setDisplayList(DisplayList* displayList,
int left, int top, int right, int bottom);
- ANDROID_API void setPaint(const SkPaint* paint) {
- OpenGLRenderer::getAlphaAndModeDirect(paint, &mAlpha, &mMode);
- }
-
- ANDROID_API void setColorFilter(SkColorFilter* colorFilter);
+ ANDROID_API void setPaint(const SkPaint* paint);
ANDROID_API bool apply();
diff --git a/libs/hwui/Layer.cpp b/libs/hwui/Layer.cpp
index 70eeb39..54ce64f 100644
--- a/libs/hwui/Layer.cpp
+++ b/libs/hwui/Layer.cpp
@@ -131,8 +131,9 @@ void Layer::removeFbo(bool flush) {
}
}
-void Layer::setPaint(SkPaint* paint) {
+void Layer::setPaint(const SkPaint* paint) {
OpenGLRenderer::getAlphaAndModeDirect(paint, &alpha, &mode);
+ setColorFilter((paint) ? paint->getColorFilter() : NULL);
}
void Layer::setColorFilter(SkColorFilter* filter) {
diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h
index ec80e9c..8cc027a 100644
--- a/libs/hwui/Layer.h
+++ b/libs/hwui/Layer.h
@@ -117,7 +117,7 @@ public:
texture.height = height;
}
- ANDROID_API void setPaint(SkPaint* paint);
+ ANDROID_API void setPaint(const SkPaint* paint);
inline void setBlend(bool blend) {
texture.blend = blend;
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 9b253a6..2da0fd3 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -868,14 +868,11 @@ bool OpenGLRenderer::createLayer(float left, float top, float right, float botto
const bool fboLayer = flags & SkCanvas::kClipToLayer_SaveFlag;
- SkXfermode::Mode mode = getXfermodeDirect(paint);
- int alpha = getAlphaDirect(paint);
-
// Window coordinates of the layer
Rect clip;
Rect bounds(left, top, right, bottom);
calculateLayerBoundsAndClip(bounds, clip, fboLayer);
- updateSnapshotIgnoreForLayer(bounds, clip, fboLayer, alpha);
+ updateSnapshotIgnoreForLayer(bounds, clip, fboLayer, getAlphaDirect(paint));
// Bail out if we won't draw in this snapshot
if (currentSnapshot()->isIgnored()) {
@@ -888,12 +885,11 @@ bool OpenGLRenderer::createLayer(float left, float top, float right, float botto
return false;
}
- layer->setAlpha(alpha, mode);
+ layer->setPaint(paint);
layer->layer.set(bounds);
layer->texCoords.set(0.0f, bounds.getHeight() / float(layer->getHeight()),
bounds.getWidth() / float(layer->getWidth()), 0.0f);
- layer->setColorFilter(getColorFilter(paint));
layer->setBlend(true);
layer->setDirty(false);
@@ -1011,7 +1007,6 @@ void OpenGLRenderer::composeLayer(const Snapshot& removed, const Snapshot& resto
}
if (!fboLayer && layer->getAlpha() < 255) {
- // TODO: this seems to point to the fact that the layer should store the paint
SkPaint layerPaint;
layerPaint.setAlpha(layer->getAlpha());
layerPaint.setXfermodeMode(SkXfermode::kDstIn_Mode);