| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 SkSurface* SkSurface_Raster::onNewSurface(const SkImageInfo& info) { | 108 SkSurface* SkSurface_Raster::onNewSurface(const SkImageInfo& info) { |
| 109 return SkSurface::NewRaster(info); | 109 return SkSurface::NewRaster(info); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void SkSurface_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, | 112 void SkSurface_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, |
| 113 const SkPaint* paint) { | 113 const SkPaint* paint) { |
| 114 canvas->drawBitmap(fBitmap, x, y, paint); | 114 canvas->drawBitmap(fBitmap, x, y, paint); |
| 115 } | 115 } |
| 116 | 116 |
| 117 SkImage* SkSurface_Raster::onNewImageSnapshot() { | 117 SkImage* SkSurface_Raster::onNewImageSnapshot() { |
| 118 return SkNewImageFromBitmap(fBitmap, fWeOwnThePixels); | 118 return SkNewImageFromBitmap(fBitmap, fWeOwnThePixels, &this->props()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) { | 121 void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) { |
| 122 // are we sharing pixelrefs with the image? | 122 // are we sharing pixelrefs with the image? |
| 123 SkASSERT(this->getCachedImage()); | 123 SkASSERT(this->getCachedImage()); |
| 124 if (SkBitmapImageGetPixelRef(this->getCachedImage()) == fBitmap.pixelRef())
{ | 124 if (SkBitmapImageGetPixelRef(this->getCachedImage()) == fBitmap.pixelRef())
{ |
| 125 SkASSERT(fWeOwnThePixels); | 125 SkASSERT(fWeOwnThePixels); |
| 126 if (kDiscard_ContentChangeMode == mode) { | 126 if (kDiscard_ContentChangeMode == mode) { |
| 127 fBitmap.setPixelRef(NULL); | 127 fBitmap.setPixelRef(NULL); |
| 128 fBitmap.allocPixels(); | 128 fBitmap.allocPixels(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 if (!SkSurface_Raster::Valid(info)) { | 165 if (!SkSurface_Raster::Valid(info)) { |
| 166 return NULL; | 166 return NULL; |
| 167 } | 167 } |
| 168 | 168 |
| 169 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL)); | 169 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL)); |
| 170 if (NULL == pr.get()) { | 170 if (NULL == pr.get()) { |
| 171 return NULL; | 171 return NULL; |
| 172 } | 172 } |
| 173 return SkNEW_ARGS(SkSurface_Raster, (pr, props)); | 173 return SkNEW_ARGS(SkSurface_Raster, (pr, props)); |
| 174 } | 174 } |
| OLD | NEW |