diff options
author | John Reck <jreck@google.com> | 2015-04-17 20:45:40 +0000 |
---|---|---|
committer | John Reck <jreck@google.com> | 2015-04-17 20:47:27 +0000 |
commit | 9d4efdf2802f06ccf7031610891f75af70ea5538 (patch) | |
tree | a86a7a833af6b45b466a391c5ff72fbffcdca329 /libs/hwui | |
parent | 7809f835cae637c12eebdc92103ad88890228d97 (diff) | |
download | frameworks_base-9d4efdf2802f06ccf7031610891f75af70ea5538.zip frameworks_base-9d4efdf2802f06ccf7031610891f75af70ea5538.tar.gz frameworks_base-9d4efdf2802f06ccf7031610891f75af70ea5538.tar.bz2 |
Revert "A bunch more cleanups"
This reverts commit c294d128d03bc9a9982b273a82516c04583438cc.
Change-Id: Id1ebb236950f7c36c6d86e1dd95566d3a200748d
Diffstat (limited to 'libs/hwui')
-rw-r--r-- | libs/hwui/Canvas.h | 7 | ||||
-rw-r--r-- | libs/hwui/DisplayListRenderer.h | 2 | ||||
-rw-r--r-- | libs/hwui/SkiaCanvas.cpp | 28 | ||||
-rw-r--r-- | libs/hwui/renderthread/RenderProxy.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/renderthread/RenderProxy.h | 2 |
5 files changed, 27 insertions, 16 deletions
diff --git a/libs/hwui/Canvas.h b/libs/hwui/Canvas.h index aa24673..7ad0683 100644 --- a/libs/hwui/Canvas.h +++ b/libs/hwui/Canvas.h @@ -29,7 +29,7 @@ class ANDROID_API Canvas { public: virtual ~Canvas() {}; - static Canvas* create_canvas(const SkBitmap& bitmap); + static Canvas* create_canvas(SkBitmap* bitmap); /** * Create a new Canvas object which delegates to an SkCanvas. @@ -52,7 +52,7 @@ public: */ virtual SkCanvas* asSkCanvas() = 0; - virtual void setBitmap(const SkBitmap& bitmap) = 0; + virtual void setBitmap(SkBitmap* bitmap, bool copyState) = 0; virtual bool isOpaque() = 0; virtual int width() = 0; @@ -87,8 +87,7 @@ public: virtual bool quickRejectRect(float left, float top, float right, float bottom) const = 0; virtual bool quickRejectPath(const SkPath& path) const = 0; - virtual bool clipRect(float left, float top, float right, float bottom, - SkRegion::Op op = SkRegion::kIntersect_Op) = 0; + virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op) = 0; virtual bool clipPath(const SkPath* path, SkRegion::Op op) = 0; virtual bool clipRegion(const SkRegion* region, SkRegion::Op op) = 0; diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h index ff698f5..53fd1ad 100644 --- a/libs/hwui/DisplayListRenderer.h +++ b/libs/hwui/DisplayListRenderer.h @@ -138,7 +138,7 @@ public: // ---------------------------------------------------------------------------- virtual SkCanvas* asSkCanvas() override; - virtual void setBitmap(const SkBitmap& bitmap) override { + virtual void setBitmap(SkBitmap* bitmap, bool copyState) override { LOG_ALWAYS_FATAL("DisplayListRenderer is not backed by a bitmap."); } diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp index a323065..8b11757 100644 --- a/libs/hwui/SkiaCanvas.cpp +++ b/libs/hwui/SkiaCanvas.cpp @@ -31,7 +31,7 @@ namespace android { // Holds an SkCanvas reference plus additional native data. class SkiaCanvas : public Canvas { public: - explicit SkiaCanvas(const SkBitmap& bitmap); + explicit SkiaCanvas(SkBitmap* bitmap); /** * Create a new SkiaCanvas. @@ -49,7 +49,7 @@ public: return mCanvas.get(); } - virtual void setBitmap(const SkBitmap& bitmap) override; + virtual void setBitmap(SkBitmap* bitmap, bool copyState) override; virtual bool isOpaque() override; virtual int width() override; @@ -145,7 +145,19 @@ private: SkAutoTDelete<SkDeque> mSaveStack; // lazily allocated, tracks partial saves. }; -Canvas* Canvas::create_canvas(const SkBitmap& bitmap) { +// Construct an SkCanvas from the bitmap. +static SkCanvas* createCanvas(SkBitmap* bitmap) { + if (bitmap) { + return SkNEW_ARGS(SkCanvas, (*bitmap)); + } + + // Create an empty bitmap device to prevent callers from crashing + // if they attempt to draw into this canvas. + SkBitmap emptyBitmap; + return new SkCanvas(emptyBitmap); +} + +Canvas* Canvas::create_canvas(SkBitmap* bitmap) { return new SkiaCanvas(bitmap); } @@ -153,8 +165,8 @@ Canvas* Canvas::create_canvas(SkCanvas* skiaCanvas) { return new SkiaCanvas(skiaCanvas); } -SkiaCanvas::SkiaCanvas(const SkBitmap& bitmap) { - mCanvas.reset(new SkCanvas(bitmap)); +SkiaCanvas::SkiaCanvas(SkBitmap* bitmap) { + mCanvas.reset(createCanvas(bitmap)); } // ---------------------------------------------------------------------------- @@ -179,11 +191,11 @@ private: SkCanvas* m_dstCanvas; }; -void SkiaCanvas::setBitmap(const SkBitmap& bitmap) { - SkCanvas* newCanvas = new SkCanvas(bitmap); +void SkiaCanvas::setBitmap(SkBitmap* bitmap, bool copyState) { + SkCanvas* newCanvas = createCanvas(bitmap); SkASSERT(newCanvas); - if (!bitmap.isNull()) { + if (copyState) { // Copy the canvas matrix & clip state. newCanvas->setMatrix(mCanvas->getTotalMatrix()); if (NULL != mCanvas->getDevice() && NULL != newCanvas->getDevice()) { diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp index d15fa39..cc87241 100644 --- a/libs/hwui/renderthread/RenderProxy.cpp +++ b/libs/hwui/renderthread/RenderProxy.cpp @@ -293,11 +293,11 @@ CREATE_BRIDGE3(copyLayerInto, CanvasContext* context, DeferredLayerUpdater* laye return (void*) success; } -bool RenderProxy::copyLayerInto(DeferredLayerUpdater* layer, SkBitmap& bitmap) { +bool RenderProxy::copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap) { SETUP_TASK(copyLayerInto); args->context = mContext; args->layer = layer; - args->bitmap = &bitmap; + args->bitmap = bitmap; return (bool) postAndWait(task); } diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h index cc475fa..29c6f08 100644 --- a/libs/hwui/renderthread/RenderProxy.h +++ b/libs/hwui/renderthread/RenderProxy.h @@ -83,7 +83,7 @@ public: ANDROID_API DeferredLayerUpdater* createTextureLayer(); ANDROID_API void buildLayer(RenderNode* node); - ANDROID_API bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap& bitmap); + ANDROID_API bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap); ANDROID_API void pushLayerUpdate(DeferredLayerUpdater* layer); ANDROID_API void cancelLayerUpdate(DeferredLayerUpdater* layer); ANDROID_API void detachSurfaceTexture(DeferredLayerUpdater* layer); |