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

Unified Diff: src/core/SkImageGenerator.cpp

Issue 1396323007: API to support native scaling by image-generator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: mark test image as opaque, so jpeg has a chance of encoding it Created 5 years 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 | « include/core/SkImageGenerator.h ('k') | src/core/SkPictureImageGenerator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkImageGenerator.cpp
diff --git a/src/core/SkImageGenerator.cpp b/src/core/SkImageGenerator.cpp
index 5e401920cd97a68cf5cb5e88e73a3fa9d6092c99..dcd3ad00b17e812d27b647360b9f4529463124f5 100644
--- a/src/core/SkImageGenerator.cpp
+++ b/src/core/SkImageGenerator.cpp
@@ -111,6 +111,30 @@ GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, const SkIRect* subs
return this->onGenerateTexture(ctx, subset);
}
+bool SkImageGenerator::computeScaledDimensions(SkScalar scale, SupportedSizes* sizes) {
+ if (scale > 0 && scale <= 1) {
+ return this->onComputeScaledDimensions(scale, sizes);
+ }
+ return false;
+}
+
+bool SkImageGenerator::generateScaledPixels(const SkISize& scaledSize,
+ const SkIPoint& subsetOrigin,
+ const SkPixmap& subsetPixels) {
+ if (scaledSize.width() <= 0 || scaledSize.height() <= 0) {
+ return false;
+ }
+ if (subsetPixels.width() <= 0 || subsetPixels.height() <= 0) {
+ return false;
+ }
+ const SkIRect subset = SkIRect::MakeXYWH(subsetOrigin.x(), subsetOrigin.y(),
+ subsetPixels.width(), subsetPixels.height());
+ if (!SkIRect::MakeWH(scaledSize.width(), scaledSize.height()).contains(subset)) {
+ return false;
+ }
+ return this->onGenerateScaledPixels(scaledSize, subsetOrigin, subsetPixels);
+}
+
/////////////////////////////////////////////////////////////////////////////////////////////
SkData* SkImageGenerator::onRefEncodedData() {
« no previous file with comments | « include/core/SkImageGenerator.h ('k') | src/core/SkPictureImageGenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698