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

Unified Diff: src/effects/SkBitmapSource.cpp

Issue 395603002: Simplify flattening to just write enough to call the factory (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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/effects/SkAvoidXfermode.cpp ('k') | src/effects/SkBlurDrawLooper.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkBitmapSource.cpp
diff --git a/src/effects/SkBitmapSource.cpp b/src/effects/SkBitmapSource.cpp
index d8d4329e655a5a698b15eda987944934a50ac60e..aee4a361f2050b2bf96d612fa8151c50cf2bf3c1 100644
--- a/src/effects/SkBitmapSource.cpp
+++ b/src/effects/SkBitmapSource.cpp
@@ -13,12 +13,12 @@
#include "SkValidationUtils.h"
SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap)
- : INHERITED(0, 0),
- fBitmap(bitmap),
- fSrcRect(SkRect::MakeWH(SkIntToScalar(bitmap.width()),
- SkIntToScalar(bitmap.height()))),
- fDstRect(fSrcRect) {
-}
+ : INHERITED(0, 0)
+ , fBitmap(bitmap)
+ , fSrcRect(SkRect::MakeWH(SkIntToScalar(bitmap.width()),
+ SkIntToScalar(bitmap.height())))
+ , fDstRect(fSrcRect)
+{}
SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap, const SkRect& srcRect, const SkRect& dstRect)
: INHERITED(0, 0)
@@ -26,6 +26,7 @@ SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap, const SkRect& srcRect, co
, fSrcRect(srcRect)
, fDstRect(dstRect) {}
+#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
SkBitmapSource::SkBitmapSource(SkReadBuffer& buffer) : INHERITED(0, buffer) {
if (buffer.isVersionLT(SkReadBuffer::kNoMoreBitmapFlatten_Version)) {
fBitmap.legacyUnflatten(buffer);
@@ -36,12 +37,23 @@ SkBitmapSource::SkBitmapSource(SkReadBuffer& buffer) : INHERITED(0, buffer) {
buffer.readRect(&fDstRect);
buffer.validate(buffer.isValid() && SkIsValidRect(fSrcRect) && SkIsValidRect(fDstRect));
}
+#endif
+
+SkFlattenable* SkBitmapSource::CreateProc(SkReadBuffer& buffer) {
+ SkRect src, dst;
+ buffer.readRect(&src);
+ buffer.readRect(&dst);
+ SkBitmap bitmap;
+ if (!buffer.readBitmap(&bitmap)) {
+ return NULL;
+ }
+ return SkBitmapSource::Create(bitmap, src, dst);
+}
void SkBitmapSource::flatten(SkWriteBuffer& buffer) const {
- this->INHERITED::flatten(buffer);
- buffer.writeBitmap(fBitmap);
buffer.writeRect(fSrcRect);
buffer.writeRect(fDstRect);
+ buffer.writeBitmap(fBitmap);
}
bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const Context& ctx,
« no previous file with comments | « src/effects/SkAvoidXfermode.cpp ('k') | src/effects/SkBlurDrawLooper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698