| OLD | NEW |
| 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/resources/raster_worker_pool.h" | 5 #include "cc/resources/raster_worker_pool.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 const gfx::Rect& rect, | 221 const gfx::Rect& rect, |
| 222 float scale) { | 222 float scale) { |
| 223 DCHECK(IsSupportedPlaybackToMemoryFormat(format)) << format; | 223 DCHECK(IsSupportedPlaybackToMemoryFormat(format)) << format; |
| 224 | 224 |
| 225 // Uses kPremul_SkAlphaType since the result is not known to be opaque. | 225 // Uses kPremul_SkAlphaType since the result is not known to be opaque. |
| 226 SkImageInfo info = | 226 SkImageInfo info = |
| 227 SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType); | 227 SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType); |
| 228 SkColorType buffer_color_type = ResourceFormatToSkColorType(format); | 228 SkColorType buffer_color_type = ResourceFormatToSkColorType(format); |
| 229 bool needs_copy = buffer_color_type != info.colorType(); | 229 bool needs_copy = buffer_color_type != info.colorType(); |
| 230 | 230 |
| 231 // TODO(danakj): Make a SkSurfaceProps with an SkPixelGeometry to enable or | 231 // Use unknown pixel geometry to disable LCD text. |
| 232 // disable LCD text. | 232 SkSurfaceProps surface_props(0, kUnknown_SkPixelGeometry); |
| 233 // TODO(danakj): Disable LCD text on Mac during layout tests: | 233 if (raster_source->CanUseLCDText()) { |
| 234 // https://cs.chromium.org#chromium/src/third_party/WebKit/Source/platform/fon
ts/mac/FontPlatformDataMac.mm&l=55 | 234 // LegacyFontHost will get LCD text and skia figures out what type to use. |
| 235 // TODO(danakj): On Windows when LCD text is disabled, ask skia to draw LCD | 235 surface_props = SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType); |
| 236 // text offscreen and downsample it to AA text. | 236 } |
| 237 // https://cs.chromium.org#chromium/src/third_party/WebKit/Source/platform/fon
ts/win/FontPlatformDataWin.cpp&l=86 | |
| 238 SkSurfaceProps* surface_props = nullptr; | |
| 239 | 237 |
| 240 if (!stride) | 238 if (!stride) |
| 241 stride = info.minRowBytes(); | 239 stride = info.minRowBytes(); |
| 242 | 240 |
| 243 if (!needs_copy) { | 241 if (!needs_copy) { |
| 244 skia::RefPtr<SkSurface> surface = skia::AdoptRef( | 242 skia::RefPtr<SkSurface> surface = skia::AdoptRef( |
| 245 SkSurface::NewRasterDirect(info, memory, stride, surface_props)); | 243 SkSurface::NewRasterDirect(info, memory, stride, &surface_props)); |
| 246 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas()); | 244 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas()); |
| 247 raster_source->PlaybackToCanvas(canvas.get(), rect, scale); | 245 raster_source->PlaybackToCanvas(canvas.get(), rect, scale); |
| 248 return; | 246 return; |
| 249 } | 247 } |
| 250 | 248 |
| 251 skia::RefPtr<SkSurface> surface = | 249 skia::RefPtr<SkSurface> surface = |
| 252 skia::AdoptRef(SkSurface::NewRaster(info, surface_props)); | 250 skia::AdoptRef(SkSurface::NewRaster(info, &surface_props)); |
| 253 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas()); | 251 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas()); |
| 254 raster_source->PlaybackToCanvas(canvas.get(), rect, scale); | 252 raster_source->PlaybackToCanvas(canvas.get(), rect, scale); |
| 255 | 253 |
| 256 SkImageInfo dst_info = info; | 254 SkImageInfo dst_info = info; |
| 257 dst_info.fColorType = buffer_color_type; | 255 dst_info.fColorType = buffer_color_type; |
| 258 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the | 256 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the |
| 259 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 | 257 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 |
| 260 // is fixed. | 258 // is fixed. |
| 261 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); | 259 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); |
| 262 DCHECK_EQ(0u, dst_row_bytes % 4); | 260 DCHECK_EQ(0u, dst_row_bytes % 4); |
| 263 bool success = canvas->readPixels(dst_info, memory, dst_row_bytes, 0, 0); | 261 bool success = canvas->readPixels(dst_info, memory, dst_row_bytes, 0, 0); |
| 264 DCHECK_EQ(true, success); | 262 DCHECK_EQ(true, success); |
| 265 } | 263 } |
| 266 | 264 |
| 267 } // namespace cc | 265 } // namespace cc |
| OLD | NEW |