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

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

Issue 544233002: "NULL !=" = NULL (Closed) Base URL: https://skia.googlesource.com/skia.git@are
Patch Set: rebase 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/SkGr.cpp ('k') | src/gpu/effects/GrConvolutionEffect.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 /* 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (fSurface) { 118 if (fSurface) {
119 SkASSERT(info.width() <= fSurface->width()); 119 SkASSERT(info.width() <= fSurface->width());
120 SkASSERT(info.height() <= fSurface->height()); 120 SkASSERT(info.height() <= fSurface->height());
121 } 121 }
122 } 122 }
123 123
124 SkGrPixelRef::~SkGrPixelRef() { 124 SkGrPixelRef::~SkGrPixelRef() {
125 if (fUnlock) { 125 if (fUnlock) {
126 GrContext* context = fSurface->getContext(); 126 GrContext* context = fSurface->getContext();
127 GrTexture* texture = fSurface->asTexture(); 127 GrTexture* texture = fSurface->asTexture();
128 if (NULL != context && NULL != texture) { 128 if (context && texture) {
129 context->unlockScratchTexture(texture); 129 context->unlockScratchTexture(texture);
130 } 130 }
131 } 131 }
132 SkSafeUnref(fSurface); 132 SkSafeUnref(fSurface);
133 } 133 }
134 134
135 GrTexture* SkGrPixelRef::getTexture() { 135 GrTexture* SkGrPixelRef::getTexture() {
136 if (NULL != fSurface) { 136 if (fSurface) {
137 return fSurface->asTexture(); 137 return fSurface->asTexture();
138 } 138 }
139 return NULL; 139 return NULL;
140 } 140 }
141 141
142 SkPixelRef* SkGrPixelRef::deepCopy(SkColorType dstCT, const SkIRect* subset) { 142 SkPixelRef* SkGrPixelRef::deepCopy(SkColorType dstCT, const SkIRect* subset) {
143 if (NULL == fSurface) { 143 if (NULL == fSurface) {
144 return NULL; 144 return NULL;
145 } 145 }
146 146
147 // Note that when copying a render-target-backed pixel ref, we 147 // Note that when copying a render-target-backed pixel ref, we
148 // return a texture-backed pixel ref instead. This is because 148 // return a texture-backed pixel ref instead. This is because
149 // render-target pixel refs are usually created in conjunction with 149 // render-target pixel refs are usually created in conjunction with
150 // a GrTexture owned elsewhere (e.g., SkGpuDevice), and cannot live 150 // a GrTexture owned elsewhere (e.g., SkGpuDevice), and cannot live
151 // independently of that texture. Texture-backed pixel refs, on the other 151 // independently of that texture. Texture-backed pixel refs, on the other
152 // hand, own their GrTextures, and are thus self-contained. 152 // hand, own their GrTextures, and are thus self-contained.
153 return copyToTexturePixelRef(fSurface->asTexture(), dstCT, subset); 153 return copyToTexturePixelRef(fSurface->asTexture(), dstCT, subset);
154 } 154 }
155 155
156 bool SkGrPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) { 156 bool SkGrPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) {
157 if (NULL == fSurface || fSurface->wasDestroyed()) { 157 if (NULL == fSurface || fSurface->wasDestroyed()) {
158 return false; 158 return false;
159 } 159 }
160 160
161 int left, top, width, height; 161 int left, top, width, height;
162 if (NULL != subset) { 162 if (subset) {
163 left = subset->fLeft; 163 left = subset->fLeft;
164 width = subset->width(); 164 width = subset->width();
165 top = subset->fTop; 165 top = subset->fTop;
166 height = subset->height(); 166 height = subset->height();
167 } else { 167 } else {
168 left = 0; 168 left = 0;
169 width = this->info().width(); 169 width = this->info().width();
170 top = 0; 170 top = 0;
171 height = this->info().height(); 171 height = this->info().height();
172 } 172 }
173 if (!dst->tryAllocN32Pixels(width, height)) { 173 if (!dst->tryAllocN32Pixels(width, height)) {
174 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\ n"); 174 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\ n");
175 return false; 175 return false;
176 } 176 }
177 SkAutoLockPixels al(*dst); 177 SkAutoLockPixels al(*dst);
178 void* buffer = dst->getPixels(); 178 void* buffer = dst->getPixels();
179 return fSurface->readPixels(left, top, width, height, 179 return fSurface->readPixels(left, top, width, height,
180 kSkia8888_GrPixelConfig, 180 kSkia8888_GrPixelConfig,
181 buffer, dst->rowBytes()); 181 buffer, dst->rowBytes());
182 } 182 }
OLDNEW
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | src/gpu/effects/GrConvolutionEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698