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

Side by Side 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, 3 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.cpp ('k') | no next file » | 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 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 10
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 SkImageInfo info = SkImageInfo::Make(desc.fWidth, desc.fHeight, dstCT, kPrem ul_SkAlphaType); 99 SkImageInfo info = SkImageInfo::Make(desc.fWidth, desc.fHeight, dstCT, kPrem ul_SkAlphaType);
100 SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (info, dst)); 100 SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (info, dst));
101 SkSafeUnref(dst); 101 SkSafeUnref(dst);
102 return pixelRef; 102 return pixelRef;
103 } 103 }
104 104
105 /////////////////////////////////////////////////////////////////////////////// 105 ///////////////////////////////////////////////////////////////////////////////
106 106
107 SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface, 107 SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface,
108 bool transferCacheLock) : INHERITED(info) { 108 bool transferCacheLock) : INHERITED(info) {
109 // TODO: figure out if this is responsible for Chrome canvas errors 109 // For surfaces that are both textures and render targets, the texture owns the
110 #if 0 110 // render target but not vice versa. So we ref the texture to keep both aliv e for
111 // The GrTexture has a ref to the GrRenderTarget but not vice versa. 111 // the lifetime of this pixel ref.
112 // If the GrTexture exists take a ref to that (rather than the render 112 fSurface = SkSafeRef(surface->asTexture());
113 // target)
114 fSurface = surface->asTexture();
115 #else
116 fSurface = NULL;
117 #endif
118 if (NULL == fSurface) { 113 if (NULL == fSurface) {
119 fSurface = surface; 114 fSurface = SkSafeRef(surface);
120 } 115 }
121 fUnlock = transferCacheLock; 116 fUnlock = transferCacheLock;
122 SkSafeRef(surface);
123 117
124 if (fSurface) { 118 if (fSurface) {
125 SkASSERT(info.fWidth <= fSurface->width()); 119 SkASSERT(info.fWidth <= fSurface->width());
126 SkASSERT(info.fHeight <= fSurface->height()); 120 SkASSERT(info.fHeight <= fSurface->height());
127 } 121 }
128 } 122 }
129 123
130 SkGrPixelRef::~SkGrPixelRef() { 124 SkGrPixelRef::~SkGrPixelRef() {
131 if (fUnlock) { 125 if (fUnlock) {
132 GrContext* context = fSurface->getContext(); 126 GrContext* context = fSurface->getContext();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 if (!dst->allocPixels(SkImageInfo::MakeN32Premul(width, height))) { 173 if (!dst->allocPixels(SkImageInfo::MakeN32Premul(width, height))) {
180 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\ n"); 174 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\ n");
181 return false; 175 return false;
182 } 176 }
183 SkAutoLockPixels al(*dst); 177 SkAutoLockPixels al(*dst);
184 void* buffer = dst->getPixels(); 178 void* buffer = dst->getPixels();
185 return fSurface->readPixels(left, top, width, height, 179 return fSurface->readPixels(left, top, width, height,
186 kSkia8888_GrPixelConfig, 180 kSkia8888_GrPixelConfig,
187 buffer, dst->rowBytes()); 181 buffer, dst->rowBytes());
188 } 182 }
OLDNEW
« 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