diff options
| author | 2016-10-24 15:35:21 -0700 | |
|---|---|---|
| committer | 2016-10-26 13:57:38 -0700 | |
| commit | 98fa4f9e7b33a3004ce9142c9acd4300391b9a0e (patch) | |
| tree | 362ddb4cd164347c2008810d030c954d7dc2c778 /libs/hwui/PathCache.h | |
| parent | 817695589c80cfc0913d94e3dd52dac2782e8ed6 (diff) | |
Use Bitmap in Texture.upload
Test: refactoring cl.
bug:32216791
Change-Id: Ib0b16c878d8371e0471e9a502f55626ec5999c60
Diffstat (limited to 'libs/hwui/PathCache.h')
| -rw-r--r-- | libs/hwui/PathCache.h | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/libs/hwui/PathCache.h b/libs/hwui/PathCache.h index 18bcc566296f..7bd190df951b 100644 --- a/libs/hwui/PathCache.h +++ b/libs/hwui/PathCache.h @@ -19,6 +19,7 @@ #include "Debug.h" #include "Texture.h" +#include "hwui/Bitmap.h" #include "thread/Task.h" #include "thread/TaskProcessor.h" #include "utils/Macros.h" @@ -32,7 +33,6 @@ #include <vector> -class SkBitmap; class SkCanvas; class SkPaint; struct SkRect; @@ -41,7 +41,6 @@ namespace android { namespace uirenderer { class Caches; - /////////////////////////////////////////////////////////////////////////////// // Defines /////////////////////////////////////////////////////////////////////////////// @@ -57,6 +56,21 @@ class Caches; // Classes /////////////////////////////////////////////////////////////////////////////// +struct PathTexture; +class PathTask: public Task<sk_sp<Bitmap>> { +public: + PathTask(const SkPath* path, const SkPaint* paint, PathTexture* texture): + path(*path), paint(*paint), texture(texture) { + } + + // copied, since input path not guaranteed to survive for duration of task + const SkPath path; + + // copied, since input paint may not be immutable + const SkPaint paint; + PathTexture* texture; +}; + /** * Alpha texture used to represent a path. */ @@ -83,11 +97,11 @@ struct PathTexture: public Texture { */ float offset = 0; - sp<Task<SkBitmap*> > task() const { + sp<PathTask> task() const { return mTask; } - void setTask(const sp<Task<SkBitmap*> >& task) { + void setTask(const sp<PathTask>& task) { mTask = task; } @@ -98,7 +112,7 @@ struct PathTexture: public Texture { } private: - sp<Task<SkBitmap*> > mTask; + sp<PathTask> mTask; }; // struct PathTexture enum class ShapeType { @@ -222,13 +236,12 @@ public: private: PathTexture* addTexture(const PathDescription& entry, const SkPath *path, const SkPaint* paint); - PathTexture* addTexture(const PathDescription& entry, SkBitmap* bitmap); /** * Generates the texture from a bitmap into the specified texture structure. */ - void generateTexture(SkBitmap& bitmap, Texture* texture); - void generateTexture(const PathDescription& entry, SkBitmap* bitmap, PathTexture* texture, + void generateTexture(Bitmap& bitmap, Texture* texture); + void generateTexture(const PathDescription& entry, Bitmap& bitmap, PathTexture* texture, bool addToCache = true); PathTexture* get(const PathDescription& entry) { @@ -245,30 +258,13 @@ private: void init(); - class PathTask: public Task<SkBitmap*> { - public: - PathTask(const SkPath* path, const SkPaint* paint, PathTexture* texture): - path(*path), paint(*paint), texture(texture) { - } - - ~PathTask() { - delete future()->get(); - } - - // copied, since input path not guaranteed to survive for duration of task - const SkPath path; - - // copied, since input paint may not be immutable - const SkPaint paint; - PathTexture* texture; - }; - class PathProcessor: public TaskProcessor<SkBitmap*> { + class PathProcessor: public TaskProcessor<sk_sp<Bitmap> > { public: explicit PathProcessor(Caches& caches); ~PathProcessor() { } - virtual void onProcess(const sp<Task<SkBitmap*> >& task) override; + virtual void onProcess(const sp<Task<sk_sp<Bitmap> > >& task) override; private: uint32_t mMaxTextureSize; |