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

Side by Side Diff: cc/texture_copier.cc

Issue 11111005: Remove GraphicsContext3D:: stubs from cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again 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 "cc/texture_copier.h" 7 #include "cc/texture_copier.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 "base/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
11 #include <public/WebGraphicsContext3D.h> 12 #include <public/WebGraphicsContext3D.h>
12 13
13 namespace cc { 14 namespace cc {
14 15
15 AcceleratedTextureCopier::AcceleratedTextureCopier(WebKit::WebGraphicsContext3D* context, bool usingBindUniforms) 16 AcceleratedTextureCopier::AcceleratedTextureCopier(WebKit::WebGraphicsContext3D* context, bool usingBindUniforms)
16 : m_context(context) 17 : m_context(context)
17 , m_usingBindUniforms(usingBindUniforms) 18 , m_usingBindUniforms(usingBindUniforms)
18 { 19 {
19 DCHECK(m_context); 20 DCHECK(m_context);
20 GLC(m_context, m_fbo = m_context->createFramebuffer()); 21 GLC(m_context, m_fbo = m_context->createFramebuffer());
21 GLC(m_context, m_positionBuffer = m_context->createBuffer()); 22 GLC(m_context, m_positionBuffer = m_context->createBuffer());
22 23
23 static const float kPositions[4][4] = { 24 static const float kPositions[4][4] = {
24 {-1, -1, 0, 1}, 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 }; 29 };
29 30
30 GLC(m_context, m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_posi tionBuffer)); 31 GLC(m_context, m_context->bindBuffer(GL_ARRAY_BUFFER, m_positionBuffer));
31 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));
32 GLC(m_context, m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0)); 33 GLC(m_context, m_context->bindBuffer(GL_ARRAY_BUFFER, 0));
33 34
34 m_blitProgram.reset(new BlitProgram(m_context)); 35 m_blitProgram.reset(new BlitProgram(m_context));
35 } 36 }
36 37
37 AcceleratedTextureCopier::~AcceleratedTextureCopier() 38 AcceleratedTextureCopier::~AcceleratedTextureCopier()
38 { 39 {
39 if (m_blitProgram) 40 if (m_blitProgram)
40 m_blitProgram->cleanup(m_context); 41 m_blitProgram->cleanup(m_context);
41 if (m_positionBuffer) 42 if (m_positionBuffer)
42 GLC(m_context, m_context->deleteBuffer(m_positionBuffer)); 43 GLC(m_context, m_context->deleteBuffer(m_positionBuffer));
43 if (m_fbo) 44 if (m_fbo)
44 GLC(m_context, m_context->deleteFramebuffer(m_fbo)); 45 GLC(m_context, m_context->deleteFramebuffer(m_fbo));
45 } 46 }
46 47
47 void AcceleratedTextureCopier::copyTexture(Parameters parameters) 48 void AcceleratedTextureCopier::copyTexture(Parameters parameters)
48 { 49 {
49 TRACE_EVENT0("cc", "TextureCopier::copyTexture"); 50 TRACE_EVENT0("cc", "TextureCopier::copyTexture");
50 51
51 // 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.
52 GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_ fbo)); 53 GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo));
53 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));
54 55
55 #if OS(ANDROID) 56 #if OS(ANDROID)
56 // Clear destination to improve performance on tiling GPUs. 57 // Clear destination to improve performance on tiling GPUs.
57 // 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.
58 GLC(m_context, m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT)); 59 GLC(m_context, m_context->clear(GL_COLOR_BUFFER_BIT));
59 #endif 60 #endif
60 61
61 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));
62 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));
63 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));
64 65
65 if (!m_blitProgram->initialized()) 66 if (!m_blitProgram->initialized())
66 m_blitProgram->initialize(m_context, m_usingBindUniforms); 67 m_blitProgram->initialize(m_context, m_usingBindUniforms);
67 68
68 // TODO: Use EXT_framebuffer_blit if available. 69 // TODO: Use EXT_framebuffer_blit if available.
69 GLC(m_context, m_context->useProgram(m_blitProgram->program())); 70 GLC(m_context, m_context->useProgram(m_blitProgram->program()));
70 71
71 const int kPositionAttribute = 0; 72 const int kPositionAttribute = 0;
72 GLC(m_context, m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_posi tionBuffer)); 73 GLC(m_context, m_context->bindBuffer(GL_ARRAY_BUFFER, m_positionBuffer));
73 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));
74 GLC(m_context, m_context->enableVertexAttribArray(kPositionAttribute)); 75 GLC(m_context, m_context->enableVertexAttribArray(kPositionAttribute));
75 GLC(m_context, m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0)); 76 GLC(m_context, m_context->bindBuffer(GL_ARRAY_BUFFER, 0));
76 77
77 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()));
78 GLC(m_context, m_context->disable(GraphicsContext3D::BLEND)); 79 GLC(m_context, m_context->disable(GL_BLEND));
79 GLC(m_context, m_context->drawArrays(GraphicsContext3D::TRIANGLE_FAN, 0, 4)) ; 80 GLC(m_context, m_context->drawArrays(GL_TRIANGLE_FAN, 0, 4));
80 81
81 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));
82 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));
83 GLC(m_context, m_context->disableVertexAttribArray(kPositionAttribute)); 84 GLC(m_context, m_context->disableVertexAttribArray(kPositionAttribute));
84 85
85 GLC(m_context, m_context->useProgram(0)); 86 GLC(m_context, m_context->useProgram(0));
86 87
87 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));
88 GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0) ); 89 GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, 0));
89 GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0)); 90 GLC(m_context, m_context->bindTexture(GL_TEXTURE_2D, 0));
90 } 91 }
91 92
92 void AcceleratedTextureCopier::flush() 93 void AcceleratedTextureCopier::flush()
93 { 94 {
94 GLC(m_context, m_context->flush()); 95 GLC(m_context, m_context->flush());
95 } 96 }
96 97
97 } 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