Commit 97f37d55 authored by saintlou@chromium.org's avatar saintlou@chromium.org

Revert http://codereview.chromium.org/9838043/

TBR=mukai@chromium.org
BUG=120601
TEST=none

Review URL: https://chromiumcodereview.appspot.com/9874030

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129475 0039d316-1c4b-4281-b951-d872f2087c98
parent d804ac00
...@@ -66,8 +66,23 @@ void SaveScreenshot(bool is_logged_in, ...@@ -66,8 +66,23 @@ void SaveScreenshot(bool is_logged_in,
} }
} }
// Actually takes the screenshot. // How opaque should the layer that we flash onscreen to provide visual
void TakeScreenshot(aura::Window* window, const gfx::Rect& rect) { // feedback after the screenshot is taken be?
const float kVisualFeedbackLayerOpacity = 0.25f;
// How long should the visual feedback layer be displayed?
const int64 kVisualFeedbackLayerDisplayTimeMs = 100;
} // namespace
ScreenshotTaker::ScreenshotTaker() {
}
ScreenshotTaker::~ScreenshotTaker() {
}
void ScreenshotTaker::HandleTakePartialScreenshot(
aura::Window* window, const gfx::Rect& rect) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
scoped_refptr<RefCountedBytes> png_data(new RefCountedBytes); scoped_refptr<RefCountedBytes> png_data(new RefCountedBytes);
...@@ -78,6 +93,7 @@ void TakeScreenshot(aura::Window* window, const gfx::Rect& rect) { ...@@ -78,6 +93,7 @@ void TakeScreenshot(aura::Window* window, const gfx::Rect& rect) {
#endif #endif
if (browser::GrabWindowSnapshot(window, &png_data->data(), rect)) { if (browser::GrabWindowSnapshot(window, &png_data->data(), rect)) {
DisplayVisualFeedback(rect);
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
content::BrowserThread::FILE, FROM_HERE, content::BrowserThread::FILE, FROM_HERE,
base::Bind(&SaveScreenshot, is_logged_in, png_data)); base::Bind(&SaveScreenshot, is_logged_in, png_data));
...@@ -86,42 +102,15 @@ void TakeScreenshot(aura::Window* window, const gfx::Rect& rect) { ...@@ -86,42 +102,15 @@ void TakeScreenshot(aura::Window* window, const gfx::Rect& rect) {
} }
} }
// How opaque should the layer that we flash onscreen to provide visual
// feedback after the screenshot is taken be?
const float kVisualFeedbackLayerOpacity = 0.25f;
// How long should the visual feedback layer be displayed?
const int64 kVisualFeedbackLayerDisplayTimeMs = 100;
} // namespace
ScreenshotTaker::ScreenshotTaker() {
}
ScreenshotTaker::~ScreenshotTaker() {
}
void ScreenshotTaker::HandleTakePartialScreenshot(aura::Window* window,
const gfx::Rect& rect) {
// browser::GrabWindowSnapshot takes ~100msec and making visual feedback after
// that leads noticeable delay. To prevent this delay, we just make the
// visual effect first, and then run the actual task of taking screenshot.
DisplayVisualFeedback(
rect,
base::Bind(&TakeScreenshot, base::Unretained(window), rect));
}
void ScreenshotTaker::HandleTakeScreenshot(aura::Window* window) { void ScreenshotTaker::HandleTakeScreenshot(aura::Window* window) {
HandleTakePartialScreenshot(window, window->bounds()); HandleTakePartialScreenshot(window, window->bounds());
} }
void ScreenshotTaker::CloseVisualFeedbackLayer(const base::Closure& task) { void ScreenshotTaker::CloseVisualFeedbackLayer() {
visual_feedback_layer_.reset(); visual_feedback_layer_.reset();
task.Run();
} }
void ScreenshotTaker::DisplayVisualFeedback(const gfx::Rect& rect, void ScreenshotTaker::DisplayVisualFeedback(const gfx::Rect& rect) {
const base::Closure& task) {
visual_feedback_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); visual_feedback_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
visual_feedback_layer_->SetColor(SK_ColorWHITE); visual_feedback_layer_->SetColor(SK_ColorWHITE);
visual_feedback_layer_->SetOpacity(kVisualFeedbackLayerOpacity); visual_feedback_layer_->SetOpacity(kVisualFeedbackLayerOpacity);
...@@ -135,7 +124,6 @@ void ScreenshotTaker::DisplayVisualFeedback(const gfx::Rect& rect, ...@@ -135,7 +124,6 @@ void ScreenshotTaker::DisplayVisualFeedback(const gfx::Rect& rect,
MessageLoopForUI::current()->PostDelayedTask( MessageLoopForUI::current()->PostDelayedTask(
FROM_HERE, FROM_HERE,
base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer, base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer,
base::Unretained(this), base::Unretained(this)),
task),
base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs)); base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs));
} }
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "ash/screenshot_delegate.h" #include "ash/screenshot_delegate.h"
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/callback.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "ui/gfx/compositor/layer.h" #include "ui/gfx/compositor/layer.h"
...@@ -28,12 +27,11 @@ class ScreenshotTaker : public ash::ScreenshotDelegate { ...@@ -28,12 +27,11 @@ class ScreenshotTaker : public ash::ScreenshotDelegate {
private: private:
// Flashes the screen to provide visual feedback that a screenshot has // Flashes the screen to provide visual feedback that a screenshot has
// been taken. |task| runs after the visual feedback finishes. // been taken.
void DisplayVisualFeedback(const gfx::Rect& rect, const base::Closure& task); void DisplayVisualFeedback(const gfx::Rect& rect);
// Closes the visual feedback layer. |task| runs after the visual // Closes the visual feedback layer.
// feedback finishes. void CloseVisualFeedbackLayer();
void CloseVisualFeedbackLayer(const base::Closure& task);
scoped_ptr<ui::Layer> visual_feedback_layer_; scoped_ptr<ui::Layer> visual_feedback_layer_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment