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

Side by Side Diff: cc/output/gl_renderer.cc

Issue 638353002: [C++11 Allowed Features] Declares a type-safe null pointer converting from NULL to nullptr in src/… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formating. Created 6 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
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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 "cc/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 skia::RefPtr<SkImage> filter_bitmap; 1094 skia::RefPtr<SkImage> filter_bitmap;
1095 SkScalar color_matrix[20]; 1095 SkScalar color_matrix[20];
1096 bool use_color_matrix = false; 1096 bool use_color_matrix = false;
1097 if (!quad->filters.IsEmpty()) { 1097 if (!quad->filters.IsEmpty()) {
1098 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( 1098 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter(
1099 quad->filters, contents_texture->size()); 1099 quad->filters, contents_texture->size());
1100 if (filter) { 1100 if (filter) {
1101 skia::RefPtr<SkColorFilter> cf; 1101 skia::RefPtr<SkColorFilter> cf;
1102 1102
1103 { 1103 {
1104 SkColorFilter* colorfilter_rawptr = NULL; 1104 SkColorFilter* colorfilter_rawptr = nullptr;
1105 filter->asColorFilter(&colorfilter_rawptr); 1105 filter->asColorFilter(&colorfilter_rawptr);
1106 cf = skia::AdoptRef(colorfilter_rawptr); 1106 cf = skia::AdoptRef(colorfilter_rawptr);
1107 } 1107 }
1108 1108
1109 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) { 1109 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) {
1110 // We have a single color matrix as a filter; apply it locally 1110 // We have a single color matrix as a filter; apply it locally
1111 // in the compositor. 1111 // in the compositor.
1112 use_color_matrix = true; 1112 use_color_matrix = true;
1113 } else { 1113 } else {
1114 filter_bitmap = 1114 filter_bitmap =
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 // V - 128 : Turns unsigned V into signed V [-128,127] 1923 // V - 128 : Turns unsigned V into signed V [-128,127]
1924 float yuv_adjust_rec601[3] = { 1924 float yuv_adjust_rec601[3] = {
1925 -0.0625f, -0.5f, -0.5f, 1925 -0.0625f, -0.5f, -0.5f,
1926 }; 1926 };
1927 1927
1928 // Same as above, but without the head and footroom. 1928 // Same as above, but without the head and footroom.
1929 float yuv_adjust_rec601_jpeg[3] = { 1929 float yuv_adjust_rec601_jpeg[3] = {
1930 0.0f, -0.5f, -0.5f, 1930 0.0f, -0.5f, -0.5f,
1931 }; 1931 };
1932 1932
1933 float* yuv_to_rgb = NULL; 1933 float* yuv_to_rgb = nullptr;
1934 float* yuv_adjust = NULL; 1934 float* yuv_adjust = nullptr;
1935 1935
1936 switch (quad->color_space) { 1936 switch (quad->color_space) {
1937 case YUVVideoDrawQuad::REC_601: 1937 case YUVVideoDrawQuad::REC_601:
1938 yuv_to_rgb = yuv_to_rgb_rec601; 1938 yuv_to_rgb = yuv_to_rgb_rec601;
1939 yuv_adjust = yuv_adjust_rec601; 1939 yuv_adjust = yuv_adjust_rec601;
1940 break; 1940 break;
1941 case YUVVideoDrawQuad::REC_601_JPEG: 1941 case YUVVideoDrawQuad::REC_601_JPEG:
1942 yuv_to_rgb = yuv_to_rgb_rec601_jpeg; 1942 yuv_to_rgb = yuv_to_rgb_rec601_jpeg;
1943 yuv_adjust = yuv_adjust_rec601_jpeg; 1943 yuv_adjust = yuv_adjust_rec601_jpeg;
1944 break; 1944 break;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2003 quad->texture_size, 2003 quad->texture_size,
2004 GL_TEXTURE_2D, 2004 GL_TEXTURE_2D,
2005 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, 2005 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM,
2006 GL_CLAMP_TO_EDGE, 2006 GL_CLAMP_TO_EDGE,
2007 ResourceProvider::TextureHintImmutable, 2007 ResourceProvider::TextureHintImmutable,
2008 quad->texture_format); 2008 quad->texture_format);
2009 } 2009 }
2010 2010
2011 SkCanvas canvas(on_demand_tile_raster_bitmap_); 2011 SkCanvas canvas(on_demand_tile_raster_bitmap_);
2012 quad->picture_pile->RasterToBitmap( 2012 quad->picture_pile->RasterToBitmap(
2013 &canvas, quad->content_rect, quad->contents_scale, NULL); 2013 &canvas, quad->content_rect, quad->contents_scale, nullptr);
2014 2014
2015 uint8_t* bitmap_pixels = NULL; 2015 uint8_t* bitmap_pixels = nullptr;
2016 SkBitmap on_demand_tile_raster_bitmap_dest; 2016 SkBitmap on_demand_tile_raster_bitmap_dest;
2017 SkColorType colorType = ResourceFormatToSkColorType(quad->texture_format); 2017 SkColorType colorType = ResourceFormatToSkColorType(quad->texture_format);
2018 if (on_demand_tile_raster_bitmap_.colorType() != colorType) { 2018 if (on_demand_tile_raster_bitmap_.colorType() != colorType) {
2019 on_demand_tile_raster_bitmap_.copyTo(&on_demand_tile_raster_bitmap_dest, 2019 on_demand_tile_raster_bitmap_.copyTo(&on_demand_tile_raster_bitmap_dest,
2020 colorType); 2020 colorType);
2021 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the 2021 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the
2022 // bitmap data. This check will be removed once crbug.com/293728 is fixed. 2022 // bitmap data. This check will be removed once crbug.com/293728 is fixed.
2023 CHECK_EQ(0u, on_demand_tile_raster_bitmap_dest.rowBytes() % 4); 2023 CHECK_EQ(0u, on_demand_tile_raster_bitmap_dest.rowBytes() % 4);
2024 bitmap_pixels = reinterpret_cast<uint8_t*>( 2024 bitmap_pixels = reinterpret_cast<uint8_t*>(
2025 on_demand_tile_raster_bitmap_dest.getPixels()); 2025 on_demand_tile_raster_bitmap_dest.getPixels());
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
2579 DCHECK_EQ(static_cast<unsigned>(GL_FRAMEBUFFER_COMPLETE), 2579 DCHECK_EQ(static_cast<unsigned>(GL_FRAMEBUFFER_COMPLETE),
2580 gl_->CheckFramebufferStatus(GL_FRAMEBUFFER)); 2580 gl_->CheckFramebufferStatus(GL_FRAMEBUFFER));
2581 } 2581 }
2582 2582
2583 GLuint buffer = 0; 2583 GLuint buffer = 0;
2584 gl_->GenBuffers(1, &buffer); 2584 gl_->GenBuffers(1, &buffer);
2585 GLC(gl_, gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, buffer)); 2585 GLC(gl_, gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, buffer));
2586 GLC(gl_, 2586 GLC(gl_,
2587 gl_->BufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 2587 gl_->BufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
2588 4 * window_rect.size().GetArea(), 2588 4 * window_rect.size().GetArea(),
2589 NULL, 2589 nullptr,
2590 GL_STREAM_READ)); 2590 GL_STREAM_READ));
2591 2591
2592 GLuint query = 0; 2592 GLuint query = 0;
2593 gl_->GenQueriesEXT(1, &query); 2593 gl_->GenQueriesEXT(1, &query);
2594 GLC(gl_, gl_->BeginQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, query)); 2594 GLC(gl_, gl_->BeginQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, query));
2595 2595
2596 GLC(gl_, 2596 GLC(gl_,
2597 gl_->ReadPixels(window_rect.x(), 2597 gl_->ReadPixels(window_rect.x(),
2598 window_rect.y(), 2598 window_rect.y(),
2599 window_rect.width(), 2599 window_rect.width(),
2600 window_rect.height(), 2600 window_rect.height(),
2601 GL_RGBA, 2601 GL_RGBA,
2602 GL_UNSIGNED_BYTE, 2602 GL_UNSIGNED_BYTE,
2603 NULL)); 2603 nullptr));
2604 2604
2605 GLC(gl_, gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0)); 2605 GLC(gl_, gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0));
2606 2606
2607 if (do_workaround) { 2607 if (do_workaround) {
2608 // Clean up. 2608 // Clean up.
2609 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0)); 2609 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0));
2610 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, 0)); 2610 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, 0));
2611 GLC(gl_, gl_->DeleteFramebuffers(1, &temporary_fbo)); 2611 GLC(gl_, gl_->DeleteFramebuffers(1, &temporary_fbo));
2612 GLC(gl_, gl_->DeleteTextures(1, &temporary_texture)); 2612 GLC(gl_, gl_->DeleteTextures(1, &temporary_texture));
2613 } 2613 }
(...skipping 25 matching lines...) Expand all
2639 DCHECK(!pending_async_read_pixels_.empty()); 2639 DCHECK(!pending_async_read_pixels_.empty());
2640 2640
2641 if (query != 0) { 2641 if (query != 0) {
2642 GLC(gl_, gl_->DeleteQueriesEXT(1, &query)); 2642 GLC(gl_, gl_->DeleteQueriesEXT(1, &query));
2643 } 2643 }
2644 2644
2645 PendingAsyncReadPixels* current_read = pending_async_read_pixels_.back(); 2645 PendingAsyncReadPixels* current_read = pending_async_read_pixels_.back();
2646 // Make sure we service the readbacks in order. 2646 // Make sure we service the readbacks in order.
2647 DCHECK_EQ(source_buffer, current_read->buffer); 2647 DCHECK_EQ(source_buffer, current_read->buffer);
2648 2648
2649 uint8* src_pixels = NULL; 2649 uint8* src_pixels = nullptr;
2650 scoped_ptr<SkBitmap> bitmap; 2650 scoped_ptr<SkBitmap> bitmap;
2651 2651
2652 if (source_buffer != 0) { 2652 if (source_buffer != 0) {
2653 GLC(gl_, 2653 GLC(gl_,
2654 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, source_buffer)); 2654 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, source_buffer));
2655 src_pixels = static_cast<uint8*>(gl_->MapBufferCHROMIUM( 2655 src_pixels = static_cast<uint8*>(gl_->MapBufferCHROMIUM(
2656 GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, GL_READ_ONLY)); 2656 GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, GL_READ_ONLY));
2657 2657
2658 if (src_pixels) { 2658 if (src_pixels) {
2659 bitmap.reset(new SkBitmap); 2659 bitmap.reset(new SkBitmap);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2711 window_rect.width(), 2711 window_rect.width(),
2712 window_rect.height(), 2712 window_rect.height(),
2713 0)); 2713 0));
2714 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, 0)); 2714 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, 0));
2715 } 2715 }
2716 2716
2717 bool GLRenderer::UseScopedTexture(DrawingFrame* frame, 2717 bool GLRenderer::UseScopedTexture(DrawingFrame* frame,
2718 const ScopedResource* texture, 2718 const ScopedResource* texture,
2719 const gfx::Rect& viewport_rect) { 2719 const gfx::Rect& viewport_rect) {
2720 DCHECK(texture->id()); 2720 DCHECK(texture->id());
2721 frame->current_render_pass = NULL; 2721 frame->current_render_pass = nullptr;
2722 frame->current_texture = texture; 2722 frame->current_texture = texture;
2723 2723
2724 return BindFramebufferToTexture(frame, texture, viewport_rect); 2724 return BindFramebufferToTexture(frame, texture, viewport_rect);
2725 } 2725 }
2726 2726
2727 void GLRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) { 2727 void GLRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) {
2728 current_framebuffer_lock_ = nullptr; 2728 current_framebuffer_lock_ = nullptr;
2729 output_surface_->BindFramebuffer(); 2729 output_surface_->BindFramebuffer();
2730 2730
2731 if (output_surface_->HasExternalStencilTest()) { 2731 if (output_surface_->HasExternalStencilTest()) {
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
3141 TRACE_EVENT0("cc", "GLRenderer::videoYUVAProgram::initialize"); 3141 TRACE_EVENT0("cc", "GLRenderer::videoYUVAProgram::initialize");
3142 program->Initialize( 3142 program->Initialize(
3143 output_surface_->context_provider(), precision, SamplerType2D); 3143 output_surface_->context_provider(), precision, SamplerType2D);
3144 } 3144 }
3145 return program; 3145 return program;
3146 } 3146 }
3147 3147
3148 const GLRenderer::VideoStreamTextureProgram* 3148 const GLRenderer::VideoStreamTextureProgram*
3149 GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) { 3149 GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) {
3150 if (!Capabilities().using_egl_image) 3150 if (!Capabilities().using_egl_image)
3151 return NULL; 3151 return nullptr;
3152 DCHECK_GE(precision, 0); 3152 DCHECK_GE(precision, 0);
3153 DCHECK_LT(precision, NumTexCoordPrecisions); 3153 DCHECK_LT(precision, NumTexCoordPrecisions);
3154 VideoStreamTextureProgram* program = 3154 VideoStreamTextureProgram* program =
3155 &video_stream_texture_program_[precision]; 3155 &video_stream_texture_program_[precision];
3156 if (!program->initialized()) { 3156 if (!program->initialized()) {
3157 TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize"); 3157 TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize");
3158 program->Initialize( 3158 program->Initialize(
3159 output_surface_->context_provider(), precision, SamplerTypeExternalOES); 3159 output_surface_->context_provider(), precision, SamplerTypeExternalOES);
3160 } 3160 }
3161 return program; 3161 return program;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
3283 context_support_->ScheduleOverlayPlane( 3283 context_support_->ScheduleOverlayPlane(
3284 overlay.plane_z_order, 3284 overlay.plane_z_order,
3285 overlay.transform, 3285 overlay.transform,
3286 pending_overlay_resources_.back()->texture_id(), 3286 pending_overlay_resources_.back()->texture_id(),
3287 overlay.display_rect, 3287 overlay.display_rect,
3288 overlay.uv_rect); 3288 overlay.uv_rect);
3289 } 3289 }
3290 } 3290 }
3291 3291
3292 } // namespace cc 3292 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698