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

Side by Side Diff: content/common/gpu/client/gl_helper.h

Issue 11234008: Enable texture readback support for Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #ifndef CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_ 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_
6 #define CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_ 6 #define CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_
7 7
8 #include "base/atomicops.h" 8 #include "base/atomicops.h"
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 12 matching lines...) Expand all
23 class GLHelper { 23 class GLHelper {
24 public: 24 public:
25 GLHelper(WebKit::WebGraphicsContext3D* context, 25 GLHelper(WebKit::WebGraphicsContext3D* context,
26 WebKit::WebGraphicsContext3D* context_for_thread); 26 WebKit::WebGraphicsContext3D* context_for_thread);
27 virtual ~GLHelper(); 27 virtual ~GLHelper();
28 28
29 WebKit::WebGraphicsContext3D* context() const; 29 WebKit::WebGraphicsContext3D* context() const;
30 30
31 // Copies the block of pixels specified with |src_subrect| from |src_texture|, 31 // Copies the block of pixels specified with |src_subrect| from |src_texture|,
32 // scales it to |dst_size|, and writes it into |out|. 32 // scales it to |dst_size|, and writes it into |out|.
33 // |src_size| is the size of |src_texture|. |callback| is invoked with the 33 // |src_size| is the size of |src_texture|. The result is of format GL_BGRA
34 // copy result when the copy operation has completed. 34 // and is potentially flipped vertically to make it a correct image
35 void CopyTextureTo(WebKit::WebGLId src_texture, 35 // representation. |callback| is invoked with the copy result when the copy
36 const gfx::Size& src_size, 36 // operation has completed.
37 const gfx::Rect& src_subrect, 37 void CropScaleReadbackAndCleanTexture(
38 const gfx::Size& dst_size, 38 WebKit::WebGLId src_texture,
39 unsigned char* out, 39 const gfx::Size& src_size,
40 const base::Callback<void(bool)>& callback); 40 const gfx::Rect& src_subrect,
41 const gfx::Size& dst_size,
42 unsigned char* out,
43 const base::Callback<void(bool)>& callback);
44
45 // Copies the texture data out of |texture| into |out|. |size| is the
46 // size of the texture. No post processing is applied to the pixels. The
47 // texture is assumed to have a format of GL_RGBA with a pixel type of
48 // GL_UNSIGNED_BYTE. This is a blocking call that calls glReadPixels on this
49 // current context.
50 void ReadbackTextureSync(WebKit::WebGLId texture,
51 const gfx::Size& size,
52 unsigned char* out);
41 53
42 // Creates a copy of the specified texture. |size| is the size of the texture. 54 // Creates a copy of the specified texture. |size| is the size of the texture.
43 WebKit::WebGLId CopyTexture(WebKit::WebGLId texture, 55 WebKit::WebGLId CopyTexture(WebKit::WebGLId texture,
44 const gfx::Size& size); 56 const gfx::Size& size);
45 57
58 // Creates a scaled copy of the specified texture. |src_size| is the size of
59 // the texture and |dst_size| is the size of the resulting copy.
60 WebKit::WebGLId CopyAndScaleTexture(WebKit::WebGLId texture,
61 const gfx::Size& src_size,
62 const gfx::Size& dst_size);
63
46 // Returns the shader compiled from the source. 64 // Returns the shader compiled from the source.
47 WebKit::WebGLId CompileShaderFromSource(const WebKit::WGC3Dchar* source, 65 WebKit::WebGLId CompileShaderFromSource(const WebKit::WGC3Dchar* source,
48 WebKit::WGC3Denum type); 66 WebKit::WGC3Denum type);
49 67
50 private: 68 private:
51 class CopyTextureToImpl; 69 class CopyTextureToImpl;
52 70
53 // Creates |copy_texture_to_impl_| if NULL. 71 // Creates |copy_texture_to_impl_| if NULL.
54 void InitCopyTextToImpl(); 72 void InitCopyTextToImpl();
55 73
56 WebKit::WebGraphicsContext3D* context_; 74 WebKit::WebGraphicsContext3D* context_;
57 WebKit::WebGraphicsContext3D* context_for_thread_; 75 WebKit::WebGraphicsContext3D* context_for_thread_;
58 scoped_ptr<CopyTextureToImpl> copy_texture_to_impl_; 76 scoped_ptr<CopyTextureToImpl> copy_texture_to_impl_;
59 77
60 // The number of all GLHelper instances. 78 // The number of all GLHelper instances.
61 static base::subtle::Atomic32 count_; 79 static base::subtle::Atomic32 count_;
62 80
63 DISALLOW_COPY_AND_ASSIGN(GLHelper); 81 DISALLOW_COPY_AND_ASSIGN(GLHelper);
64 }; 82 };
65 83
66 } // namespace content 84 } // namespace content
67 85
68 #endif // CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_ 86 #endif // CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698