OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/texture_copier.h" | 7 #include "cc/texture_copier.h" |
8 | 8 |
9 #include "CCRendererGL.h" // For the GLC() macro. | 9 #include "CCRendererGL.h" // For the GLC() macro. |
10 #include "GraphicsContext3D.h" | |
11 #include "TraceEvent.h" | 10 #include "TraceEvent.h" |
12 #include <public/WebGraphicsContext3D.h> | 11 #include <public/WebGraphicsContext3D.h> |
13 | 12 |
14 namespace cc { | 13 namespace cc { |
15 | 14 |
16 AcceleratedTextureCopier::AcceleratedTextureCopier(WebKit::WebGraphicsContext3D*
context, bool usingBindUniforms) | 15 AcceleratedTextureCopier::AcceleratedTextureCopier(WebKit::WebGraphicsContext3D*
context, bool usingBindUniforms) |
17 : m_context(context) | 16 : m_context(context) |
18 , m_usingBindUniforms(usingBindUniforms) | 17 , m_usingBindUniforms(usingBindUniforms) |
19 { | 18 { |
20 ASSERT(m_context); | 19 ASSERT(m_context); |
21 GLC(m_context, m_fbo = m_context->createFramebuffer()); | 20 GLC(m_context, m_fbo = m_context->createFramebuffer()); |
22 GLC(m_context, m_positionBuffer = m_context->createBuffer()); | 21 GLC(m_context, m_positionBuffer = m_context->createBuffer()); |
23 | 22 |
24 static const float kPositions[4][4] = { | 23 static const float kPositions[4][4] = { |
25 {-1, -1, 0, 1}, | 24 {-1, -1, 0, 1}, |
26 { 1, -1, 0, 1}, | 25 { 1, -1, 0, 1}, |
27 { 1, 1, 0, 1}, | 26 { 1, 1, 0, 1}, |
28 {-1, 1, 0, 1} | 27 {-1, 1, 0, 1} |
29 }; | 28 }; |
30 | 29 |
31 GLC(m_context, m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_posi
tionBuffer)); | 30 GLC(m_context, m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_posi
tionBuffer)); |
32 GLC(m_context, m_context->bufferData(GraphicsContext3D::ARRAY_BUFFER, sizeof
(kPositions), kPositions, GraphicsContext3D::STATIC_DRAW)); | 31 GLC(m_context, m_context->bufferData(GraphicsContext3D::ARRAY_BUFFER, sizeof
(kPositions), kPositions, GraphicsContext3D::STATIC_DRAW)); |
33 GLC(m_context, m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0)); | 32 GLC(m_context, m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0)); |
34 | 33 |
35 m_blitProgram = adoptPtr(new BlitProgram(m_context)); | 34 m_blitProgram.reset(new BlitProgram(m_context)); |
36 } | 35 } |
37 | 36 |
38 AcceleratedTextureCopier::~AcceleratedTextureCopier() | 37 AcceleratedTextureCopier::~AcceleratedTextureCopier() |
39 { | 38 { |
40 if (m_blitProgram) | 39 if (m_blitProgram) |
41 m_blitProgram->cleanup(m_context); | 40 m_blitProgram->cleanup(m_context); |
42 if (m_positionBuffer) | 41 if (m_positionBuffer) |
43 GLC(m_context, m_context->deleteBuffer(m_positionBuffer)); | 42 GLC(m_context, m_context->deleteBuffer(m_positionBuffer)); |
44 if (m_fbo) | 43 if (m_fbo) |
45 GLC(m_context, m_context->deleteFramebuffer(m_fbo)); | 44 GLC(m_context, m_context->deleteFramebuffer(m_fbo)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0)
); | 88 GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0)
); |
90 GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0)); | 89 GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0)); |
91 } | 90 } |
92 | 91 |
93 void AcceleratedTextureCopier::flush() | 92 void AcceleratedTextureCopier::flush() |
94 { | 93 { |
95 GLC(m_context, m_context->flush()); | 94 GLC(m_context, m_context->flush()); |
96 } | 95 } |
97 | 96 |
98 } | 97 } |
OLD | NEW |