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

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

Issue 1266883002: unify pixelref and image ID space, so we can share IDs when we share pixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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_Gpu.h ('k') | src/image/SkImage_Raster.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 2012 Google Inc. 2 * Copyright 2012 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_Gpu.h" 8 #include "SkImage_Gpu.h"
9 #include "GrContext.h" 9 #include "GrContext.h"
10 #include "GrDrawContext.h" 10 #include "GrDrawContext.h"
11 #include "effects/GrYUVtoRGBEffect.h" 11 #include "effects/GrYUVtoRGBEffect.h"
12 #include "SkCanvas.h" 12 #include "SkCanvas.h"
13 #include "SkGpuDevice.h" 13 #include "SkGpuDevice.h"
14 14
15 15
16 SkImage_Gpu::SkImage_Gpu(int w, int h, SkAlphaType at, GrTexture* tex, 16 SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, GrText ure* tex,
17 int sampleCountForNewSurfaces, SkSurface::Budgeted budg eted) 17 int sampleCountForNewSurfaces, SkSurface::Budgeted budg eted)
18 : INHERITED(w, h, NULL) 18 : INHERITED(w, h, uniqueID, NULL)
19 , fTexture(SkRef(tex)) 19 , fTexture(SkRef(tex))
20 , fSampleCountForNewSurfaces(sampleCountForNewSurfaces) 20 , fSampleCountForNewSurfaces(sampleCountForNewSurfaces)
21 , fAlphaType(at) 21 , fAlphaType(at)
22 , fBudgeted(budgeted) 22 , fBudgeted(budgeted)
23 {} 23 {}
24 24
25 SkSurface* SkImage_Gpu::onNewSurface(const SkImageInfo& info, const SkSurfacePro ps& props) const { 25 SkSurface* SkImage_Gpu::onNewSurface(const SkImageInfo& info, const SkSurfacePro ps& props) const {
26 GrTexture* tex = this->getTexture(); 26 GrTexture* tex = this->getTexture();
27 SkASSERT(tex); 27 SkASSERT(tex);
28 GrContext* ctx = tex->getContext(); 28 GrContext* ctx = tex->getContext();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 123 }
124 SkAutoTUnref<GrTexture> tex(ctx->textureProvider()->wrapBackendTexture(desc, ownership)); 124 SkAutoTUnref<GrTexture> tex(ctx->textureProvider()->wrapBackendTexture(desc, ownership));
125 if (!tex) { 125 if (!tex) {
126 return NULL; 126 return NULL;
127 } 127 }
128 if (releaseProc) { 128 if (releaseProc) {
129 tex->setRelease(releaseProc, releaseCtx); 129 tex->setRelease(releaseProc, releaseCtx);
130 } 130 }
131 131
132 const SkSurface::Budgeted budgeted = SkSurface::kNo_Budgeted; 132 const SkSurface::Budgeted budgeted = SkSurface::kNo_Budgeted;
133 return SkNEW_ARGS(SkImage_Gpu, (desc.fWidth, desc.fHeight, at, tex, 0, budge ted)); 133 return SkNEW_ARGS(SkImage_Gpu,
134 (desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, at, tex , 0, budgeted));
134 135
135 } 136 }
136 137
137 SkImage* SkImage::NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& des c, SkAlphaType at, 138 SkImage* SkImage::NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& des c, SkAlphaType at,
138 TextureReleaseProc releaseP, ReleaseContext rel easeC) { 139 TextureReleaseProc releaseP, ReleaseContext rel easeC) {
139 return new_wrapped_texture_common(ctx, desc, at, kBorrow_GrWrapOwnership, re leaseP, releaseC); 140 return new_wrapped_texture_common(ctx, desc, at, kBorrow_GrWrapOwnership, re leaseP, releaseC);
140 } 141 }
141 142
142 SkImage* SkImage::NewFromAdoptedTexture(GrContext* ctx, const GrBackendTextureDe sc& desc, 143 SkImage* SkImage::NewFromAdoptedTexture(GrContext* ctx, const GrBackendTextureDe sc& desc,
143 SkAlphaType at) { 144 SkAlphaType at) {
(...skipping 13 matching lines...) Expand all
157 } 158 }
158 159
159 const bool isBudgeted = true; 160 const bool isBudgeted = true;
160 SkAutoTUnref<GrTexture> dst(GrDeepCopyTexture(src, isBudgeted)); 161 SkAutoTUnref<GrTexture> dst(GrDeepCopyTexture(src, isBudgeted));
161 if (!dst) { 162 if (!dst) {
162 return NULL; 163 return NULL;
163 } 164 }
164 165
165 const SkSurface::Budgeted budgeted = SkSurface::kYes_Budgeted; 166 const SkSurface::Budgeted budgeted = SkSurface::kYes_Budgeted;
166 const int sampleCount = 0; // todo: make this an explicit parameter to newS urface()? 167 const int sampleCount = 0; // todo: make this an explicit parameter to newS urface()?
167 return SkNEW_ARGS(SkImage_Gpu, (desc.fWidth, desc.fHeight, at, dst, sampleCo unt, budgeted)); 168 return SkNEW_ARGS(SkImage_Gpu, (desc.fWidth, desc.fHeight, kNeedNewImageUniq ueID,
169 at, dst, sampleCount, budgeted));
168 } 170 }
169 171
170 SkImage* SkImage::NewFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace colorS pace, 172 SkImage* SkImage::NewFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace colorS pace,
171 const GrBackendObject yuvTextureHandles [3], 173 const GrBackendObject yuvTextureHandles [3],
172 const SkISize yuvSizes[3], 174 const SkISize yuvSizes[3],
173 GrSurfaceOrigin origin) { 175 GrSurfaceOrigin origin) {
174 const SkSurface::Budgeted budgeted = SkSurface::kYes_Budgeted; 176 const SkSurface::Budgeted budgeted = SkSurface::kYes_Budgeted;
175 177
176 if (yuvSizes[0].fWidth <= 0 || yuvSizes[0].fHeight <= 0 || 178 if (yuvSizes[0].fWidth <= 0 || yuvSizes[0].fHeight <= 0 ||
177 yuvSizes[1].fWidth <= 0 || yuvSizes[1].fHeight <= 0 || 179 yuvSizes[1].fWidth <= 0 || yuvSizes[1].fHeight <= 0 ||
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 GrPaint paint; 233 GrPaint paint;
232 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); 234 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
233 paint.addColorProcessor(GrYUVtoRGBEffect::Create(paint.getProcessorDataManag er(), yTex, uTex, 235 paint.addColorProcessor(GrYUVtoRGBEffect::Create(paint.getProcessorDataManag er(), yTex, uTex,
234 vTex, yuvSizes, colorSpace) )->unref(); 236 vTex, yuvSizes, colorSpace) )->unref();
235 237
236 const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth), 238 const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth),
237 SkIntToScalar(dstDesc.fHeight)); 239 SkIntToScalar(dstDesc.fHeight));
238 GrDrawContext* drawContext = ctx->drawContext(); 240 GrDrawContext* drawContext = ctx->drawContext();
239 drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMa trix::I(), rect); 241 drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMa trix::I(), rect);
240 ctx->flushSurfaceWrites(dst); 242 ctx->flushSurfaceWrites(dst);
241 return SkNEW_ARGS(SkImage_Gpu, (dstDesc.fWidth, dstDesc.fHeight, kOpaque_SkA lphaType, dst, 0, 243 return SkNEW_ARGS(SkImage_Gpu, (dstDesc.fWidth, dstDesc.fHeight, kNeedNewIma geUniqueID,
242 budgeted)); 244 kOpaque_SkAlphaType, dst, 0, budgeted));
243 } 245 }
244 246
245 //////////////////////////////////////////////////////////////////////////////// /////////////////// 247 //////////////////////////////////////////////////////////////////////////////// ///////////////////
246 248
247 GrTexture* GrDeepCopyTexture(GrTexture* src, bool budgeted) { 249 GrTexture* GrDeepCopyTexture(GrTexture* src, bool budgeted) {
248 GrContext* ctx = src->getContext(); 250 GrContext* ctx = src->getContext();
249 251
250 GrSurfaceDesc desc = src->desc(); 252 GrSurfaceDesc desc = src->desc();
251 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, NULL, 0); 253 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, NULL, 0);
252 if (!dst) { 254 if (!dst) {
253 return NULL; 255 return NULL;
254 } 256 }
255 257
256 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); 258 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight);
257 const SkIPoint dstP = SkIPoint::Make(0, 0); 259 const SkIPoint dstP = SkIPoint::Make(0, 0);
258 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); 260 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp);
259 return dst; 261 return dst;
260 } 262 }
261 263
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.h ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698