| 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, SkShader::TileMode, SkMatr
ix* localMatrix = NULL) const SK_OVERRIDE; |
| 31 private: | 31 private: |
| 32 SkBitmap fBitmap; | 32 SkBitmap fBitmap; |
| 33 | 33 |
| 34 typedef SkImage_Base INHERITED; | 34 typedef SkImage_Base INHERITED; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 /////////////////////////////////////////////////////////////////////////////// | 37 /////////////////////////////////////////////////////////////////////////////// |
| 38 | 38 |
| 39 SkImage_Gpu::SkImage_Gpu(const SkBitmap& bitmap) | 39 SkImage_Gpu::SkImage_Gpu(const SkBitmap& bitmap) |
| 40 : INHERITED(bitmap.width(), bitmap.height()) | 40 : INHERITED(bitmap.width(), bitmap.height()) |
| 41 , fBitmap(bitmap) { | 41 , fBitmap(bitmap) { |
| 42 SkASSERT(NULL != fBitmap.getTexture()); | 42 SkASSERT(NULL != fBitmap.getTexture()); |
| 43 } | 43 } |
| 44 | 44 |
| 45 SkImage_Gpu::~SkImage_Gpu() { | 45 SkImage_Gpu::~SkImage_Gpu() { |
| 46 } | 46 } |
| 47 | 47 |
| 48 SkShader* SkImage_Gpu::onNewShader(SkShader::TileMode tileX, SkShader::TileMode
tileY) const { | 48 SkShader* SkImage_Gpu::onNewShader(SkShader::TileMode tileX, SkShader::TileMode
tileY, SkMatrix* localMatrix) const { |
| 49 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, NULL); | 49 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, localMatrix); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void SkImage_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, | 52 void SkImage_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, |
| 53 const SkPaint* paint) { | 53 const SkPaint* paint) { |
| 54 canvas->drawBitmap(fBitmap, x, y, paint); | 54 canvas->drawBitmap(fBitmap, x, y, paint); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void SkImage_Gpu::onDrawRectToRect(SkCanvas* canvas, const SkRect* src, const Sk
Rect& dst, | 57 void SkImage_Gpu::onDrawRectToRect(SkCanvas* canvas, const SkRect* src, const Sk
Rect& dst, |
| 58 const SkPaint* paint) { | 58 const SkPaint* paint) { |
| 59 canvas->drawBitmapRectToRect(fBitmap, src, dst, paint); | 59 canvas->drawBitmapRectToRect(fBitmap, src, dst, paint); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 73 if (NULL == bitmap.getTexture()) { | 73 if (NULL == bitmap.getTexture()) { |
| 74 return NULL; | 74 return NULL; |
| 75 } | 75 } |
| 76 | 76 |
| 77 return SkNEW_ARGS(SkImage_Gpu, (bitmap)); | 77 return SkNEW_ARGS(SkImage_Gpu, (bitmap)); |
| 78 } | 78 } |
| 79 | 79 |
| 80 GrTexture* SkTextureImageGetTexture(SkImage* image) { | 80 GrTexture* SkTextureImageGetTexture(SkImage* image) { |
| 81 return ((SkImage_Gpu*)image)->getTexture(); | 81 return ((SkImage_Gpu*)image)->getTexture(); |
| 82 } | 82 } |
| OLD | NEW |