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

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

Issue 750023002: clarify samplecount field in imagegpu (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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/SkImagePriv.h ('k') | no next file » | 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_Base.h"
9 #include "SkImagePriv.h" 9 #include "SkImagePriv.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkSurface.h" 12 #include "SkSurface.h"
13 #include "GrContext.h" 13 #include "GrContext.h"
14 #include "GrTexture.h" 14 #include "GrTexture.h"
15 15
16 class SkImage_Gpu : public SkImage_Base { 16 class SkImage_Gpu : public SkImage_Base {
17 public: 17 public:
18 SK_DECLARE_INST_COUNT(SkImage_Gpu) 18 SK_DECLARE_INST_COUNT(SkImage_Gpu)
19 19
20 SkImage_Gpu(const SkBitmap&, int sampleCount); 20 SkImage_Gpu(const SkBitmap&, int sampleCountForNewSurfaces);
21 21
22 void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const SK_OVER RIDE; 22 void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const SK_OVER RIDE;
23 void onDrawRect(SkCanvas*, const SkRect* src, const SkRect& dst, 23 void onDrawRect(SkCanvas*, const SkRect* src, const SkRect& dst,
24 const SkPaint*) const SK_OVERRIDE; 24 const SkPaint*) const SK_OVERRIDE;
25 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const SK_ OVERRIDE; 25 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const SK_ OVERRIDE;
26 GrTexture* onGetTexture() const SK_OVERRIDE; 26 GrTexture* onGetTexture() const SK_OVERRIDE;
27 bool getROPixels(SkBitmap*) const SK_OVERRIDE; 27 bool getROPixels(SkBitmap*) const SK_OVERRIDE;
28 28
29 GrTexture* getTexture() const { return fBitmap.getTexture(); } 29 GrTexture* getTexture() const { return fBitmap.getTexture(); }
30 30
31 SkShader* onNewShader(SkShader::TileMode, 31 SkShader* onNewShader(SkShader::TileMode,
32 SkShader::TileMode, 32 SkShader::TileMode,
33 const SkMatrix* localMatrix) const SK_OVERRIDE ; 33 const SkMatrix* localMatrix) const SK_OVERRIDE ;
34 34
35 bool isOpaque() const SK_OVERRIDE; 35 bool isOpaque() const SK_OVERRIDE;
36 36
37 private: 37 private:
38 SkBitmap fBitmap; 38 SkBitmap fBitmap;
39 const int fSampleCount; // 0 if we weren't built from a surface 39 const int fSampleCountForNewSurfaces; // 0 if we don't know
40 40
41 typedef SkImage_Base INHERITED; 41 typedef SkImage_Base INHERITED;
42 }; 42 };
43 43
44 /////////////////////////////////////////////////////////////////////////////// 44 ///////////////////////////////////////////////////////////////////////////////
45 45
46 SkImage_Gpu::SkImage_Gpu(const SkBitmap& bitmap, int sampleCount) 46 SkImage_Gpu::SkImage_Gpu(const SkBitmap& bitmap, int sampleCountForNewSurfaces)
47 : INHERITED(bitmap.width(), bitmap.height(), NULL) 47 : INHERITED(bitmap.width(), bitmap.height(), NULL)
48 , fBitmap(bitmap) 48 , fBitmap(bitmap)
49 , fSampleCount(sampleCount) 49 , fSampleCountForNewSurfaces(sampleCountForNewSurfaces)
50 { 50 {
51 SkASSERT(fBitmap.getTexture()); 51 SkASSERT(fBitmap.getTexture());
52 } 52 }
53 53
54 SkShader* SkImage_Gpu::onNewShader(SkShader::TileMode tileX, 54 SkShader* SkImage_Gpu::onNewShader(SkShader::TileMode tileX,
55 SkShader::TileMode tileY, 55 SkShader::TileMode tileY,
56 const SkMatrix* localMatrix) const 56 const SkMatrix* localMatrix) const
57 { 57 {
58 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, localMatrix); 58 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, localMatrix);
59 } 59 }
60 60
61 void SkImage_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint * paint) const { 61 void SkImage_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint * paint) const {
62 canvas->drawBitmap(fBitmap, x, y, paint); 62 canvas->drawBitmap(fBitmap, x, y, paint);
63 } 63 }
64 64
65 void SkImage_Gpu::onDrawRect(SkCanvas* canvas, const SkRect* src, const SkRect& dst, 65 void SkImage_Gpu::onDrawRect(SkCanvas* canvas, const SkRect* src, const SkRect& dst,
66 const SkPaint* paint) const { 66 const SkPaint* paint) const {
67 canvas->drawBitmapRectToRect(fBitmap, src, dst, paint); 67 canvas->drawBitmapRectToRect(fBitmap, src, dst, paint);
68 } 68 }
69 69
70 SkSurface* SkImage_Gpu::onNewSurface(const SkImageInfo& info, const SkSurfacePro ps& props) const { 70 SkSurface* SkImage_Gpu::onNewSurface(const SkImageInfo& info, const SkSurfacePro ps& props) const {
71 GrContext* ctx = this->getTexture()->getContext(); 71 GrContext* ctx = this->getTexture()->getContext();
72 return SkSurface::NewRenderTarget(ctx, info, fSampleCount, &props); 72 return SkSurface::NewRenderTarget(ctx, info, fSampleCountForNewSurfaces, &pr ops);
73 } 73 }
74 74
75 GrTexture* SkImage_Gpu::onGetTexture() const { 75 GrTexture* SkImage_Gpu::onGetTexture() const {
76 return fBitmap.getTexture(); 76 return fBitmap.getTexture();
77 } 77 }
78 78
79 bool SkImage_Gpu::getROPixels(SkBitmap* dst) const { 79 bool SkImage_Gpu::getROPixels(SkBitmap* dst) const {
80 return fBitmap.copyTo(dst, kN32_SkColorType); 80 return fBitmap.copyTo(dst, kN32_SkColorType);
81 } 81 }
82 82
83 bool SkImage_Gpu::isOpaque() const { 83 bool SkImage_Gpu::isOpaque() const {
84 return fBitmap.isOpaque(); 84 return fBitmap.isOpaque();
85 } 85 }
86 86
87 /////////////////////////////////////////////////////////////////////////////// 87 ///////////////////////////////////////////////////////////////////////////////
88 88
89 SkImage* SkNewImageFromBitmapTexture(const SkBitmap& bitmap, int sampleCount) { 89 SkImage* SkNewImageFromBitmapTexture(const SkBitmap& bitmap, int sampleCountForN ewSurfaces) {
90 if (NULL == bitmap.getTexture()) { 90 if (NULL == bitmap.getTexture()) {
91 return NULL; 91 return NULL;
92 } 92 }
93 return SkNEW_ARGS(SkImage_Gpu, (bitmap, sampleCount)); 93 return SkNEW_ARGS(SkImage_Gpu, (bitmap, sampleCountForNewSurfaces));
94 } 94 }
95 95
96 SkImage* SkImage::NewTexture(const SkBitmap& bitmap) { 96 SkImage* SkImage::NewTexture(const SkBitmap& bitmap) {
97 return SkNewImageFromBitmapTexture(bitmap, 0); 97 return SkNewImageFromBitmapTexture(bitmap, 0);
98 } 98 }
99 99
100 GrTexture* SkTextureImageGetTexture(SkImage* image) { 100 GrTexture* SkTextureImageGetTexture(SkImage* image) {
101 return ((SkImage_Gpu*)image)->getTexture(); 101 return ((SkImage_Gpu*)image)->getTexture();
102 } 102 }
103 103
OLDNEW
« no previous file with comments | « src/image/SkImagePriv.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698