| 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" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 } | 184 } |
| 185 | 185 |
| 186 void SkGpuDevice::initFromRenderTarget(GrContext* context, | 186 void SkGpuDevice::initFromRenderTarget(GrContext* context, |
| 187 GrRenderTarget* renderTarget, | 187 GrRenderTarget* renderTarget, |
| 188 unsigned flags) { | 188 unsigned flags) { |
| 189 fDrawProcs = NULL; | 189 fDrawProcs = NULL; |
| 190 | 190 |
| 191 fContext = context; | 191 fContext = context; |
| 192 fContext->ref(); | 192 fContext->ref(); |
| 193 | 193 |
| 194 bool useDFFonts = !!(flags & kDFFonts_Flag); | |
| 195 fMainTextContext = SkNEW_ARGS(GrDistanceFieldTextContext, (fContext, fLeakyP
roperties, | |
| 196 useDFFonts)); | |
| 197 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp
erties)); | |
| 198 | |
| 199 fRenderTarget = NULL; | 194 fRenderTarget = NULL; |
| 200 fNeedClear = flags & kNeedClear_Flag; | 195 fNeedClear = flags & kNeedClear_Flag; |
| 201 | 196 |
| 202 SkASSERT(NULL != renderTarget); | 197 SkASSERT(NULL != renderTarget); |
| 203 fRenderTarget = renderTarget; | 198 fRenderTarget = renderTarget; |
| 204 fRenderTarget->ref(); | 199 fRenderTarget->ref(); |
| 205 | 200 |
| 206 // Hold onto to the texture in the pixel ref (if there is one) because the t
exture holds a ref | 201 // Hold onto to the texture in the pixel ref (if there is one) because the t
exture holds a ref |
| 207 // on the RT but not vice-versa. | 202 // on the RT but not vice-versa. |
| 208 // TODO: Remove this trickery once we figure out how to make SkGrPixelRef do
this without | 203 // TODO: Remove this trickery once we figure out how to make SkGrPixelRef do
this without |
| 209 // busting chrome (for a currently unknown reason). | 204 // busting chrome (for a currently unknown reason). |
| 210 GrSurface* surface = fRenderTarget->asTexture(); | 205 GrSurface* surface = fRenderTarget->asTexture(); |
| 211 if (NULL == surface) { | 206 if (NULL == surface) { |
| 212 surface = fRenderTarget; | 207 surface = fRenderTarget; |
| 213 } | 208 } |
| 214 | 209 |
| 215 SkImageInfo info; | 210 SkImageInfo info; |
| 216 surface->asImageInfo(&info); | 211 surface->asImageInfo(&info); |
| 217 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, surface, SkToBool(flags & k
Cached_Flag))); | 212 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, surface, SkToBool(flags & k
Cached_Flag))); |
| 218 | 213 |
| 219 this->setPixelRef(pr)->unref(); | 214 this->setPixelRef(pr)->unref(); |
| 215 |
| 216 bool useDFFonts = !!(flags & kDFFonts_Flag); |
| 217 fMainTextContext = fContext->createTextContext(fRenderTarget, fLeakyProperti
es, useDFFonts); |
| 218 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp
erties)); |
| 220 } | 219 } |
| 221 | 220 |
| 222 SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo
, | 221 SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo
, |
| 223 int sampleCount) { | 222 int sampleCount) { |
| 224 if (kUnknown_SkColorType == origInfo.colorType() || | 223 if (kUnknown_SkColorType == origInfo.colorType() || |
| 225 origInfo.width() < 0 || origInfo.height() < 0) { | 224 origInfo.width() < 0 || origInfo.height() < 0) { |
| 226 return NULL; | 225 return NULL; |
| 227 } | 226 } |
| 228 | 227 |
| 229 SkImageInfo info = origInfo; | 228 SkImageInfo info = origInfo; |
| (...skipping 1776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2006 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict
ure, i); | 2005 GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(pict
ure, i); |
| 2007 | 2006 |
| 2008 if (NULL != layer->getTexture()) { | 2007 if (NULL != layer->getTexture()) { |
| 2009 fContext->unlockScratchTexture(layer->getTexture()); | 2008 fContext->unlockScratchTexture(layer->getTexture()); |
| 2010 layer->setTexture(NULL); | 2009 layer->setTexture(NULL); |
| 2011 } | 2010 } |
| 2012 } | 2011 } |
| 2013 | 2012 |
| 2014 return true; | 2013 return true; |
| 2015 } | 2014 } |
| OLD | NEW |