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

Side by Side Diff: src/utils/SkImageGeneratorUtils.cpp

Issue 1404433002: Remove image usage type enum. Use GrTextureParams instead. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix no gpu build Created 5 years, 2 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 | « src/image/SkImage_Raster.cpp ('k') | tests/ReadPixelsTest.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 2015 Google Inc. 2 * Copyright 2015 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 "SkImageGeneratorUtils.h" 8 #include "SkImageGeneratorUtils.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "GrTexture.h" 49 #include "GrTexture.h"
50 #include "SkGrPriv.h" 50 #include "SkGrPriv.h"
51 51
52 class GeneratorFromTexture : public SkImageGenerator { 52 class GeneratorFromTexture : public SkImageGenerator {
53 public: 53 public:
54 GeneratorFromTexture(GrContext* ctx, GrTexture* tex, const SkImageInfo& info ) 54 GeneratorFromTexture(GrContext* ctx, GrTexture* tex, const SkImageInfo& info )
55 : SkImageGenerator(info), fCtx(ctx), fTexture(tex) 55 : SkImageGenerator(info), fCtx(ctx), fTexture(tex)
56 {} 56 {}
57 57
58 protected: 58 protected:
59 GrTexture* onGenerateTexture(GrContext* ctx, SkImageUsageType, const SkIRect * subset) override { 59 GrTexture* onGenerateTexture(GrContext* ctx, const GrTextureParams&,
60 const SkIRect* subset) override {
60 if (ctx) { 61 if (ctx) {
61 SkASSERT(ctx == fCtx.get()); 62 SkASSERT(ctx == fCtx.get());
62 } 63 }
63 64
64 if (!subset) { 65 if (!subset) {
65 return SkRef(fTexture.get()); 66 return SkRef(fTexture.get());
66 } 67 }
67 // need to copy the subset into a new texture 68 // need to copy the subset into a new texture
68 GrSurfaceDesc desc = fTexture->desc(); 69 GrSurfaceDesc desc = fTexture->desc();
69 desc.fWidth = subset->width(); 70 desc.fWidth = subset->width();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 public: 106 public:
106 GeneratorFromImage(const SkImage* image, const SkImageInfo& info) 107 GeneratorFromImage(const SkImage* image, const SkImageInfo& info)
107 : SkImageGenerator(info), fImage(image) {} 108 : SkImageGenerator(info), fImage(image) {}
108 109
109 protected: 110 protected:
110 bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, 111 bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
111 SkPMColor*, int*) override { 112 SkPMColor*, int*) override {
112 return fImage->readPixels(info, pixels, rowBytes, 0, 0); 113 return fImage->readPixels(info, pixels, rowBytes, 0, 0);
113 } 114 }
114 115
115 GrTexture* onGenerateTexture(GrContext* ctx, SkImageUsageType, const SkIRect * subset) override { 116 GrTexture* onGenerateTexture(GrContext* ctx, const GrTextureParams&,
117 const SkIRect* subset) override {
116 // waiting on https://code.google.com/p/skia/issues/detail?id=4233 118 // waiting on https://code.google.com/p/skia/issues/detail?id=4233
117 return nullptr; 119 return nullptr;
118 } 120 }
119 121
120 private: 122 private:
121 SkAutoTUnref<const SkImage> fImage; 123 SkAutoTUnref<const SkImage> fImage;
122 }; 124 };
123 125
124 SkImageGenerator* SkImageGeneratorUtils::NewFromImage(const SkImage* image) { 126 SkImageGenerator* SkImageGeneratorUtils::NewFromImage(const SkImage* image) {
125 if (image) { 127 if (image) {
126 const SkColorType ct = kN32_SkColorType; 128 const SkColorType ct = kN32_SkColorType;
127 const SkAlphaType at = image->isOpaque() ? kOpaque_SkAlphaType : kPremul _SkAlphaType; 129 const SkAlphaType at = image->isOpaque() ? kOpaque_SkAlphaType : kPremul _SkAlphaType;
128 const SkImageInfo info = SkImageInfo::Make(image->width(), image->height (), ct, at); 130 const SkImageInfo info = SkImageInfo::Make(image->width(), image->height (), ct, at);
129 return new GeneratorFromImage(image, info); 131 return new GeneratorFromImage(image, info);
130 } 132 }
131 return nullptr; 133 return nullptr;
132 } 134 }
133 135
134 136
OLDNEW
« no previous file with comments | « src/image/SkImage_Raster.cpp ('k') | tests/ReadPixelsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698