| OLD | NEW |
| 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" |
| 11 #include "effects/GrTextureDomain.h" | 11 #include "effects/GrTextureDomain.h" |
| 12 #include "effects/GrSimpleTextureEffect.h" | 12 #include "effects/GrSimpleTextureEffect.h" |
| 13 | 13 |
| 14 #include "GrContext.h" | 14 #include "GrContext.h" |
| 15 #include "GrBitmapTextContext.h" | 15 #include "GrBitmapTextContext.h" |
| 16 #if SK_DISTANCEFIELD_FONTS | |
| 17 #include "GrDistanceFieldTextContext.h" | 16 #include "GrDistanceFieldTextContext.h" |
| 18 #endif | |
| 19 | 17 |
| 20 #include "SkGrTexturePixelRef.h" | 18 #include "SkGrTexturePixelRef.h" |
| 21 | 19 |
| 22 #include "SkBounder.h" | 20 #include "SkBounder.h" |
| 23 #include "SkColorFilter.h" | 21 #include "SkColorFilter.h" |
| 24 #include "SkDeviceImageFilterProxy.h" | 22 #include "SkDeviceImageFilterProxy.h" |
| 25 #include "SkDrawProcs.h" | 23 #include "SkDrawProcs.h" |
| 26 #include "SkGlyphCache.h" | 24 #include "SkGlyphCache.h" |
| 27 #include "SkImageFilter.h" | 25 #include "SkImageFilter.h" |
| 28 #include "SkMaskFilter.h" | 26 #include "SkMaskFilter.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 180 } |
| 183 | 181 |
| 184 void SkGpuDevice::initFromRenderTarget(GrContext* context, | 182 void SkGpuDevice::initFromRenderTarget(GrContext* context, |
| 185 GrRenderTarget* renderTarget, | 183 GrRenderTarget* renderTarget, |
| 186 bool cached) { | 184 bool cached) { |
| 187 fDrawProcs = NULL; | 185 fDrawProcs = NULL; |
| 188 | 186 |
| 189 fContext = context; | 187 fContext = context; |
| 190 fContext->ref(); | 188 fContext->ref(); |
| 191 | 189 |
| 192 #if SK_DISTANCEFIELD_FONTS | |
| 193 fMainTextContext = SkNEW_ARGS(GrDistanceFieldTextContext, (fContext, fLeakyP
roperties)); | 190 fMainTextContext = SkNEW_ARGS(GrDistanceFieldTextContext, (fContext, fLeakyP
roperties)); |
| 194 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp
erties)); | 191 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp
erties)); |
| 195 #else | |
| 196 fMainTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProperti
es)); | |
| 197 fFallbackTextContext = NULL; | |
| 198 #endif | |
| 199 | 192 |
| 200 fRenderTarget = NULL; | 193 fRenderTarget = NULL; |
| 201 fNeedClear = false; | 194 fNeedClear = false; |
| 202 | 195 |
| 203 SkASSERT(NULL != renderTarget); | 196 SkASSERT(NULL != renderTarget); |
| 204 fRenderTarget = renderTarget; | 197 fRenderTarget = renderTarget; |
| 205 fRenderTarget->ref(); | 198 fRenderTarget->ref(); |
| 206 | 199 |
| 207 // Hold onto to the texture in the pixel ref (if there is one) because the t
exture holds a ref | 200 // Hold onto to the texture in the pixel ref (if there is one) because the t
exture holds a ref |
| 208 // on the RT but not vice-versa. | 201 // on the RT but not vice-versa. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 int width, | 260 int width, |
| 268 int height, | 261 int height, |
| 269 int sampleCount) | 262 int sampleCount) |
| 270 : SkBitmapDevice(make_bitmap(config, width, height)) | 263 : SkBitmapDevice(make_bitmap(config, width, height)) |
| 271 { | 264 { |
| 272 fDrawProcs = NULL; | 265 fDrawProcs = NULL; |
| 273 | 266 |
| 274 fContext = context; | 267 fContext = context; |
| 275 fContext->ref(); | 268 fContext->ref(); |
| 276 | 269 |
| 277 #if SK_DISTANCEFIELD_FONTS | |
| 278 fMainTextContext = SkNEW_ARGS(GrDistanceFieldTextContext, (fContext, fLeakyP
roperties)); | 270 fMainTextContext = SkNEW_ARGS(GrDistanceFieldTextContext, (fContext, fLeakyP
roperties)); |
| 279 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp
erties)); | 271 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp
erties)); |
| 280 #else | |
| 281 fMainTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProperti
es)); | |
| 282 fFallbackTextContext = NULL; | |
| 283 #endif | |
| 284 | 272 |
| 285 fRenderTarget = NULL; | 273 fRenderTarget = NULL; |
| 286 fNeedClear = false; | 274 fNeedClear = false; |
| 287 | 275 |
| 288 if (config != SkBitmap::kRGB_565_Config) { | 276 if (config != SkBitmap::kRGB_565_Config) { |
| 289 config = SkBitmap::kARGB_8888_Config; | 277 config = SkBitmap::kARGB_8888_Config; |
| 290 } | 278 } |
| 291 | 279 |
| 292 GrTextureDesc desc; | 280 GrTextureDesc desc; |
| 293 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 281 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
| (...skipping 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2004 GrTexture* texture, | 1992 GrTexture* texture, |
| 2005 bool needClear) | 1993 bool needClear) |
| 2006 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { | 1994 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { |
| 2007 | 1995 |
| 2008 SkASSERT(texture && texture->asRenderTarget()); | 1996 SkASSERT(texture && texture->asRenderTarget()); |
| 2009 // This constructor is called from onCreateDevice. It has locked the RT in t
he texture | 1997 // This constructor is called from onCreateDevice. It has locked the RT in t
he texture |
| 2010 // cache. We pass true for the third argument so that it will get unlocked. | 1998 // cache. We pass true for the third argument so that it will get unlocked. |
| 2011 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1999 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
| 2012 fNeedClear = needClear; | 2000 fNeedClear = needClear; |
| 2013 } | 2001 } |
| OLD | NEW |