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

Side by Side Diff: cc/TextureCopier.cpp

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

Powered by Google App Engine
This is Rietveld 408576698