diff options
author | reed <reed@google.com> | 2014-08-11 13:03:55 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-11 13:03:56 -0700 |
commit | 8572fc01ac4f6bdcf173b05417776abc55f729c1 (patch) | |
tree | cb00fa2127a5b0367b69caec22618f0a9fead6d7 /src/image/SkImage_Codec.cpp | |
parent | 3f860991ade1128e770c1268372f755a397e2942 (diff) |
mark all SkImage methods const, so we can make it thread-safe
BUG=skia:
R=mtklein@google.com, halcanary@google.com
Author: reed@google.com
Review URL: https://codereview.chromium.org/453613003
Diffstat (limited to 'src/image/SkImage_Codec.cpp')
-rw-r--r-- | src/image/SkImage_Codec.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/image/SkImage_Codec.cpp b/src/image/SkImage_Codec.cpp index 3d815ce7f4..21c844d01d 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; } } |