| 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" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 class SkRegion; | 29 class SkRegion; |
| 30 | 30 |
| 31 namespace content { | 31 namespace content { |
| 32 | 32 |
| 33 class GLHelperScaling; | 33 class GLHelperScaling; |
| 34 | 34 |
| 35 class ScopedWebGLId { | 35 class ScopedWebGLId { |
| 36 public: | 36 public: |
| 37 typedef void (WebKit::WebGraphicsContext3D::*DeleteFunc)(WebGLId); | 37 typedef void (blink::WebGraphicsContext3D::*DeleteFunc)(WebGLId); |
| 38 ScopedWebGLId(WebKit::WebGraphicsContext3D* context, | 38 ScopedWebGLId(blink::WebGraphicsContext3D* context, |
| 39 WebGLId id, | 39 WebGLId id, |
| 40 DeleteFunc delete_func) | 40 DeleteFunc delete_func) |
| 41 : context_(context), | 41 : context_(context), |
| 42 id_(id), | 42 id_(id), |
| 43 delete_func_(delete_func) { | 43 delete_func_(delete_func) { |
| 44 } | 44 } |
| 45 | 45 |
| 46 operator WebGLId() const { | 46 operator WebGLId() const { |
| 47 return id_; | 47 return id_; |
| 48 } | 48 } |
| 49 | 49 |
| 50 WebGLId id() const { return id_; } | 50 WebGLId id() const { return id_; } |
| 51 | 51 |
| 52 WebGLId Detach() { | 52 WebGLId Detach() { |
| 53 WebGLId id = id_; | 53 WebGLId id = id_; |
| 54 id_ = 0; | 54 id_ = 0; |
| 55 return id; | 55 return id; |
| 56 } | 56 } |
| 57 | 57 |
| 58 ~ScopedWebGLId() { | 58 ~ScopedWebGLId() { |
| 59 if (id_ != 0) { | 59 if (id_ != 0) { |
| 60 (context_->*delete_func_)(id_); | 60 (context_->*delete_func_)(id_); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 WebKit::WebGraphicsContext3D* context_; | 65 blink::WebGraphicsContext3D* context_; |
| 66 WebGLId id_; | 66 WebGLId id_; |
| 67 DeleteFunc delete_func_; | 67 DeleteFunc delete_func_; |
| 68 | 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(ScopedWebGLId); | 69 DISALLOW_COPY_AND_ASSIGN(ScopedWebGLId); |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 class ScopedBuffer : public ScopedWebGLId { | 72 class ScopedBuffer : public ScopedWebGLId { |
| 73 public: | 73 public: |
| 74 ScopedBuffer(WebKit::WebGraphicsContext3D* context, | 74 ScopedBuffer(blink::WebGraphicsContext3D* context, |
| 75 WebGLId id) | 75 WebGLId id) |
| 76 : ScopedWebGLId(context, | 76 : ScopedWebGLId(context, |
| 77 id, | 77 id, |
| 78 &WebKit::WebGraphicsContext3D::deleteBuffer) {} | 78 &blink::WebGraphicsContext3D::deleteBuffer) {} |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 class ScopedFramebuffer : public ScopedWebGLId { | 81 class ScopedFramebuffer : public ScopedWebGLId { |
| 82 public: | 82 public: |
| 83 ScopedFramebuffer(WebKit::WebGraphicsContext3D* context, | 83 ScopedFramebuffer(blink::WebGraphicsContext3D* context, |
| 84 WebGLId id) | 84 WebGLId id) |
| 85 : ScopedWebGLId(context, | 85 : ScopedWebGLId(context, |
| 86 id, | 86 id, |
| 87 &WebKit::WebGraphicsContext3D::deleteFramebuffer) {} | 87 &blink::WebGraphicsContext3D::deleteFramebuffer) {} |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 class ScopedProgram : public ScopedWebGLId { | 90 class ScopedProgram : public ScopedWebGLId { |
| 91 public: | 91 public: |
| 92 ScopedProgram(WebKit::WebGraphicsContext3D* context, | 92 ScopedProgram(blink::WebGraphicsContext3D* context, |
| 93 WebGLId id) | 93 WebGLId id) |
| 94 : ScopedWebGLId(context, | 94 : ScopedWebGLId(context, |
| 95 id, | 95 id, |
| 96 &WebKit::WebGraphicsContext3D::deleteProgram) {} | 96 &blink::WebGraphicsContext3D::deleteProgram) {} |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 class ScopedShader : public ScopedWebGLId { | 99 class ScopedShader : public ScopedWebGLId { |
| 100 public: | 100 public: |
| 101 ScopedShader(WebKit::WebGraphicsContext3D* context, | 101 ScopedShader(blink::WebGraphicsContext3D* context, |
| 102 WebGLId id) | 102 WebGLId id) |
| 103 : ScopedWebGLId(context, | 103 : ScopedWebGLId(context, |
| 104 id, | 104 id, |
| 105 &WebKit::WebGraphicsContext3D::deleteShader) {} | 105 &blink::WebGraphicsContext3D::deleteShader) {} |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 class ScopedTexture : public ScopedWebGLId { | 108 class ScopedTexture : public ScopedWebGLId { |
| 109 public: | 109 public: |
| 110 ScopedTexture(WebKit::WebGraphicsContext3D* context, | 110 ScopedTexture(blink::WebGraphicsContext3D* context, |
| 111 WebGLId id) | 111 WebGLId id) |
| 112 : ScopedWebGLId(context, | 112 : ScopedWebGLId(context, |
| 113 id, | 113 id, |
| 114 &WebKit::WebGraphicsContext3D::deleteTexture) {} | 114 &blink::WebGraphicsContext3D::deleteTexture) {} |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 template <WebKit::WGC3Denum target> | 117 template <blink::WGC3Denum target> |
| 118 class ScopedBinder { | 118 class ScopedBinder { |
| 119 public: | 119 public: |
| 120 typedef void (WebKit::WebGraphicsContext3D::*BindFunc)(WebKit::WGC3Denum, | 120 typedef void (blink::WebGraphicsContext3D::*BindFunc)(blink::WGC3Denum, |
| 121 WebGLId); | 121 WebGLId); |
| 122 ScopedBinder(WebKit::WebGraphicsContext3D* context, | 122 ScopedBinder(blink::WebGraphicsContext3D* context, |
| 123 WebGLId id, | 123 WebGLId id, |
| 124 BindFunc bind_func) | 124 BindFunc bind_func) |
| 125 : context_(context), | 125 : context_(context), |
| 126 bind_func_(bind_func) { | 126 bind_func_(bind_func) { |
| 127 (context_->*bind_func_)(target, id); | 127 (context_->*bind_func_)(target, id); |
| 128 } | 128 } |
| 129 | 129 |
| 130 virtual ~ScopedBinder() { | 130 virtual ~ScopedBinder() { |
| 131 (context_->*bind_func_)(target, 0); | 131 (context_->*bind_func_)(target, 0); |
| 132 } | 132 } |
| 133 | 133 |
| 134 private: | 134 private: |
| 135 WebKit::WebGraphicsContext3D* context_; | 135 blink::WebGraphicsContext3D* context_; |
| 136 BindFunc bind_func_; | 136 BindFunc bind_func_; |
| 137 | 137 |
| 138 DISALLOW_COPY_AND_ASSIGN(ScopedBinder); | 138 DISALLOW_COPY_AND_ASSIGN(ScopedBinder); |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 template <WebKit::WGC3Denum target> | 141 template <blink::WGC3Denum target> |
| 142 class ScopedBufferBinder : ScopedBinder<target> { | 142 class ScopedBufferBinder : ScopedBinder<target> { |
| 143 public: | 143 public: |
| 144 ScopedBufferBinder(WebKit::WebGraphicsContext3D* context, | 144 ScopedBufferBinder(blink::WebGraphicsContext3D* context, |
| 145 WebGLId id) | 145 WebGLId id) |
| 146 : ScopedBinder<target>( | 146 : ScopedBinder<target>( |
| 147 context, | 147 context, |
| 148 id, | 148 id, |
| 149 &WebKit::WebGraphicsContext3D::bindBuffer) {} | 149 &blink::WebGraphicsContext3D::bindBuffer) {} |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 template <WebKit::WGC3Denum target> | 152 template <blink::WGC3Denum target> |
| 153 class ScopedFramebufferBinder : ScopedBinder<target> { | 153 class ScopedFramebufferBinder : ScopedBinder<target> { |
| 154 public: | 154 public: |
| 155 ScopedFramebufferBinder(WebKit::WebGraphicsContext3D* context, | 155 ScopedFramebufferBinder(blink::WebGraphicsContext3D* context, |
| 156 WebGLId id) | 156 WebGLId id) |
| 157 : ScopedBinder<target>( | 157 : ScopedBinder<target>( |
| 158 context, | 158 context, |
| 159 id, | 159 id, |
| 160 &WebKit::WebGraphicsContext3D::bindFramebuffer) {} | 160 &blink::WebGraphicsContext3D::bindFramebuffer) {} |
| 161 }; | 161 }; |
| 162 | 162 |
| 163 template <WebKit::WGC3Denum target> | 163 template <blink::WGC3Denum target> |
| 164 class ScopedTextureBinder : ScopedBinder<target> { | 164 class ScopedTextureBinder : ScopedBinder<target> { |
| 165 public: | 165 public: |
| 166 ScopedTextureBinder(WebKit::WebGraphicsContext3D* context, | 166 ScopedTextureBinder(blink::WebGraphicsContext3D* context, |
| 167 WebGLId id) | 167 WebGLId id) |
| 168 : ScopedBinder<target>( | 168 : ScopedBinder<target>( |
| 169 context, | 169 context, |
| 170 id, | 170 id, |
| 171 &WebKit::WebGraphicsContext3D::bindTexture) {} | 171 &blink::WebGraphicsContext3D::bindTexture) {} |
| 172 }; | 172 }; |
| 173 | 173 |
| 174 class ScopedFlush { | 174 class ScopedFlush { |
| 175 public: | 175 public: |
| 176 explicit ScopedFlush(WebKit::WebGraphicsContext3D* context) | 176 explicit ScopedFlush(blink::WebGraphicsContext3D* context) |
| 177 : context_(context) { | 177 : context_(context) { |
| 178 } | 178 } |
| 179 | 179 |
| 180 ~ScopedFlush() { | 180 ~ScopedFlush() { |
| 181 context_->flush(); | 181 context_->flush(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 private: | 184 private: |
| 185 WebKit::WebGraphicsContext3D* context_; | 185 blink::WebGraphicsContext3D* context_; |
| 186 | 186 |
| 187 DISALLOW_COPY_AND_ASSIGN(ScopedFlush); | 187 DISALLOW_COPY_AND_ASSIGN(ScopedFlush); |
| 188 }; | 188 }; |
| 189 | 189 |
| 190 | 190 |
| 191 class ReadbackYUVInterface; | 191 class ReadbackYUVInterface; |
| 192 | 192 |
| 193 // Provides higher level operations on top of the WebKit::WebGraphicsContext3D | 193 // Provides higher level operations on top of the blink::WebGraphicsContext3D |
| 194 // interfaces. | 194 // interfaces. |
| 195 class CONTENT_EXPORT GLHelper { | 195 class CONTENT_EXPORT GLHelper { |
| 196 public: | 196 public: |
| 197 GLHelper(WebKit::WebGraphicsContext3D* context, | 197 GLHelper(blink::WebGraphicsContext3D* context, |
| 198 gpu::ContextSupport* context_support); | 198 gpu::ContextSupport* context_support); |
| 199 ~GLHelper(); | 199 ~GLHelper(); |
| 200 | 200 |
| 201 enum ScalerQuality { | 201 enum ScalerQuality { |
| 202 // Bilinear single pass, fastest possible. | 202 // Bilinear single pass, fastest possible. |
| 203 SCALER_QUALITY_FAST = 1, | 203 SCALER_QUALITY_FAST = 1, |
| 204 | 204 |
| 205 // Bilinear upscale + N * 50% bilinear downscales. | 205 // Bilinear upscale + N * 50% bilinear downscales. |
| 206 // This is still fast enough for most purposes and | 206 // This is still fast enough for most purposes and |
| 207 // Image quality is nearly as good as the BEST option. | 207 // Image quality is nearly as good as the BEST option. |
| 208 SCALER_QUALITY_GOOD = 2, | 208 SCALER_QUALITY_GOOD = 2, |
| 209 | 209 |
| 210 // Bicubic upscale + N * 50% bicubic downscales. | 210 // Bicubic upscale + N * 50% bicubic downscales. |
| 211 // Produces very good quality scaled images, but it's | 211 // Produces very good quality scaled images, but it's |
| 212 // 2-8x slower than the "GOOD" quality, so it's not always | 212 // 2-8x slower than the "GOOD" quality, so it's not always |
| 213 // worth it. | 213 // worth it. |
| 214 SCALER_QUALITY_BEST = 3, | 214 SCALER_QUALITY_BEST = 3, |
| 215 }; | 215 }; |
| 216 | 216 |
| 217 | 217 |
| 218 // Copies the block of pixels specified with |src_subrect| from |src_texture|, | 218 // Copies the block of pixels specified with |src_subrect| from |src_texture|, |
| 219 // scales it to |dst_size|, and writes it into |out|. | 219 // scales it to |dst_size|, and writes it into |out|. |
| 220 // |src_size| is the size of |src_texture|. The result is of format GL_BGRA | 220 // |src_size| is the size of |src_texture|. The result is of format GL_BGRA |
| 221 // and is potentially flipped vertically to make it a correct image | 221 // and is potentially flipped vertically to make it a correct image |
| 222 // representation. |callback| is invoked with the copy result when the copy | 222 // representation. |callback| is invoked with the copy result when the copy |
| 223 // operation has completed. | 223 // operation has completed. |
| 224 // Note that the src_texture will have the min/mag filter set to GL_LINEAR | 224 // Note that the src_texture will have the min/mag filter set to GL_LINEAR |
| 225 // and wrap_s/t set to CLAMP_TO_EDGE in this call. | 225 // and wrap_s/t set to CLAMP_TO_EDGE in this call. |
| 226 void CropScaleReadbackAndCleanTexture( | 226 void CropScaleReadbackAndCleanTexture( |
| 227 WebKit::WebGLId src_texture, | 227 blink::WebGLId src_texture, |
| 228 const gfx::Size& src_size, | 228 const gfx::Size& src_size, |
| 229 const gfx::Rect& src_subrect, | 229 const gfx::Rect& src_subrect, |
| 230 const gfx::Size& dst_size, | 230 const gfx::Size& dst_size, |
| 231 unsigned char* out, | 231 unsigned char* out, |
| 232 const base::Callback<void(bool)>& callback); | 232 const base::Callback<void(bool)>& callback); |
| 233 | 233 |
| 234 // Copies the block of pixels specified with |src_subrect| from |src_mailbox|, | 234 // Copies the block of pixels specified with |src_subrect| from |src_mailbox|, |
| 235 // scales it to |dst_size|, and writes it into |out|. | 235 // scales it to |dst_size|, and writes it into |out|. |
| 236 // |src_size| is the size of |src_mailbox|. The result is of format GL_BGRA | 236 // |src_size| is the size of |src_mailbox|. The result is of format GL_BGRA |
| 237 // and is potentially flipped vertically to make it a correct image | 237 // and is potentially flipped vertically to make it a correct image |
| 238 // representation. |callback| is invoked with the copy result when the copy | 238 // representation. |callback| is invoked with the copy result when the copy |
| 239 // operation has completed. | 239 // operation has completed. |
| 240 // Note that the texture bound to src_mailbox will have the min/mag filter set | 240 // Note that the texture bound to src_mailbox will have the min/mag filter set |
| 241 // to GL_LINEAR and wrap_s/t set to CLAMP_TO_EDGE in this call. src_mailbox is | 241 // to GL_LINEAR and wrap_s/t set to CLAMP_TO_EDGE in this call. src_mailbox is |
| 242 // assumed to be GL_TEXTURE_2D. | 242 // assumed to be GL_TEXTURE_2D. |
| 243 void CropScaleReadbackAndCleanMailbox( | 243 void CropScaleReadbackAndCleanMailbox( |
| 244 const gpu::Mailbox& src_mailbox, | 244 const gpu::Mailbox& src_mailbox, |
| 245 uint32 sync_point, | 245 uint32 sync_point, |
| 246 const gfx::Size& src_size, | 246 const gfx::Size& src_size, |
| 247 const gfx::Rect& src_subrect, | 247 const gfx::Rect& src_subrect, |
| 248 const gfx::Size& dst_size, | 248 const gfx::Size& dst_size, |
| 249 unsigned char* out, | 249 unsigned char* out, |
| 250 const base::Callback<void(bool)>& callback); | 250 const base::Callback<void(bool)>& callback); |
| 251 | 251 |
| 252 // Copies the texture data out of |texture| into |out|. |size| is the | 252 // Copies the texture data out of |texture| into |out|. |size| is the |
| 253 // size of the texture. No post processing is applied to the pixels. The | 253 // size of the texture. No post processing is applied to the pixels. The |
| 254 // texture is assumed to have a format of GL_RGBA with a pixel type of | 254 // texture is assumed to have a format of GL_RGBA with a pixel type of |
| 255 // GL_UNSIGNED_BYTE. This is a blocking call that calls glReadPixels on this | 255 // GL_UNSIGNED_BYTE. This is a blocking call that calls glReadPixels on this |
| 256 // current context. | 256 // current context. |
| 257 void ReadbackTextureSync(WebKit::WebGLId texture, | 257 void ReadbackTextureSync(blink::WebGLId texture, |
| 258 const gfx::Rect& src_rect, | 258 const gfx::Rect& src_rect, |
| 259 unsigned char* out); | 259 unsigned char* out); |
| 260 | 260 |
| 261 // Creates a copy of the specified texture. |size| is the size of the texture. | 261 // Creates a copy of the specified texture. |size| is the size of the texture. |
| 262 // Note that the src_texture will have the min/mag filter set to GL_LINEAR | 262 // Note that the src_texture will have the min/mag filter set to GL_LINEAR |
| 263 // and wrap_s/t set to CLAMP_TO_EDGE in this call. | 263 // and wrap_s/t set to CLAMP_TO_EDGE in this call. |
| 264 WebKit::WebGLId CopyTexture(WebKit::WebGLId texture, | 264 blink::WebGLId CopyTexture(blink::WebGLId texture, |
| 265 const gfx::Size& size); | 265 const gfx::Size& size); |
| 266 | 266 |
| 267 // Creates a scaled copy of the specified texture. |src_size| is the size of | 267 // Creates a scaled copy of the specified texture. |src_size| is the size of |
| 268 // the texture and |dst_size| is the size of the resulting copy. | 268 // the texture and |dst_size| is the size of the resulting copy. |
| 269 // Note that the src_texture will have the min/mag filter set to GL_LINEAR | 269 // Note that the src_texture will have the min/mag filter set to GL_LINEAR |
| 270 // and wrap_s/t set to CLAMP_TO_EDGE in this call. | 270 // and wrap_s/t set to CLAMP_TO_EDGE in this call. |
| 271 WebKit::WebGLId CopyAndScaleTexture( | 271 blink::WebGLId CopyAndScaleTexture( |
| 272 WebKit::WebGLId texture, | 272 blink::WebGLId texture, |
| 273 const gfx::Size& src_size, | 273 const gfx::Size& src_size, |
| 274 const gfx::Size& dst_size, | 274 const gfx::Size& dst_size, |
| 275 bool vertically_flip_texture, | 275 bool vertically_flip_texture, |
| 276 ScalerQuality quality); | 276 ScalerQuality quality); |
| 277 | 277 |
| 278 // Returns the shader compiled from the source. | 278 // Returns the shader compiled from the source. |
| 279 WebKit::WebGLId CompileShaderFromSource(const WebKit::WGC3Dchar* source, | 279 blink::WebGLId CompileShaderFromSource(const blink::WGC3Dchar* source, |
| 280 WebKit::WGC3Denum type); | 280 blink::WGC3Denum type); |
| 281 | 281 |
| 282 // Copies all pixels from |previous_texture| into |texture| that are | 282 // Copies all pixels from |previous_texture| into |texture| that are |
| 283 // inside the region covered by |old_damage| but not part of |new_damage|. | 283 // inside the region covered by |old_damage| but not part of |new_damage|. |
| 284 void CopySubBufferDamage(WebKit::WebGLId texture, | 284 void CopySubBufferDamage(blink::WebGLId texture, |
| 285 WebKit::WebGLId previous_texture, | 285 blink::WebGLId previous_texture, |
| 286 const SkRegion& new_damage, | 286 const SkRegion& new_damage, |
| 287 const SkRegion& old_damage); | 287 const SkRegion& old_damage); |
| 288 | 288 |
| 289 // Simply creates a texture. | 289 // Simply creates a texture. |
| 290 WebKit::WebGLId CreateTexture(); | 290 blink::WebGLId CreateTexture(); |
| 291 | 291 |
| 292 // Creates a texture and consumes a mailbox into it. Returns 0 on failure. | 292 // Creates a texture and consumes a mailbox into it. Returns 0 on failure. |
| 293 // Note the mailbox is assumed to be GL_TEXTURE_2D. | 293 // Note the mailbox is assumed to be GL_TEXTURE_2D. |
| 294 WebKit::WebGLId ConsumeMailboxToTexture(const gpu::Mailbox& mailbox, | 294 blink::WebGLId ConsumeMailboxToTexture(const gpu::Mailbox& mailbox, |
| 295 uint32 sync_point); | 295 uint32 sync_point); |
| 296 | 296 |
| 297 // Resizes the texture's size to |size|. | 297 // Resizes the texture's size to |size|. |
| 298 void ResizeTexture(WebKit::WebGLId texture, const gfx::Size& size); | 298 void ResizeTexture(blink::WebGLId texture, const gfx::Size& size); |
| 299 | 299 |
| 300 // Copies the framebuffer data given in |rect| to |texture|. | 300 // Copies the framebuffer data given in |rect| to |texture|. |
| 301 void CopyTextureSubImage(WebKit::WebGLId texture, const gfx::Rect& rect); | 301 void CopyTextureSubImage(blink::WebGLId texture, const gfx::Rect& rect); |
| 302 | 302 |
| 303 // Copies the all framebuffer data to |texture|. |size| specifies the | 303 // Copies the all framebuffer data to |texture|. |size| specifies the |
| 304 // size of the framebuffer. | 304 // size of the framebuffer. |
| 305 void CopyTextureFullImage(WebKit::WebGLId texture, const gfx::Size& size); | 305 void CopyTextureFullImage(blink::WebGLId texture, const gfx::Size& size); |
| 306 | 306 |
| 307 // A scaler will cache all intermediate textures and programs | 307 // A scaler will cache all intermediate textures and programs |
| 308 // needed to scale from a specified size to a destination size. | 308 // needed to scale from a specified size to a destination size. |
| 309 // If the source or destination sizes changes, you must create | 309 // If the source or destination sizes changes, you must create |
| 310 // a new scaler. | 310 // a new scaler. |
| 311 class CONTENT_EXPORT ScalerInterface { | 311 class CONTENT_EXPORT ScalerInterface { |
| 312 public: | 312 public: |
| 313 ScalerInterface() {} | 313 ScalerInterface() {} |
| 314 virtual ~ScalerInterface() {} | 314 virtual ~ScalerInterface() {} |
| 315 | 315 |
| 316 // Note that the src_texture will have the min/mag filter set to GL_LINEAR | 316 // Note that the src_texture will have the min/mag filter set to GL_LINEAR |
| 317 // and wrap_s/t set to CLAMP_TO_EDGE in this call. | 317 // and wrap_s/t set to CLAMP_TO_EDGE in this call. |
| 318 virtual void Scale(WebKit::WebGLId source_texture, | 318 virtual void Scale(blink::WebGLId source_texture, |
| 319 WebKit::WebGLId dest_texture) = 0; | 319 blink::WebGLId dest_texture) = 0; |
| 320 virtual const gfx::Size& SrcSize() = 0; | 320 virtual const gfx::Size& SrcSize() = 0; |
| 321 virtual const gfx::Rect& SrcSubrect() = 0; | 321 virtual const gfx::Rect& SrcSubrect() = 0; |
| 322 virtual const gfx::Size& DstSize() = 0; | 322 virtual const gfx::Size& DstSize() = 0; |
| 323 }; | 323 }; |
| 324 | 324 |
| 325 // Note that the quality may be adjusted down if texture | 325 // Note that the quality may be adjusted down if texture |
| 326 // allocations fail or hardware doesn't support the requtested | 326 // allocations fail or hardware doesn't support the requtested |
| 327 // quality. Note that ScalerQuality enum is arranged in | 327 // quality. Note that ScalerQuality enum is arranged in |
| 328 // numerical order for simplicity. | 328 // numerical order for simplicity. |
| 329 ScalerInterface* CreateScaler(ScalerQuality quality, | 329 ScalerInterface* CreateScaler(ScalerQuality quality, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 345 ScalerQuality quality, | 345 ScalerQuality quality, |
| 346 const gfx::Size& src_size, | 346 const gfx::Size& src_size, |
| 347 const gfx::Rect& src_subrect, | 347 const gfx::Rect& src_subrect, |
| 348 const gfx::Size& dst_size, | 348 const gfx::Size& dst_size, |
| 349 const gfx::Rect& dst_subrect, | 349 const gfx::Rect& dst_subrect, |
| 350 bool flip_vertically, | 350 bool flip_vertically, |
| 351 bool use_mrt); | 351 bool use_mrt); |
| 352 | 352 |
| 353 // Returns the maximum number of draw buffers available, | 353 // Returns the maximum number of draw buffers available, |
| 354 // 0 if GL_EXT_draw_buffers is not available. | 354 // 0 if GL_EXT_draw_buffers is not available. |
| 355 WebKit::WGC3Dint MaxDrawBuffers(); | 355 blink::WGC3Dint MaxDrawBuffers(); |
| 356 | 356 |
| 357 protected: | 357 protected: |
| 358 class CopyTextureToImpl; | 358 class CopyTextureToImpl; |
| 359 | 359 |
| 360 // Creates |copy_texture_to_impl_| if NULL. | 360 // Creates |copy_texture_to_impl_| if NULL. |
| 361 void InitCopyTextToImpl(); | 361 void InitCopyTextToImpl(); |
| 362 // Creates |scaler_impl_| if NULL. | 362 // Creates |scaler_impl_| if NULL. |
| 363 void InitScalerImpl(); | 363 void InitScalerImpl(); |
| 364 | 364 |
| 365 WebKit::WebGraphicsContext3D* context_; | 365 blink::WebGraphicsContext3D* context_; |
| 366 gpu::ContextSupport* context_support_; | 366 gpu::ContextSupport* context_support_; |
| 367 scoped_ptr<CopyTextureToImpl> copy_texture_to_impl_; | 367 scoped_ptr<CopyTextureToImpl> copy_texture_to_impl_; |
| 368 scoped_ptr<GLHelperScaling> scaler_impl_; | 368 scoped_ptr<GLHelperScaling> scaler_impl_; |
| 369 | 369 |
| 370 DISALLOW_COPY_AND_ASSIGN(GLHelper); | 370 DISALLOW_COPY_AND_ASSIGN(GLHelper); |
| 371 }; | 371 }; |
| 372 | 372 |
| 373 // Similar to a ScalerInterface, a yuv readback pipeline will | 373 // Similar to a ScalerInterface, a yuv readback pipeline will |
| 374 // cache a scaler and all intermediate textures and frame buffers | 374 // cache a scaler and all intermediate textures and frame buffers |
| 375 // needed to scale, crop, letterbox and read back a texture from | 375 // needed to scale, crop, letterbox and read back a texture from |
| (...skipping 11 matching lines...) Expand all Loading... |
| 387 const gpu::Mailbox& mailbox, | 387 const gpu::Mailbox& mailbox, |
| 388 uint32 sync_point, | 388 uint32 sync_point, |
| 389 const scoped_refptr<media::VideoFrame>& target, | 389 const scoped_refptr<media::VideoFrame>& target, |
| 390 const base::Callback<void(bool)>& callback) = 0; | 390 const base::Callback<void(bool)>& callback) = 0; |
| 391 virtual GLHelper::ScalerInterface* scaler() = 0; | 391 virtual GLHelper::ScalerInterface* scaler() = 0; |
| 392 }; | 392 }; |
| 393 | 393 |
| 394 } // namespace content | 394 } // namespace content |
| 395 | 395 |
| 396 #endif // CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_ | 396 #endif // CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_ |
| OLD | NEW |