OLD | NEW |
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" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC
ontext3D.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC
ontext3D.h" |
13 | 13 |
14 namespace gfx { | 14 namespace gfx { |
| 15 class Rect; |
15 class Size; | 16 class Size; |
16 } | 17 } |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 | 20 |
20 // Provides higher level operations on top of the WebKit::WebGraphicsContext3D | 21 // Provides higher level operations on top of the WebKit::WebGraphicsContext3D |
21 // interfaces. | 22 // interfaces. |
22 class GLHelper { | 23 class GLHelper { |
23 public: | 24 public: |
24 GLHelper(WebKit::WebGraphicsContext3D* context, | 25 GLHelper(WebKit::WebGraphicsContext3D* context, |
25 WebKit::WebGraphicsContext3D* context_for_thread); | 26 WebKit::WebGraphicsContext3D* context_for_thread); |
26 virtual ~GLHelper(); | 27 virtual ~GLHelper(); |
27 | 28 |
28 WebKit::WebGraphicsContext3D* context() const; | 29 WebKit::WebGraphicsContext3D* context() const; |
29 | 30 |
30 // Copies the contents of |src_texture| with the size of |src_size| into | 31 // Copies the block of pixels specified with |src_subrect| from |src_texture|, |
31 // |out|. The contents is transformed so that it fits in |dst_size|. | 32 // scales it to |dst_size|, and writes it into |out|. |
32 // |callback| is invoked with the copy result when the copy operation has | 33 // |src_size| is the size of |src_texture|. |callback| is invoked with the |
33 // completed. | 34 // copy result when the copy operation has completed. |
34 void CopyTextureTo(WebKit::WebGLId src_texture, | 35 void CopyTextureTo(WebKit::WebGLId src_texture, |
35 const gfx::Size& src_size, | 36 const gfx::Size& src_size, |
| 37 const gfx::Rect& src_subrect, |
36 const gfx::Size& dst_size, | 38 const gfx::Size& dst_size, |
37 unsigned char* out, | 39 unsigned char* out, |
38 const base::Callback<void(bool)>& callback); | 40 const base::Callback<void(bool)>& callback); |
39 | 41 |
40 // Returns the shader compiled from the source. | 42 // Returns the shader compiled from the source. |
41 WebKit::WebGLId CompileShaderFromSource(const WebKit::WGC3Dchar* source, | 43 WebKit::WebGLId CompileShaderFromSource(const WebKit::WGC3Dchar* source, |
42 WebKit::WGC3Denum type); | 44 WebKit::WGC3Denum type); |
43 | 45 |
44 private: | 46 private: |
45 class CopyTextureToImpl; | 47 class CopyTextureToImpl; |
46 | 48 |
47 WebKit::WebGraphicsContext3D* context_; | 49 WebKit::WebGraphicsContext3D* context_; |
48 WebKit::WebGraphicsContext3D* context_for_thread_; | 50 WebKit::WebGraphicsContext3D* context_for_thread_; |
49 scoped_ptr<CopyTextureToImpl> copy_texture_to_impl_; | 51 scoped_ptr<CopyTextureToImpl> copy_texture_to_impl_; |
50 | 52 |
51 // The number of all GLHelper instances. | 53 // The number of all GLHelper instances. |
52 static base::subtle::Atomic32 count_; | 54 static base::subtle::Atomic32 count_; |
53 | 55 |
54 DISALLOW_COPY_AND_ASSIGN(GLHelper); | 56 DISALLOW_COPY_AND_ASSIGN(GLHelper); |
55 }; | 57 }; |
56 | 58 |
57 } // namespace content | 59 } // namespace content |
58 | 60 |
59 #endif // CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_ | 61 #endif // CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_ |
OLD | NEW |