cache private readback for gpu-images
Does not try to cache calls to readPixels at the moment:
- not triggered by drawing
- not clear if we want to perform any pixel transformations (that readPixels allows) on the GPU or CPU
Can consider that another time.
BUG=513695
Review URL: https://codereview.chromium.org/1262923003
diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h
index 4c7ebd6..9481690 100644
--- a/src/image/SkImage_Gpu.h
+++ b/src/image/SkImage_Gpu.h
@@ -8,6 +8,7 @@
#ifndef SkImage_Gpu_DEFINED
#define SkImage_Gpu_DEFINED
+#include "SkAtomics.h"
#include "GrTexture.h"
#include "GrGpuResourcePriv.h"
#include "SkBitmap.h"
@@ -17,14 +18,13 @@
class SkImage_Gpu : public SkImage_Base {
public:
-
-
/**
* An "image" can be a subset/window into a larger texture, so we explicit take the
* width and height.
*/
SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType, GrTexture*,
int sampleCountForNewSurfaces, SkSurface::Budgeted);
+ ~SkImage_Gpu() override;
void applyBudgetDecision() const {
GrTexture* tex = this->getTexture();
@@ -47,10 +47,12 @@
int srcX, int srcY) const override;
private:
- SkAutoTUnref<GrTexture> fTexture;
- const int fSampleCountForNewSurfaces; // 0 if we don't know
- const SkAlphaType fAlphaType;
- SkSurface::Budgeted fBudgeted;
+ SkAutoTUnref<GrTexture> fTexture;
+ const int fSampleCountForNewSurfaces; // 0 if we don't know
+ const SkAlphaType fAlphaType;
+ const SkSurface::Budgeted fBudgeted;
+ mutable SkAtomic<bool> fAddedRasterVersionToCache;
+
typedef SkImage_Base INHERITED;
};