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

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

Issue 113193003: Revert of remvoe duplicate impl for SkImageInfo flattening (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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 fRenderTarget->ref(); 207 fRenderTarget->ref();
208 208
209 // Hold onto to the texture in the pixel ref (if there is one) because the t exture holds a ref 209 // Hold onto to the texture in the pixel ref (if there is one) because the t exture holds a ref
210 // on the RT but not vice-versa. 210 // on the RT but not vice-versa.
211 // TODO: Remove this trickery once we figure out how to make SkGrPixelRef do this without 211 // TODO: Remove this trickery once we figure out how to make SkGrPixelRef do this without
212 // busting chrome (for a currently unknown reason). 212 // busting chrome (for a currently unknown reason).
213 GrSurface* surface = fRenderTarget->asTexture(); 213 GrSurface* surface = fRenderTarget->asTexture();
214 if (NULL == surface) { 214 if (NULL == surface) {
215 surface = fRenderTarget; 215 surface = fRenderTarget;
216 } 216 }
217 217 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (surface, cached));
218 SkImageInfo info;
219 surface->asImageInfo(&info);
220 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, surface, cached));
221 218
222 this->setPixelRef(pr, 0)->unref(); 219 this->setPixelRef(pr, 0)->unref();
223 } 220 }
224 221
225 SkGpuDevice::SkGpuDevice(GrContext* context, 222 SkGpuDevice::SkGpuDevice(GrContext* context,
226 SkBitmap::Config config, 223 SkBitmap::Config config,
227 int width, 224 int width,
228 int height, 225 int height,
229 int sampleCount) 226 int sampleCount)
230 : SkBitmapDevice(make_bitmap(config, width, height, false /*isOpaque*/)) 227 : SkBitmapDevice(make_bitmap(config, width, height, false /*isOpaque*/)) {
231 { 228
232 fDrawProcs = NULL; 229 fDrawProcs = NULL;
233 230
234 fContext = context; 231 fContext = context;
235 fContext->ref(); 232 fContext->ref();
236 233
237 fRenderTarget = NULL; 234 fRenderTarget = NULL;
238 fNeedClear = false; 235 fNeedClear = false;
239 236
240 if (config != SkBitmap::kRGB_565_Config) { 237 if (config != SkBitmap::kRGB_565_Config) {
241 config = SkBitmap::kARGB_8888_Config; 238 config = SkBitmap::kARGB_8888_Config;
242 } 239 }
243 240
244 GrTextureDesc desc; 241 GrTextureDesc desc;
245 desc.fFlags = kRenderTarget_GrTextureFlagBit; 242 desc.fFlags = kRenderTarget_GrTextureFlagBit;
246 desc.fWidth = width; 243 desc.fWidth = width;
247 desc.fHeight = height; 244 desc.fHeight = height;
248 desc.fConfig = SkBitmapConfig2GrPixelConfig(config); 245 desc.fConfig = SkBitmapConfig2GrPixelConfig(config);
249 desc.fSampleCnt = sampleCount; 246 desc.fSampleCnt = sampleCount;
250 247
251 SkImageInfo info;
252 if (!GrPixelConfig2ColorType(desc.fConfig, &info.fColorType)) {
253 sk_throw();
254 }
255 info.fWidth = width;
256 info.fHeight = height;
257 info.fAlphaType = kPremul_SkAlphaType;
258
259 SkAutoTUnref<GrTexture> texture(fContext->createUncachedTexture(desc, NULL, 0)); 248 SkAutoTUnref<GrTexture> texture(fContext->createUncachedTexture(desc, NULL, 0));
260 249
261 if (NULL != texture) { 250 if (NULL != texture) {
262 fRenderTarget = texture->asRenderTarget(); 251 fRenderTarget = texture->asRenderTarget();
263 fRenderTarget->ref(); 252 fRenderTarget->ref();
264 253
265 SkASSERT(NULL != fRenderTarget); 254 SkASSERT(NULL != fRenderTarget);
266 255
267 // wrap the bitmap with a pixelref to expose our texture 256 // wrap the bitmap with a pixelref to expose our texture
268 SkGrPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, texture)); 257 SkGrPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (texture));
269 this->setPixelRef(pr, 0)->unref(); 258 this->setPixelRef(pr, 0)->unref();
270 } else { 259 } else {
271 GrPrintf("--- failed to create gpu-offscreen [%d %d]\n", 260 GrPrintf("--- failed to create gpu-offscreen [%d %d]\n",
272 width, height); 261 width, height);
273 SkASSERT(false); 262 SkASSERT(false);
274 } 263 }
275 } 264 }
276 265
277 SkGpuDevice::~SkGpuDevice() { 266 SkGpuDevice::~SkGpuDevice() {
278 if (fDrawProcs) { 267 if (fDrawProcs) {
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 833
845 // Draw the mask into maskTexture with the path's top-left at the origin usi ng tempPaint. 834 // Draw the mask into maskTexture with the path's top-left at the origin usi ng tempPaint.
846 SkMatrix translate; 835 SkMatrix translate;
847 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop); 836 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop);
848 am.set(context, translate); 837 am.set(context, translate);
849 context->drawPath(tempPaint, devPath, stroke); 838 context->drawPath(tempPaint, devPath, stroke);
850 return true; 839 return true;
851 } 840 }
852 841
853 SkBitmap wrap_texture(GrTexture* texture) { 842 SkBitmap wrap_texture(GrTexture* texture) {
854 SkImageInfo info;
855 texture->asImageInfo(&info);
856
857 SkBitmap result; 843 SkBitmap result;
858 result.setConfig(info); 844 bool dummy;
859 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); 845 SkBitmap::Config config = grConfig2skConfig(texture->config(), &dummy);
846 result.setConfig(config, texture->width(), texture->height());
847 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (texture)))->unref();
860 return result; 848 return result;
861 } 849 }
862 850
863 }; 851 };
864 852
865 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, 853 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
866 const SkPaint& paint, const SkMatrix* prePathMatrix, 854 const SkPaint& paint, const SkMatrix* prePathMatrix,
867 bool pathIsMutable) { 855 bool pathIsMutable) {
868 CHECK_FOR_ANNOTATION(paint); 856 CHECK_FOR_ANNOTATION(paint);
869 CHECK_SHOULD_DRAW(draw, false); 857 CHECK_SHOULD_DRAW(draw, false);
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 GrTexture* texture, 1900 GrTexture* texture,
1913 bool needClear) 1901 bool needClear)
1914 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { 1902 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) {
1915 1903
1916 SkASSERT(texture && texture->asRenderTarget()); 1904 SkASSERT(texture && texture->asRenderTarget());
1917 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture 1905 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture
1918 // cache. We pass true for the third argument so that it will get unlocked. 1906 // cache. We pass true for the third argument so that it will get unlocked.
1919 this->initFromRenderTarget(context, texture->asRenderTarget(), true); 1907 this->initFromRenderTarget(context, texture->asRenderTarget(), true);
1920 fNeedClear = needClear; 1908 fNeedClear = needClear;
1921 } 1909 }
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