| OLD | NEW |
| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "cc/base/math_util.h" | 15 #include "cc/base/math_util.h" |
| 16 #include "cc/layers/video_layer_impl.h" | 16 #include "cc/layers/video_layer_impl.h" |
| 17 #include "cc/output/compositor_frame.h" | 17 #include "cc/output/compositor_frame.h" |
| 18 #include "cc/output/compositor_frame_metadata.h" | 18 #include "cc/output/compositor_frame_metadata.h" |
| 19 #include "cc/output/context_provider.h" | 19 #include "cc/output/context_provider.h" |
| 20 #include "cc/output/copy_output_request.h" | 20 #include "cc/output/copy_output_request.h" |
| 21 #include "cc/output/geometry_binding.h" | 21 #include "cc/output/geometry_binding.h" |
| 22 #include "cc/output/gl_frame_data.h" | 22 #include "cc/output/gl_frame_data.h" |
| 23 #include "cc/output/output_surface.h" | 23 #include "cc/output/output_surface.h" |
| 24 #include "cc/output/render_surface_filters.h" | 24 #include "cc/output/render_surface_filters.h" |
| 25 #include "cc/quads/picture_draw_quad.h" | 25 #include "cc/quads/picture_draw_quad.h" |
| 26 #include "cc/quads/render_pass.h" | 26 #include "cc/quads/render_pass.h" |
| 27 #include "cc/quads/stream_video_draw_quad.h" | 27 #include "cc/quads/stream_video_draw_quad.h" |
| 28 #include "cc/quads/texture_draw_quad.h" | 28 #include "cc/quads/texture_draw_quad.h" |
| 29 #include "cc/resources/layer_quad.h" | 29 #include "cc/resources/layer_quad.h" |
| 30 #include "cc/resources/raster_worker_pool.h" | |
| 31 #include "cc/resources/scoped_resource.h" | 30 #include "cc/resources/scoped_resource.h" |
| 32 #include "cc/resources/texture_mailbox_deleter.h" | 31 #include "cc/resources/texture_mailbox_deleter.h" |
| 33 #include "gpu/GLES2/gl2extchromium.h" | 32 #include "gpu/GLES2/gl2extchromium.h" |
| 34 #include "gpu/command_buffer/client/context_support.h" | 33 #include "gpu/command_buffer/client/context_support.h" |
| 35 #include "gpu/command_buffer/client/gles2_interface.h" | 34 #include "gpu/command_buffer/client/gles2_interface.h" |
| 36 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 35 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
| 37 #include "third_party/skia/include/core/SkBitmap.h" | 36 #include "third_party/skia/include/core/SkBitmap.h" |
| 38 #include "third_party/skia/include/core/SkColor.h" | 37 #include "third_party/skia/include/core/SkColor.h" |
| 39 #include "third_party/skia/include/core/SkColorFilter.h" | 38 #include "third_party/skia/include/core/SkColorFilter.h" |
| 40 #include "third_party/skia/include/core/SkSurface.h" | 39 #include "third_party/skia/include/core/SkSurface.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 TRACE_EVENT0("cc", "FallbackFence::Synchronize"); | 72 TRACE_EVENT0("cc", "FallbackFence::Synchronize"); |
| 74 gl_->Finish(); | 73 gl_->Finish(); |
| 75 } | 74 } |
| 76 | 75 |
| 77 gpu::gles2::GLES2Interface* gl_; | 76 gpu::gles2::GLES2Interface* gl_; |
| 78 bool has_passed_; | 77 bool has_passed_; |
| 79 | 78 |
| 80 DISALLOW_COPY_AND_ASSIGN(FallbackFence); | 79 DISALLOW_COPY_AND_ASSIGN(FallbackFence); |
| 81 }; | 80 }; |
| 82 | 81 |
| 83 class OnDemandRasterTaskImpl : public Task { | |
| 84 public: | |
| 85 OnDemandRasterTaskImpl(PicturePileImpl* picture_pile, | |
| 86 SkBitmap* bitmap, | |
| 87 gfx::Rect content_rect, | |
| 88 float contents_scale) | |
| 89 : picture_pile_(picture_pile), | |
| 90 bitmap_(bitmap), | |
| 91 content_rect_(content_rect), | |
| 92 contents_scale_(contents_scale) { | |
| 93 DCHECK(picture_pile_); | |
| 94 DCHECK(bitmap_); | |
| 95 } | |
| 96 | |
| 97 // Overridden from Task: | |
| 98 virtual void RunOnWorkerThread() OVERRIDE { | |
| 99 TRACE_EVENT0("cc", "OnDemandRasterTaskImpl::RunOnWorkerThread"); | |
| 100 SkCanvas canvas(*bitmap_); | |
| 101 | |
| 102 PicturePileImpl* picture_pile = picture_pile_->GetCloneForDrawingOnThread( | |
| 103 RasterWorkerPool::GetPictureCloneIndexForCurrentThread()); | |
| 104 DCHECK(picture_pile); | |
| 105 | |
| 106 picture_pile->RasterToBitmap(&canvas, content_rect_, contents_scale_, NULL); | |
| 107 } | |
| 108 | |
| 109 protected: | |
| 110 virtual ~OnDemandRasterTaskImpl() {} | |
| 111 | |
| 112 private: | |
| 113 PicturePileImpl* picture_pile_; | |
| 114 SkBitmap* bitmap_; | |
| 115 const gfx::Rect content_rect_; | |
| 116 const float contents_scale_; | |
| 117 | |
| 118 DISALLOW_COPY_AND_ASSIGN(OnDemandRasterTaskImpl); | |
| 119 }; | |
| 120 | |
| 121 bool NeedsIOSurfaceReadbackWorkaround() { | 82 bool NeedsIOSurfaceReadbackWorkaround() { |
| 122 #if defined(OS_MACOSX) | 83 #if defined(OS_MACOSX) |
| 123 // This isn't strictly required in DumpRenderTree-mode when Mesa is used, | 84 // This isn't strictly required in DumpRenderTree-mode when Mesa is used, |
| 124 // but it doesn't seem to hurt. | 85 // but it doesn't seem to hurt. |
| 125 return true; | 86 return true; |
| 126 #else | 87 #else |
| 127 return false; | 88 return false; |
| 128 #endif | 89 #endif |
| 129 } | 90 } |
| 130 | 91 |
| (...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1931 | 1892 |
| 1932 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( | 1893 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( |
| 1933 quad->texture_size, | 1894 quad->texture_size, |
| 1934 GL_TEXTURE_2D, | 1895 GL_TEXTURE_2D, |
| 1935 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, | 1896 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, |
| 1936 GL_CLAMP_TO_EDGE, | 1897 GL_CLAMP_TO_EDGE, |
| 1937 ResourceProvider::TextureHintImmutable, | 1898 ResourceProvider::TextureHintImmutable, |
| 1938 quad->texture_format); | 1899 quad->texture_format); |
| 1939 } | 1900 } |
| 1940 | 1901 |
| 1941 // Create and run on-demand raster task for tile. | 1902 SkCanvas canvas(on_demand_tile_raster_bitmap_); |
| 1942 scoped_refptr<Task> on_demand_raster_task( | 1903 quad->picture_pile->RasterToBitmap( |
| 1943 new OnDemandRasterTaskImpl(quad->picture_pile, | 1904 &canvas, quad->content_rect, quad->contents_scale, NULL); |
| 1944 &on_demand_tile_raster_bitmap_, | |
| 1945 quad->content_rect, | |
| 1946 quad->contents_scale)); | |
| 1947 client_->RunOnDemandRasterTask(on_demand_raster_task.get()); | |
| 1948 | 1905 |
| 1949 uint8_t* bitmap_pixels = NULL; | 1906 uint8_t* bitmap_pixels = NULL; |
| 1950 SkBitmap on_demand_tile_raster_bitmap_dest; | 1907 SkBitmap on_demand_tile_raster_bitmap_dest; |
| 1951 SkColorType colorType = ResourceFormatToSkColorType(quad->texture_format); | 1908 SkColorType colorType = ResourceFormatToSkColorType(quad->texture_format); |
| 1952 if (on_demand_tile_raster_bitmap_.colorType() != colorType) { | 1909 if (on_demand_tile_raster_bitmap_.colorType() != colorType) { |
| 1953 on_demand_tile_raster_bitmap_.copyTo(&on_demand_tile_raster_bitmap_dest, | 1910 on_demand_tile_raster_bitmap_.copyTo(&on_demand_tile_raster_bitmap_dest, |
| 1954 colorType); | 1911 colorType); |
| 1955 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the | 1912 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the |
| 1956 // bitmap data. This check will be removed once crbug.com/293728 is fixed. | 1913 // bitmap data. This check will be removed once crbug.com/293728 is fixed. |
| 1957 CHECK_EQ(0u, on_demand_tile_raster_bitmap_dest.rowBytes() % 4); | 1914 CHECK_EQ(0u, on_demand_tile_raster_bitmap_dest.rowBytes() % 4); |
| (...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3217 context_support_->ScheduleOverlayPlane( | 3174 context_support_->ScheduleOverlayPlane( |
| 3218 overlay.plane_z_order, | 3175 overlay.plane_z_order, |
| 3219 overlay.transform, | 3176 overlay.transform, |
| 3220 pending_overlay_resources_.back()->texture_id(), | 3177 pending_overlay_resources_.back()->texture_id(), |
| 3221 overlay.display_rect, | 3178 overlay.display_rect, |
| 3222 overlay.uv_rect); | 3179 overlay.uv_rect); |
| 3223 } | 3180 } |
| 3224 } | 3181 } |
| 3225 | 3182 |
| 3226 } // namespace cc | 3183 } // namespace cc |
| OLD | NEW |