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

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

Issue 160023002: cc: Only make num_threads - 1 SkPicture clones. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment Created 6 years, 10 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 | Annotate | Revision Log
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 contents_rect,
86 float contents_scale)
87 : picture_pile_(picture_pile),
88 bitmap_(bitmap),
89 contents_rect_(contents_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, contents_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 contents_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 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 SkBitmapDevice device(on_demand_tile_raster_bitmap_);
1721 SkCanvas canvas(&device); 1756 SkCanvas canvas(&device);
1722 1757
1723 quad->picture_pile->RasterToBitmap( 1758 internal::TaskGraphRunner* task_graph_runner =
1724 &canvas, quad->content_rect, quad->contents_scale, NULL); 1759 RasterWorkerPool::GetTaskGraphRunner();
1760 // Make sure we have a unique task namespace token.
1761 if (!on_demand_task_namespace_.IsValid())
1762 on_demand_task_namespace_ = task_graph_runner->GetNamespaceToken();
1763
1764 // Create a raster task for for tile.
1765 scoped_refptr<internal::Task> on_demand_raster_task(
1766 new OnDemandRasterTaskImpl(quad->picture_pile,
1767 &on_demand_tile_raster_bitmap_,
1768 quad->content_rect,
1769 quad->contents_scale));
1770
1771 // Construct a task graph that contains this single raster task.
1772 internal::TaskGraph graph;
1773 graph.nodes.push_back(
1774 internal::TaskGraph::Node(on_demand_raster_task.get(),
1775 RasterWorkerPool::kOnDemandRasterTaskPriority,
1776 0u));
1777
1778 // Schedule task and wait for task grap runner to finish running it.
enne (OOO) 2014/02/11 22:30:45 typo
reveman 2014/02/11 23:40:42 Done.
1779 task_graph_runner->SetTaskGraph(on_demand_task_namespace_, &graph);
1780 task_graph_runner->WaitForTasksToFinishRunning(on_demand_task_namespace_);
1781
1782 // Collect task now that it has finished running.
1783 internal::Task::Vector completed_tasks;
1784 task_graph_runner->CollectCompletedTasks(on_demand_task_namespace_,
1785 &completed_tasks);
1786 DCHECK_EQ(1u, completed_tasks.size());
1787 DCHECK_EQ(completed_tasks[0], on_demand_raster_task.get());
1725 1788
1726 uint8_t* bitmap_pixels = NULL; 1789 uint8_t* bitmap_pixels = NULL;
1727 SkBitmap on_demand_tile_raster_bitmap_dest; 1790 SkBitmap on_demand_tile_raster_bitmap_dest;
1728 SkBitmap::Config config = SkBitmapConfig(quad->texture_format); 1791 SkBitmap::Config config = SkBitmapConfig(quad->texture_format);
1729 if (on_demand_tile_raster_bitmap_.getConfig() != config) { 1792 if (on_demand_tile_raster_bitmap_.getConfig() != config) {
1730 on_demand_tile_raster_bitmap_.copyTo(&on_demand_tile_raster_bitmap_dest, 1793 on_demand_tile_raster_bitmap_.copyTo(&on_demand_tile_raster_bitmap_dest,
1731 config); 1794 config);
1732 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the 1795 // 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. 1796 // 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); 1797 CHECK_EQ(0u, on_demand_tile_raster_bitmap_dest.rowBytes() % 4);
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
3005 is_scissor_enabled_ = false; 3068 is_scissor_enabled_ = false;
3006 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST)); 3069 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST));
3007 scissor_rect_needs_reset_ = true; 3070 scissor_rect_needs_reset_ = true;
3008 } 3071 }
3009 3072
3010 bool GLRenderer::IsContextLost() { 3073 bool GLRenderer::IsContextLost() {
3011 return output_surface_->context_provider()->IsContextLost(); 3074 return output_surface_->context_provider()->IsContextLost();
3012 } 3075 }
3013 3076
3014 } // namespace cc 3077 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698