OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 47 matching lines...) Loading... | |
58 info.fAlphaType = SkImage::kPremul_AlphaType; | 58 info.fAlphaType = SkImage::kPremul_AlphaType; |
59 return SkSurface::NewRenderTarget(gr, info); | 59 return SkSurface::NewRenderTarget(gr, info); |
60 } | 60 } |
61 | 61 |
62 PassOwnPtr<Canvas2DLayerBridge> Canvas2DLayerBridge::create(PassRefPtr<GraphicsC ontext3D> context, const IntSize& size, OpacityMode opacityMode) | 62 PassOwnPtr<Canvas2DLayerBridge> Canvas2DLayerBridge::create(PassRefPtr<GraphicsC ontext3D> context, const IntSize& size, OpacityMode opacityMode) |
63 { | 63 { |
64 TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation"); | 64 TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation"); |
65 SkAutoTUnref<SkSurface> surface(createSurface(context.get(), size)); | 65 SkAutoTUnref<SkSurface> surface(createSurface(context.get(), size)); |
66 if (!surface.get()) | 66 if (!surface.get()) |
67 return PassOwnPtr<Canvas2DLayerBridge>(); | 67 return PassOwnPtr<Canvas2DLayerBridge>(); |
68 SkDeferredCanvas* canvas = new SkDeferredCanvas(surface); | 68 SkDeferredCanvas* canvas = SkDeferredCanvas::Create(surface.get()); |
69 OwnPtr<Canvas2DLayerBridge> layerBridge = adoptPtr(new Canvas2DLayerBridge(c ontext, canvas, opacityMode)); | 69 OwnPtr<Canvas2DLayerBridge> layerBridge = adoptPtr(new Canvas2DLayerBridge(c ontext, canvas, opacityMode)); |
Stephen White
2013/08/08 18:04:59
Not new to this patch, but the ownership semantics
| |
70 return layerBridge.release(); | 70 return layerBridge.release(); |
71 } | 71 } |
72 | 72 |
73 Canvas2DLayerBridge::Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, SkDeferredCanvas* canvas, OpacityMode opacityMode) | 73 Canvas2DLayerBridge::Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, SkDeferredCanvas* canvas, OpacityMode opacityMode) |
74 : m_canvas(canvas) | 74 : m_canvas(canvas) |
75 , m_context(context) | 75 , m_context(context) |
76 , m_bytesAllocated(0) | 76 , m_bytesAllocated(0) |
77 , m_didRecordDrawCommand(false) | 77 , m_didRecordDrawCommand(false) |
78 , m_surfaceIsValid(true) | 78 , m_surfaceIsValid(true) |
79 , m_framesPending(0) | 79 , m_framesPending(0) |
(...skipping 263 matching lines...) Loading... | |
343 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) { | 343 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) { |
344 // This copy constructor should only be used for Vector reallocation | 344 // This copy constructor should only be used for Vector reallocation |
345 // Assuming 'other' is to be destroyed, we swap m_image ownership | 345 // Assuming 'other' is to be destroyed, we swap m_image ownership |
346 // rather than do a refcount dance. | 346 // rather than do a refcount dance. |
347 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); | 347 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); |
348 m_image.swap(const_cast<SkAutoTUnref<SkImage>*>(&other.m_image)); | 348 m_image.swap(const_cast<SkAutoTUnref<SkImage>*>(&other.m_image)); |
349 m_status = other.m_status; | 349 m_status = other.m_status; |
350 } | 350 } |
351 | 351 |
352 } | 352 } |
OLD | NEW |