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

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

Issue 138143022: SkGrPixelRef can only reference the subset of the Surface specified by its SkImageInfo (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // target) 120 // target)
121 fSurface = surface->asTexture(); 121 fSurface = surface->asTexture();
122 #else 122 #else
123 fSurface = NULL; 123 fSurface = NULL;
124 #endif 124 #endif
125 if (NULL == fSurface) { 125 if (NULL == fSurface) {
126 fSurface = surface; 126 fSurface = surface;
127 } 127 }
128 fUnlock = transferCacheLock; 128 fUnlock = transferCacheLock;
129 SkSafeRef(surface); 129 SkSafeRef(surface);
130
131 if (fSurface) {
132 SkASSERT(info.fWidth <= fSurface->width());
133 SkASSERT(info.fHeight <= fSurface->height());
134 }
130 } 135 }
131 136
132 SkGrPixelRef::~SkGrPixelRef() { 137 SkGrPixelRef::~SkGrPixelRef() {
133 if (fUnlock) { 138 if (fUnlock) {
134 GrContext* context = fSurface->getContext(); 139 GrContext* context = fSurface->getContext();
135 GrTexture* texture = fSurface->asTexture(); 140 GrTexture* texture = fSurface->asTexture();
136 if (NULL != context && NULL != texture) { 141 if (NULL != context && NULL != texture) {
137 context->unlockScratchTexture(texture); 142 context->unlockScratchTexture(texture);
138 } 143 }
139 } 144 }
(...skipping 27 matching lines...) Expand all
167 } 172 }
168 173
169 int left, top, width, height; 174 int left, top, width, height;
170 if (NULL != subset) { 175 if (NULL != subset) {
171 left = subset->fLeft; 176 left = subset->fLeft;
172 width = subset->width(); 177 width = subset->width();
173 top = subset->fTop; 178 top = subset->fTop;
174 height = subset->height(); 179 height = subset->height();
175 } else { 180 } else {
176 left = 0; 181 left = 0;
177 width = fSurface->width(); 182 width = this->info().fWidth;
178 top = 0; 183 top = 0;
179 height = fSurface->height(); 184 height = this->info().fHeight;
180 } 185 }
181 if (!dst->allocPixels(SkImageInfo::MakeN32Premul(width, height))) { 186 if (!dst->allocPixels(SkImageInfo::MakeN32Premul(width, height))) {
182 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\ n"); 187 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\ n");
183 return false; 188 return false;
184 } 189 }
185 SkAutoLockPixels al(*dst); 190 SkAutoLockPixels al(*dst);
186 void* buffer = dst->getPixels(); 191 void* buffer = dst->getPixels();
187 return fSurface->readPixels(left, top, width, height, 192 return fSurface->readPixels(left, top, width, height,
188 kSkia8888_GrPixelConfig, 193 kSkia8888_GrPixelConfig,
189 buffer, dst->rowBytes()); 194 buffer, dst->rowBytes());
190 } 195 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698