OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |