OLD | NEW |
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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 virtual void onDrawRectToRect(SkCanvas*, const SkRect* src, const SkRect& ds
t, | 24 virtual void onDrawRectToRect(SkCanvas*, const SkRect* src, const SkRect& ds
t, |
25 const SkPaint*) const SK_OVERRIDE; | 25 const SkPaint*) const SK_OVERRIDE; |
26 virtual GrTexture* onGetTexture() const SK_OVERRIDE; | 26 virtual GrTexture* onGetTexture() const SK_OVERRIDE; |
27 virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE; | 27 virtual 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 virtual SkShader* onNewShader(SkShader::TileMode, | 31 virtual 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 | |
35 virtual bool isOpaque() const SK_OVERRIDE; | |
36 | |
37 private: | 34 private: |
38 SkBitmap fBitmap; | 35 SkBitmap fBitmap; |
39 | 36 |
40 typedef SkImage_Base INHERITED; | 37 typedef SkImage_Base INHERITED; |
41 }; | 38 }; |
42 | 39 |
43 /////////////////////////////////////////////////////////////////////////////// | 40 /////////////////////////////////////////////////////////////////////////////// |
44 | 41 |
45 SkImage_Gpu::SkImage_Gpu(const SkBitmap& bitmap) | 42 SkImage_Gpu::SkImage_Gpu(const SkBitmap& bitmap) |
46 : INHERITED(bitmap.width(), bitmap.height()) | 43 : INHERITED(bitmap.width(), bitmap.height()) |
(...skipping 21 matching lines...) Expand all Loading... |
68 } | 65 } |
69 | 66 |
70 GrTexture* SkImage_Gpu::onGetTexture() const { | 67 GrTexture* SkImage_Gpu::onGetTexture() const { |
71 return fBitmap.getTexture(); | 68 return fBitmap.getTexture(); |
72 } | 69 } |
73 | 70 |
74 bool SkImage_Gpu::getROPixels(SkBitmap* dst) const { | 71 bool SkImage_Gpu::getROPixels(SkBitmap* dst) const { |
75 return fBitmap.copyTo(dst, kN32_SkColorType); | 72 return fBitmap.copyTo(dst, kN32_SkColorType); |
76 } | 73 } |
77 | 74 |
78 bool SkImage_Gpu::isOpaque() const { | |
79 return fBitmap.isOpaque(); | |
80 } | |
81 | |
82 /////////////////////////////////////////////////////////////////////////////// | 75 /////////////////////////////////////////////////////////////////////////////// |
83 | 76 |
84 SkImage* SkImage::NewTexture(const SkBitmap& bitmap) { | 77 SkImage* SkImage::NewTexture(const SkBitmap& bitmap) { |
85 if (NULL == bitmap.getTexture()) { | 78 if (NULL == bitmap.getTexture()) { |
86 return NULL; | 79 return NULL; |
87 } | 80 } |
88 | 81 |
89 return SkNEW_ARGS(SkImage_Gpu, (bitmap)); | 82 return SkNEW_ARGS(SkImage_Gpu, (bitmap)); |
90 } | 83 } |
91 | 84 |
92 GrTexture* SkTextureImageGetTexture(SkImage* image) { | 85 GrTexture* SkTextureImageGetTexture(SkImage* image) { |
93 return ((SkImage_Gpu*)image)->getTexture(); | 86 return ((SkImage_Gpu*)image)->getTexture(); |
94 } | 87 } |
OLD | NEW |