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.
5 #ifndef CC_TEXTURE_COPIER_H_
6 #define CC_TEXTURE_COPIER_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "cc/cc_export.h"
11 #include "cc/program_binding.h"
12 #include "cc/shader.h"
13 #include "third_party/khronos/GLES2/gl2.h"
14 #include "ui/gfx/size.h"
17 class WebGraphicsContext3D
;
22 class CC_EXPORT TextureCopier
{
25 unsigned sourceTexture
;
29 // Copy the base level contents of |sourceTexture| to |destTexture|. Both texture objects
30 // must be complete and have a base level of |size| dimensions. The color formats do not need
31 // to match, but |destTexture| must have a renderable format.
32 virtual void copyTexture(Parameters
) = 0;
33 virtual void flush() = 0;
35 virtual ~TextureCopier() { }
38 class CC_EXPORT AcceleratedTextureCopier
: public TextureCopier
{
40 static scoped_ptr
<AcceleratedTextureCopier
> create(WebKit::WebGraphicsContext3D
* context
, bool usingBindUniforms
)
42 return make_scoped_ptr(new AcceleratedTextureCopier(context
, usingBindUniforms
));
44 virtual ~AcceleratedTextureCopier();
46 virtual void copyTexture(Parameters
) OVERRIDE
;
47 virtual void flush() OVERRIDE
;
50 AcceleratedTextureCopier(WebKit::WebGraphicsContext3D
*, bool usingBindUniforms
);
53 typedef ProgramBinding
<VertexShaderPosTexIdentity
, FragmentShaderRGBATex
> BlitProgram
;
55 WebKit::WebGraphicsContext3D
* m_context
;
57 GLuint m_positionBuffer
;
58 scoped_ptr
<BlitProgram
> m_blitProgram
;
59 bool m_usingBindUniforms
;
61 DISALLOW_COPY_AND_ASSIGN(AcceleratedTextureCopier
);
66 #endif // CC_TEXTURE_COPIER_H_