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

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

Issue 1139063002: cc: Partial tile update for one-copy raster. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: monocle: rebase Created 5 years, 6 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/tile_task_worker_pool.h ('k') | cc/raster/tile_task_worker_pool_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/tile_task_worker_pool.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
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"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 NOTREACHED(); 152 NOTREACHED();
153 return false; 153 return false;
154 } 154 }
155 155
156 // static 156 // static
157 void TileTaskWorkerPool::PlaybackToMemory(void* memory, 157 void TileTaskWorkerPool::PlaybackToMemory(void* memory,
158 ResourceFormat format, 158 ResourceFormat format,
159 const gfx::Size& size, 159 const gfx::Size& size,
160 int stride, 160 int stride,
161 const RasterSource* raster_source, 161 const RasterSource* raster_source,
162 const gfx::Rect& rect, 162 const gfx::Rect& canvas_bitmap_rect,
163 const gfx::Rect& canvas_playback_rect,
163 float scale) { 164 float scale) {
164 DCHECK(IsSupportedPlaybackToMemoryFormat(format)) << format; 165 DCHECK(IsSupportedPlaybackToMemoryFormat(format)) << format;
165 166
166 // Uses kPremul_SkAlphaType since the result is not known to be opaque. 167 // Uses kPremul_SkAlphaType since the result is not known to be opaque.
167 SkImageInfo info = 168 SkImageInfo info =
168 SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType); 169 SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType);
169 SkColorType buffer_color_type = ResourceFormatToSkColorType(format); 170 SkColorType buffer_color_type = ResourceFormatToSkColorType(format);
170 bool needs_copy = buffer_color_type != info.colorType(); 171 bool needs_copy = buffer_color_type != info.colorType();
171 172
172 // Use unknown pixel geometry to disable LCD text. 173 // Use unknown pixel geometry to disable LCD text.
173 SkSurfaceProps surface_props(0, kUnknown_SkPixelGeometry); 174 SkSurfaceProps surface_props(0, kUnknown_SkPixelGeometry);
174 if (raster_source->CanUseLCDText()) { 175 if (raster_source->CanUseLCDText()) {
175 // LegacyFontHost will get LCD text and skia figures out what type to use. 176 // LegacyFontHost will get LCD text and skia figures out what type to use.
176 surface_props = SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType); 177 surface_props = SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType);
177 } 178 }
178 179
179 if (!stride) 180 if (!stride)
180 stride = info.minRowBytes(); 181 stride = info.minRowBytes();
181 DCHECK_GT(stride, 0); 182 DCHECK_GT(stride, 0);
182 183
183 if (!needs_copy) { 184 if (!needs_copy) {
184 skia::RefPtr<SkSurface> surface = skia::AdoptRef( 185 skia::RefPtr<SkSurface> surface = skia::AdoptRef(
185 SkSurface::NewRasterDirect(info, memory, stride, &surface_props)); 186 SkSurface::NewRasterDirect(info, memory, stride, &surface_props));
186 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas()); 187 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas());
187 raster_source->PlaybackToCanvas(canvas.get(), rect, scale); 188 raster_source->PlaybackToCanvas(canvas.get(), canvas_bitmap_rect,
189 canvas_playback_rect, scale);
188 return; 190 return;
189 } 191 }
190 192
191 skia::RefPtr<SkSurface> surface = 193 skia::RefPtr<SkSurface> surface =
192 skia::AdoptRef(SkSurface::NewRaster(info, &surface_props)); 194 skia::AdoptRef(SkSurface::NewRaster(info, &surface_props));
193 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas()); 195 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas());
194 raster_source->PlaybackToCanvas(canvas.get(), rect, scale); 196 raster_source->PlaybackToCanvas(canvas.get(), canvas_bitmap_rect,
197 canvas_playback_rect, scale);
195 198
196 SkImageInfo dst_info = 199 SkImageInfo dst_info =
197 SkImageInfo::Make(info.width(), info.height(), buffer_color_type, 200 SkImageInfo::Make(info.width(), info.height(), buffer_color_type,
198 info.alphaType(), info.profileType()); 201 info.alphaType(), info.profileType());
199 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the 202 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the
200 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 203 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728
201 // is fixed. 204 // is fixed.
202 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); 205 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes());
203 DCHECK_EQ(0u, dst_row_bytes % 4); 206 DCHECK_EQ(0u, dst_row_bytes % 4);
204 bool success = canvas->readPixels(dst_info, memory, dst_row_bytes, 0, 0); 207 bool success = canvas->readPixels(dst_info, memory, dst_row_bytes, 0, 0);
205 DCHECK_EQ(true, success); 208 DCHECK_EQ(true, success);
206 } 209 }
207 210
208 } // namespace cc 211 } // namespace cc
OLDNEW
« no previous file with comments | « cc/raster/tile_task_worker_pool.h ('k') | cc/raster/tile_task_worker_pool_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698