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

Side by Side Diff: gm/image.cpp

Issue 2250663002: Add alphaType() to SkImage (Closed) Base URL: https://skia.googlesource.com/skia.git@special-image-alpha-type
Patch Set: Remove virtuals from SkImage, slight cleanup Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | include/core/SkImage.h » ('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 2011 Google Inc. 2 * Copyright 2011 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 <functional> 8 #include <functional>
9 #include "gm.h" 9 #include "gm.h"
10 #include "SkAutoPixmapStorage.h" 10 #include "SkAutoPixmapStorage.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 private: 296 private:
297 typedef skiagm::GM INHERITED; 297 typedef skiagm::GM INHERITED;
298 }; 298 };
299 DEF_GM( return new ScalePixelsGM; ) 299 DEF_GM( return new ScalePixelsGM; )
300 300
301 //////////////////////////////////////////////////////////////////////////////// /////////////////// 301 //////////////////////////////////////////////////////////////////////////////// ///////////////////
302 302
303 #include "SkImageGenerator.h" 303 #include "SkImageGenerator.h"
304 304
305 static SkImageInfo make_info(SkImage* img) { 305 static SkImageInfo make_info(SkImage* img) {
306 return SkImageInfo::MakeN32(img->width(), img->height(), 306 return SkImageInfo::MakeN32(img->width(), img->height(), img->alphaType());
307 img->isOpaque() ? kOpaque_SkAlphaType : kPremul_ SkAlphaType);
308 } 307 }
309 308
310 // Its simple, but I wonder if we should expose this formally? 309 // Its simple, but I wonder if we should expose this formally?
311 // 310 //
312 class ImageGeneratorFromImage : public SkImageGenerator { 311 class ImageGeneratorFromImage : public SkImageGenerator {
313 public: 312 public:
314 ImageGeneratorFromImage(SkImage* img) : INHERITED(make_info(img)), fImg(SkRe f(img)) {} 313 ImageGeneratorFromImage(SkImage* img) : INHERITED(make_info(img)), fImg(SkRe f(img)) {}
315 314
316 protected: 315 protected:
317 bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkP MColor ctable[], 316 bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkP MColor ctable[],
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 } 500 }
502 if (context) { 501 if (context) {
503 sk_sp<SkImage> texImage(image->makeTextureImage(context)); 502 sk_sp<SkImage> texImage(image->makeTextureImage(context));
504 if (texImage) { 503 if (texImage) {
505 canvas->drawImage(texImage, 0, 0); 504 canvas->drawImage(texImage, 0, 0);
506 } 505 }
507 } 506 }
508 canvas->translate(image->width() + kPad, 0); 507 canvas->translate(image->width() + kPad, 0);
509 } 508 }
510 } 509 }
OLDNEW
« no previous file with comments | « no previous file | include/core/SkImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698