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

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

Issue 1684993002: Revert of skia: Add support for CHROMIUM_image backed textures. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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/SkGpuDevice.h ('k') | src/gpu/SkGrPixelRef.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 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 "SkGpuDevice.h" 8 #include "SkGpuDevice.h"
9 9
10 #include "GrBlurUtils.h" 10 #include "GrBlurUtils.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 142 }
143 unsigned flags; 143 unsigned flags;
144 if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) { 144 if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) {
145 return nullptr; 145 return nullptr;
146 } 146 }
147 return new SkGpuDevice(rt, width, height, props, flags); 147 return new SkGpuDevice(rt, width, height, props, flags);
148 } 148 }
149 149
150 SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkSurface::Budgeted budgete d, 150 SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkSurface::Budgeted budgete d,
151 const SkImageInfo& info, int sampleCount, 151 const SkImageInfo& info, int sampleCount,
152 const SkSurfaceProps* props, InitContents init, 152 const SkSurfaceProps* props, InitContents init) {
153 GrTextureStorageAllocator customAllocator) {
154 unsigned flags; 153 unsigned flags;
155 if (!CheckAlphaTypeAndGetFlags(&info, init, &flags)) { 154 if (!CheckAlphaTypeAndGetFlags(&info, init, &flags)) {
156 return nullptr; 155 return nullptr;
157 } 156 }
158 157
159 SkAutoTUnref<GrRenderTarget> rt(CreateRenderTarget( 158 SkAutoTUnref<GrRenderTarget> rt(CreateRenderTarget(context, budgeted, info, sampleCount));
160 context, budgeted, info, sampleCount, customAllocator));
161 if (nullptr == rt) { 159 if (nullptr == rt) {
162 return nullptr; 160 return nullptr;
163 } 161 }
164 162
165 return new SkGpuDevice(rt, info.width(), info.height(), props, flags); 163 return new SkGpuDevice(rt, info.width(), info.height(), props, flags);
166 } 164 }
167 165
168 SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height, 166 SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height,
169 const SkSurfaceProps* props, unsigned flags) 167 const SkSurfaceProps* props, unsigned flags)
170 : INHERITED(SkSurfacePropsCopyOrDefault(props)) 168 : INHERITED(SkSurfacePropsCopyOrDefault(props))
171 , fContext(SkRef(rt->getContext())) 169 , fContext(SkRef(rt->getContext()))
172 , fRenderTarget(SkRef(rt)) { 170 , fRenderTarget(SkRef(rt)) {
173 fOpaque = SkToBool(flags & kIsOpaque_Flag); 171 fOpaque = SkToBool(flags & kIsOpaque_Flag);
174 172
175 SkAlphaType at = fOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType; 173 SkAlphaType at = fOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
176 SkImageInfo info = rt->surfacePriv().info(at).makeWH(width, height); 174 SkImageInfo info = rt->surfacePriv().info(at).makeWH(width, height);
177 SkPixelRef* pr = new SkGrPixelRef(info, rt); 175 SkPixelRef* pr = new SkGrPixelRef(info, rt);
178 fLegacyBitmap.setInfo(info); 176 fLegacyBitmap.setInfo(info);
179 fLegacyBitmap.setPixelRef(pr)->unref(); 177 fLegacyBitmap.setPixelRef(pr)->unref();
180 178
181 fDrawContext.reset(this->context()->drawContext(rt, &this->surfaceProps())); 179 fDrawContext.reset(this->context()->drawContext(rt, &this->surfaceProps()));
182 if (flags & kNeedClear_Flag) { 180 if (flags & kNeedClear_Flag) {
183 this->clearAll(); 181 this->clearAll();
184 } 182 }
185 } 183 }
186 184
187 GrRenderTarget* SkGpuDevice::CreateRenderTarget( 185 GrRenderTarget* SkGpuDevice::CreateRenderTarget(GrContext* context, SkSurface::B udgeted budgeted,
188 GrContext* context, SkSurface::Budgeted budgeted, const SkImageInfo& ori gInfo, 186 const SkImageInfo& origInfo, int sampleCount) {
189 int sampleCount, GrTextureStorageAllocator textureStorageAllocator) {
190 if (kUnknown_SkColorType == origInfo.colorType() || 187 if (kUnknown_SkColorType == origInfo.colorType() ||
191 origInfo.width() < 0 || origInfo.height() < 0) { 188 origInfo.width() < 0 || origInfo.height() < 0) {
192 return nullptr; 189 return nullptr;
193 } 190 }
194 191
195 if (!context) { 192 if (!context) {
196 return nullptr; 193 return nullptr;
197 } 194 }
198 195
199 SkColorType ct = origInfo.colorType(); 196 SkColorType ct = origInfo.colorType();
200 SkAlphaType at = origInfo.alphaType(); 197 SkAlphaType at = origInfo.alphaType();
201 if (kRGB_565_SkColorType == ct) { 198 if (kRGB_565_SkColorType == ct) {
202 at = kOpaque_SkAlphaType; // force this setting 199 at = kOpaque_SkAlphaType; // force this setting
203 } else if (ct != kBGRA_8888_SkColorType && ct != kRGBA_8888_SkColorType) { 200 } else if (ct != kBGRA_8888_SkColorType && ct != kRGBA_8888_SkColorType) {
204 // Fall back from whatever ct was to default of kRGBA or kBGRA which is aliased as kN32 201 // Fall back from whatever ct was to default of kRGBA or kBGRA which is aliased as kN32
205 ct = kN32_SkColorType; 202 ct = kN32_SkColorType;
206 } 203 }
207 if (kOpaque_SkAlphaType != at) { 204 if (kOpaque_SkAlphaType != at) {
208 at = kPremul_SkAlphaType; // force this setting 205 at = kPremul_SkAlphaType; // force this setting
209 } 206 }
210 const SkImageInfo info = SkImageInfo::Make(origInfo.width(), origInfo.height (), ct, at); 207 const SkImageInfo info = SkImageInfo::Make(origInfo.width(), origInfo.height (), ct, at);
211 208
212 GrSurfaceDesc desc; 209 GrSurfaceDesc desc;
213 desc.fFlags = kRenderTarget_GrSurfaceFlag; 210 desc.fFlags = kRenderTarget_GrSurfaceFlag;
214 desc.fWidth = info.width(); 211 desc.fWidth = info.width();
215 desc.fHeight = info.height(); 212 desc.fHeight = info.height();
216 desc.fConfig = SkImageInfo2GrPixelConfig(info); 213 desc.fConfig = SkImageInfo2GrPixelConfig(info);
217 desc.fSampleCnt = sampleCount; 214 desc.fSampleCnt = sampleCount;
218 desc.fTextureStorageAllocator = textureStorageAllocator;
219 GrTexture* texture = context->textureProvider()->createTexture( 215 GrTexture* texture = context->textureProvider()->createTexture(
220 desc, SkToBool(budgeted), nullptr, 0); 216 desc, SkToBool(budgeted), nullptr, 0);
221 if (nullptr == texture) { 217 if (nullptr == texture) {
222 return nullptr; 218 return nullptr;
223 } 219 }
224 SkASSERT(nullptr != texture->asRenderTarget()); 220 SkASSERT(nullptr != texture->asRenderTarget());
225 return texture->asRenderTarget(); 221 return texture->asRenderTarget();
226 } 222 }
227 223
228 /////////////////////////////////////////////////////////////////////////////// 224 ///////////////////////////////////////////////////////////////////////////////
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 } 315 }
320 316
321 void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) { 317 void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) {
322 ASSERT_SINGLE_OWNER 318 ASSERT_SINGLE_OWNER
323 319
324 SkSurface::Budgeted budgeted = 320 SkSurface::Budgeted budgeted =
325 fRenderTarget->resourcePriv().isBudgeted() ? SkSurface::kYes_Budgete d 321 fRenderTarget->resourcePriv().isBudgeted() ? SkSurface::kYes_Budgete d
326 : SkSurface::kNo_Budgeted ; 322 : SkSurface::kNo_Budgeted ;
327 323
328 SkAutoTUnref<GrRenderTarget> newRT(CreateRenderTarget( 324 SkAutoTUnref<GrRenderTarget> newRT(CreateRenderTarget(
329 this->context(), budgeted, this->imageInfo(), fRenderTarget->desc().fSam pleCnt, 325 this->context(), budgeted, this->imageInfo(), fRenderTarget->desc().fSam pleCnt));
330 fRenderTarget->desc().fTextureStorageAllocator));
331 326
332 if (nullptr == newRT) { 327 if (nullptr == newRT) {
333 return; 328 return;
334 } 329 }
335 330
336 if (shouldRetainContent) { 331 if (shouldRetainContent) {
337 if (fRenderTarget->wasDestroyed()) { 332 if (fRenderTarget->wasDestroyed()) {
338 return; 333 return;
339 } 334 }
340 this->context()->copySurface(newRT, fRenderTarget); 335 this->context()->copySurface(newRT, fRenderTarget);
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 fRenderTarget->isUnifiedMultisampled(); 1467 fRenderTarget->isUnifiedMultisampled();
1473 bool doBicubic; 1468 bool doBicubic;
1474 GrTextureParams::FilterMode textureFilterMode = 1469 GrTextureParams::FilterMode textureFilterMode =
1475 GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), *draw.fMatrix, SkMatrix::I(), 1470 GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), *draw.fMatrix, SkMatrix::I(),
1476 &doBicubic); 1471 &doBicubic);
1477 if (useFallback || doBicubic || GrTextureParams::kNone_FilterMode != texture FilterMode) { 1472 if (useFallback || doBicubic || GrTextureParams::kNone_FilterMode != texture FilterMode) {
1478 SkNinePatchIter iter(producer->width(), producer->height(), center, dst) ; 1473 SkNinePatchIter iter(producer->width(), producer->height(), center, dst) ;
1479 1474
1480 SkRect srcR, dstR; 1475 SkRect srcR, dstR;
1481 while (iter.next(&srcR, &dstR)) { 1476 while (iter.next(&srcR, &dstR)) {
1482 this->drawTextureProducer(producer, &srcR, &dstR, SkCanvas::kStrict_ SrcRectConstraint, 1477 this->drawTextureProducer(producer, &srcR, &dstR, SkCanvas::kStrict_ SrcRectConstraint,
1483 *draw.fMatrix, fClip, paint); 1478 *draw.fMatrix, fClip, paint);
1484 } 1479 }
1485 return; 1480 return;
1486 } 1481 }
1487 1482
1488 static const GrTextureParams::FilterMode kMode = GrTextureParams::kNone_Filt erMode; 1483 static const GrTextureParams::FilterMode kMode = GrTextureParams::kNone_Filt erMode;
1489 SkAutoTUnref<const GrFragmentProcessor> fp( 1484 SkAutoTUnref<const GrFragmentProcessor> fp(
1490 producer->createFragmentProcessor(SkMatrix::I(), 1485 producer->createFragmentProcessor(SkMatrix::I(),
1491 SkRect::MakeIWH(producer->width(), pro ducer->height()), 1486 SkRect::MakeIWH(producer->width(), pro ducer->height()),
1492 GrTextureProducer::kNo_FilterConstrain t, true, 1487 GrTextureProducer::kNo_FilterConstrain t, true,
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 } 1885 }
1891 1886
1892 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1887 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1893 ASSERT_SINGLE_OWNER 1888 ASSERT_SINGLE_OWNER
1894 // We always return a transient cache, so it is freed after each 1889 // We always return a transient cache, so it is freed after each
1895 // filter traversal. 1890 // filter traversal.
1896 return SkGpuDevice::NewImageFilterCache(); 1891 return SkGpuDevice::NewImageFilterCache();
1897 } 1892 }
1898 1893
1899 #endif 1894 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/gpu/SkGrPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698