| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, void* pixels, size_t
rb) | 79 SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, void* pixels, size_t
rb) |
| 80 : INHERITED(info) | 80 : INHERITED(info) |
| 81 { | 81 { |
| 82 fBitmap.setConfig(info, rb); | 82 fBitmap.setConfig(info, rb); |
| 83 fBitmap.setPixels(pixels); | 83 fBitmap.setPixels(pixels); |
| 84 fWeOwnThePixels = false; // We are "Direct" | 84 fWeOwnThePixels = false; // We are "Direct" |
| 85 } | 85 } |
| 86 | 86 |
| 87 SkSurface_Raster::SkSurface_Raster(SkPixelRef* pr) | 87 SkSurface_Raster::SkSurface_Raster(SkPixelRef* pr) |
| 88 : INHERITED(pr->info()) | 88 : INHERITED(pr->info().fWidth, pr->info().fHeight) |
| 89 { | 89 { |
| 90 fBitmap.installPixelRef(pr); | 90 const SkImageInfo& info = pr->info(); |
| 91 |
| 92 fBitmap.setConfig(info, info.minRowBytes()); |
| 93 fBitmap.setPixelRef(pr); |
| 91 fWeOwnThePixels = true; | 94 fWeOwnThePixels = true; |
| 92 | 95 |
| 93 if (!pr->info().isOpaque()) { | 96 if (!info.isOpaque()) { |
| 94 fBitmap.eraseColor(SK_ColorTRANSPARENT); | 97 fBitmap.eraseColor(SK_ColorTRANSPARENT); |
| 95 } | 98 } |
| 96 } | 99 } |
| 97 | 100 |
| 98 SkCanvas* SkSurface_Raster::onNewCanvas() { | 101 SkCanvas* SkSurface_Raster::onNewCanvas() { |
| 99 return SkNEW_ARGS(SkCanvas, (fBitmap)); | 102 return SkNEW_ARGS(SkCanvas, (fBitmap)); |
| 100 } | 103 } |
| 101 | 104 |
| 102 SkSurface* SkSurface_Raster::onNewSurface(const SkImageInfo& info) { | 105 SkSurface* SkSurface_Raster::onNewSurface(const SkImageInfo& info) { |
| 103 return SkSurface::NewRaster(info); | 106 return SkSurface::NewRaster(info); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if (!SkSurface_Raster::Valid(info)) { | 152 if (!SkSurface_Raster::Valid(info)) { |
| 150 return NULL; | 153 return NULL; |
| 151 } | 154 } |
| 152 | 155 |
| 153 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL)); | 156 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL)); |
| 154 if (NULL == pr.get()) { | 157 if (NULL == pr.get()) { |
| 155 return NULL; | 158 return NULL; |
| 156 } | 159 } |
| 157 return SkNEW_ARGS(SkSurface_Raster, (pr)); | 160 return SkNEW_ARGS(SkSurface_Raster, (pr)); |
| 158 } | 161 } |
| OLD | NEW |