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

Side by Side Diff: src/image/SkImage_Generator.cpp

Issue 2037413002: Add SkSourceGammaTreatment enum so we know how to create mips (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix DM compilation Created 4 years, 6 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_Base.h ('k') | src/image/SkImage_Gpu.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 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 "SkImage_Base.h" 8 #include "SkImage_Base.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 13 matching lines...) Expand all
24 virtual SkImageInfo onImageInfo() const override { 24 virtual SkImageInfo onImageInfo() const override {
25 return fCache->info(); 25 return fCache->info();
26 } 26 }
27 27
28 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY, Cac hingHint) const override; 28 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY, Cac hingHint) const override;
29 SkImageCacherator* peekCacherator() const override { return fCache; } 29 SkImageCacherator* peekCacherator() const override { return fCache; }
30 SkData* onRefEncoded(GrContext*) const override; 30 SkData* onRefEncoded(GrContext*) const override;
31 bool isOpaque() const override { return fCache->info().isOpaque(); } 31 bool isOpaque() const override { return fCache->info().isOpaque(); }
32 sk_sp<SkImage> onMakeSubset(const SkIRect&) const override; 32 sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
33 bool getROPixels(SkBitmap*, CachingHint) const override; 33 bool getROPixels(SkBitmap*, CachingHint) const override;
34 GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const override; 34 GrTexture* asTextureRef(GrContext*, const GrTextureParams&,
35 SkSourceGammaTreatment) const override;
35 bool onIsLazyGenerated() const override { return true; } 36 bool onIsLazyGenerated() const override { return true; }
36 37
37 private: 38 private:
38 SkAutoTDelete<SkImageCacherator> fCache; 39 SkAutoTDelete<SkImageCacherator> fCache;
39 40
40 typedef SkImage_Base INHERITED; 41 typedef SkImage_Base INHERITED;
41 }; 42 };
42 43
43 /////////////////////////////////////////////////////////////////////////////// 44 ///////////////////////////////////////////////////////////////////////////////
44 45
(...skipping 21 matching lines...) Expand all
66 } 67 }
67 68
68 SkData* SkImage_Generator::onRefEncoded(GrContext* ctx) const { 69 SkData* SkImage_Generator::onRefEncoded(GrContext* ctx) const {
69 return fCache->refEncoded(ctx); 70 return fCache->refEncoded(ctx);
70 } 71 }
71 72
72 bool SkImage_Generator::getROPixels(SkBitmap* bitmap, CachingHint chint) const { 73 bool SkImage_Generator::getROPixels(SkBitmap* bitmap, CachingHint chint) const {
73 return fCache->lockAsBitmap(bitmap, this, chint); 74 return fCache->lockAsBitmap(bitmap, this, chint);
74 } 75 }
75 76
76 GrTexture* SkImage_Generator::asTextureRef(GrContext* ctx, const GrTextureParams & params) const { 77 GrTexture* SkImage_Generator::asTextureRef(GrContext* ctx, const GrTextureParams & params,
77 return fCache->lockAsTexture(ctx, params, this); 78 SkSourceGammaTreatment gammaTreatment ) const {
79 return fCache->lockAsTexture(ctx, params, gammaTreatment, this);
78 } 80 }
79 81
80 sk_sp<SkImage> SkImage_Generator::onMakeSubset(const SkIRect& subset) const { 82 sk_sp<SkImage> SkImage_Generator::onMakeSubset(const SkIRect& subset) const {
81 // TODO: make this lazy, by wrapping the subset inside a new generator or so mething 83 // TODO: make this lazy, by wrapping the subset inside a new generator or so mething
82 // For now, we do effectively what we did before, make it a raster 84 // For now, we do effectively what we did before, make it a raster
83 85
84 const SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height( ), 86 const SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height( ),
85 this->isOpaque() ? kOpaque_SkAlphaType : k Premul_SkAlphaType); 87 this->isOpaque() ? kOpaque_SkAlphaType : k Premul_SkAlphaType);
86 auto surface(SkSurface::MakeRaster(info)); 88 auto surface(SkSurface::MakeRaster(info));
87 if (!surface) { 89 if (!surface) {
88 return nullptr; 90 return nullptr;
89 } 91 }
90 surface->getCanvas()->clear(0); 92 surface->getCanvas()->clear(0);
91 surface->getCanvas()->drawImage(this, SkIntToScalar(-subset.x()), SkIntToSca lar(-subset.y()), 93 surface->getCanvas()->drawImage(this, SkIntToScalar(-subset.x()), SkIntToSca lar(-subset.y()),
92 nullptr); 94 nullptr);
93 return surface->makeImageSnapshot(); 95 return surface->makeImageSnapshot();
94 } 96 }
95 97
96 sk_sp<SkImage> SkImage::MakeFromGenerator(SkImageGenerator* generator, const SkI Rect* subset) { 98 sk_sp<SkImage> SkImage::MakeFromGenerator(SkImageGenerator* generator, const SkI Rect* subset) {
97 if (!generator) { 99 if (!generator) {
98 return nullptr; 100 return nullptr;
99 } 101 }
100 SkImageCacherator* cache = SkImageCacherator::NewFromGenerator(generator, su bset); 102 SkImageCacherator* cache = SkImageCacherator::NewFromGenerator(generator, su bset);
101 if (!cache) { 103 if (!cache) {
102 return nullptr; 104 return nullptr;
103 } 105 }
104 return sk_make_sp<SkImage_Generator>(cache); 106 return sk_make_sp<SkImage_Generator>(cache);
105 } 107 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Base.h ('k') | src/image/SkImage_Gpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698