| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 | 161 |
| 162 void SkGpuDevice::initFromRenderTarget(GrContext* context, | 162 void SkGpuDevice::initFromRenderTarget(GrContext* context, |
| 163 GrRenderTarget* renderTarget, | 163 GrRenderTarget* renderTarget, |
| 164 unsigned flags) { | 164 unsigned flags) { |
| 165 fDrawProcs = NULL; | 165 fDrawProcs = NULL; |
| 166 | 166 |
| 167 fContext = context; | 167 fContext = context; |
| 168 fContext->ref(); | 168 fContext->ref(); |
| 169 | 169 |
| 170 bool useDFFonts = !!(flags & kDFFonts_Flag); | |
| 171 fMainTextContext = SkNEW_ARGS(GrDistanceFieldTextContext, (fContext, fLeakyP
roperties, | |
| 172 useDFFonts)); | |
| 173 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp
erties)); | |
| 174 | |
| 175 fRenderTarget = NULL; | 170 fRenderTarget = NULL; |
| 176 fNeedClear = flags & kNeedClear_Flag; | 171 fNeedClear = flags & kNeedClear_Flag; |
| 177 | 172 |
| 178 SkASSERT(NULL != renderTarget); | 173 SkASSERT(NULL != renderTarget); |
| 179 fRenderTarget = renderTarget; | 174 fRenderTarget = renderTarget; |
| 180 fRenderTarget->ref(); | 175 fRenderTarget->ref(); |
| 181 | 176 |
| 182 // Hold onto to the texture in the pixel ref (if there is one) because the t
exture holds a ref | 177 // Hold onto to the texture in the pixel ref (if there is one) because the t
exture holds a ref |
| 183 // on the RT but not vice-versa. | 178 // on the RT but not vice-versa. |
| 184 // TODO: Remove this trickery once we figure out how to make SkGrPixelRef do
this without | 179 // TODO: Remove this trickery once we figure out how to make SkGrPixelRef do
this without |
| 185 // busting chrome (for a currently unknown reason). | 180 // busting chrome (for a currently unknown reason). |
| 186 GrSurface* surface = fRenderTarget->asTexture(); | 181 GrSurface* surface = fRenderTarget->asTexture(); |
| 187 if (NULL == surface) { | 182 if (NULL == surface) { |
| 188 surface = fRenderTarget; | 183 surface = fRenderTarget; |
| 189 } | 184 } |
| 190 | 185 |
| 191 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, | 186 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, |
| 192 (surface->info(), surface, SkToBool(flags & kCac
hed_Flag))); | 187 (surface->info(), surface, SkToBool(flags & kCac
hed_Flag))); |
| 193 | 188 |
| 194 this->setPixelRef(pr)->unref(); | 189 this->setPixelRef(pr)->unref(); |
| 190 |
| 191 bool useDFFonts = !!(flags & kDFFonts_Flag); |
| 192 fMainTextContext = fContext->createTextContext(fRenderTarget, fLeakyProperti
es, useDFFonts); |
| 193 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp
erties)); |
| 195 } | 194 } |
| 196 | 195 |
| 197 SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo
, | 196 SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo
, |
| 198 int sampleCount) { | 197 int sampleCount) { |
| 199 if (kUnknown_SkColorType == origInfo.colorType() || | 198 if (kUnknown_SkColorType == origInfo.colorType() || |
| 200 origInfo.width() < 0 || origInfo.height() < 0) { | 199 origInfo.width() < 0 || origInfo.height() < 0) { |
| 201 return NULL; | 200 return NULL; |
| 202 } | 201 } |
| 203 | 202 |
| 204 SkImageInfo info = origInfo; | 203 SkImageInfo info = origInfo; |
| (...skipping 1801 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 |