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

Unified Diff: src/images/SkDecodingImageGenerator.cpp

Issue 74793011: Add SkImageGenerator Interface (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: whitespace Created 7 years, 1 month 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/images/SkDecodingImageGenerator.h ('k') | src/lazy/SkDiscardablePixelRef.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkDecodingImageGenerator.cpp
diff --git a/src/images/SkDecodingImageGenerator.cpp b/src/images/SkDecodingImageGenerator.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..65fa6fd5612abfec9f803943a7fe1e4ab0540c18
--- /dev/null
+++ b/src/images/SkDecodingImageGenerator.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkDecodingImageGenerator.h"
+
+#include "SkBitmapFactory.h"
+#include "SkData.h"
+#include "SkDiscardablePixelRef.h"
+#include "SkImageDecoder.h"
+
+SkDecodingImageGenerator::SkDecodingImageGenerator(SkData* data)
+ : fData(data) {
+ SkASSERT(fData != NULL);
+ fData->ref();
+}
+
+SkDecodingImageGenerator::~SkDecodingImageGenerator() {
+ fData->unref();
+}
+
+SkData* SkDecodingImageGenerator::refEncodedData() {
+ fData->ref();
+ return fData;
+}
+
+bool SkDecodingImageGenerator::getInfo(SkImageInfo* info) {
+ SkASSERT(info != NULL);
+ return SkImageDecoder::DecodeMemoryToTarget(fData->data(),
+ fData->size(),
+ info, NULL);
+}
+
+bool SkDecodingImageGenerator::getPixels(const SkImageInfo& info,
+ void* pixels,
+ size_t rowBytes) {
+ SkASSERT(pixels != NULL);
+ SkBitmapFactory::Target target = {pixels, rowBytes};
+ SkImageInfo tmpInfo = info;
+ return SkImageDecoder::DecodeMemoryToTarget(fData->data(),
+ fData->size(),
+ &tmpInfo, &target);
+}
+bool SkDecodingImageGenerator::Install(SkData* data, SkBitmap* dst) {
+ SkASSERT(data != NULL);
+ SkASSERT(dst != NULL);
+ SkImageGenerator* gen(SkNEW_ARGS(SkDecodingImageGenerator, (data)));
+ return SkDiscardablePixelRef::Install(gen, dst);
+}
« no previous file with comments | « src/images/SkDecodingImageGenerator.h ('k') | src/lazy/SkDiscardablePixelRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698