| 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 "SkSurface_Base.h" | 8 #include "SkSurface_Base.h" |
| 9 #include "SkImagePriv.h" | 9 #include "SkImagePriv.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 private: | 32 private: |
| 33 SkBitmap fBitmap; | 33 SkBitmap fBitmap; |
| 34 bool fWeOwnThePixels; | 34 bool fWeOwnThePixels; |
| 35 | 35 |
| 36 typedef SkSurface_Base INHERITED; | 36 typedef SkSurface_Base INHERITED; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 /////////////////////////////////////////////////////////////////////////////// | 39 /////////////////////////////////////////////////////////////////////////////// |
| 40 | 40 |
| 41 bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) { | 41 bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) { |
| 42 if (info.isEmpty()) { |
| 43 return false; |
| 44 } |
| 45 |
| 42 static const size_t kMaxTotalSize = SK_MaxS32; | 46 static const size_t kMaxTotalSize = SK_MaxS32; |
| 43 | 47 |
| 44 int shift = 0; | 48 int shift = 0; |
| 45 switch (info.colorType()) { | 49 switch (info.colorType()) { |
| 46 case kAlpha_8_SkColorType: | 50 case kAlpha_8_SkColorType: |
| 47 shift = 0; | 51 shift = 0; |
| 48 break; | 52 break; |
| 49 case kRGB_565_SkColorType: | 53 case kRGB_565_SkColorType: |
| 50 shift = 1; | 54 shift = 1; |
| 51 break; | 55 break; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 if (!SkSurface_Raster::Valid(info)) { | 169 if (!SkSurface_Raster::Valid(info)) { |
| 166 return NULL; | 170 return NULL; |
| 167 } | 171 } |
| 168 | 172 |
| 169 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL)); | 173 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL)); |
| 170 if (NULL == pr.get()) { | 174 if (NULL == pr.get()) { |
| 171 return NULL; | 175 return NULL; |
| 172 } | 176 } |
| 173 return SkNEW_ARGS(SkSurface_Raster, (pr, props)); | 177 return SkNEW_ARGS(SkSurface_Raster, (pr, props)); |
| 174 } | 178 } |
| OLD | NEW |