diff options
author | Zeno Albisser <zeno.albisser@digia.com> | 2013-11-21 14:09:57 +0100 |
---|---|---|
committer | Andras Becsi <andras.becsi@digia.com> | 2013-11-29 15:14:36 +0100 |
commit | eb32ba6f51d0c21d58cd7d89785285ff8fa64624 (patch) | |
tree | 2c7c940e1dbee81b89d935626110816b494aa32c /chromium/ui/aura | |
parent | 9427c1a0222ebd67efef1a2c7990a0fa5c9aac84 (diff) | |
download | qtwebengine-chromium-eb32ba6f51d0c21d58cd7d89785285ff8fa64624.tar.gz |
Update chromium to branch 1599.
Change-Id: I04e775a946a208bb4500d3b722bcb05c82b9d7cb
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/ui/aura')
-rw-r--r-- | chromium/ui/aura/bench/DEPS | 1 | ||||
-rw-r--r-- | chromium/ui/aura/bench/bench_main.cc | 38 | ||||
-rw-r--r-- | chromium/ui/aura/remote_root_window_host_win.cc | 7 | ||||
-rw-r--r-- | chromium/ui/aura/remote_root_window_host_win.h | 3 | ||||
-rw-r--r-- | chromium/ui/aura/root_window.cc | 9 | ||||
-rw-r--r-- | chromium/ui/aura/root_window.h | 8 | ||||
-rw-r--r-- | chromium/ui/aura/root_window_host.h | 9 | ||||
-rw-r--r-- | chromium/ui/aura/root_window_host_mac.mm | 3 | ||||
-rw-r--r-- | chromium/ui/aura/root_window_host_ozone.cc | 7 | ||||
-rw-r--r-- | chromium/ui/aura/root_window_host_ozone.h | 3 | ||||
-rw-r--r-- | chromium/ui/aura/root_window_host_win.cc | 7 | ||||
-rw-r--r-- | chromium/ui/aura/root_window_host_win.h | 3 | ||||
-rw-r--r-- | chromium/ui/aura/root_window_host_x11.cc | 49 | ||||
-rw-r--r-- | chromium/ui/aura/root_window_host_x11.h | 3 |
14 files changed, 128 insertions, 22 deletions
diff --git a/chromium/ui/aura/bench/DEPS b/chromium/ui/aura/bench/DEPS index 1fda55436bc..69deb976808 100644 --- a/chromium/ui/aura/bench/DEPS +++ b/chromium/ui/aura/bench/DEPS @@ -1,5 +1,4 @@ include_rules = [ - "+cc", "+third_party/khronos", "+third_party/WebKit/public/platform", ] diff --git a/chromium/ui/aura/bench/bench_main.cc b/chromium/ui/aura/bench/bench_main.cc index 17ed068e60b..aee7e79c83a 100644 --- a/chromium/ui/aura/bench/bench_main.cc +++ b/chromium/ui/aura/bench/bench_main.cc @@ -10,7 +10,6 @@ #include "base/message_loop/message_loop.h" #include "base/strings/string_split.h" #include "base/time/time.h" -#include "cc/output/context_provider.h" #include "third_party/khronos/GLES2/gl2.h" #include "third_party/skia/include/core/SkXfermode.h" #include "ui/aura/client/default_capture_client.h" @@ -182,7 +181,7 @@ class WebGLBench : public BenchCompositorObserver { parent_(parent), webgl_(ui::LAYER_TEXTURED), compositor_(compositor), - context_provider_(), + context_(), texture_(), fbo_(0), do_draw_(true) { @@ -208,26 +207,24 @@ class WebGLBench : public BenchCompositorObserver { webgl_.SetBounds(bounds); parent_->Add(&webgl_); - context_provider_ = ui::ContextFactory::GetInstance() - ->OffscreenContextProviderForMainThread(); - WebKit::WebGraphicsContext3D* context = context_provider_->Context3d(); - context->makeContextCurrent(); - texture_ = new WebGLTexture(context, bounds.size()); - fbo_ = context->createFramebuffer(); + context_ = ui::ContextFactory::GetInstance()->CreateOffscreenContext(); + context_->makeContextCurrent(); + texture_ = new WebGLTexture(context_.get(), bounds.size()); + fbo_ = context_->createFramebuffer(); compositor->AddObserver(this); webgl_.SetExternalTexture(texture_.get()); - context->bindFramebuffer(GL_FRAMEBUFFER, fbo_); - context->framebufferTexture2D( + context_->bindFramebuffer(GL_FRAMEBUFFER, fbo_); + context_->framebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_->PrepareTexture(), 0); - context->clearColor(0.f, 1.f, 0.f, 1.f); - context->clear(GL_COLOR_BUFFER_BIT); - context->flush(); + context_->clearColor(0.f, 1.f, 0.f, 1.f); + context_->clear(GL_COLOR_BUFFER_BIT); + context_->flush(); } virtual ~WebGLBench() { - context_provider_->Context3d()->makeContextCurrent(); - context_provider_->Context3d()->deleteFramebuffer(fbo_); + context_->makeContextCurrent(); + context_->deleteFramebuffer(fbo_); webgl_.SetExternalTexture(NULL); texture_ = NULL; compositor_->RemoveObserver(this); @@ -235,11 +232,10 @@ class WebGLBench : public BenchCompositorObserver { virtual void Draw() OVERRIDE { if (do_draw_) { - WebKit::WebGraphicsContext3D* context = context_provider_->Context3d(); - context->makeContextCurrent(); - context->clearColor((frames() % kFrames)*1.0/kFrames, 1.f, 0.f, 1.f); - context->clear(GL_COLOR_BUFFER_BIT); - context->flush(); + context_->makeContextCurrent(); + context_->clearColor((frames() % kFrames)*1.0/kFrames, 1.f, 0.f, 1.f); + context_->clear(GL_COLOR_BUFFER_BIT); + context_->flush(); } webgl_.SetExternalTexture(texture_.get()); webgl_.SchedulePaint(gfx::Rect(webgl_.bounds().size())); @@ -250,7 +246,7 @@ class WebGLBench : public BenchCompositorObserver { Layer* parent_; Layer webgl_; Compositor* compositor_; - scoped_refptr<cc::ContextProvider> context_provider_; + scoped_ptr<WebGraphicsContext3D> context_; scoped_refptr<WebGLTexture> texture_; // The FBO that is used to render to the texture. diff --git a/chromium/ui/aura/remote_root_window_host_win.cc b/chromium/ui/aura/remote_root_window_host_win.cc index d4285389578..f5dc26bff55 100644 --- a/chromium/ui/aura/remote_root_window_host_win.cc +++ b/chromium/ui/aura/remote_root_window_host_win.cc @@ -339,6 +339,13 @@ bool RemoteRootWindowHostWin::ConfineCursorToRootWindow() { return true; } +bool RemoteRootWindowHostWin::CopyAreaToSkCanvas(const gfx::Rect& source_bounds, + const gfx::Point& dest_offset, + SkCanvas* canvas) { + NOTIMPLEMENTED(); + return false; +} + void RemoteRootWindowHostWin::UnConfineCursor() { } diff --git a/chromium/ui/aura/remote_root_window_host_win.h b/chromium/ui/aura/remote_root_window_host_win.h index e2e6d1ca286..132f0f236f0 100644 --- a/chromium/ui/aura/remote_root_window_host_win.h +++ b/chromium/ui/aura/remote_root_window_host_win.h @@ -184,6 +184,9 @@ class AURA_EXPORT RemoteRootWindowHostWin : public RootWindowHost { virtual void OnCursorVisibilityChanged(bool show) OVERRIDE; virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE; + virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds, + const gfx::Point& dest_offset, + SkCanvas* canvas) OVERRIDE; virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; virtual void PrepareForShutdown() OVERRIDE; diff --git a/chromium/ui/aura/root_window.cc b/chromium/ui/aura/root_window.cc index a638dc1bbe6..43366f001aa 100644 --- a/chromium/ui/aura/root_window.cc +++ b/chromium/ui/aura/root_window.cc @@ -499,6 +499,15 @@ void RootWindow::SetFocusWhenShown(bool focused) { host_->SetFocusWhenShown(focused); } +bool RootWindow::CopyAreaToSkCanvas(const gfx::Rect& source_bounds, + const gfx::Point& dest_offset, + SkCanvas* canvas) { + DCHECK(canvas); + DCHECK(bounds().Contains(source_bounds)); + gfx::Rect source_pixels = ui::ConvertRectToPixel(layer(), source_bounds); + return host_->CopyAreaToSkCanvas(source_pixels, dest_offset, canvas); +} + gfx::Point RootWindow::GetLastMouseLocationInRoot() const { gfx::Point location = Env::GetInstance()->last_mouse_location(); client::ScreenPositionClient* client = client::GetScreenPositionClient(this); diff --git a/chromium/ui/aura/root_window.h b/chromium/ui/aura/root_window.h index d9055175163..e8a6b260f85 100644 --- a/chromium/ui/aura/root_window.h +++ b/chromium/ui/aura/root_window.h @@ -29,6 +29,8 @@ #include "ui/gfx/point.h" #include "ui/gfx/transform.h" +class SkCanvas; + namespace gfx { class Size; class Transform; @@ -237,6 +239,12 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate, // Sets if the window should be focused when shown. void SetFocusWhenShown(bool focus_when_shown); + // Copies |source_bounds| from the root window (as displayed on the host + // machine) to |canvas| at offset |dest_offset|. + bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds, + const gfx::Point& dest_offset, + SkCanvas* canvas); + // Gets the last location seen in a mouse event in this root window's // coordinates. This may return a point outside the root window's bounds. gfx::Point GetLastMouseLocationInRoot() const; diff --git a/chromium/ui/aura/root_window_host.h b/chromium/ui/aura/root_window_host.h index f1b52041707..09e48fad817 100644 --- a/chromium/ui/aura/root_window_host.h +++ b/chromium/ui/aura/root_window_host.h @@ -12,6 +12,8 @@ #include "ui/base/cursor/cursor.h" #include "ui/gfx/native_widget_types.h" +class SkCanvas; + namespace gfx { class Insets; class Point; @@ -97,6 +99,13 @@ class AURA_EXPORT RootWindowHost { // Sets if the window should be focused when shown. virtual void SetFocusWhenShown(bool focus_when_shown) = 0; + // Copies |source_bounds| from the root window (as displayed on the host + // machine) to |canvas| at offset |dest_offset|. The bounds need to be in + // physical pixels. + virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds, + const gfx::Point& dest_offset, + SkCanvas* canvas) = 0; + // Posts |native_event| to the platform's event queue. #if !defined(OS_MACOSX) virtual void PostNativeEvent(const base::NativeEvent& native_event) = 0; diff --git a/chromium/ui/aura/root_window_host_mac.mm b/chromium/ui/aura/root_window_host_mac.mm index de00e9b244f..28943a958f9 100644 --- a/chromium/ui/aura/root_window_host_mac.mm +++ b/chromium/ui/aura/root_window_host_mac.mm @@ -46,6 +46,9 @@ class RootWindowHostMac : public RootWindowHost, virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; virtual bool ConfineCursorToRootWindow() OVERRIDE; virtual void UnConfineCursor() OVERRIDE; + virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds, + const gfx::Point& dest_offset, + SkCanvas* canvas) OVERRIDE; // RootWindowHostMacDelegate: virtual void SendEvent(const base::NativeEvent& native_event) OVERRIDE; diff --git a/chromium/ui/aura/root_window_host_ozone.cc b/chromium/ui/aura/root_window_host_ozone.cc index d3fe7c3865d..28c8d0c4807 100644 --- a/chromium/ui/aura/root_window_host_ozone.cc +++ b/chromium/ui/aura/root_window_host_ozone.cc @@ -106,6 +106,13 @@ void RootWindowHostOzone::SetFocusWhenShown(bool focus_when_shown) { NOTIMPLEMENTED(); } +bool RootWindowHostOzone::CopyAreaToSkCanvas(const gfx::Rect& source_bounds, + const gfx::Point& dest_offset, + SkCanvas* canvas) { + NOTIMPLEMENTED(); + return false; +} + void RootWindowHostOzone::PostNativeEvent( const base::NativeEvent& native_event) { NOTIMPLEMENTED(); diff --git a/chromium/ui/aura/root_window_host_ozone.h b/chromium/ui/aura/root_window_host_ozone.h index f510d418678..6acd1a2c0ce 100644 --- a/chromium/ui/aura/root_window_host_ozone.h +++ b/chromium/ui/aura/root_window_host_ozone.h @@ -46,6 +46,9 @@ class RootWindowHostOzone : public RootWindowHost, virtual void OnCursorVisibilityChanged(bool show) OVERRIDE; virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE; + virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds, + const gfx::Point& dest_offset, + SkCanvas* canvas) OVERRIDE; virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE; virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; virtual void PrepareForShutdown() OVERRIDE; diff --git a/chromium/ui/aura/root_window_host_win.cc b/chromium/ui/aura/root_window_host_win.cc index 723de57fe0a..5c67b776d07 100644 --- a/chromium/ui/aura/root_window_host_win.cc +++ b/chromium/ui/aura/root_window_host_win.cc @@ -210,6 +210,13 @@ bool RootWindowHostWin::ConfineCursorToRootWindow() { return ClipCursor(&window_rect) != 0; } +bool RootWindowHostWin::CopyAreaToSkCanvas(const gfx::Rect& source_bounds, + const gfx::Point& dest_offset, + SkCanvas* canvas) { + NOTIMPLEMENTED(); + return false; +} + void RootWindowHostWin::UnConfineCursor() { ClipCursor(NULL); } diff --git a/chromium/ui/aura/root_window_host_win.h b/chromium/ui/aura/root_window_host_win.h index e2a60ddf738..491ab903445 100644 --- a/chromium/ui/aura/root_window_host_win.h +++ b/chromium/ui/aura/root_window_host_win.h @@ -37,6 +37,9 @@ class RootWindowHostWin : public RootWindowHost, public ui::WindowImpl { virtual void OnCursorVisibilityChanged(bool show) OVERRIDE; virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE; + virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds, + const gfx::Point& dest_offset, + SkCanvas* canvas) OVERRIDE; virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; virtual void PrepareForShutdown() OVERRIDE; diff --git a/chromium/ui/aura/root_window_host_x11.cc b/chromium/ui/aura/root_window_host_x11.cc index 783e960095d..f69a54a8898 100644 --- a/chromium/ui/aura/root_window_host_x11.cc +++ b/chromium/ui/aura/root_window_host_x11.cc @@ -25,6 +25,9 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" +#include "third_party/skia/include/core/SkBitmap.h" +#include "third_party/skia/include/core/SkCanvas.h" +#include "third_party/skia/include/core/SkPostConfig.h" #include "ui/aura/client/capture_client.h" #include "ui/aura/client/cursor_client.h" #include "ui/aura/client/screen_position_client.h" @@ -42,6 +45,7 @@ #include "ui/base/x/x11_util.h" #include "ui/compositor/dip_util.h" #include "ui/compositor/layer.h" +#include "ui/gfx/codec/png_codec.h" #include "ui/gfx/screen.h" #if defined(OS_CHROMEOS) @@ -815,6 +819,51 @@ void RootWindowHostX11::SetFocusWhenShown(bool focus_when_shown) { } } +bool RootWindowHostX11::CopyAreaToSkCanvas(const gfx::Rect& source_bounds, + const gfx::Point& dest_offset, + SkCanvas* canvas) { + ui::XScopedImage scoped_image( + XGetImage(xdisplay_, xwindow_, + source_bounds.x(), source_bounds.y(), + source_bounds.width(), source_bounds.height(), + AllPlanes, ZPixmap)); + XImage* image = scoped_image.get(); + if (!image) { + LOG(ERROR) << "XGetImage failed"; + return false; + } + + if (image->bits_per_pixel == 32) { + if ((0xff << SK_R32_SHIFT) != image->red_mask || + (0xff << SK_G32_SHIFT) != image->green_mask || + (0xff << SK_B32_SHIFT) != image->blue_mask) { + LOG(WARNING) << "XImage and Skia byte orders differ"; + return false; + } + + // Set the alpha channel before copying to the canvas. Otherwise, areas of + // the framebuffer that were cleared by ply-image rather than being obscured + // by an image during boot may end up transparent. + // TODO(derat|marcheu): Remove this if/when ply-image has been updated to + // set the framebuffer's alpha channel regardless of whether the device + // claims to support alpha or not. + for (int i = 0; i < image->width * image->height * 4; i += 4) + image->data[i + 3] = 0xff; + + SkBitmap bitmap; + bitmap.setConfig(SkBitmap::kARGB_8888_Config, + image->width, image->height, + image->bytes_per_line); + bitmap.setPixels(image->data); + canvas->drawBitmap(bitmap, SkIntToScalar(0), SkIntToScalar(0), NULL); + } else { + NOTIMPLEMENTED() << "Unsupported bits-per-pixel " << image->bits_per_pixel; + return false; + } + + return true; +} + void RootWindowHostX11::PostNativeEvent( const base::NativeEvent& native_event) { DCHECK(xwindow_); diff --git a/chromium/ui/aura/root_window_host_x11.h b/chromium/ui/aura/root_window_host_x11.h index ac9cc74933e..c38002dda07 100644 --- a/chromium/ui/aura/root_window_host_x11.h +++ b/chromium/ui/aura/root_window_host_x11.h @@ -63,6 +63,9 @@ class RootWindowHostX11 : public RootWindowHost, virtual void OnCursorVisibilityChanged(bool show) OVERRIDE; virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE; + virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds, + const gfx::Point& dest_offset, + SkCanvas* canvas) OVERRIDE; virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE; virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; virtual void PrepareForShutdown() OVERRIDE; |