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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
218 SkImageInfo info; | 218 SkImageInfo info; |
219 surface->asImageInfo(&info); | 219 surface->asImageInfo(&info); |
220 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, surface, cached)); | 220 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, surface, cached)); |
221 | 221 |
222 this->setPixelRef(pr, 0)->unref(); | 222 this->setPixelRef(pr)->unref(); |
223 } | 223 } |
224 | 224 |
225 SkGpuDevice::SkGpuDevice(GrContext* context, | 225 SkGpuDevice::SkGpuDevice(GrContext* context, |
226 SkBitmap::Config config, | 226 SkBitmap::Config config, |
227 int width, | 227 int width, |
228 int height, | 228 int height, |
229 int sampleCount) | 229 int sampleCount) |
230 : SkBitmapDevice(make_bitmap(config, width, height, false /*isOpaque*/)) | 230 : SkBitmapDevice(make_bitmap(config, width, height, false /*isOpaque*/)) |
231 { | 231 { |
232 fDrawProcs = NULL; | 232 fDrawProcs = NULL; |
(...skipping 26 matching lines...) Expand all Loading... |
259 SkAutoTUnref<GrTexture> texture(fContext->createUncachedTexture(desc, NULL,
0)); | 259 SkAutoTUnref<GrTexture> texture(fContext->createUncachedTexture(desc, NULL,
0)); |
260 | 260 |
261 if (NULL != texture) { | 261 if (NULL != texture) { |
262 fRenderTarget = texture->asRenderTarget(); | 262 fRenderTarget = texture->asRenderTarget(); |
263 fRenderTarget->ref(); | 263 fRenderTarget->ref(); |
264 | 264 |
265 SkASSERT(NULL != fRenderTarget); | 265 SkASSERT(NULL != fRenderTarget); |
266 | 266 |
267 // wrap the bitmap with a pixelref to expose our texture | 267 // wrap the bitmap with a pixelref to expose our texture |
268 SkGrPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, texture)); | 268 SkGrPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, texture)); |
269 this->setPixelRef(pr, 0)->unref(); | 269 this->setPixelRef(pr)->unref(); |
270 } else { | 270 } else { |
271 GrPrintf("--- failed to create gpu-offscreen [%d %d]\n", | 271 GrPrintf("--- failed to create gpu-offscreen [%d %d]\n", |
272 width, height); | 272 width, height); |
273 SkASSERT(false); | 273 SkASSERT(false); |
274 } | 274 } |
275 } | 275 } |
276 | 276 |
277 SkGpuDevice::~SkGpuDevice() { | 277 SkGpuDevice::~SkGpuDevice() { |
278 if (fDrawProcs) { | 278 if (fDrawProcs) { |
279 delete fDrawProcs; | 279 delete fDrawProcs; |
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1919 GrTexture* texture, | 1919 GrTexture* texture, |
1920 bool needClear) | 1920 bool needClear) |
1921 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { | 1921 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { |
1922 | 1922 |
1923 SkASSERT(texture && texture->asRenderTarget()); | 1923 SkASSERT(texture && texture->asRenderTarget()); |
1924 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture | 1924 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture |
1925 // cache. We pass true for the third argument so that it will get unlocked. | 1925 // cache. We pass true for the third argument so that it will get unlocked. |
1926 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1926 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
1927 fNeedClear = needClear; | 1927 fNeedClear = needClear; |
1928 } | 1928 } |
OLD | NEW |