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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 }; | 48 }; |
49 | 49 |
50 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, canvas2DLayerBridgeInstance
Counter, ("Canvas2DLayerBridge")); | 50 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, canvas2DLayerBridgeInstance
Counter, ("Canvas2DLayerBridge")); |
51 } | 51 } |
52 | 52 |
53 namespace WebCore { | 53 namespace WebCore { |
54 | 54 |
55 static PassRefPtr<SkSurface> createSkSurface(GrContext* gr, const IntSize& size,
int msaaSampleCount = 0) | 55 static PassRefPtr<SkSurface> createSkSurface(GrContext* gr, const IntSize& size,
int msaaSampleCount = 0) |
56 { | 56 { |
57 if (!gr) | 57 if (!gr) |
58 return 0; | 58 return nullptr; |
59 gr->resetContext(); | 59 gr->resetContext(); |
60 SkImageInfo info; | 60 SkImageInfo info; |
61 info.fWidth = size.width(); | 61 info.fWidth = size.width(); |
62 info.fHeight = size.height(); | 62 info.fHeight = size.height(); |
63 info.fColorType = kPMColor_SkColorType; | 63 info.fColorType = kPMColor_SkColorType; |
64 info.fAlphaType = kPremul_SkAlphaType; | 64 info.fAlphaType = kPremul_SkAlphaType; |
65 return adoptRef(SkSurface::NewRenderTarget(gr, info, msaaSampleCount)); | 65 return adoptRef(SkSurface::NewRenderTarget(gr, info, msaaSampleCount)); |
66 } | 66 } |
67 | 67 |
68 PassRefPtr<Canvas2DLayerBridge> Canvas2DLayerBridge::create(const IntSize& size,
OpacityMode opacityMode, int msaaSampleCount) | 68 PassRefPtr<Canvas2DLayerBridge> Canvas2DLayerBridge::create(const IntSize& size,
OpacityMode opacityMode, int msaaSampleCount) |
69 { | 69 { |
70 TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation"); | 70 TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation"); |
71 OwnPtr<blink::WebGraphicsContext3DProvider> contextProvider = adoptPtr(blink
::Platform::current()->createSharedOffscreenGraphicsContext3DProvider()); | 71 OwnPtr<blink::WebGraphicsContext3DProvider> contextProvider = adoptPtr(blink
::Platform::current()->createSharedOffscreenGraphicsContext3DProvider()); |
72 if (!contextProvider) | 72 if (!contextProvider) |
73 return 0; | 73 return nullptr; |
74 RefPtr<SkSurface> surface(createSkSurface(contextProvider->grContext(), size
, msaaSampleCount)); | 74 RefPtr<SkSurface> surface(createSkSurface(contextProvider->grContext(), size
, msaaSampleCount)); |
75 if (!surface) | 75 if (!surface) |
76 return 0; | 76 return nullptr; |
77 RefPtr<Canvas2DLayerBridge> layerBridge; | 77 RefPtr<Canvas2DLayerBridge> layerBridge; |
78 OwnPtr<SkDeferredCanvas> canvas = adoptPtr(SkDeferredCanvas::Create(surface.
get())); | 78 OwnPtr<SkDeferredCanvas> canvas = adoptPtr(SkDeferredCanvas::Create(surface.
get())); |
79 layerBridge = adoptRef(new Canvas2DLayerBridge(contextProvider.release(), ca
nvas.release(), msaaSampleCount, opacityMode)); | 79 layerBridge = adoptRef(new Canvas2DLayerBridge(contextProvider.release(), ca
nvas.release(), msaaSampleCount, opacityMode)); |
80 return layerBridge.release(); | 80 return layerBridge.release(); |
81 } | 81 } |
82 | 82 |
83 Canvas2DLayerBridge::Canvas2DLayerBridge(PassOwnPtr<blink::WebGraphicsContext3DP
rovider> contextProvider, PassOwnPtr<SkDeferredCanvas> canvas, int msaaSampleCou
nt, OpacityMode opacityMode) | 83 Canvas2DLayerBridge::Canvas2DLayerBridge(PassOwnPtr<blink::WebGraphicsContext3DP
rovider> contextProvider, PassOwnPtr<SkDeferredCanvas> canvas, int msaaSampleCou
nt, OpacityMode opacityMode) |
84 : m_canvas(canvas) | 84 : m_canvas(canvas) |
85 , m_contextProvider(contextProvider) | 85 , m_contextProvider(contextProvider) |
86 , m_msaaSampleCount(msaaSampleCount) | 86 , m_msaaSampleCount(msaaSampleCount) |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) { | 505 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) { |
506 // This copy constructor should only be used for Vector reallocation | 506 // This copy constructor should only be used for Vector reallocation |
507 // Assuming 'other' is to be destroyed, we transfer m_image ownership | 507 // Assuming 'other' is to be destroyed, we transfer m_image ownership |
508 // rather than do a refcount dance. | 508 // rather than do a refcount dance. |
509 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); | 509 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); |
510 m_image = const_cast<MailboxInfo*>(&other)->m_image.release(); | 510 m_image = const_cast<MailboxInfo*>(&other)->m_image.release(); |
511 m_status = other.m_status; | 511 m_status = other.m_status; |
512 } | 512 } |
513 | 513 |
514 } | 514 } |
OLD | NEW |