Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Side by Side Diff: src/image/SkImage_Gpu.cpp

Issue 872543002: Take budgeted param when snapping new image. (Closed) Base URL: https://skia.googlesource.com/skia.git@budgeted
Patch Set: Address comment and rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/image/SkImage_Gpu.h ('k') | src/image/SkSurface.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 #include "SkImage_Base.h" 8 #include "SkImage_Gpu.h"
9 #include "SkImagePriv.h"
10 #include "SkBitmap.h"
11 #include "SkCanvas.h" 9 #include "SkCanvas.h"
12 #include "SkSurface.h"
13 #include "GrContext.h" 10 #include "GrContext.h"
14 #include "GrTexture.h"
15 11
16 class SkImage_Gpu : public SkImage_Base { 12 SkImage_Gpu::SkImage_Gpu(const SkBitmap& bitmap, int sampleCountForNewSurfaces,
17 public: 13 SkSurface::Budgeted budgeted)
18 SK_DECLARE_INST_COUNT(SkImage_Gpu)
19
20 SkImage_Gpu(const SkBitmap&, int sampleCountForNewSurfaces);
21
22 void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const SK_OVER RIDE;
23 void onDrawRect(SkCanvas*, const SkRect* src, const SkRect& dst,
24 const SkPaint*) const SK_OVERRIDE;
25 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const SK_ OVERRIDE;
26 GrTexture* onGetTexture() const SK_OVERRIDE;
27 bool getROPixels(SkBitmap*) const SK_OVERRIDE;
28
29 GrTexture* getTexture() const { return fBitmap.getTexture(); }
30
31 SkShader* onNewShader(SkShader::TileMode,
32 SkShader::TileMode,
33 const SkMatrix* localMatrix) const SK_OVERRIDE ;
34
35 bool isOpaque() const SK_OVERRIDE;
36
37 private:
38 SkBitmap fBitmap;
39 const int fSampleCountForNewSurfaces; // 0 if we don't know
40
41 typedef SkImage_Base INHERITED;
42 };
43
44 ///////////////////////////////////////////////////////////////////////////////
45
46 SkImage_Gpu::SkImage_Gpu(const SkBitmap& bitmap, int sampleCountForNewSurfaces)
47 : INHERITED(bitmap.width(), bitmap.height(), NULL) 14 : INHERITED(bitmap.width(), bitmap.height(), NULL)
48 , fBitmap(bitmap) 15 , fBitmap(bitmap)
49 , fSampleCountForNewSurfaces(sampleCountForNewSurfaces) 16 , fSampleCountForNewSurfaces(sampleCountForNewSurfaces)
17 , fBudgeted(budgeted)
50 { 18 {
51 SkASSERT(fBitmap.getTexture()); 19 SkASSERT(fBitmap.getTexture());
52 } 20 }
53 21
54 SkShader* SkImage_Gpu::onNewShader(SkShader::TileMode tileX, 22 SkShader* SkImage_Gpu::onNewShader(SkShader::TileMode tileX,
55 SkShader::TileMode tileY, 23 SkShader::TileMode tileY,
56 const SkMatrix* localMatrix) const 24 const SkMatrix* localMatrix) const
57 { 25 {
58 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, localMatrix); 26 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, localMatrix);
59 } 27 }
(...skipping 21 matching lines...) Expand all
81 bool SkImage_Gpu::getROPixels(SkBitmap* dst) const { 49 bool SkImage_Gpu::getROPixels(SkBitmap* dst) const {
82 return fBitmap.copyTo(dst, kN32_SkColorType); 50 return fBitmap.copyTo(dst, kN32_SkColorType);
83 } 51 }
84 52
85 bool SkImage_Gpu::isOpaque() const { 53 bool SkImage_Gpu::isOpaque() const {
86 return fBitmap.isOpaque(); 54 return fBitmap.isOpaque();
87 } 55 }
88 56
89 /////////////////////////////////////////////////////////////////////////////// 57 ///////////////////////////////////////////////////////////////////////////////
90 58
91 SkImage* SkNewImageFromBitmapTexture(const SkBitmap& bitmap, int sampleCountForN ewSurfaces) { 59 SkImage* SkNewImageFromBitmapTexture(const SkBitmap& bitmap, int sampleCountForN ewSurfaces,
60 SkSurface::Budgeted budgeted) {
92 if (0 == bitmap.width() || 0 == bitmap.height() || NULL == bitmap.getTexture ()) { 61 if (0 == bitmap.width() || 0 == bitmap.height() || NULL == bitmap.getTexture ()) {
93 return NULL; 62 return NULL;
94 } 63 }
95 return SkNEW_ARGS(SkImage_Gpu, (bitmap, sampleCountForNewSurfaces)); 64 return SkNEW_ARGS(SkImage_Gpu, (bitmap, sampleCountForNewSurfaces, budgeted) );
96 } 65 }
97 66
98 GrTexture* SkTextureImageGetTexture(SkImage* image) { 67 GrTexture* SkTextureImageGetTexture(SkImage* image) {
99 return ((SkImage_Gpu*)image)->getTexture(); 68 return ((SkImage_Gpu*)image)->getTexture();
100 } 69 }
101 70
71 extern void SkTextureImageApplyBudgetedDecision(SkImage* image) {
72 ((SkImage_Gpu*)image)->applyBudgetDecision();
73 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.h ('k') | src/image/SkSurface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698