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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « include/core/SkImageGenerator.h ('k') | src/core/SkPictureImageGenerator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkImageGenerator.h" 8 #include "SkImageGenerator.h"
9 #include "SkNextID.h" 9 #include "SkNextID.h"
10 10
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 return this->onGetYUV8Planes(sizes, planes, rowBytes); 104 return this->onGetYUV8Planes(sizes, planes, rowBytes);
105 } 105 }
106 106
107 GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, const SkIRect* subs et) { 107 GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, const SkIRect* subs et) {
108 if (subset && !SkIRect::MakeWH(fInfo.width(), fInfo.height()).contains(*subs et)) { 108 if (subset && !SkIRect::MakeWH(fInfo.width(), fInfo.height()).contains(*subs et)) {
109 return nullptr; 109 return nullptr;
110 } 110 }
111 return this->onGenerateTexture(ctx, subset); 111 return this->onGenerateTexture(ctx, subset);
112 } 112 }
113 113
114 bool SkImageGenerator::computeScaledDimensions(SkScalar scale, SupportedSizes* s izes) {
115 if (scale > 0 && scale <= 1) {
116 return this->onComputeScaledDimensions(scale, sizes);
117 }
118 return false;
119 }
120
121 bool SkImageGenerator::generateScaledPixels(const SkISize& scaledSize,
122 const SkIPoint& subsetOrigin,
123 const SkPixmap& subsetPixels) {
124 if (scaledSize.width() <= 0 || scaledSize.height() <= 0) {
125 return false;
126 }
127 if (subsetPixels.width() <= 0 || subsetPixels.height() <= 0) {
128 return false;
129 }
130 const SkIRect subset = SkIRect::MakeXYWH(subsetOrigin.x(), subsetOrigin.y(),
131 subsetPixels.width(), subsetPixels. height());
132 if (!SkIRect::MakeWH(scaledSize.width(), scaledSize.height()).contains(subse t)) {
133 return false;
134 }
135 return this->onGenerateScaledPixels(scaledSize, subsetOrigin, subsetPixels);
136 }
137
114 //////////////////////////////////////////////////////////////////////////////// ///////////// 138 //////////////////////////////////////////////////////////////////////////////// /////////////
115 139
116 SkData* SkImageGenerator::onRefEncodedData() { 140 SkData* SkImageGenerator::onRefEncodedData() {
117 return nullptr; 141 return nullptr;
118 } 142 }
119 143
120 bool SkImageGenerator::onGetPixels(const SkImageInfo& info, void* dst, size_t rb , 144 bool SkImageGenerator::onGetPixels(const SkImageInfo& info, void* dst, size_t rb ,
121 SkPMColor* colors, int* colorCount) { 145 SkPMColor* colors, int* colorCount) {
122 return false; 146 return false;
123 } 147 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 if (nullptr == data) { 238 if (nullptr == data) {
215 return nullptr; 239 return nullptr;
216 } 240 }
217 if (gFactory) { 241 if (gFactory) {
218 if (SkImageGenerator* generator = gFactory(data)) { 242 if (SkImageGenerator* generator = gFactory(data)) {
219 return generator; 243 return generator;
220 } 244 }
221 } 245 }
222 return SkImageGenerator::NewFromEncodedImpl(data); 246 return SkImageGenerator::NewFromEncodedImpl(data);
223 } 247 }
OLDNEW
« 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