| 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 #ifndef SkImage_DEFINED | 8 #ifndef SkImage_DEFINED |
| 9 #define SkImage_DEFINED | 9 #define SkImage_DEFINED |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * SkImage is an abstraction for drawing a rectagle of pixels, though the | 27 * SkImage is an abstraction for drawing a rectagle of pixels, though the |
| 28 * particular type of image could be actually storing its data on the GPU, or | 28 * particular type of image could be actually storing its data on the GPU, or |
| 29 * as drawing commands (picture or PDF or otherwise), ready to be played back | 29 * as drawing commands (picture or PDF or otherwise), ready to be played back |
| 30 * into another canvas. | 30 * into another canvas. |
| 31 * | 31 * |
| 32 * The content of SkImage is always immutable, though the actual storage may | 32 * The content of SkImage is always immutable, though the actual storage may |
| 33 * change, if for example that image can be re-created via encoded data or | 33 * change, if for example that image can be re-created via encoded data or |
| 34 * other means. | 34 * other means. |
| 35 * |
| 36 * SkImage always has a non-zero dimensions. If there is a request to create a
new image, either |
| 37 * directly or via SkSurface, and either of the requested dimensions are zero,
then NULL will be |
| 38 * returned. |
| 35 */ | 39 */ |
| 36 class SK_API SkImage : public SkRefCnt { | 40 class SK_API SkImage : public SkRefCnt { |
| 37 public: | 41 public: |
| 38 SK_DECLARE_INST_COUNT(SkImage) | 42 SK_DECLARE_INST_COUNT(SkImage) |
| 39 | 43 |
| 40 typedef SkImageInfo Info; | 44 typedef SkImageInfo Info; |
| 41 | 45 |
| 42 static SkImage* NewRasterCopy(const Info&, const void* pixels, size_t rowByt
es); | 46 static SkImage* NewRasterCopy(const Info&, const void* pixels, size_t rowByt
es); |
| 43 static SkImage* NewRasterData(const Info&, SkData* pixels, size_t rowBytes); | 47 static SkImage* NewRasterData(const Info&, SkData* pixels, size_t rowBytes); |
| 44 | 48 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 * was created (if it came from a surface). | 127 * was created (if it came from a surface). |
| 124 */ | 128 */ |
| 125 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps* = NULL) cons
t; | 129 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps* = NULL) cons
t; |
| 126 | 130 |
| 127 protected: | 131 protected: |
| 128 SkImage(int width, int height) : | 132 SkImage(int width, int height) : |
| 129 fWidth(width), | 133 fWidth(width), |
| 130 fHeight(height), | 134 fHeight(height), |
| 131 fUniqueID(NextUniqueID()) { | 135 fUniqueID(NextUniqueID()) { |
| 132 | 136 |
| 133 SkASSERT(width >= 0); | 137 SkASSERT(width > 0); |
| 134 SkASSERT(height >= 0); | 138 SkASSERT(height > 0); |
| 135 } | 139 } |
| 136 | 140 |
| 137 private: | 141 private: |
| 138 const int fWidth; | 142 const int fWidth; |
| 139 const int fHeight; | 143 const int fHeight; |
| 140 const uint32_t fUniqueID; | 144 const uint32_t fUniqueID; |
| 141 | 145 |
| 142 static uint32_t NextUniqueID(); | 146 static uint32_t NextUniqueID(); |
| 143 | 147 |
| 144 typedef SkRefCnt INHERITED; | 148 typedef SkRefCnt INHERITED; |
| 145 | 149 |
| 146 friend class SkCanvas; | 150 friend class SkCanvas; |
| 147 | 151 |
| 148 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const; | 152 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const; |
| 149 | 153 |
| 150 /** | 154 /** |
| 151 * Draw the image, cropped to the src rect, to the dst rect of a canvas. | 155 * Draw the image, cropped to the src rect, to the dst rect of a canvas. |
| 152 * If src is larger than the bounds of the image, the rest of the image is | 156 * If src is larger than the bounds of the image, the rest of the image is |
| 153 * filled with transparent black pixels. | 157 * filled with transparent black pixels. |
| 154 * | 158 * |
| 155 * See SkCanvas::drawBitmapRectToRect for similar behavior. | 159 * See SkCanvas::drawBitmapRectToRect for similar behavior. |
| 156 */ | 160 */ |
| 157 void drawRect(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint
*) const; | 161 void drawRect(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint
*) const; |
| 158 }; | 162 }; |
| 159 | 163 |
| 160 #endif | 164 #endif |
| OLD | NEW |