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

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

Issue 246513002: eliminate config param -- it was always self's config (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 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 | « src/core/SkBitmap.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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 void SkROLockPixelsPixelRef::onUnlockPixels() { 44 void SkROLockPixelsPixelRef::onUnlockPixels() {
45 fBitmap.unlockPixels(); 45 fBitmap.unlockPixels();
46 } 46 }
47 47
48 bool SkROLockPixelsPixelRef::onLockPixelsAreWritable() const { 48 bool SkROLockPixelsPixelRef::onLockPixelsAreWritable() const {
49 return false; 49 return false;
50 } 50 }
51 51
52 /////////////////////////////////////////////////////////////////////////////// 52 ///////////////////////////////////////////////////////////////////////////////
53 53
54 static SkGrPixelRef* copyToTexturePixelRef(GrTexture* texture, SkBitmap::Config dstConfig, 54 static SkGrPixelRef* copyToTexturePixelRef(GrTexture* texture, const SkIRect* su bset) {
55 const SkIRect* subset) {
56 if (NULL == texture) { 55 if (NULL == texture) {
57 return NULL; 56 return NULL;
58 } 57 }
59 GrContext* context = texture->getContext(); 58 GrContext* context = texture->getContext();
60 if (NULL == context) { 59 if (NULL == context) {
61 return NULL; 60 return NULL;
62 } 61 }
63 GrTextureDesc desc; 62 GrTextureDesc desc;
64 63
65 SkIPoint pointStorage; 64 SkIPoint pointStorage;
66 SkIPoint* topLeft; 65 SkIPoint* topLeft;
67 if (subset != NULL) { 66 if (subset != NULL) {
68 SkASSERT(SkIRect::MakeWH(texture->width(), texture->height()).contains(* subset)); 67 SkASSERT(SkIRect::MakeWH(texture->width(), texture->height()).contains(* subset));
69 // Create a new texture that is the size of subset. 68 // Create a new texture that is the size of subset.
70 desc.fWidth = subset->width(); 69 desc.fWidth = subset->width();
71 desc.fHeight = subset->height(); 70 desc.fHeight = subset->height();
72 pointStorage.set(subset->x(), subset->y()); 71 pointStorage.set(subset->x(), subset->y());
73 topLeft = &pointStorage; 72 topLeft = &pointStorage;
74 } else { 73 } else {
75 desc.fWidth = texture->width(); 74 desc.fWidth = texture->width();
76 desc.fHeight = texture->height(); 75 desc.fHeight = texture->height();
77 topLeft = NULL; 76 topLeft = NULL;
78 } 77 }
79 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; 78 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
80 desc.fConfig = SkBitmapConfig2GrPixelConfig(dstConfig); 79 desc.fConfig = texture->config();
81 80
82 SkImageInfo info; 81 SkImageInfo info;
83 if (!GrPixelConfig2ColorType(desc.fConfig, &info.fColorType)) { 82 if (!GrPixelConfig2ColorType(desc.fConfig, &info.fColorType)) {
84 return NULL; 83 return NULL;
85 } 84 }
86 info.fWidth = desc.fWidth; 85 info.fWidth = desc.fWidth;
87 info.fHeight = desc.fHeight; 86 info.fHeight = desc.fHeight;
88 info.fAlphaType = kPremul_SkAlphaType; 87 info.fAlphaType = kPremul_SkAlphaType;
89 88
90 GrTexture* dst = context->createUncachedTexture(desc, NULL, 0); 89 GrTexture* dst = context->createUncachedTexture(desc, NULL, 0);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 SkSafeUnref(fSurface); 144 SkSafeUnref(fSurface);
146 } 145 }
147 146
148 GrTexture* SkGrPixelRef::getTexture() { 147 GrTexture* SkGrPixelRef::getTexture() {
149 if (NULL != fSurface) { 148 if (NULL != fSurface) {
150 return fSurface->asTexture(); 149 return fSurface->asTexture();
151 } 150 }
152 return NULL; 151 return NULL;
153 } 152 }
154 153
155 SkPixelRef* SkGrPixelRef::deepCopy(SkBitmap::Config dstConfig, const SkIRect* su bset) { 154 SkPixelRef* SkGrPixelRef::deepCopy(const SkIRect* subset) {
156 if (NULL == fSurface) { 155 if (NULL == fSurface) {
157 return NULL; 156 return NULL;
158 } 157 }
159 158
160 // Note that when copying a render-target-backed pixel ref, we 159 // Note that when copying a render-target-backed pixel ref, we
161 // return a texture-backed pixel ref instead. This is because 160 // return a texture-backed pixel ref instead. This is because
162 // render-target pixel refs are usually created in conjunction with 161 // render-target pixel refs are usually created in conjunction with
163 // a GrTexture owned elsewhere (e.g., SkGpuDevice), and cannot live 162 // a GrTexture owned elsewhere (e.g., SkGpuDevice), and cannot live
164 // independently of that texture. Texture-backed pixel refs, on the other 163 // independently of that texture. Texture-backed pixel refs, on the other
165 // hand, own their GrTextures, and are thus self-contained. 164 // hand, own their GrTextures, and are thus self-contained.
166 return copyToTexturePixelRef(fSurface->asTexture(), dstConfig, subset); 165 return copyToTexturePixelRef(fSurface->asTexture(), subset);
167 } 166 }
168 167
169 bool SkGrPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) { 168 bool SkGrPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) {
170 if (NULL == fSurface || !fSurface->isValid()) { 169 if (NULL == fSurface || !fSurface->isValid()) {
171 return false; 170 return false;
172 } 171 }
173 172
174 int left, top, width, height; 173 int left, top, width, height;
175 if (NULL != subset) { 174 if (NULL != subset) {
176 left = subset->fLeft; 175 left = subset->fLeft;
177 width = subset->width(); 176 width = subset->width();
178 top = subset->fTop; 177 top = subset->fTop;
179 height = subset->height(); 178 height = subset->height();
180 } else { 179 } else {
181 left = 0; 180 left = 0;
182 width = this->info().fWidth; 181 width = this->info().fWidth;
183 top = 0; 182 top = 0;
184 height = this->info().fHeight; 183 height = this->info().fHeight;
185 } 184 }
186 if (!dst->allocPixels(SkImageInfo::MakeN32Premul(width, height))) { 185 if (!dst->allocPixels(SkImageInfo::MakeN32Premul(width, height))) {
187 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\ n"); 186 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\ n");
188 return false; 187 return false;
189 } 188 }
190 SkAutoLockPixels al(*dst); 189 SkAutoLockPixels al(*dst);
191 void* buffer = dst->getPixels(); 190 void* buffer = dst->getPixels();
192 return fSurface->readPixels(left, top, width, height, 191 return fSurface->readPixels(left, top, width, height,
193 kSkia8888_GrPixelConfig, 192 kSkia8888_GrPixelConfig,
194 buffer, dst->rowBytes()); 193 buffer, dst->rowBytes());
195 } 194 }
OLDNEW
« no previous file with comments | « src/core/SkBitmap.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698