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

Unified Diff: src/utils/SkBitmapSourceDeserializer.cpp

Issue 1363913002: Remove SkBitmapSource (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: immutable bitmap Created 5 years, 3 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/utils/SkBitmapSourceDeserializer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkBitmapSourceDeserializer.cpp
diff --git a/src/utils/SkBitmapSourceDeserializer.cpp b/src/utils/SkBitmapSourceDeserializer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bb783bfeef2b9c34eaf50cbab7af7a2f890d0b68
--- /dev/null
+++ b/src/utils/SkBitmapSourceDeserializer.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkBitmapSourceDeserializer.h"
+
+#include "SkBitmap.h"
+#include "SkFilterQuality.h"
+#include "SkImage.h"
+#include "SkImageSource.h"
+#include "SkReadBuffer.h"
+
+SkFlattenable* SkBitmapSourceDeserializer::CreateProc(SkReadBuffer& buffer) {
+ SkFilterQuality filterQuality;
+ if (buffer.isVersionLT(SkReadBuffer::kBitmapSourceFilterQuality_Version)) {
+ filterQuality = kHigh_SkFilterQuality;
+ } else {
+ filterQuality = (SkFilterQuality)buffer.readInt();
+ }
+ SkRect src, dst;
+ buffer.readRect(&src);
+ buffer.readRect(&dst);
+ SkBitmap bitmap;
+ if (!buffer.readBitmap(&bitmap)) {
+ return nullptr;
+ }
+ bitmap.setImmutable();
+
+ SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap(bitmap));
+ return SkImageSource::Create(image, src, dst, filterQuality);
+}
« no previous file with comments | « src/utils/SkBitmapSourceDeserializer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698