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

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

Issue 1673923003: 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 149 }
150 unsigned flags; 150 unsigned flags;
151 if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) { 151 if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) {
152 return nullptr; 152 return nullptr;
153 } 153 }
154 return new SkGpuDevice(rt, width, height, props, flags); 154 return new SkGpuDevice(rt, width, height, props, flags);
155 } 155 }
156 156
157 SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkSurface::Budgeted budgete d, 157 SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkSurface::Budgeted budgete d,
158 const SkImageInfo& info, int sampleCount, 158 const SkImageInfo& info, int sampleCount,
159 const SkSurfaceProps* props, InitContents init, 159 const SkSurfaceProps* props, InitContents init) {
160 GrTextureStorageAllocator customAllocator) {
161 unsigned flags; 160 unsigned flags;
162 if (!CheckAlphaTypeAndGetFlags(&info, init, &flags)) { 161 if (!CheckAlphaTypeAndGetFlags(&info, init, &flags)) {
163 return nullptr; 162 return nullptr;
164 } 163 }
165 164
166 SkAutoTUnref<GrRenderTarget> rt(CreateRenderTarget( 165 SkAutoTUnref<GrRenderTarget> rt(CreateRenderTarget(context, budgeted, info, sampleCount));
167 context, budgeted, info, sampleCount, customAllocator));
168 if (nullptr == rt) { 166 if (nullptr == rt) {
169 return nullptr; 167 return nullptr;
170 } 168 }
171 169
172 return new SkGpuDevice(rt, info.width(), info.height(), props, flags); 170 return new SkGpuDevice(rt, info.width(), info.height(), props, flags);
173 } 171 }
174 172
175 SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height, 173 SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height,
176 const SkSurfaceProps* props, unsigned flags) 174 const SkSurfaceProps* props, unsigned flags)
177 : INHERITED(SkSurfacePropsCopyOrDefault(props)) 175 : INHERITED(SkSurfacePropsCopyOrDefault(props))
178 , fContext(SkRef(rt->getContext())) 176 , fContext(SkRef(rt->getContext()))
179 , fRenderTarget(SkRef(rt)) { 177 , fRenderTarget(SkRef(rt)) {
180 fNeedClear = SkToBool(flags & kNeedClear_Flag); 178 fNeedClear = SkToBool(flags & kNeedClear_Flag);
181 fOpaque = SkToBool(flags & kIsOpaque_Flag); 179 fOpaque = SkToBool(flags & kIsOpaque_Flag);
182 180
183 SkAlphaType at = fOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType; 181 SkAlphaType at = fOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
184 SkImageInfo info = rt->surfacePriv().info(at).makeWH(width, height); 182 SkImageInfo info = rt->surfacePriv().info(at).makeWH(width, height);
185 SkPixelRef* pr = new SkGrPixelRef(info, rt); 183 SkPixelRef* pr = new SkGrPixelRef(info, rt);
186 fLegacyBitmap.setInfo(info); 184 fLegacyBitmap.setInfo(info);
187 fLegacyBitmap.setPixelRef(pr)->unref(); 185 fLegacyBitmap.setPixelRef(pr)->unref();
188 186
189 fDrawContext.reset(this->context()->drawContext(rt, &this->surfaceProps())); 187 fDrawContext.reset(this->context()->drawContext(rt, &this->surfaceProps()));
190 } 188 }
191 189
192 GrRenderTarget* SkGpuDevice::CreateRenderTarget( 190 GrRenderTarget* SkGpuDevice::CreateRenderTarget(GrContext* context, SkSurface::B udgeted budgeted,
193 GrContext* context, SkSurface::Budgeted budgeted, const SkImageInfo& ori gInfo, 191 const SkImageInfo& origInfo, int sampleCount) {
194 int sampleCount, GrTextureStorageAllocator textureStorageAllocator) {
195 if (kUnknown_SkColorType == origInfo.colorType() || 192 if (kUnknown_SkColorType == origInfo.colorType() ||
196 origInfo.width() < 0 || origInfo.height() < 0) { 193 origInfo.width() < 0 || origInfo.height() < 0) {
197 return nullptr; 194 return nullptr;
198 } 195 }
199 196
200 if (!context) { 197 if (!context) {
201 return nullptr; 198 return nullptr;
202 } 199 }
203 200
204 SkColorType ct = origInfo.colorType(); 201 SkColorType ct = origInfo.colorType();
205 SkAlphaType at = origInfo.alphaType(); 202 SkAlphaType at = origInfo.alphaType();
206 if (kRGB_565_SkColorType == ct) { 203 if (kRGB_565_SkColorType == ct) {
207 at = kOpaque_SkAlphaType; // force this setting 204 at = kOpaque_SkAlphaType; // force this setting
208 } else if (ct != kBGRA_8888_SkColorType && ct != kRGBA_8888_SkColorType) { 205 } else if (ct != kBGRA_8888_SkColorType && ct != kRGBA_8888_SkColorType) {
209 // Fall back from whatever ct was to default of kRGBA or kBGRA which is aliased as kN32 206 // Fall back from whatever ct was to default of kRGBA or kBGRA which is aliased as kN32
210 ct = kN32_SkColorType; 207 ct = kN32_SkColorType;
211 } 208 }
212 if (kOpaque_SkAlphaType != at) { 209 if (kOpaque_SkAlphaType != at) {
213 at = kPremul_SkAlphaType; // force this setting 210 at = kPremul_SkAlphaType; // force this setting
214 } 211 }
215 const SkImageInfo info = SkImageInfo::Make(origInfo.width(), origInfo.height (), ct, at); 212 const SkImageInfo info = SkImageInfo::Make(origInfo.width(), origInfo.height (), ct, at);
216 213
217 GrSurfaceDesc desc; 214 GrSurfaceDesc desc;
218 desc.fFlags = kRenderTarget_GrSurfaceFlag; 215 desc.fFlags = kRenderTarget_GrSurfaceFlag;
219 desc.fWidth = info.width(); 216 desc.fWidth = info.width();
220 desc.fHeight = info.height(); 217 desc.fHeight = info.height();
221 desc.fConfig = SkImageInfo2GrPixelConfig(info); 218 desc.fConfig = SkImageInfo2GrPixelConfig(info);
222 desc.fSampleCnt = sampleCount; 219 desc.fSampleCnt = sampleCount;
223 desc.fTextureStorageAllocator = textureStorageAllocator;
224 GrTexture* texture = context->textureProvider()->createTexture( 220 GrTexture* texture = context->textureProvider()->createTexture(
225 desc, SkToBool(budgeted), nullptr, 0); 221 desc, SkToBool(budgeted), nullptr, 0);
226 if (nullptr == texture) { 222 if (nullptr == texture) {
227 return nullptr; 223 return nullptr;
228 } 224 }
229 SkASSERT(nullptr != texture->asRenderTarget()); 225 SkASSERT(nullptr != texture->asRenderTarget());
230 return texture->asRenderTarget(); 226 return texture->asRenderTarget();
231 } 227 }
232 228
233 /////////////////////////////////////////////////////////////////////////////// 229 ///////////////////////////////////////////////////////////////////////////////
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) { 329 void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) {
334 ASSERT_SINGLE_OWNER 330 ASSERT_SINGLE_OWNER
335 // Caller must have accessed the render target, because it knows the rt must be replaced. 331 // Caller must have accessed the render target, because it knows the rt must be replaced.
336 SkASSERT(!fNeedClear); 332 SkASSERT(!fNeedClear);
337 333
338 SkSurface::Budgeted budgeted = 334 SkSurface::Budgeted budgeted =
339 fRenderTarget->resourcePriv().isBudgeted() ? SkSurface::kYes_Budgete d 335 fRenderTarget->resourcePriv().isBudgeted() ? SkSurface::kYes_Budgete d
340 : SkSurface::kNo_Budgeted ; 336 : SkSurface::kNo_Budgeted ;
341 337
342 SkAutoTUnref<GrRenderTarget> newRT(CreateRenderTarget( 338 SkAutoTUnref<GrRenderTarget> newRT(CreateRenderTarget(
343 this->context(), budgeted, this->imageInfo(), fRenderTarget->desc().fSam pleCnt, 339 this->context(), budgeted, this->imageInfo(), fRenderTarget->desc().fSam pleCnt));
344 fRenderTarget->desc().fTextureStorageAllocator));
345 340
346 if (nullptr == newRT) { 341 if (nullptr == newRT) {
347 return; 342 return;
348 } 343 }
349 344
350 if (shouldRetainContent) { 345 if (shouldRetainContent) {
351 if (fRenderTarget->wasDestroyed()) { 346 if (fRenderTarget->wasDestroyed()) {
352 return; 347 return;
353 } 348 }
354 this->context()->copySurface(newRT, fRenderTarget); 349 this->context()->copySurface(newRT, fRenderTarget);
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 fRenderTarget->isUnifiedMultisampled(); 1481 fRenderTarget->isUnifiedMultisampled();
1487 bool doBicubic; 1482 bool doBicubic;
1488 GrTextureParams::FilterMode textureFilterMode = 1483 GrTextureParams::FilterMode textureFilterMode =
1489 GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), *draw.fMatrix, SkMatrix::I(), 1484 GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), *draw.fMatrix, SkMatrix::I(),
1490 &doBicubic); 1485 &doBicubic);
1491 if (useFallback || doBicubic || GrTextureParams::kNone_FilterMode != texture FilterMode) { 1486 if (useFallback || doBicubic || GrTextureParams::kNone_FilterMode != texture FilterMode) {
1492 SkNinePatchIter iter(producer->width(), producer->height(), center, dst) ; 1487 SkNinePatchIter iter(producer->width(), producer->height(), center, dst) ;
1493 1488
1494 SkRect srcR, dstR; 1489 SkRect srcR, dstR;
1495 while (iter.next(&srcR, &dstR)) { 1490 while (iter.next(&srcR, &dstR)) {
1496 this->drawTextureProducer(producer, &srcR, &dstR, SkCanvas::kStrict_ SrcRectConstraint, 1491 this->drawTextureProducer(producer, &srcR, &dstR, SkCanvas::kStrict_ SrcRectConstraint,
1497 *draw.fMatrix, fClip, paint); 1492 *draw.fMatrix, fClip, paint);
1498 } 1493 }
1499 return; 1494 return;
1500 } 1495 }
1501 1496
1502 static const GrTextureParams::FilterMode kMode = GrTextureParams::kNone_Filt erMode; 1497 static const GrTextureParams::FilterMode kMode = GrTextureParams::kNone_Filt erMode;
1503 SkAutoTUnref<const GrFragmentProcessor> fp( 1498 SkAutoTUnref<const GrFragmentProcessor> fp(
1504 producer->createFragmentProcessor(SkMatrix::I(), 1499 producer->createFragmentProcessor(SkMatrix::I(),
1505 SkRect::MakeIWH(producer->width(), pro ducer->height()), 1500 SkRect::MakeIWH(producer->width(), pro ducer->height()),
1506 GrTextureProducer::kNo_FilterConstrain t, true, 1501 GrTextureProducer::kNo_FilterConstrain t, true,
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 } 1900 }
1906 1901
1907 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1902 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1908 ASSERT_SINGLE_OWNER 1903 ASSERT_SINGLE_OWNER
1909 // We always return a transient cache, so it is freed after each 1904 // We always return a transient cache, so it is freed after each
1910 // filter traversal. 1905 // filter traversal.
1911 return SkGpuDevice::NewImageFilterCache(); 1906 return SkGpuDevice::NewImageFilterCache();
1912 } 1907 }
1913 1908
1914 #endif 1909 #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