| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/compositor/surface_utils.h" | 5 #include "content/browser/compositor/surface_utils.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "cc/output/copy_output_result.h" | 10 #include "cc/output/copy_output_result.h" |
| 11 #include "cc/resources/single_release_callback.h" | 11 #include "cc/resources/single_release_callback.h" |
| 12 #include "cc/surfaces/surface_id_allocator.h" | 12 #include "cc/surfaces/surface_id_allocator.h" |
| 13 #include "content/common/gpu/client/gl_helper.h" | 13 #include "content/common/gpu/client/gl_helper.h" |
| 14 #include "skia/ext/image_operations.h" | 14 #include "skia/ext/image_operations.h" |
| 15 #include "skia/ext/refptr.h" | 15 #include "skia/ext/refptr.h" |
| 16 #include "third_party/skia/include/core/SkCanvas.h" | 16 #include "third_party/skia/include/core/SkCanvas.h" |
| 17 #include "third_party/skia/include/core/SkColorFilter.h" | 17 #include "third_party/skia/include/core/SkColorFilter.h" |
| 18 #include "third_party/skia/include/core/SkPaint.h" | 18 #include "third_party/skia/include/core/SkPaint.h" |
| 19 #include "third_party/skia/include/effects/SkLumaColorFilter.h" | 19 #include "third_party/skia/include/effects/SkLumaColorFilter.h" |
| 20 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
| 21 | 21 |
| 22 #if defined(OS_ANDROID) | 22 #if !defined(OS_ANDROID) |
| 23 #include "content/browser/renderer_host/compositor_impl_android.h" | |
| 24 #else | |
| 25 #include "content/browser/compositor/image_transport_factory.h" | 23 #include "content/browser/compositor/image_transport_factory.h" |
| 26 #include "ui/compositor/compositor.h" | |
| 27 #endif | 24 #endif |
| 28 | 25 |
| 29 namespace { | 26 namespace { |
| 30 | 27 |
| 31 #if !defined(OS_ANDROID) || defined(USE_AURA) | 28 #if !defined(OS_ANDROID) || defined(USE_AURA) |
| 32 void CopyFromCompositingSurfaceFinished( | 29 void CopyFromCompositingSurfaceFinished( |
| 33 const content::ReadbackRequestCallback& callback, | 30 const content::ReadbackRequestCallback& callback, |
| 34 scoped_ptr<cc::SingleReleaseCallback> release_callback, | 31 scoped_ptr<cc::SingleReleaseCallback> release_callback, |
| 35 scoped_ptr<SkBitmap> bitmap, | 32 scoped_ptr<SkBitmap> bitmap, |
| 36 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, | 33 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 skia::AdoptRef(SkLumaColorFilter::Create()); | 151 skia::AdoptRef(SkLumaColorFilter::Create()); |
| 155 paint.setColorFilter(filter.get()); | 152 paint.setColorFilter(filter.get()); |
| 156 canvas.drawBitmap(scaled_bitmap, SkIntToScalar(0), SkIntToScalar(0), &paint); | 153 canvas.drawBitmap(scaled_bitmap, SkIntToScalar(0), SkIntToScalar(0), &paint); |
| 157 callback.Run(grayscale_bitmap, content::READBACK_SUCCESS); | 154 callback.Run(grayscale_bitmap, content::READBACK_SUCCESS); |
| 158 } | 155 } |
| 159 | 156 |
| 160 } // namespace | 157 } // namespace |
| 161 | 158 |
| 162 namespace content { | 159 namespace content { |
| 163 | 160 |
| 164 scoped_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator() { | |
| 165 #if defined(OS_ANDROID) | |
| 166 return CompositorImpl::CreateSurfaceIdAllocator(); | |
| 167 #else | |
| 168 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | |
| 169 return factory->GetContextFactory()->CreateSurfaceIdAllocator(); | |
| 170 #endif | |
| 171 } | |
| 172 | |
| 173 cc::SurfaceManager* GetSurfaceManager() { | |
| 174 #if defined(OS_ANDROID) | |
| 175 return CompositorImpl::GetSurfaceManager(); | |
| 176 #else | |
| 177 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | |
| 178 return factory->GetSurfaceManager(); | |
| 179 #endif | |
| 180 } | |
| 181 | |
| 182 void CopyFromCompositingSurfaceHasResult( | 161 void CopyFromCompositingSurfaceHasResult( |
| 183 const gfx::Size& dst_size_in_pixel, | 162 const gfx::Size& dst_size_in_pixel, |
| 184 const SkColorType color_type, | 163 const SkColorType color_type, |
| 185 const ReadbackRequestCallback& callback, | 164 const ReadbackRequestCallback& callback, |
| 186 scoped_ptr<cc::CopyOutputResult> result) { | 165 scoped_ptr<cc::CopyOutputResult> result) { |
| 187 if (result->IsEmpty() || result->size().IsEmpty()) { | 166 if (result->IsEmpty() || result->size().IsEmpty()) { |
| 188 callback.Run(SkBitmap(), READBACK_FAILED); | 167 callback.Run(SkBitmap(), READBACK_FAILED); |
| 189 return; | 168 return; |
| 190 } | 169 } |
| 191 | 170 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 202 return; | 181 return; |
| 203 } | 182 } |
| 204 | 183 |
| 205 DCHECK(result->HasBitmap()); | 184 DCHECK(result->HasBitmap()); |
| 206 // Software path | 185 // Software path |
| 207 PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback, | 186 PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback, |
| 208 std::move(result)); | 187 std::move(result)); |
| 209 } | 188 } |
| 210 | 189 |
| 211 } // namespace content | 190 } // namespace content |
| OLD | NEW |