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 27 matching lines...) Expand all Loading... |
38 #include <public/Platform.h> | 38 #include <public/Platform.h> |
39 #include <public/WebCompositorSupport.h> | 39 #include <public/WebCompositorSupport.h> |
40 #include <public/WebGraphicsContext3D.h> | 40 #include <public/WebGraphicsContext3D.h> |
41 | 41 |
42 using WebKit::WebExternalTextureLayer; | 42 using WebKit::WebExternalTextureLayer; |
43 using WebKit::WebGraphicsContext3D; | 43 using WebKit::WebGraphicsContext3D; |
44 using WebKit::WebTextureUpdater; | 44 using WebKit::WebTextureUpdater; |
45 | 45 |
46 namespace WebCore { | 46 namespace WebCore { |
47 | 47 |
48 Canvas2DLayerBridge::Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context,
SkDeferredCanvas* canvas, ThreadMode threadMode) | 48 Canvas2DLayerBridge::Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context,
SkDeferredCanvas* canvas, OpacityMode opacityMode, ThreadMode threadMode) |
49 : m_canvas(canvas) | 49 : m_canvas(canvas) |
50 , m_context(context) | 50 , m_context(context) |
51 , m_bytesAllocated(0) | 51 , m_bytesAllocated(0) |
52 , m_didRecordDrawCommand(false) | 52 , m_didRecordDrawCommand(false) |
53 , m_framesPending(0) | 53 , m_framesPending(0) |
54 , m_next(0) | 54 , m_next(0) |
55 , m_prev(0) | 55 , m_prev(0) |
56 { | 56 { |
57 ASSERT(m_canvas); | 57 ASSERT(m_canvas); |
58 // Used by browser tests to detect the use of a Canvas2DLayerBridge. | 58 // Used by browser tests to detect the use of a Canvas2DLayerBridge. |
59 TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation"); | 59 TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation"); |
60 m_canvas->setNotificationClient(this); | 60 m_canvas->setNotificationClient(this); |
61 m_layer = adoptPtr(WebKit::Platform::current()->compositorSupport()->createE
xternalTextureLayer(this)); | 61 m_layer = adoptPtr(WebKit::Platform::current()->compositorSupport()->createE
xternalTextureLayer(this)); |
62 m_layer->setRateLimitContext(threadMode == SingleThread); | 62 m_layer->setRateLimitContext(threadMode == SingleThread); |
63 GrRenderTarget* renderTarget = reinterpret_cast<GrRenderTarget*>(m_canvas->g
etDevice()->accessRenderTarget()); | 63 GrRenderTarget* renderTarget = reinterpret_cast<GrRenderTarget*>(m_canvas->g
etDevice()->accessRenderTarget()); |
64 if (renderTarget) { | 64 if (renderTarget) { |
65 m_layer->setTextureId(renderTarget->asTexture()->getTextureHandle()); | 65 m_layer->setTextureId(renderTarget->asTexture()->getTextureHandle()); |
66 } | 66 } |
| 67 m_layer->setOpaque(opacityMode == Opaque); |
67 GraphicsLayerChromium::registerContentsLayer(m_layer->layer()); | 68 GraphicsLayerChromium::registerContentsLayer(m_layer->layer()); |
68 } | 69 } |
69 | 70 |
70 Canvas2DLayerBridge::~Canvas2DLayerBridge() | 71 Canvas2DLayerBridge::~Canvas2DLayerBridge() |
71 { | 72 { |
72 GraphicsLayerChromium::unregisterContentsLayer(m_layer->layer()); | 73 GraphicsLayerChromium::unregisterContentsLayer(m_layer->layer()); |
73 Canvas2DLayerManager::get().layerToBeDestroyed(this); | 74 Canvas2DLayerManager::get().layerToBeDestroyed(this); |
74 m_canvas->setNotificationClient(0); | 75 m_canvas->setNotificationClient(0); |
75 m_layer->setTextureId(0); | 76 m_layer->setTextureId(0); |
76 } | 77 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 m_canvas->flush(); | 170 m_canvas->flush(); |
170 m_context->flush(); | 171 m_context->flush(); |
171 GrRenderTarget* renderTarget = reinterpret_cast<GrRenderTarget*>(m_canvas->g
etDevice()->accessRenderTarget()); | 172 GrRenderTarget* renderTarget = reinterpret_cast<GrRenderTarget*>(m_canvas->g
etDevice()->accessRenderTarget()); |
172 if (renderTarget) { | 173 if (renderTarget) { |
173 return renderTarget->asTexture()->getTextureHandle(); | 174 return renderTarget->asTexture()->getTextureHandle(); |
174 } | 175 } |
175 return 0; | 176 return 0; |
176 } | 177 } |
177 | 178 |
178 } | 179 } |
OLD | NEW |