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

Unified Diff: content/browser/compositor/delegated_frame_host.cc

Issue 389683002: Improving GestureNav screenshotting performance - part 2 - GestureNav (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@slow_readback_final_GL_HELPER
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_entry_screenshot_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/compositor/delegated_frame_host.cc
diff --git a/content/browser/compositor/delegated_frame_host.cc b/content/browser/compositor/delegated_frame_host.cc
index 91c8e035ceefcbef7fe1d401eaf64c2764a0cba0..51c9ad736b57925485a0cbf0faf452fb74f41e68 100644
--- a/content/browser/compositor/delegated_frame_host.cc
+++ b/content/browser/compositor/delegated_frame_host.cc
@@ -18,6 +18,9 @@
#include "media/base/video_frame.h"
#include "media/base/video_util.h"
#include "skia/ext/image_operations.h"
+#include "third_party/skia/include/core/SkCanvas.h"
+#include "third_party/skia/include/core/SkPaint.h"
+#include "third_party/skia/include/effects/SkLumaColorFilter.h"
namespace content {
@@ -122,7 +125,8 @@ void DelegatedFrameHost::CopyFromCompositingSurface(
const base::Callback<void(bool, const SkBitmap&)>& callback,
const SkColorType color_type) {
// Only ARGB888 and RGB565 supported as of now.
mfomitchev 2014/07/11 20:34:22 Comment needs updating. Would be nice to use a gl_
- bool format_support = ((color_type == kRGB_565_SkColorType) ||
+ bool format_support = ((color_type == kAlpha_8_SkColorType) ||
+ (color_type == kRGB_565_SkColorType) ||
(color_type == kN32_SkColorType));
DCHECK(format_support);
if (!CanCopyToBitmap()) {
@@ -438,6 +442,7 @@ void DelegatedFrameHost::CopyFromCompositingSurfaceHasResult(
}
if (result->HasTexture()) {
+ LOG(ERROR) << "result->HasTexture()";
PrepareTextureCopyOutputResult(dst_size_in_pixel, color_type,
callback,
result.Pass());
@@ -445,6 +450,7 @@ void DelegatedFrameHost::CopyFromCompositingSurfaceHasResult(
}
DCHECK(result->HasBitmap());
+ LOG(ERROR) << "result->HasBitmap()";
PrepareBitmapCopyOutputResult(dst_size_in_pixel, color_type, callback,
result.Pass());
}
@@ -455,6 +461,7 @@ static void CopyFromCompositingSurfaceFinished(
scoped_ptr<SkBitmap> bitmap,
scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock,
bool result) {
+ LOG(ERROR) << "CopyFromCompositingSurfaceFinished";
bitmap_pixels_lock.reset();
uint32 sync_point = 0;
@@ -466,6 +473,7 @@ static void CopyFromCompositingSurfaceFinished(
release_callback->Run(sync_point, lost_resource);
callback.Run(result, *bitmap);
+ LOG(ERROR) << "=== CopyFromCompositingSurfaceFinished EXITING";
}
// static
@@ -474,6 +482,9 @@ void DelegatedFrameHost::PrepareTextureCopyOutputResult(
const SkColorType color_type,
const base::Callback<void(bool, const SkBitmap&)>& callback,
scoped_ptr<cc::CopyOutputResult> result) {
+ LOG(ERROR) << "DelegatedFrameHost::PrepareTextureCopyOutputResult"
+ << ", bitmap color_type=" << color_type;
+
DCHECK(result->HasTexture());
base::ScopedClosureRunner scoped_callback_runner(
base::Bind(callback, false, SkBitmap()));
@@ -523,7 +534,7 @@ void DelegatedFrameHost::PrepareBitmapCopyOutputResult(
const SkColorType color_type,
const base::Callback<void(bool, const SkBitmap&)>& callback,
scoped_ptr<cc::CopyOutputResult> result) {
- if (color_type != kN32_SkColorType) {
+ if (color_type != kN32_SkColorType && color_type != kAlpha_8_SkColorType) {
NOTIMPLEMENTED();
callback.Run(false, SkBitmap());
return;
@@ -531,12 +542,34 @@ void DelegatedFrameHost::PrepareBitmapCopyOutputResult(
DCHECK(result->HasBitmap());
scoped_ptr<SkBitmap> source = result->TakeBitmap();
DCHECK(source);
- SkBitmap bitmap = skia::ImageOperations::Resize(
- *source,
- skia::ImageOperations::RESIZE_BEST,
- dst_size_in_pixel.width(),
- dst_size_in_pixel.height());
- callback.Run(true, bitmap);
+ SkBitmap scaled_bitmap;
+ if (source->width() != dst_size_in_pixel.width() ||
+ source->height() != dst_size_in_pixel.height()) {
+ scaled_bitmap =
+ skia::ImageOperations::Resize(*source,
+ skia::ImageOperations::RESIZE_BEST,
+ dst_size_in_pixel.width(),
+ dst_size_in_pixel.height());
+ } else {
+ scaled_bitmap = *source;
+ }
+ if (color_type == kN32_SkColorType) {
+ callback.Run(true, scaled_bitmap);
+ return;
+ }
+ DCHECK_EQ(color_type, kAlpha_8_SkColorType);
+ // Paint |scaledBitmap| to alpha-only |a8Bitmap|.
+ SkBitmap grayscale_bitmap;
+ grayscale_bitmap.allocPixels(
mfomitchev 2014/07/11 21:20:13 We should first check the color type of the return
mfomitchev 2014/08/25 20:57:47 Done.
+ SkImageInfo::MakeA8(scaled_bitmap.width(), scaled_bitmap.height()));
+ // TODO (mfomitchev): should handle allocPixels failing here.
+ SkCanvas canvas(grayscale_bitmap);
+ SkPaint paint;
+ skia::RefPtr<SkColorFilter> filter =
+ skia::AdoptRef(SkLumaColorFilter::Create());
+ paint.setColorFilter(filter.get());
+ canvas.drawBitmap(scaled_bitmap, SkIntToScalar(0), SkIntToScalar(0), &paint);
+ callback.Run(true, grayscale_bitmap);
}
// static
@@ -555,6 +588,7 @@ void DelegatedFrameHost::ReturnSubscriberTexture(
dfh->idle_frame_subscriber_textures_.push_back(subscriber_texture);
}
+// static
void DelegatedFrameHost::CopyFromCompositingSurfaceFinishedForVideo(
base::WeakPtr<DelegatedFrameHost> dfh,
const base::Callback<void(bool)>& callback,
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_entry_screenshot_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698