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

Side by Side Diff: cc/texture_copier.cc

Issue 11150025: Patch from https://codereview.chromium.org/11111005/ without actual file deletes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
« no previous file with comments | « cc/texture_copier.h ('k') | cc/texture_copier_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "TextureCopier.h" 7 #include "TextureCopier.h"
8 8
9 #include "third_party/khronos/GLES2/gl2.h"
9 #include "CCRendererGL.h" // For the GLC() macro. 10 #include "CCRendererGL.h" // For the GLC() macro.
10 #include "GraphicsContext3D.h"
11 #include "TraceEvent.h" 11 #include "TraceEvent.h"
12 #include <public/WebGraphicsContext3D.h> 12 #include <public/WebGraphicsContext3D.h>
13 13
14 namespace cc { 14 namespace cc {
15 15
16 AcceleratedTextureCopier::AcceleratedTextureCopier(WebKit::WebGraphicsContext3D* context, bool usingBindUniforms) 16 AcceleratedTextureCopier::AcceleratedTextureCopier(WebKit::WebGraphicsContext3D* context, bool usingBindUniforms)
17 : m_context(context) 17 : m_context(context)
18 , m_usingBindUniforms(usingBindUniforms) 18 , m_usingBindUniforms(usingBindUniforms)
19 { 19 {
20 ASSERT(m_context); 20 ASSERT(m_context);
21 GLC(m_context, m_fbo = m_context->createFramebuffer()); 21 GLC(m_context, m_fbo = m_context->createFramebuffer());
22 GLC(m_context, m_positionBuffer = m_context->createBuffer()); 22 GLC(m_context, m_positionBuffer = m_context->createBuffer());
23 23
24 static const float kPositions[4][4] = { 24 static const float kPositions[4][4] = {
25 {-1, -1, 0, 1}, 25 {-1, -1, 0, 1},
26 { 1, -1, 0, 1}, 26 { 1, -1, 0, 1},
27 { 1, 1, 0, 1}, 27 { 1, 1, 0, 1},
28 {-1, 1, 0, 1} 28 {-1, 1, 0, 1}
29 }; 29 };
30 30
31 GLC(m_context, m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_posi tionBuffer)); 31 GLC(m_context, m_context->bindBuffer(GL_ARRAY_BUFFER, m_positionBuffer));
32 GLC(m_context, m_context->bufferData(GraphicsContext3D::ARRAY_BUFFER, sizeof (kPositions), kPositions, GraphicsContext3D::STATIC_DRAW)); 32 GLC(m_context, m_context->bufferData(GL_ARRAY_BUFFER, sizeof(kPositions), kP ositions, GL_STATIC_DRAW));
33 GLC(m_context, m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0)); 33 GLC(m_context, m_context->bindBuffer(GL_ARRAY_BUFFER, 0));
34 34
35 m_blitProgram = adoptPtr(new BlitProgram(m_context)); 35 m_blitProgram = adoptPtr(new BlitProgram(m_context));
36 } 36 }
37 37
38 AcceleratedTextureCopier::~AcceleratedTextureCopier() 38 AcceleratedTextureCopier::~AcceleratedTextureCopier()
39 { 39 {
40 if (m_blitProgram) 40 if (m_blitProgram)
41 m_blitProgram->cleanup(m_context); 41 m_blitProgram->cleanup(m_context);
42 if (m_positionBuffer) 42 if (m_positionBuffer)
43 GLC(m_context, m_context->deleteBuffer(m_positionBuffer)); 43 GLC(m_context, m_context->deleteBuffer(m_positionBuffer));
44 if (m_fbo) 44 if (m_fbo)
45 GLC(m_context, m_context->deleteFramebuffer(m_fbo)); 45 GLC(m_context, m_context->deleteFramebuffer(m_fbo));
46 } 46 }
47 47
48 void AcceleratedTextureCopier::copyTexture(Parameters parameters) 48 void AcceleratedTextureCopier::copyTexture(Parameters parameters)
49 { 49 {
50 TRACE_EVENT0("cc", "TextureCopier::copyTexture"); 50 TRACE_EVENT0("cc", "TextureCopier::copyTexture");
51 51
52 // Note: this code does not restore the viewport, bound program, 2D texture, framebuffer, buffer or blend enable. 52 // Note: this code does not restore the viewport, bound program, 2D texture, framebuffer, buffer or blend enable.
53 GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_ fbo)); 53 GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo));
54 GLC(m_context, m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFE R, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, paramete rs.destTexture, 0)); 54 GLC(m_context, m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTA CHMENT0, GL_TEXTURE_2D, parameters.destTexture, 0));
55 55
56 #if OS(ANDROID) 56 #if OS(ANDROID)
57 // Clear destination to improve performance on tiling GPUs. 57 // Clear destination to improve performance on tiling GPUs.
58 // TODO: Use EXT_discard_framebuffer or skip clearing if it isn't available. 58 // TODO: Use EXT_discard_framebuffer or skip clearing if it isn't available.
59 GLC(m_context, m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT)); 59 GLC(m_context, m_context->clear(GL_COLOR_BUFFER_BIT));
60 #endif 60 #endif
61 61
62 GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, paramet ers.sourceTexture)); 62 GLC(m_context, m_context->bindTexture(GL_TEXTURE_2D, parameters.sourceTextur e));
63 GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, Graph icsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::NEAREST)); 63 GLC(m_context, m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER , GL_NEAREST));
64 GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, Graph icsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::NEAREST)); 64 GLC(m_context, m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER , GL_NEAREST));
65 65
66 if (!m_blitProgram->initialized()) 66 if (!m_blitProgram->initialized())
67 m_blitProgram->initialize(m_context, m_usingBindUniforms); 67 m_blitProgram->initialize(m_context, m_usingBindUniforms);
68 68
69 // TODO: Use EXT_framebuffer_blit if available. 69 // TODO: Use EXT_framebuffer_blit if available.
70 GLC(m_context, m_context->useProgram(m_blitProgram->program())); 70 GLC(m_context, m_context->useProgram(m_blitProgram->program()));
71 71
72 const int kPositionAttribute = 0; 72 const int kPositionAttribute = 0;
73 GLC(m_context, m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_posi tionBuffer)); 73 GLC(m_context, m_context->bindBuffer(GL_ARRAY_BUFFER, m_positionBuffer));
74 GLC(m_context, m_context->vertexAttribPointer(kPositionAttribute, 4, Graphic sContext3D::FLOAT, false, 0, 0)); 74 GLC(m_context, m_context->vertexAttribPointer(kPositionAttribute, 4, GL_FLOA T, false, 0, 0));
75 GLC(m_context, m_context->enableVertexAttribArray(kPositionAttribute)); 75 GLC(m_context, m_context->enableVertexAttribArray(kPositionAttribute));
76 GLC(m_context, m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0)); 76 GLC(m_context, m_context->bindBuffer(GL_ARRAY_BUFFER, 0));
77 77
78 GLC(m_context, m_context->viewport(0, 0, parameters.size.width(), parameters .size.height())); 78 GLC(m_context, m_context->viewport(0, 0, parameters.size.width(), parameters .size.height()));
79 GLC(m_context, m_context->disable(GraphicsContext3D::BLEND)); 79 GLC(m_context, m_context->disable(GL_BLEND));
80 GLC(m_context, m_context->drawArrays(GraphicsContext3D::TRIANGLE_FAN, 0, 4)) ; 80 GLC(m_context, m_context->drawArrays(GL_TRIANGLE_FAN, 0, 4));
81 81
82 GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, Graph icsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR)); 82 GLC(m_context, m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER , GL_LINEAR));
83 GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, Graph icsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); 83 GLC(m_context, m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER , GL_LINEAR));
84 GLC(m_context, m_context->disableVertexAttribArray(kPositionAttribute)); 84 GLC(m_context, m_context->disableVertexAttribArray(kPositionAttribute));
85 85
86 GLC(m_context, m_context->useProgram(0)); 86 GLC(m_context, m_context->useProgram(0));
87 87
88 GLC(m_context, m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFE R, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, 0, 0)); 88 GLC(m_context, m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTA CHMENT0, GL_TEXTURE_2D, 0, 0));
89 GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0) ); 89 GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, 0));
90 GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0)); 90 GLC(m_context, m_context->bindTexture(GL_TEXTURE_2D, 0));
91 } 91 }
92 92
93 void AcceleratedTextureCopier::flush() 93 void AcceleratedTextureCopier::flush()
94 { 94 {
95 GLC(m_context, m_context->flush()); 95 GLC(m_context, m_context->flush());
96 } 96 }
97 97
98 } 98 }
OLDNEW
« no previous file with comments | « cc/texture_copier.h ('k') | cc/texture_copier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698