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" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "GrContext.h" | 12 #include "GrContext.h" |
13 #include "GrTexture.h" | 13 #include "GrTexture.h" |
14 #include "SkGrPixelRef.h" | 14 #include "SkGrPixelRef.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 explicit SkImage_Gpu(const SkBitmap&); | 20 explicit SkImage_Gpu(const SkBitmap&); |
21 virtual ~SkImage_Gpu(); | 21 virtual ~SkImage_Gpu(); |
22 | 22 |
23 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) SK_OV
ERRIDE; | 23 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) SK_OV
ERRIDE; |
24 virtual void onDrawRectToRect(SkCanvas*, const SkRect* src, const SkRect& ds
t, const SkPaint*) SK_OVERRIDE; | 24 virtual void onDrawRectToRect(SkCanvas*, const SkRect* src, const SkRect& ds
t, const SkPaint*) SK_OVERRIDE; |
25 virtual GrTexture* onGetTexture() SK_OVERRIDE; | 25 virtual GrTexture* onGetTexture() SK_OVERRIDE; |
26 virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE; | 26 virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE; |
27 | 27 |
28 GrTexture* getTexture() { return fBitmap.getTexture(); } | 28 GrTexture* getTexture() { return fBitmap.getTexture(); } |
29 | 29 |
30 virtual SkShader* onNewShader(SkShader::TileMode, SkShader::TileMode) const
SK_OVERRIDE; | 30 virtual SkShader* onNewShader(SkShader::TileMode, |
| 31 SkShader::TileMode, |
| 32 const SkMatrix* localMatrix) const SK_OVERRIDE
; |
31 private: | 33 private: |
32 SkBitmap fBitmap; | 34 SkBitmap fBitmap; |
33 | 35 |
34 typedef SkImage_Base INHERITED; | 36 typedef SkImage_Base INHERITED; |
35 }; | 37 }; |
36 | 38 |
37 /////////////////////////////////////////////////////////////////////////////// | 39 /////////////////////////////////////////////////////////////////////////////// |
38 | 40 |
39 SkImage_Gpu::SkImage_Gpu(const SkBitmap& bitmap) | 41 SkImage_Gpu::SkImage_Gpu(const SkBitmap& bitmap) |
40 : INHERITED(bitmap.width(), bitmap.height()) | 42 : INHERITED(bitmap.width(), bitmap.height()) |
41 , fBitmap(bitmap) { | 43 , fBitmap(bitmap) { |
42 SkASSERT(NULL != fBitmap.getTexture()); | 44 SkASSERT(NULL != fBitmap.getTexture()); |
43 } | 45 } |
44 | 46 |
45 SkImage_Gpu::~SkImage_Gpu() { | 47 SkImage_Gpu::~SkImage_Gpu() { |
46 } | 48 } |
47 | 49 |
48 SkShader* SkImage_Gpu::onNewShader(SkShader::TileMode tileX, SkShader::TileMode
tileY) const { | 50 SkShader* SkImage_Gpu::onNewShader(SkShader::TileMode tileX, |
49 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, NULL); | 51 SkShader::TileMode tileY, |
| 52 const SkMatrix* localMatrix) const |
| 53 { |
| 54 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, localMatrix); |
50 } | 55 } |
51 | 56 |
52 void SkImage_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, | 57 void SkImage_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, |
53 const SkPaint* paint) { | 58 const SkPaint* paint) { |
54 canvas->drawBitmap(fBitmap, x, y, paint); | 59 canvas->drawBitmap(fBitmap, x, y, paint); |
55 } | 60 } |
56 | 61 |
57 void SkImage_Gpu::onDrawRectToRect(SkCanvas* canvas, const SkRect* src, const Sk
Rect& dst, | 62 void SkImage_Gpu::onDrawRectToRect(SkCanvas* canvas, const SkRect* src, const Sk
Rect& dst, |
58 const SkPaint* paint) { | 63 const SkPaint* paint) { |
59 canvas->drawBitmapRectToRect(fBitmap, src, dst, paint); | 64 canvas->drawBitmapRectToRect(fBitmap, src, dst, paint); |
(...skipping 13 matching lines...) Expand all Loading... |
73 if (NULL == bitmap.getTexture()) { | 78 if (NULL == bitmap.getTexture()) { |
74 return NULL; | 79 return NULL; |
75 } | 80 } |
76 | 81 |
77 return SkNEW_ARGS(SkImage_Gpu, (bitmap)); | 82 return SkNEW_ARGS(SkImage_Gpu, (bitmap)); |
78 } | 83 } |
79 | 84 |
80 GrTexture* SkTextureImageGetTexture(SkImage* image) { | 85 GrTexture* SkTextureImageGetTexture(SkImage* image) { |
81 return ((SkImage_Gpu*)image)->getTexture(); | 86 return ((SkImage_Gpu*)image)->getTexture(); |
82 } | 87 } |
OLD | NEW |