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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 } | 181 } |
182 | 182 |
183 void SkGpuDevice::initFromRenderTarget(GrContext* context, | 183 void SkGpuDevice::initFromRenderTarget(GrContext* context, |
184 GrRenderTarget* renderTarget, | 184 GrRenderTarget* renderTarget, |
185 unsigned flags) { | 185 unsigned flags) { |
186 fDrawProcs = NULL; | 186 fDrawProcs = NULL; |
187 | 187 |
188 fContext = context; | 188 fContext = context; |
189 fContext->ref(); | 189 fContext->ref(); |
190 | 190 |
191 fMainTextContext = SkNEW_ARGS(GrDistanceFieldTextContext, (fContext, fLeakyP roperties)); | |
192 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp erties)); | |
193 | |
194 fRenderTarget = NULL; | 191 fRenderTarget = NULL; |
195 fNeedClear = flags & kNeedClear_Flag; | 192 fNeedClear = flags & kNeedClear_Flag; |
196 | 193 |
197 SkASSERT(NULL != renderTarget); | 194 SkASSERT(NULL != renderTarget); |
198 fRenderTarget = renderTarget; | 195 fRenderTarget = renderTarget; |
199 fRenderTarget->ref(); | 196 fRenderTarget->ref(); |
200 | 197 |
201 // Hold onto to the texture in the pixel ref (if there is one) because the t exture holds a ref | 198 // Hold onto to the texture in the pixel ref (if there is one) because the t exture holds a ref |
202 // on the RT but not vice-versa. | 199 // on the RT but not vice-versa. |
203 // TODO: Remove this trickery once we figure out how to make SkGrPixelRef do this without | 200 // TODO: Remove this trickery once we figure out how to make SkGrPixelRef do this without |
204 // busting chrome (for a currently unknown reason). | 201 // busting chrome (for a currently unknown reason). |
205 GrSurface* surface = fRenderTarget->asTexture(); | 202 GrSurface* surface = fRenderTarget->asTexture(); |
206 if (NULL == surface) { | 203 if (NULL == surface) { |
207 surface = fRenderTarget; | 204 surface = fRenderTarget; |
208 } | 205 } |
209 | 206 |
210 SkImageInfo info; | 207 SkImageInfo info; |
211 surface->asImageInfo(&info); | 208 surface->asImageInfo(&info); |
212 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, surface, SkToBool(flags & k Cached_Flag))); | 209 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, surface, SkToBool(flags & k Cached_Flag))); |
213 | 210 |
214 this->setPixelRef(pr)->unref(); | 211 this->setPixelRef(pr)->unref(); |
212 | |
213 fMainTextContext = fContext->createTextContext(fRenderTarget, fLeakyProperti es); | |
214 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp erties)); | |
215 } | 215 } |
216 | 216 |
217 SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo , | 217 SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo , |
218 int sampleCount) { | 218 int sampleCount) { |
219 if (kUnknown_SkColorType == origInfo.colorType() || | 219 if (kUnknown_SkColorType == origInfo.colorType() || |
220 origInfo.width() < 0 || origInfo.height() < 0) { | 220 origInfo.width() < 0 || origInfo.height() < 0) { |
221 return NULL; | 221 return NULL; |
222 } | 222 } |
223 | 223 |
224 SkImageInfo info = origInfo; | 224 SkImageInfo info = origInfo; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 int width, | 261 int width, |
262 int height, | 262 int height, |
263 int sampleCount) | 263 int sampleCount) |
264 : SkBitmapDevice(make_bitmap(config, width, height)) | 264 : SkBitmapDevice(make_bitmap(config, width, height)) |
265 { | 265 { |
266 fDrawProcs = NULL; | 266 fDrawProcs = NULL; |
267 | 267 |
268 fContext = context; | 268 fContext = context; |
269 fContext->ref(); | 269 fContext->ref(); |
270 | 270 |
271 fMainTextContext = SkNEW_ARGS(GrDistanceFieldTextContext, (fContext, fLeakyP roperties)); | |
272 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp erties)); | |
273 | |
274 fRenderTarget = NULL; | 271 fRenderTarget = NULL; |
275 fNeedClear = false; | 272 fNeedClear = false; |
276 | 273 |
277 if (config != SkBitmap::kRGB_565_Config) { | 274 if (config != SkBitmap::kRGB_565_Config) { |
278 config = SkBitmap::kARGB_8888_Config; | 275 config = SkBitmap::kARGB_8888_Config; |
279 } | 276 } |
280 | 277 |
281 GrTextureDesc desc; | 278 GrTextureDesc desc; |
282 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 279 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
283 desc.fWidth = width; | 280 desc.fWidth = width; |
(...skipping 18 matching lines...) Expand all Loading... | |
302 SkASSERT(NULL != fRenderTarget); | 299 SkASSERT(NULL != fRenderTarget); |
303 | 300 |
304 // wrap the bitmap with a pixelref to expose our texture | 301 // wrap the bitmap with a pixelref to expose our texture |
305 SkGrPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, texture)); | 302 SkGrPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, texture)); |
306 this->setPixelRef(pr)->unref(); | 303 this->setPixelRef(pr)->unref(); |
307 } else { | 304 } else { |
308 GrPrintf("--- failed to create gpu-offscreen [%d %d]\n", | 305 GrPrintf("--- failed to create gpu-offscreen [%d %d]\n", |
309 width, height); | 306 width, height); |
310 SkASSERT(false); | 307 SkASSERT(false); |
311 } | 308 } |
309 | |
310 fMainTextContext = fContext->createTextContext(fRenderTarget, fLeakyProperti es); | |
Kimmo Kinnunen
2014/03/25 12:32:48
Jim, this hunk was wrong before. Eg. it wasn't eve
| |
311 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp erties)); | |
312 } | 312 } |
313 #endif | 313 #endif |
314 | 314 |
315 SkGpuDevice::~SkGpuDevice() { | 315 SkGpuDevice::~SkGpuDevice() { |
316 if (fDrawProcs) { | 316 if (fDrawProcs) { |
317 delete fDrawProcs; | 317 delete fDrawProcs; |
318 } | 318 } |
319 | 319 |
320 delete fMainTextContext; | 320 delete fMainTextContext; |
321 delete fFallbackTextContext; | 321 delete fFallbackTextContext; |
(...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2030 if (NULL == data) { | 2030 if (NULL == data) { |
2031 return false; | 2031 return false; |
2032 } | 2032 } |
2033 | 2033 |
2034 #if 0 | 2034 #if 0 |
2035 const GPUAccelData *gpuData = static_cast<const GPUAccelData*>(data); | 2035 const GPUAccelData *gpuData = static_cast<const GPUAccelData*>(data); |
2036 #endif | 2036 #endif |
2037 | 2037 |
2038 return false; | 2038 return false; |
2039 } | 2039 } |
OLD | NEW |