Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: src/image/SkImage_Raster.cpp

Issue 791473006: fix images in multi-thread by doing shallow-copies (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkMultiPictureDraw.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 124 }
125 125
126 SkImage_Raster::~SkImage_Raster() {} 126 SkImage_Raster::~SkImage_Raster() {}
127 127
128 SkShader* SkImage_Raster::onNewShader(SkShader::TileMode tileX, SkShader::TileMo de tileY, 128 SkShader* SkImage_Raster::onNewShader(SkShader::TileMode tileX, SkShader::TileMo de tileY,
129 const SkMatrix* localMatrix) const { 129 const SkMatrix* localMatrix) const {
130 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, localMatrix); 130 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, localMatrix);
131 } 131 }
132 132
133 void SkImage_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPa int* paint) const { 133 void SkImage_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPa int* paint) const {
134 canvas->drawBitmap(fBitmap, x, y, paint); 134 SkBitmap shallowCopy(fBitmap);
135 canvas->drawBitmap(shallowCopy, x, y, paint);
135 } 136 }
136 137
137 void SkImage_Raster::onDrawRect(SkCanvas* canvas, const SkRect* src, const SkRec t& dst, 138 void SkImage_Raster::onDrawRect(SkCanvas* canvas, const SkRect* src, const SkRec t& dst,
138 const SkPaint* paint) const { 139 const SkPaint* paint) const {
139 canvas->drawBitmapRectToRect(fBitmap, src, dst, paint); 140 SkBitmap shallowCopy(fBitmap);
141 canvas->drawBitmapRectToRect(shallowCopy, src, dst, paint);
140 } 142 }
141 143
142 SkSurface* SkImage_Raster::onNewSurface(const SkImageInfo& info, const SkSurface Props& props) const { 144 SkSurface* SkImage_Raster::onNewSurface(const SkImageInfo& info, const SkSurface Props& props) const {
143 return SkSurface::NewRaster(info, &props); 145 return SkSurface::NewRaster(info, &props);
144 } 146 }
145 147
146 bool SkImage_Raster::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, s ize_t dstRowBytes, 148 bool SkImage_Raster::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, s ize_t dstRowBytes,
147 int srcX, int srcY) const { 149 int srcX, int srcY) const {
148 return fBitmap.readPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY); 150 SkBitmap shallowCopy(fBitmap);
151 return shallowCopy.readPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
149 } 152 }
150 153
151 const void* SkImage_Raster::onPeekPixels(SkImageInfo* infoPtr, size_t* rowBytesP tr) const { 154 const void* SkImage_Raster::onPeekPixels(SkImageInfo* infoPtr, size_t* rowBytesP tr) const {
152 const SkImageInfo info = fBitmap.info(); 155 const SkImageInfo info = fBitmap.info();
153 if ((kUnknown_SkColorType == info.colorType()) || !fBitmap.getPixels()) { 156 if ((kUnknown_SkColorType == info.colorType()) || !fBitmap.getPixels()) {
154 return NULL; 157 return NULL;
155 } 158 }
156 *infoPtr = info; 159 *infoPtr = info;
157 *rowBytesPtr = fBitmap.rowBytes(); 160 *rowBytesPtr = fBitmap.rowBytes();
158 return fBitmap.getPixels(); 161 return fBitmap.getPixels();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes, props)); 220 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes, props));
218 } 221 }
219 222
220 const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* image) { 223 const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* image) {
221 return ((const SkImage_Raster*)image)->getPixelRef(); 224 return ((const SkImage_Raster*)image)->getPixelRef();
222 } 225 }
223 226
224 bool SkImage_Raster::isOpaque() const { 227 bool SkImage_Raster::isOpaque() const {
225 return fBitmap.isOpaque(); 228 return fBitmap.isOpaque();
226 } 229 }
OLDNEW
« no previous file with comments | « src/core/SkMultiPictureDraw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698