1 /* 2 * Copyright 2012 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkImage_Base_DEFINED 9 #define SkImage_Base_DEFINED 10 11 #include "SkImage.h" 12 13 class SkImage_Base : public SkImage { 14 public: SkImage_Base(int width,int height)15 SkImage_Base(int width, int height) : INHERITED(width, height) {} 16 17 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const = 0; 18 virtual void onDrawRectToRect(SkCanvas*, const SkRect* src, 19 const SkRect& dst, const SkPaint*) const = 0; 20 21 // Default impl calls onDraw 22 virtual bool onReadPixels(SkBitmap*, const SkIRect& subset) const; 23 onPeekPixels(SkImageInfo *,size_t *)24 virtual const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const { 25 return NULL; 26 } 27 onGetTexture()28 virtual GrTexture* onGetTexture() const { return NULL; } 29 30 // return a read-only copy of the pixels. We promise to not modify them, 31 // but only inspect them (or encode them). getROPixels(SkBitmap *)32 virtual bool getROPixels(SkBitmap*) const { return false; } 33 onNewShader(SkShader::TileMode,SkShader::TileMode,const SkMatrix * localMatrix)34 virtual SkShader* onNewShader(SkShader::TileMode, 35 SkShader::TileMode, 36 const SkMatrix* localMatrix) const { return NULL; }; 37 private: 38 typedef SkImage INHERITED; 39 }; 40 41 #endif 42