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

Unified Diff: src/image/SkImage_Codec.cpp

Issue 453613003: mark all SkImage methods const, so we can make it thread-safe (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/image/SkImage_Base.h ('k') | src/image/SkImage_Gpu.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImage_Codec.cpp
diff --git a/src/image/SkImage_Codec.cpp b/src/image/SkImage_Codec.cpp
index 3d815ce7f437409156b94c009a26e733ca77a270..21c844d01dd331b0f4235f215fc11ad494fb84bf 100644
--- a/src/image/SkImage_Codec.cpp
+++ b/src/image/SkImage_Codec.cpp
@@ -18,8 +18,9 @@ public:
SkImage_Codec(SkData* encodedData, int width, int height);
virtual ~SkImage_Codec();
- virtual void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) SK_OVERRIDE;
- virtual void onDrawRectToRect(SkCanvas*, const SkRect*, const SkRect&, const SkPaint*) SK_OVERRIDE;
+ virtual void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) const SK_OVERRIDE;
+ virtual void onDrawRectToRect(SkCanvas*, const SkRect*, const SkRect&,
+ const SkPaint*) const SK_OVERRIDE;
private:
SkData* fEncodedData;
@@ -39,19 +40,23 @@ SkImage_Codec::~SkImage_Codec() {
fEncodedData->unref();
}
-void SkImage_Codec::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) {
+void SkImage_Codec::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) const {
if (!fBitmap.pixelRef()) {
- if (!SkImageDecoder::DecodeMemory(fEncodedData->bytes(), fEncodedData->size(), &fBitmap)) {
+ // todo: this needs to be thread-safe
+ SkBitmap* bitmap = const_cast<SkBitmap*>(&fBitmap);
+ if (!SkImageDecoder::DecodeMemory(fEncodedData->bytes(), fEncodedData->size(), bitmap)) {
return;
}
}
canvas->drawBitmap(fBitmap, x, y, paint);
}
-void SkImage_Codec::onDrawRectToRect(SkCanvas* canvas, const SkRect* src,
- const SkRect& dst, const SkPaint* paint) {
+void SkImage_Codec::onDrawRectToRect(SkCanvas* canvas, const SkRect* src, const SkRect& dst,
+ const SkPaint* paint) const {
if (!fBitmap.pixelRef()) {
- if (!SkImageDecoder::DecodeMemory(fEncodedData->bytes(), fEncodedData->size(), &fBitmap)) {
+ // todo: this needs to be thread-safe
+ SkBitmap* bitmap = const_cast<SkBitmap*>(&fBitmap);
+ if (!SkImageDecoder::DecodeMemory(fEncodedData->bytes(), fEncodedData->size(), bitmap)) {
return;
}
}
« no previous file with comments | « src/image/SkImage_Base.h ('k') | src/image/SkImage_Gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698