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

Side by Side Diff: cc/raster/raster_buffer_provider.cc

Issue 1910213005: cc: Refactor TileTaskWorkerPool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@task_states
Patch Set: feedback Created 4 years, 7 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
« no previous file with comments | « cc/raster/raster_buffer_provider.h ('k') | cc/raster/raster_buffer_provider_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/raster/tile_task_worker_pool.h" 5 #include "cc/raster/raster_buffer_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "cc/playback/raster_source.h" 10 #include "cc/playback/raster_source.h"
11 #include "cc/raster/texture_compressor.h" 11 #include "cc/raster/texture_compressor.h"
12 #include "cc/resources/platform_color.h" 12 #include "cc/resources/platform_color.h"
13 #include "third_party/skia/include/core/SkCanvas.h" 13 #include "third_party/skia/include/core/SkCanvas.h"
14 #include "third_party/skia/include/core/SkSurface.h" 14 #include "third_party/skia/include/core/SkSurface.h"
15 15
16 namespace cc { 16 namespace cc {
17 17
18 TileTaskWorkerPool::TileTaskWorkerPool() {} 18 RasterBufferProvider::RasterBufferProvider() {}
19 19
20 TileTaskWorkerPool::~TileTaskWorkerPool() {} 20 RasterBufferProvider::~RasterBufferProvider() {}
21
22 // static
23 void TileTaskWorkerPool::ScheduleTasksOnOriginThread(
24 RasterBufferProvider* provider,
25 TaskGraph* graph) {
26 TRACE_EVENT0("cc", "TileTaskWorkerPool::ScheduleTasksOnOriginThread");
27
28 for (TaskGraph::Node::Vector::iterator it = graph->nodes.begin();
29 it != graph->nodes.end(); ++it) {
30 TaskGraph::Node& node = *it;
31 TileTask* task = static_cast<TileTask*>(node.task);
32
33 if (!task->HasBeenScheduled()) {
34 task->WillSchedule();
35 task->ScheduleOnOriginThread(provider);
36 task->DidSchedule();
37 }
38 }
39 }
40 21
41 namespace { 22 namespace {
42 23
43 bool IsSupportedPlaybackToMemoryFormat(ResourceFormat format) { 24 bool IsSupportedPlaybackToMemoryFormat(ResourceFormat format) {
44 switch (format) { 25 switch (format) {
45 case RGBA_4444: 26 case RGBA_4444:
46 case RGBA_8888: 27 case RGBA_8888:
47 case BGRA_8888: 28 case BGRA_8888:
48 case ETC1: 29 case ETC1:
49 return true; 30 return true;
50 case ALPHA_8: 31 case ALPHA_8:
51 case LUMINANCE_8: 32 case LUMINANCE_8:
52 case RGB_565: 33 case RGB_565:
53 case RED_8: 34 case RED_8:
54 case LUMINANCE_F16: 35 case LUMINANCE_F16:
55 return false; 36 return false;
56 } 37 }
57 NOTREACHED(); 38 NOTREACHED();
58 return false; 39 return false;
59 } 40 }
60 41
61 } // anonymous namespace 42 } // anonymous namespace
62 43
63 // static 44 // static
64 void TileTaskWorkerPool::PlaybackToMemory( 45 void RasterBufferProvider::PlaybackToMemory(
65 void* memory, 46 void* memory,
66 ResourceFormat format, 47 ResourceFormat format,
67 const gfx::Size& size, 48 const gfx::Size& size,
68 size_t stride, 49 size_t stride,
69 const RasterSource* raster_source, 50 const RasterSource* raster_source,
70 const gfx::Rect& canvas_bitmap_rect, 51 const gfx::Rect& canvas_bitmap_rect,
71 const gfx::Rect& canvas_playback_rect, 52 const gfx::Rect& canvas_playback_rect,
72 float scale, 53 float scale,
73 const RasterSource::PlaybackSettings& playback_settings) { 54 const RasterSource::PlaybackSettings& playback_settings) {
74 TRACE_EVENT0("cc", "TileTaskWorkerPool::PlaybackToMemory"); 55 TRACE_EVENT0("cc", "RasterBufferProvider::PlaybackToMemory");
75 56
76 DCHECK(IsSupportedPlaybackToMemoryFormat(format)) << format; 57 DCHECK(IsSupportedPlaybackToMemoryFormat(format)) << format;
77 58
78 // Uses kPremul_SkAlphaType since the result is not known to be opaque. 59 // Uses kPremul_SkAlphaType since the result is not known to be opaque.
79 SkImageInfo info = 60 SkImageInfo info =
80 SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType); 61 SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType);
81 62
82 // Use unknown pixel geometry to disable LCD text. 63 // Use unknown pixel geometry to disable LCD text.
83 SkSurfaceProps surface_props(0, kUnknown_SkPixelGeometry); 64 SkSurfaceProps surface_props(0, kUnknown_SkPixelGeometry);
84 if (raster_source->CanUseLCDText()) { 65 if (raster_source->CanUseLCDText()) {
(...skipping 19 matching lines...) Expand all
104 case ETC1: { 85 case ETC1: {
105 sk_sp<SkSurface> surface = SkSurface::MakeRaster(info, &surface_props); 86 sk_sp<SkSurface> surface = SkSurface::MakeRaster(info, &surface_props);
106 // TODO(reveman): Improve partial raster support by reducing the size of 87 // TODO(reveman): Improve partial raster support by reducing the size of
107 // playback rect passed to PlaybackToCanvas. crbug.com/519070 88 // playback rect passed to PlaybackToCanvas. crbug.com/519070
108 raster_source->PlaybackToCanvas(surface->getCanvas(), canvas_bitmap_rect, 89 raster_source->PlaybackToCanvas(surface->getCanvas(), canvas_bitmap_rect,
109 canvas_bitmap_rect, scale, 90 canvas_bitmap_rect, scale,
110 playback_settings); 91 playback_settings);
111 92
112 if (format == ETC1) { 93 if (format == ETC1) {
113 TRACE_EVENT0("cc", 94 TRACE_EVENT0("cc",
114 "TileTaskWorkerPool::PlaybackToMemory::CompressETC1"); 95 "RasterBufferProvider::PlaybackToMemory::CompressETC1");
115 DCHECK_EQ(size.width() % 4, 0); 96 DCHECK_EQ(size.width() % 4, 0);
116 DCHECK_EQ(size.height() % 4, 0); 97 DCHECK_EQ(size.height() % 4, 0);
117 std::unique_ptr<TextureCompressor> texture_compressor = 98 std::unique_ptr<TextureCompressor> texture_compressor =
118 TextureCompressor::Create(TextureCompressor::kFormatETC1); 99 TextureCompressor::Create(TextureCompressor::kFormatETC1);
119 SkPixmap pixmap; 100 SkPixmap pixmap;
120 surface->peekPixels(&pixmap); 101 surface->peekPixels(&pixmap);
121 texture_compressor->Compress( 102 texture_compressor->Compress(
122 reinterpret_cast<const uint8_t*>(pixmap.addr()), 103 reinterpret_cast<const uint8_t*>(pixmap.addr()),
123 reinterpret_cast<uint8_t*>(memory), size.width(), size.height(), 104 reinterpret_cast<uint8_t*>(memory), size.width(), size.height(),
124 TextureCompressor::kQualityHigh); 105 TextureCompressor::kQualityHigh);
125 } else { 106 } else {
126 TRACE_EVENT0("cc", 107 TRACE_EVENT0("cc",
127 "TileTaskWorkerPool::PlaybackToMemory::ConvertRGBA4444"); 108 "RasterBufferProvider::PlaybackToMemory::ConvertRGBA4444");
128 SkImageInfo dst_info = 109 SkImageInfo dst_info =
129 SkImageInfo::Make(info.width(), info.height(), 110 SkImageInfo::Make(info.width(), info.height(),
130 ResourceFormatToClosestSkColorType(format), 111 ResourceFormatToClosestSkColorType(format),
131 info.alphaType(), info.profileType()); 112 info.alphaType(), info.profileType());
132 bool rv = surface->readPixels(dst_info, memory, stride, 0, 0); 113 bool rv = surface->readPixels(dst_info, memory, stride, 0, 0);
133 DCHECK(rv); 114 DCHECK(rv);
134 } 115 }
135 return; 116 return;
136 } 117 }
137 case ALPHA_8: 118 case ALPHA_8:
138 case LUMINANCE_8: 119 case LUMINANCE_8:
139 case RGB_565: 120 case RGB_565:
140 case RED_8: 121 case RED_8:
141 case LUMINANCE_F16: 122 case LUMINANCE_F16:
142 NOTREACHED(); 123 NOTREACHED();
143 return; 124 return;
144 } 125 }
145 126
146 NOTREACHED(); 127 NOTREACHED();
147 } 128 }
148 129
149 bool TileTaskWorkerPool::ResourceFormatRequiresSwizzle(ResourceFormat format) { 130 bool RasterBufferProvider::ResourceFormatRequiresSwizzle(
131 ResourceFormat format) {
150 switch (format) { 132 switch (format) {
151 case RGBA_8888: 133 case RGBA_8888:
152 case BGRA_8888: 134 case BGRA_8888:
153 // Initialize resource using the preferred PlatformColor component 135 // Initialize resource using the preferred PlatformColor component
154 // order and swizzle in the shader instead of in software. 136 // order and swizzle in the shader instead of in software.
155 return !PlatformColor::SameComponentOrder(format); 137 return !PlatformColor::SameComponentOrder(format);
156 case RGBA_4444: 138 case RGBA_4444:
157 case ETC1: 139 case ETC1:
158 case ALPHA_8: 140 case ALPHA_8:
159 case LUMINANCE_8: 141 case LUMINANCE_8:
160 case RGB_565: 142 case RGB_565:
161 case RED_8: 143 case RED_8:
162 case LUMINANCE_F16: 144 case LUMINANCE_F16:
163 return false; 145 return false;
164 } 146 }
165 NOTREACHED(); 147 NOTREACHED();
166 return false; 148 return false;
167 } 149 }
168 150
169 } // namespace cc 151 } // namespace cc
OLDNEW
« no previous file with comments | « cc/raster/raster_buffer_provider.h ('k') | cc/raster/raster_buffer_provider_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698