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 "SkData.h" | 12 #include "SkData.h" |
13 #include "SkDataPixelRef.h" | 13 #include "SkDataPixelRef.h" |
14 | 14 |
15 class SkImage_Raster : public SkImage_Base { | 15 class SkImage_Raster : public SkImage_Base { |
16 public: | 16 public: |
17 static bool ValidArgs(const Info& info, size_t rowBytes) { | 17 static bool ValidArgs(const Info& info, size_t rowBytes) { |
18 const int maxDimension = SK_MaxS32 >> 2; | 18 const int maxDimension = SK_MaxS32 >> 2; |
19 const size_t kMaxPixelByteSize = SK_MaxS32; | 19 const size_t kMaxPixelByteSize = SK_MaxS32; |
20 | 20 |
21 if (info.fWidth < 0 || info.fHeight < 0) { | 21 if (info.fWidth < 0 || info.fHeight < 0) { |
22 return false; | 22 return false; |
23 } | 23 } |
24 if (info.fWidth > maxDimension || info.fHeight > maxDimension) { | 24 if (info.fWidth > maxDimension || info.fHeight > maxDimension) { |
25 return false; | 25 return false; |
26 } | 26 } |
27 if ((unsigned)info.fColorType > (unsigned)kLastEnum_ColorType) { | 27 if ((unsigned)info.fColorType > (unsigned)kLastEnum_ColorType) { |
28 return false; | 28 return false; |
29 } | 29 } |
30 if ((unsigned)info.fAlphaType > (unsigned)kLastEnum_AlphaType) { | 30 if ((unsigned)info.fAlphaType > (unsigned)kLastEnum_SkAlphaType) { |
31 return false; | 31 return false; |
32 } | 32 } |
33 | 33 |
34 bool isOpaque; | 34 bool isOpaque; |
35 if (SkImageInfoToBitmapConfig(info, &isOpaque) == SkBitmap::kNo_Config)
{ | 35 if (SkImageInfoToBitmapConfig(info, &isOpaque) == SkBitmap::kNo_Config)
{ |
36 return false; | 36 return false; |
37 } | 37 } |
38 | 38 |
39 // TODO: check colorspace | 39 // TODO: check colorspace |
40 | 40 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 162 } |
163 | 163 |
164 SkImage* SkNewImageFromPixelRef(const SkImage::Info& info, SkPixelRef* pr, | 164 SkImage* SkNewImageFromPixelRef(const SkImage::Info& info, SkPixelRef* pr, |
165 size_t rowBytes) { | 165 size_t rowBytes) { |
166 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes)); | 166 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes)); |
167 } | 167 } |
168 | 168 |
169 SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) { | 169 SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) { |
170 return ((SkImage_Raster*)image)->getPixelRef(); | 170 return ((SkImage_Raster*)image)->getPixelRef(); |
171 } | 171 } |
OLD | NEW |