Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(560)

Side by Side Diff: Source/core/platform/graphics/chromium/Canvas2DLayerBridge.cpp

Issue 14298018: This CL implements the first draft of Canvas 2D Context Attributes, aka getContext('2d', { alpha: f… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased to ToT; test cleanup Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/chromium/Canvas2DLayerBridge.h ('k') | Source/core/platform/graphics/skia/ImageBufferSkia.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698