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

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

Issue 108513003: Revert "PixelRef now returns (nearly) everything that is currently in SkBitmap. The goal is to refa… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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/gpu/GrSurface.cpp ('k') | src/gpu/SkGr.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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkGpuDevice.h" 8 #include "SkGpuDevice.h"
9 9
10 #include "effects/GrBicubicEffect.h" 10 #include "effects/GrBicubicEffect.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 fRenderTarget->ref(); 193 fRenderTarget->ref();
194 194
195 // Hold onto to the texture in the pixel ref (if there is one) because the t exture holds a ref 195 // Hold onto to the texture in the pixel ref (if there is one) because the t exture holds a ref
196 // on the RT but not vice-versa. 196 // on the RT but not vice-versa.
197 // TODO: Remove this trickery once we figure out how to make SkGrPixelRef do this without 197 // TODO: Remove this trickery once we figure out how to make SkGrPixelRef do this without
198 // busting chrome (for a currently unknown reason). 198 // busting chrome (for a currently unknown reason).
199 GrSurface* surface = fRenderTarget->asTexture(); 199 GrSurface* surface = fRenderTarget->asTexture();
200 if (NULL == surface) { 200 if (NULL == surface) {
201 surface = fRenderTarget; 201 surface = fRenderTarget;
202 } 202 }
203 203 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (surface, cached));
204 SkImageInfo info;
205 surface->asImageInfo(&info);
206 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, surface, cached));
207 204
208 this->setPixelRef(pr, 0)->unref(); 205 this->setPixelRef(pr, 0)->unref();
209 } 206 }
210 207
211 SkGpuDevice::SkGpuDevice(GrContext* context, 208 SkGpuDevice::SkGpuDevice(GrContext* context,
212 SkBitmap::Config config, 209 SkBitmap::Config config,
213 int width, 210 int width,
214 int height, 211 int height,
215 int sampleCount) 212 int sampleCount)
216 : SkBitmapDevice(config, width, height, false /*isOpaque*/) 213 : SkBitmapDevice(config, width, height, false /*isOpaque*/) {
217 { 214
218 fDrawProcs = NULL; 215 fDrawProcs = NULL;
219 216
220 fContext = context; 217 fContext = context;
221 fContext->ref(); 218 fContext->ref();
222 219
223 fRenderTarget = NULL; 220 fRenderTarget = NULL;
224 fNeedClear = false; 221 fNeedClear = false;
225 222
226 if (config != SkBitmap::kRGB_565_Config) { 223 if (config != SkBitmap::kRGB_565_Config) {
227 config = SkBitmap::kARGB_8888_Config; 224 config = SkBitmap::kARGB_8888_Config;
228 } 225 }
229 226
230 GrTextureDesc desc; 227 GrTextureDesc desc;
231 desc.fFlags = kRenderTarget_GrTextureFlagBit; 228 desc.fFlags = kRenderTarget_GrTextureFlagBit;
232 desc.fWidth = width; 229 desc.fWidth = width;
233 desc.fHeight = height; 230 desc.fHeight = height;
234 desc.fConfig = SkBitmapConfig2GrPixelConfig(config); 231 desc.fConfig = SkBitmapConfig2GrPixelConfig(config);
235 desc.fSampleCnt = sampleCount; 232 desc.fSampleCnt = sampleCount;
236 233
237 SkImageInfo info;
238 if (!GrPixelConfig2ColorType(desc.fConfig, &info.fColorType)) {
239 sk_throw();
240 }
241 info.fWidth = width;
242 info.fHeight = height;
243 info.fAlphaType = kPremul_SkAlphaType;
244
245 SkAutoTUnref<GrTexture> texture(fContext->createUncachedTexture(desc, NULL, 0)); 234 SkAutoTUnref<GrTexture> texture(fContext->createUncachedTexture(desc, NULL, 0));
246 235
247 if (NULL != texture) { 236 if (NULL != texture) {
248 fRenderTarget = texture->asRenderTarget(); 237 fRenderTarget = texture->asRenderTarget();
249 fRenderTarget->ref(); 238 fRenderTarget->ref();
250 239
251 SkASSERT(NULL != fRenderTarget); 240 SkASSERT(NULL != fRenderTarget);
252 241
253 // wrap the bitmap with a pixelref to expose our texture 242 // wrap the bitmap with a pixelref to expose our texture
254 SkGrPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, texture)); 243 SkGrPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (texture));
255 this->setPixelRef(pr, 0)->unref(); 244 this->setPixelRef(pr, 0)->unref();
256 } else { 245 } else {
257 GrPrintf("--- failed to create gpu-offscreen [%d %d]\n", 246 GrPrintf("--- failed to create gpu-offscreen [%d %d]\n",
258 width, height); 247 width, height);
259 SkASSERT(false); 248 SkASSERT(false);
260 } 249 }
261 } 250 }
262 251
263 SkGpuDevice::~SkGpuDevice() { 252 SkGpuDevice::~SkGpuDevice() {
264 if (fDrawProcs) { 253 if (fDrawProcs) {
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 819
831 // Draw the mask into maskTexture with the path's top-left at the origin usi ng tempPaint. 820 // Draw the mask into maskTexture with the path's top-left at the origin usi ng tempPaint.
832 SkMatrix translate; 821 SkMatrix translate;
833 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop); 822 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop);
834 am.set(context, translate); 823 am.set(context, translate);
835 context->drawPath(tempPaint, devPath, stroke); 824 context->drawPath(tempPaint, devPath, stroke);
836 return true; 825 return true;
837 } 826 }
838 827
839 SkBitmap wrap_texture(GrTexture* texture) { 828 SkBitmap wrap_texture(GrTexture* texture) {
840 SkImageInfo info;
841 texture->asImageInfo(&info);
842
843 SkBitmap result; 829 SkBitmap result;
844 result.setConfig(info); 830 bool dummy;
845 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); 831 SkBitmap::Config config = grConfig2skConfig(texture->config(), &dummy);
832 result.setConfig(config, texture->width(), texture->height());
833 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (texture)))->unref();
846 return result; 834 return result;
847 } 835 }
848 836
849 }; 837 };
850 838
851 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, 839 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
852 const SkPaint& paint, const SkMatrix* prePathMatrix, 840 const SkPaint& paint, const SkMatrix* prePathMatrix,
853 bool pathIsMutable) { 841 bool pathIsMutable) {
854 CHECK_FOR_ANNOTATION(paint); 842 CHECK_FOR_ANNOTATION(paint);
855 CHECK_SHOULD_DRAW(draw, false); 843 CHECK_SHOULD_DRAW(draw, false);
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 GrTexture* texture, 1881 GrTexture* texture,
1894 bool needClear) 1882 bool needClear)
1895 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { 1883 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) {
1896 1884
1897 SkASSERT(texture && texture->asRenderTarget()); 1885 SkASSERT(texture && texture->asRenderTarget());
1898 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture 1886 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture
1899 // cache. We pass true for the third argument so that it will get unlocked. 1887 // cache. We pass true for the third argument so that it will get unlocked.
1900 this->initFromRenderTarget(context, texture->asRenderTarget(), true); 1888 this->initFromRenderTarget(context, texture->asRenderTarget(), true);
1901 fNeedClear = needClear; 1889 fNeedClear = needClear;
1902 } 1890 }
OLDNEW
« no previous file with comments | « src/gpu/GrSurface.cpp ('k') | src/gpu/SkGr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698