| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkImage_Gpu_DEFINED | 8 #ifndef SkImage_Gpu_DEFINED |
| 9 #define SkImage_Gpu_DEFINED | 9 #define SkImage_Gpu_DEFINED |
| 10 | 10 |
| 11 #include "SkAtomics.h" | 11 #include "SkAtomics.h" |
| 12 #include "GrTexture.h" | 12 #include "GrTexture.h" |
| 13 #include "GrGpuResourcePriv.h" | 13 #include "GrGpuResourcePriv.h" |
| 14 #include "SkBitmap.h" | 14 #include "SkBitmap.h" |
| 15 #include "SkImage_Base.h" | 15 #include "SkImage_Base.h" |
| 16 #include "SkImagePriv.h" | 16 #include "SkImagePriv.h" |
| 17 #include "SkSurface.h" | 17 #include "SkSurface.h" |
| 18 | 18 |
| 19 class SkImage_Gpu : public SkImage_Base { | 19 class SkImage_Gpu : public SkImage_Base { |
| 20 public: | 20 public: |
| 21 /** | 21 /** |
| 22 * An "image" can be a subset/window into a larger texture, so we explicit
take the | 22 * An "image" can be a subset/window into a larger texture, so we explicit
take the |
| 23 * width and height. | 23 * width and height. |
| 24 */ | 24 */ |
| 25 SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType, GrTexture*, | 25 SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType, GrTexture*, SkSurf
ace::Budgeted); |
| 26 int sampleCountForNewSurfaces, SkSurface::Budgeted); | |
| 27 ~SkImage_Gpu() override; | 26 ~SkImage_Gpu() override; |
| 28 | 27 |
| 29 void applyBudgetDecision() const { | 28 void applyBudgetDecision() const { |
| 30 GrTexture* tex = this->getTexture(); | 29 GrTexture* tex = this->getTexture(); |
| 31 SkASSERT(tex); | 30 SkASSERT(tex); |
| 32 if (fBudgeted) { | 31 if (fBudgeted) { |
| 33 tex->resourcePriv().makeBudgeted(); | 32 tex->resourcePriv().makeBudgeted(); |
| 34 } else { | 33 } else { |
| 35 tex->resourcePriv().makeUnbudgeted(); | 34 tex->resourcePriv().makeUnbudgeted(); |
| 36 } | 35 } |
| 37 } | 36 } |
| 38 | 37 |
| 39 bool getROPixels(SkBitmap*) const override; | 38 bool getROPixels(SkBitmap*) const override; |
| 40 GrTexture* asTextureRef(GrContext* ctx, SkImageUsageType usage) const overri
de; | 39 GrTexture* asTextureRef(GrContext* ctx, SkImageUsageType usage) const overri
de; |
| 40 SkImage* onNewSubset(const SkIRect&) const override; |
| 41 | 41 |
| 42 GrTexture* peekTexture() const override { return fTexture; } | 42 GrTexture* peekTexture() const override { return fTexture; } |
| 43 SkShader* onNewShader(SkShader::TileMode, | 43 SkShader* onNewShader(SkShader::TileMode, |
| 44 SkShader::TileMode, | 44 SkShader::TileMode, |
| 45 const SkMatrix* localMatrix) const override; | 45 const SkMatrix* localMatrix) const override; |
| 46 bool isOpaque() const override; | 46 bool isOpaque() const override; |
| 47 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const ove
rride; | |
| 48 bool onReadPixels(const SkImageInfo&, void* dstPixels, size_t dstRowBytes, | 47 bool onReadPixels(const SkImageInfo&, void* dstPixels, size_t dstRowBytes, |
| 49 int srcX, int srcY) const override; | 48 int srcX, int srcY) const override; |
| 50 | 49 |
| 51 private: | 50 private: |
| 52 SkAutoTUnref<GrTexture> fTexture; | 51 SkAutoTUnref<GrTexture> fTexture; |
| 53 const int fSampleCountForNewSurfaces; // 0 if we don't k
now | |
| 54 const SkAlphaType fAlphaType; | 52 const SkAlphaType fAlphaType; |
| 55 const SkSurface::Budgeted fBudgeted; | 53 const SkSurface::Budgeted fBudgeted; |
| 56 mutable SkAtomic<bool> fAddedRasterVersionToCache; | 54 mutable SkAtomic<bool> fAddedRasterVersionToCache; |
| 57 | 55 |
| 58 | 56 |
| 59 typedef SkImage_Base INHERITED; | 57 typedef SkImage_Base INHERITED; |
| 60 }; | 58 }; |
| 61 | 59 |
| 62 #endif | 60 #endif |
| OLD | NEW |