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> |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 public: | 71 public: |
72 SimpleSwapFence() : has_passed_(false) {} | 72 SimpleSwapFence() : has_passed_(false) {} |
73 virtual bool HasPassed() OVERRIDE { return has_passed_; } | 73 virtual bool HasPassed() OVERRIDE { return has_passed_; } |
74 void SetHasPassed() { has_passed_ = true; } | 74 void SetHasPassed() { has_passed_ = true; } |
75 | 75 |
76 private: | 76 private: |
77 virtual ~SimpleSwapFence() {} | 77 virtual ~SimpleSwapFence() {} |
78 bool has_passed_; | 78 bool has_passed_; |
79 }; | 79 }; |
80 | 80 |
| 81 class OnDemandRasterTaskImpl : public internal::Task { |
| 82 public: |
| 83 OnDemandRasterTaskImpl(PicturePileImpl* picture_pile, |
| 84 SkBitmap* bitmap, |
| 85 gfx::Rect content_rect, |
| 86 float contents_scale) |
| 87 : picture_pile_(picture_pile), |
| 88 bitmap_(bitmap), |
| 89 content_rect_(content_rect), |
| 90 contents_scale_(contents_scale) { |
| 91 DCHECK(picture_pile_); |
| 92 DCHECK(bitmap_); |
| 93 } |
| 94 |
| 95 // Overridden from internal::Task: |
| 96 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { |
| 97 TRACE_EVENT0("cc", "OnDemandRasterTaskImpl::RunOnWorkerThread"); |
| 98 SkBitmapDevice device(*bitmap_); |
| 99 SkCanvas canvas(&device); |
| 100 picture_pile_->RasterToBitmap( |
| 101 &canvas, content_rect_, contents_scale_, NULL); |
| 102 } |
| 103 |
| 104 protected: |
| 105 virtual ~OnDemandRasterTaskImpl() {} |
| 106 |
| 107 private: |
| 108 PicturePileImpl* picture_pile_; |
| 109 SkBitmap* bitmap_; |
| 110 const gfx::Rect content_rect_; |
| 111 const float contents_scale_; |
| 112 |
| 113 DISALLOW_COPY_AND_ASSIGN(OnDemandRasterTaskImpl); |
| 114 }; |
| 115 |
81 bool NeedsIOSurfaceReadbackWorkaround() { | 116 bool NeedsIOSurfaceReadbackWorkaround() { |
82 #if defined(OS_MACOSX) | 117 #if defined(OS_MACOSX) |
83 // This isn't strictly required in DumpRenderTree-mode when Mesa is used, | 118 // This isn't strictly required in DumpRenderTree-mode when Mesa is used, |
84 // but it doesn't seem to hurt. | 119 // but it doesn't seem to hurt. |
85 return true; | 120 return true; |
86 #else | 121 #else |
87 return false; | 122 return false; |
88 #endif | 123 #endif |
89 } | 124 } |
90 | 125 |
(...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1710 | 1745 |
1711 on_demand_tile_raster_resource_id_ = | 1746 on_demand_tile_raster_resource_id_ = |
1712 resource_provider_->CreateGLTexture(quad->texture_size, | 1747 resource_provider_->CreateGLTexture(quad->texture_size, |
1713 GL_TEXTURE_2D, | 1748 GL_TEXTURE_2D, |
1714 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, | 1749 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, |
1715 GL_CLAMP_TO_EDGE, | 1750 GL_CLAMP_TO_EDGE, |
1716 ResourceProvider::TextureUsageAny, | 1751 ResourceProvider::TextureUsageAny, |
1717 quad->texture_format); | 1752 quad->texture_format); |
1718 } | 1753 } |
1719 | 1754 |
1720 SkBitmapDevice device(on_demand_tile_raster_bitmap_); | 1755 // Create and run on-demand raster task for tile. |
1721 SkCanvas canvas(&device); | 1756 scoped_refptr<internal::Task> on_demand_raster_task( |
1722 | 1757 new OnDemandRasterTaskImpl(quad->picture_pile, |
1723 quad->picture_pile->RasterToBitmap( | 1758 &on_demand_tile_raster_bitmap_, |
1724 &canvas, quad->content_rect, quad->contents_scale, NULL); | 1759 quad->content_rect, |
| 1760 quad->contents_scale)); |
| 1761 RunOnDemandRasterTask(on_demand_raster_task.get()); |
1725 | 1762 |
1726 uint8_t* bitmap_pixels = NULL; | 1763 uint8_t* bitmap_pixels = NULL; |
1727 SkBitmap on_demand_tile_raster_bitmap_dest; | 1764 SkBitmap on_demand_tile_raster_bitmap_dest; |
1728 SkBitmap::Config config = SkBitmapConfig(quad->texture_format); | 1765 SkBitmap::Config config = SkBitmapConfig(quad->texture_format); |
1729 if (on_demand_tile_raster_bitmap_.getConfig() != config) { | 1766 if (on_demand_tile_raster_bitmap_.getConfig() != config) { |
1730 on_demand_tile_raster_bitmap_.copyTo(&on_demand_tile_raster_bitmap_dest, | 1767 on_demand_tile_raster_bitmap_.copyTo(&on_demand_tile_raster_bitmap_dest, |
1731 config); | 1768 config); |
1732 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the | 1769 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the |
1733 // bitmap data. This check will be removed once crbug.com/293728 is fixed. | 1770 // bitmap data. This check will be removed once crbug.com/293728 is fixed. |
1734 CHECK_EQ(0u, on_demand_tile_raster_bitmap_dest.rowBytes() % 4); | 1771 CHECK_EQ(0u, on_demand_tile_raster_bitmap_dest.rowBytes() % 4); |
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3005 is_scissor_enabled_ = false; | 3042 is_scissor_enabled_ = false; |
3006 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST)); | 3043 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST)); |
3007 scissor_rect_needs_reset_ = true; | 3044 scissor_rect_needs_reset_ = true; |
3008 } | 3045 } |
3009 | 3046 |
3010 bool GLRenderer::IsContextLost() { | 3047 bool GLRenderer::IsContextLost() { |
3011 return output_surface_->context_provider()->IsContextLost(); | 3048 return output_surface_->context_provider()->IsContextLost(); |
3012 } | 3049 } |
3013 | 3050 |
3014 } // namespace cc | 3051 } // namespace cc |
OLD | NEW |