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

Side by Side Diff: src/gpu/GrImageIDTextureAdjuster.cpp

Issue 2150113002: Add getColorSpace to GrTextureProducer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix newline Created 4 years, 5 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/gpu/GrImageIDTextureAdjuster.h ('k') | src/gpu/GrTextureParamsAdjuster.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 "GrImageIDTextureAdjuster.h" 8 #include "GrImageIDTextureAdjuster.h"
9 9
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 23 matching lines...) Expand all
34 GrUniqueKey baseKey; 34 GrUniqueKey baseKey;
35 GrMakeKeyFromImageID(&baseKey, fBmp->getGenerationID(), 35 GrMakeKeyFromImageID(&baseKey, fBmp->getGenerationID(),
36 SkIRect::MakeWH(fBmp->width(), fBmp->height())); 36 SkIRect::MakeWH(fBmp->width(), fBmp->height()));
37 MakeCopyKeyFromOrigKey(baseKey, params, copyKey); 37 MakeCopyKeyFromOrigKey(baseKey, params, copyKey);
38 } 38 }
39 39
40 void GrBitmapTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) { 40 void GrBitmapTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) {
41 GrInstallBitmapUniqueKeyInvalidator(copyKey, fBmp->pixelRef()); 41 GrInstallBitmapUniqueKeyInvalidator(copyKey, fBmp->pixelRef());
42 } 42 }
43 43
44 SkColorSpace* GrBitmapTextureAdjuster::getColorSpace() {
45 return fBmp->colorSpace();
46 }
47
44 ////////////////////////////////////////////////////////////////////////////// 48 //////////////////////////////////////////////////////////////////////////////
45 49
46 // SkImage's don't have a way of communicating whether they're alpha-only. So we fallback to 50 // SkImage's don't have a way of communicating whether they're alpha-only. So we fallback to
47 // inspecting the texture. 51 // inspecting the texture.
48 static bool tex_image_is_alpha_only(const SkImage_Base& img) { 52 static bool tex_image_is_alpha_only(const SkImage_Base& img) {
49 return GrPixelConfigIsAlphaOnly(img.peekTexture()->config()); 53 return GrPixelConfigIsAlphaOnly(img.peekTexture()->config());
50 } 54 }
51 55
52 GrImageTextureAdjuster::GrImageTextureAdjuster(const SkImage_Base* img) 56 GrImageTextureAdjuster::GrImageTextureAdjuster(const SkImage_Base* img)
53 : INHERITED(img->peekTexture(), SkIRect::MakeWH(img->width(), img->height()) , 57 : INHERITED(img->peekTexture(), SkIRect::MakeWH(img->width(), img->height()) ,
54 tex_image_is_alpha_only(*img)) 58 tex_image_is_alpha_only(*img))
55 , fImageBase(img) {} 59 , fImageBase(img) {}
56 60
57 void GrImageTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) { 61 void GrImageTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) {
58 // By construction this texture adjuster always represents an entire SkImage , so use the 62 // By construction this texture adjuster always represents an entire SkImage , so use the
59 // image's width and height for the key's rectangle. 63 // image's width and height for the key's rectangle.
60 GrUniqueKey baseKey; 64 GrUniqueKey baseKey;
61 GrMakeKeyFromImageID(&baseKey, fImageBase->uniqueID(), 65 GrMakeKeyFromImageID(&baseKey, fImageBase->uniqueID(),
62 SkIRect::MakeWH(fImageBase->width(), fImageBase->height ())); 66 SkIRect::MakeWH(fImageBase->width(), fImageBase->height ()));
63 MakeCopyKeyFromOrigKey(baseKey, params, copyKey); 67 MakeCopyKeyFromOrigKey(baseKey, params, copyKey);
64 } 68 }
65 69
66 void GrImageTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) { 70 void GrImageTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) {
67 // We don't currently have a mechanism for notifications on Images! 71 // We don't currently have a mechanism for notifications on Images!
68 } 72 }
69 73
74 SkColorSpace* GrImageTextureAdjuster::getColorSpace() {
75 return fImageBase->onImageInfo().colorSpace();
76 }
77
70 ////////////////////////////////////////////////////////////////////////////// 78 //////////////////////////////////////////////////////////////////////////////
71 79
72 GrBitmapTextureMaker::GrBitmapTextureMaker(GrContext* context, const SkBitmap& b itmap) 80 GrBitmapTextureMaker::GrBitmapTextureMaker(GrContext* context, const SkBitmap& b itmap)
73 : INHERITED(context, bitmap.width(), bitmap.height(), bmp_is_alpha_only(bitm ap)) 81 : INHERITED(context, bitmap.width(), bitmap.height(), bmp_is_alpha_only(bitm ap))
74 , fBitmap(bitmap) { 82 , fBitmap(bitmap) {
75 SkASSERT(!bitmap.getTexture()); 83 SkASSERT(!bitmap.getTexture());
76 if (!bitmap.isVolatile()) { 84 if (!bitmap.isVolatile()) {
77 SkIPoint origin = bitmap.pixelRefOrigin(); 85 SkIPoint origin = bitmap.pixelRefOrigin();
78 SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, bitmap.width(), 86 SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, bitmap.width(),
79 bitmap.height()); 87 bitmap.height());
(...skipping 27 matching lines...) Expand all
107 void GrBitmapTextureMaker::makeCopyKey(const CopyParams& copyParams, GrUniqueKey * copyKey) { 115 void GrBitmapTextureMaker::makeCopyKey(const CopyParams& copyParams, GrUniqueKey * copyKey) {
108 if (fOriginalKey.isValid()) { 116 if (fOriginalKey.isValid()) {
109 MakeCopyKeyFromOrigKey(fOriginalKey, copyParams, copyKey); 117 MakeCopyKeyFromOrigKey(fOriginalKey, copyParams, copyKey);
110 } 118 }
111 } 119 }
112 120
113 void GrBitmapTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { 121 void GrBitmapTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) {
114 GrInstallBitmapUniqueKeyInvalidator(copyKey, fBitmap.pixelRef()); 122 GrInstallBitmapUniqueKeyInvalidator(copyKey, fBitmap.pixelRef());
115 } 123 }
116 124
125 SkColorSpace* GrBitmapTextureMaker::getColorSpace() {
126 return fBitmap.colorSpace();
127 }
128
117 ////////////////////////////////////////////////////////////////////////////// 129 //////////////////////////////////////////////////////////////////////////////
118 static bool cacher_is_alpha_only(const SkImageCacherator& cacher) { 130 static bool cacher_is_alpha_only(const SkImageCacherator& cacher) {
119 return kAlpha_8_SkColorType == cacher.info().colorType(); 131 return kAlpha_8_SkColorType == cacher.info().colorType();
120 } 132 }
121 GrImageTextureMaker::GrImageTextureMaker(GrContext* context, SkImageCacherator* cacher, 133 GrImageTextureMaker::GrImageTextureMaker(GrContext* context, SkImageCacherator* cacher,
122 const SkImage* client, SkImage::Caching Hint chint) 134 const SkImage* client, SkImage::Caching Hint chint)
123 : INHERITED(context, cacher->info().width(), cacher->info().height(), 135 : INHERITED(context, cacher->info().width(), cacher->info().height(),
124 cacher_is_alpha_only(*cacher)) 136 cacher_is_alpha_only(*cacher))
125 , fCacher(cacher) 137 , fCacher(cacher)
126 , fClient(client) 138 , fClient(client)
(...skipping 14 matching lines...) Expand all
141 if (fOriginalKey.isValid() && SkImage::kAllow_CachingHint == fCachingHint) { 153 if (fOriginalKey.isValid() && SkImage::kAllow_CachingHint == fCachingHint) {
142 MakeCopyKeyFromOrigKey(fOriginalKey, stretch, paramsCopyKey); 154 MakeCopyKeyFromOrigKey(fOriginalKey, stretch, paramsCopyKey);
143 } 155 }
144 } 156 }
145 157
146 void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { 158 void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) {
147 if (fClient) { 159 if (fClient) {
148 as_IB(fClient)->notifyAddedToCache(); 160 as_IB(fClient)->notifyAddedToCache();
149 } 161 }
150 } 162 }
163
164 SkColorSpace* GrImageTextureMaker::getColorSpace() {
165 return fCacher->info().colorSpace();
166 }
OLDNEW
« no previous file with comments | « src/gpu/GrImageIDTextureAdjuster.h ('k') | src/gpu/GrTextureParamsAdjuster.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698