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 #include "content/browser/compositor/gl_helper.h" | 5 #include "content/browser/compositor/gl_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <queue> | 10 #include <queue> |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 } | 88 } |
89 | 89 |
90 content::GLHelper::ScalerInterface* scaler() const { return scaler_.get(); } | 90 content::GLHelper::ScalerInterface* scaler() const { return scaler_.get(); } |
91 TextureFrameBufferPair* texture_and_framebuffer() { | 91 TextureFrameBufferPair* texture_and_framebuffer() { |
92 return &texture_and_framebuffer_; | 92 return &texture_and_framebuffer_; |
93 } | 93 } |
94 GLuint texture() const { return texture_and_framebuffer_.texture(); } | 94 GLuint texture() const { return texture_and_framebuffer_.texture(); } |
95 | 95 |
96 private: | 96 private: |
97 TextureFrameBufferPair texture_and_framebuffer_; | 97 TextureFrameBufferPair texture_and_framebuffer_; |
98 scoped_ptr<content::GLHelper::ScalerInterface> scaler_; | 98 std::unique_ptr<content::GLHelper::ScalerInterface> scaler_; |
99 | 99 |
100 DISALLOW_COPY_AND_ASSIGN(ScalerHolder); | 100 DISALLOW_COPY_AND_ASSIGN(ScalerHolder); |
101 }; | 101 }; |
102 | 102 |
103 } // namespace | 103 } // namespace |
104 | 104 |
105 namespace content { | 105 namespace content { |
106 typedef GLHelperReadbackSupport::FormatSupport FormatSupport; | 106 typedef GLHelperReadbackSupport::FormatSupport FormatSupport; |
107 | 107 |
108 // Implements GLHelper::CropScaleReadbackAndCleanTexture and encapsulates | 108 // Implements GLHelper::CropScaleReadbackAndCleanTexture and encapsulates |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 | 313 |
314 ScalerInterface* scaler() override { return scaler_.scaler(); } | 314 ScalerInterface* scaler() override { return scaler_.scaler(); } |
315 | 315 |
316 private: | 316 private: |
317 GLES2Interface* gl_; | 317 GLES2Interface* gl_; |
318 CopyTextureToImpl* copy_impl_; | 318 CopyTextureToImpl* copy_impl_; |
319 gfx::Size dst_size_; | 319 gfx::Size dst_size_; |
320 GLHelper::ScalerQuality quality_; | 320 GLHelper::ScalerQuality quality_; |
321 ReadbackSwizzle swizzle_; | 321 ReadbackSwizzle swizzle_; |
322 ScalerHolder scaler_; | 322 ScalerHolder scaler_; |
323 scoped_ptr<content::GLHelperScaling::ShaderInterface> pass1_shader_; | 323 std::unique_ptr<content::GLHelperScaling::ShaderInterface> pass1_shader_; |
324 scoped_ptr<content::GLHelperScaling::ShaderInterface> pass2_shader_; | 324 std::unique_ptr<content::GLHelperScaling::ShaderInterface> pass2_shader_; |
325 TextureFrameBufferPair y_; | 325 TextureFrameBufferPair y_; |
326 ScopedTexture uv_; | 326 ScopedTexture uv_; |
327 TextureFrameBufferPair u_; | 327 TextureFrameBufferPair u_; |
328 TextureFrameBufferPair v_; | 328 TextureFrameBufferPair v_; |
329 | 329 |
330 DISALLOW_COPY_AND_ASSIGN(ReadbackYUV_MRT); | 330 DISALLOW_COPY_AND_ASSIGN(ReadbackYUV_MRT); |
331 }; | 331 }; |
332 | 332 |
333 // Copies the block of pixels specified with |src_subrect| from |src_texture|, | 333 // Copies the block of pixels specified with |src_subrect| from |src_texture|, |
334 // scales it to |dst_size|, writes it into a texture, and returns its ID. | 334 // scales it to |dst_size|, writes it into a texture, and returns its ID. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 // Use GL_RGBA for destination/temporary texture unless we're working with | 414 // Use GL_RGBA for destination/temporary texture unless we're working with |
415 // 16-bit data | 415 // 16-bit data |
416 if (color_type == kRGB_565_SkColorType) { | 416 if (color_type == kRGB_565_SkColorType) { |
417 format = GL_RGB; | 417 format = GL_RGB; |
418 type = GL_UNSIGNED_SHORT_5_6_5; | 418 type = GL_UNSIGNED_SHORT_5_6_5; |
419 } | 419 } |
420 | 420 |
421 gl_->TexImage2D(GL_TEXTURE_2D, 0, format, dst_size.width(), | 421 gl_->TexImage2D(GL_TEXTURE_2D, 0, format, dst_size.width(), |
422 dst_size.height(), 0, format, type, NULL); | 422 dst_size.height(), 0, format, type, NULL); |
423 } | 423 } |
424 scoped_ptr<ScalerInterface> scaler( | 424 std::unique_ptr<ScalerInterface> scaler( |
425 helper_->CreateScaler(quality, src_size, src_subrect, dst_size, | 425 helper_->CreateScaler(quality, src_size, src_subrect, dst_size, |
426 vertically_flip_texture, swizzle)); | 426 vertically_flip_texture, swizzle)); |
427 scaler->Scale(src_texture, dst_texture); | 427 scaler->Scale(src_texture, dst_texture); |
428 return dst_texture; | 428 return dst_texture; |
429 } | 429 } |
430 | 430 |
431 GLuint GLHelper::CopyTextureToImpl::EncodeTextureAsGrayscale( | 431 GLuint GLHelper::CopyTextureToImpl::EncodeTextureAsGrayscale( |
432 GLuint src_texture, | 432 GLuint src_texture, |
433 const gfx::Size& src_size, | 433 const gfx::Size& src_size, |
434 gfx::Size* const encoded_texture_size, | 434 gfx::Size* const encoded_texture_size, |
435 bool vertically_flip_texture, | 435 bool vertically_flip_texture, |
436 bool swizzle) { | 436 bool swizzle) { |
437 GLuint dst_texture = 0u; | 437 GLuint dst_texture = 0u; |
438 gl_->GenTextures(1, &dst_texture); | 438 gl_->GenTextures(1, &dst_texture); |
439 // The size of the encoded texture. | 439 // The size of the encoded texture. |
440 *encoded_texture_size = | 440 *encoded_texture_size = |
441 gfx::Size((src_size.width() + 3) / 4, src_size.height()); | 441 gfx::Size((src_size.width() + 3) / 4, src_size.height()); |
442 { | 442 { |
443 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture); | 443 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture); |
444 gl_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, encoded_texture_size->width(), | 444 gl_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, encoded_texture_size->width(), |
445 encoded_texture_size->height(), 0, GL_RGBA, | 445 encoded_texture_size->height(), 0, GL_RGBA, |
446 GL_UNSIGNED_BYTE, NULL); | 446 GL_UNSIGNED_BYTE, NULL); |
447 } | 447 } |
448 | 448 |
449 helper_->InitScalerImpl(); | 449 helper_->InitScalerImpl(); |
450 scoped_ptr<ScalerInterface> grayscale_scaler( | 450 std::unique_ptr<ScalerInterface> grayscale_scaler( |
451 helper_->scaler_impl_.get()->CreatePlanarScaler( | 451 helper_->scaler_impl_.get()->CreatePlanarScaler( |
452 src_size, | 452 src_size, |
453 gfx::Rect(0, 0, (src_size.width() + 3) & ~3, src_size.height()), | 453 gfx::Rect(0, 0, (src_size.width() + 3) & ~3, src_size.height()), |
454 *encoded_texture_size, vertically_flip_texture, swizzle, | 454 *encoded_texture_size, vertically_flip_texture, swizzle, |
455 kRGBtoGrayscaleColorWeights)); | 455 kRGBtoGrayscaleColorWeights)); |
456 grayscale_scaler->Scale(src_texture, dst_texture); | 456 grayscale_scaler->Scale(src_texture, dst_texture); |
457 return dst_texture; | 457 return dst_texture; |
458 } | 458 } |
459 | 459 |
460 void GLHelper::CopyTextureToImpl::ReadbackAsync( | 460 void GLHelper::CopyTextureToImpl::ReadbackAsync( |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 GLuint shader = gl_->CreateShader(type); | 795 GLuint shader = gl_->CreateShader(type); |
796 GLint length = strlen(source); | 796 GLint length = strlen(source); |
797 gl_->ShaderSource(shader, 1, &source, &length); | 797 gl_->ShaderSource(shader, 1, &source, &length); |
798 gl_->CompileShader(shader); | 798 gl_->CompileShader(shader); |
799 GLint compile_status = 0; | 799 GLint compile_status = 0; |
800 gl_->GetShaderiv(shader, GL_COMPILE_STATUS, &compile_status); | 800 gl_->GetShaderiv(shader, GL_COMPILE_STATUS, &compile_status); |
801 if (!compile_status) { | 801 if (!compile_status) { |
802 GLint log_length = 0; | 802 GLint log_length = 0; |
803 gl_->GetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length); | 803 gl_->GetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length); |
804 if (log_length) { | 804 if (log_length) { |
805 scoped_ptr<GLchar[]> log(new GLchar[log_length]); | 805 std::unique_ptr<GLchar[]> log(new GLchar[log_length]); |
806 GLsizei returned_log_length = 0; | 806 GLsizei returned_log_length = 0; |
807 gl_->GetShaderInfoLog(shader, log_length, &returned_log_length, | 807 gl_->GetShaderInfoLog(shader, log_length, &returned_log_length, |
808 log.get()); | 808 log.get()); |
809 LOG(ERROR) << std::string(log.get(), returned_log_length); | 809 LOG(ERROR) << std::string(log.get(), returned_log_length); |
810 } | 810 } |
811 gl_->DeleteShader(shader); | 811 gl_->DeleteShader(shader); |
812 return 0; | 812 return 0; |
813 } | 813 } |
814 return shader; | 814 return shader; |
815 } | 815 } |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 const gfx::Rect& src_subrect, | 1217 const gfx::Rect& src_subrect, |
1218 const gfx::Size& dst_size, | 1218 const gfx::Size& dst_size, |
1219 bool flip_vertically, | 1219 bool flip_vertically, |
1220 bool use_mrt) { | 1220 bool use_mrt) { |
1221 InitCopyTextToImpl(); | 1221 InitCopyTextToImpl(); |
1222 return copy_texture_to_impl_->CreateReadbackPipelineYUV( | 1222 return copy_texture_to_impl_->CreateReadbackPipelineYUV( |
1223 quality, src_size, src_subrect, dst_size, flip_vertically, use_mrt); | 1223 quality, src_size, src_subrect, dst_size, flip_vertically, use_mrt); |
1224 } | 1224 } |
1225 | 1225 |
1226 } // namespace content | 1226 } // namespace content |
OLD | NEW |