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 "GrTexture.h" | 11 #include "GrTexture.h" |
12 #include "GrGpuResourcePriv.h" | 12 #include "GrGpuResourcePriv.h" |
13 #include "SkBitmap.h" | 13 #include "SkBitmap.h" |
14 #include "SkImage_Base.h" | 14 #include "SkImage_Base.h" |
15 #include "SkImagePriv.h" | 15 #include "SkImagePriv.h" |
16 #include "SkSurface.h" | 16 #include "SkSurface.h" |
17 | 17 |
18 class SkImage_Gpu : public SkImage_Base { | 18 class SkImage_Gpu : public SkImage_Base { |
19 public: | 19 public: |
20 SK_DECLARE_INST_COUNT(SkImage_Gpu) | 20 SK_DECLARE_INST_COUNT(SkImage_Gpu) |
21 | 21 |
robertphillips
2015/05/07 16:50:04
Maybe a comment as to why 'w' & 'h' can differ fro
reed1
2015/05/07 17:49:12
Done.
| |
22 SkImage_Gpu(const SkBitmap&, int sampleCountForNewSurfaces, SkSurface::Budge ted); | 22 SkImage_Gpu(int w, int h, GrTexture* tex, int sampleCountForNewSurfaces, SkS urface::Budgeted); |
23 | |
24 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const ove rride; | |
25 GrTexture* onGetTexture() const override; | |
26 bool getROPixels(SkBitmap*) const override; | |
27 | |
28 GrTexture* getTexture() const { return fBitmap.getTexture(); } | |
29 | |
30 SkShader* onNewShader(SkShader::TileMode, | |
31 SkShader::TileMode, | |
32 const SkMatrix* localMatrix) const override; | |
33 | |
34 bool isOpaque() const override; | |
35 | 23 |
36 void applyBudgetDecision() const { | 24 void applyBudgetDecision() const { |
25 GrTexture* tex = this->getTexture(); | |
26 SkASSERT(tex); | |
37 if (fBudgeted) { | 27 if (fBudgeted) { |
38 fBitmap.getTexture()->resourcePriv().makeBudgeted(); | 28 tex->resourcePriv().makeBudgeted(); |
39 } else { | 29 } else { |
40 fBitmap.getTexture()->resourcePriv().makeUnbudgeted(); | 30 tex->resourcePriv().makeUnbudgeted(); |
41 } | 31 } |
42 } | 32 } |
43 | 33 |
34 bool getROPixels(SkBitmap*) const override; | |
35 GrTexture* onGetTexture() const override { return fTexture; } | |
36 SkShader* onNewShader(SkShader::TileMode, | |
37 SkShader::TileMode, | |
38 const SkMatrix* localMatrix) const override; | |
39 bool isOpaque() const override; | |
40 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const ove rride; | |
41 | |
44 private: | 42 private: |
45 SkBitmap fBitmap; | 43 SkAutoTUnref<GrTexture> fTexture; |
46 const int fSampleCountForNewSurfaces; // 0 if we don't know | 44 const int fSampleCountForNewSurfaces; // 0 if we don't know |
47 SkSurface::Budgeted fBudgeted; | 45 SkSurface::Budgeted fBudgeted; |
48 | 46 |
49 typedef SkImage_Base INHERITED; | 47 typedef SkImage_Base INHERITED; |
50 }; | 48 }; |
51 | 49 |
52 #endif | 50 #endif |
OLD | NEW |