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

Unified Diff: src/gpu/SkGrPixelRef.cpp

Issue 522733003: Make SkGrPixelRef responsible for owning GrSurface's texture rather than RT. (Closed) Base URL: https://skia.googlesource.com/skia.git@cfg
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGrPixelRef.cpp
diff --git a/src/gpu/SkGrPixelRef.cpp b/src/gpu/SkGrPixelRef.cpp
index 2131f41b17b3686c07e01afc002d0680d01906c4..d378032c062dd243a6021185499d7afce0447a5f 100644
--- a/src/gpu/SkGrPixelRef.cpp
+++ b/src/gpu/SkGrPixelRef.cpp
@@ -106,20 +106,14 @@ static SkGrPixelRef* copyToTexturePixelRef(GrTexture* texture, SkColorType dstCT
SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface,
bool transferCacheLock) : INHERITED(info) {
- // TODO: figure out if this is responsible for Chrome canvas errors
-#if 0
- // The GrTexture has a ref to the GrRenderTarget but not vice versa.
- // If the GrTexture exists take a ref to that (rather than the render
- // target)
- fSurface = surface->asTexture();
-#else
- fSurface = NULL;
-#endif
+ // For surfaces that are both textures and render targets, the texture owns the
+ // render target but not vice versa. So we ref the texture to keep both alive for
+ // the lifetime of this pixel ref.
+ fSurface = SkSafeRef(surface->asTexture());
if (NULL == fSurface) {
- fSurface = surface;
+ fSurface = SkSafeRef(surface);
}
fUnlock = transferCacheLock;
- SkSafeRef(surface);
if (fSurface) {
SkASSERT(info.fWidth <= fSurface->width());
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698