summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/browser/compositor/software_output_device_win.cc1
-rw-r--r--ui/gfx/canvas.cc4
-rw-r--r--ui/gfx/canvas_paint_win.cc70
-rw-r--r--ui/gfx/canvas_paint_win.h76
-rw-r--r--ui/gfx/canvas_skia_paint.h4
-rw-r--r--ui/gfx/gfx.gyp2
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc9
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_win.h3
-rw-r--r--ui/views/widget/native_widget_delegate.h5
-rw-r--r--ui/views/widget/widget.cc9
-rw-r--r--ui/views/widget/widget.h1
-rw-r--r--ui/views/win/hwnd_message_handler.cc64
-rw-r--r--ui/views/win/hwnd_message_handler_delegate.h8
13 files changed, 9 insertions, 247 deletions
diff --git a/content/browser/compositor/software_output_device_win.cc b/content/browser/compositor/software_output_device_win.cc
index 2d6d004..3cbd97a 100644
--- a/content/browser/compositor/software_output_device_win.cc
+++ b/content/browser/compositor/software_output_device_win.cc
@@ -9,7 +9,6 @@
#include "third_party/skia/include/core/SkDevice.h"
#include "ui/compositor/compositor.h"
#include "ui/gfx/canvas.h"
-#include "ui/gfx/canvas_skia_paint.h"
#include "ui/gfx/gdi_util.h"
#include "ui/gfx/skia_util.h"
diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc
index ec7d74c..49822b7 100644
--- a/ui/gfx/canvas.cc
+++ b/ui/gfx/canvas.cc
@@ -20,10 +20,6 @@
#include "ui/gfx/skia_util.h"
#include "ui/gfx/transform.h"
-#if defined(OS_WIN)
-#include "ui/gfx/canvas_skia_paint.h"
-#endif
-
namespace gfx {
Canvas::Canvas(const Size& size, float image_scale, bool is_opaque)
diff --git a/ui/gfx/canvas_paint_win.cc b/ui/gfx/canvas_paint_win.cc
deleted file mode 100644
index c2104fb..0000000
--- a/ui/gfx/canvas_paint_win.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/canvas_skia_paint.h"
-#include "ui/gfx/geometry/rect.h"
-
-namespace gfx {
-
-CanvasSkiaPaint::CanvasSkiaPaint(HWND hwnd, HDC dc, const PAINTSTRUCT& ps)
- : hwnd_(hwnd),
- paint_dc_(dc) {
- memset(&ps_, 0, sizeof(ps_));
- ps_.rcPaint.left = ps.rcPaint.left;
- ps_.rcPaint.right = ps.rcPaint.right;
- ps_.rcPaint.top = ps.rcPaint.top;
- ps_.rcPaint.bottom = ps.rcPaint.bottom;
- Init(true);
-}
-
-CanvasSkiaPaint::CanvasSkiaPaint(HDC dc, bool opaque, int x, int y,
- int w, int h)
- : hwnd_(NULL),
- paint_dc_(dc) {
- memset(&ps_, 0, sizeof(ps_));
- ps_.rcPaint.left = x;
- ps_.rcPaint.right = x + w;
- ps_.rcPaint.top = y;
- ps_.rcPaint.bottom = y + h;
- Init(opaque);
-}
-
-CanvasSkiaPaint::~CanvasSkiaPaint() {
- if (!is_empty()) {
- skia::PlatformCanvas* canvas = platform_canvas();
- canvas->restoreToCount(1);
- // Commit the drawing to the screen
- skia::DrawToNativeContext(canvas, paint_dc_, ps_.rcPaint.left,
- ps_.rcPaint.top, NULL);
- }
-}
-
-gfx::Rect CanvasSkiaPaint::GetInvalidRect() const {
- return gfx::Rect(paint_struct().rcPaint);
-}
-
-void CanvasSkiaPaint::Init(bool opaque) {
- // FIXME(brettw) for ClearType, we probably want to expand the bounds of
- // painting by one pixel so that the boundaries will be correct (ClearType
- // text can depend on the adjacent pixel). Then we would paint just the
- // inset pixels to the screen.
- const int width = ps_.rcPaint.right - ps_.rcPaint.left;
- const int height = ps_.rcPaint.bottom - ps_.rcPaint.top;
-
- RecreateBackingCanvas(gfx::Size(width, height), gfx::GetDPIScale(), opaque);
- skia::PlatformCanvas* canvas = platform_canvas();
-
- canvas->clear(SkColorSetARGB(0, 0, 0, 0));
-
- // This will bring the canvas into the screen coordinate system for the
- // dirty rect
- canvas->translate(
- -ps_.rcPaint.left / gfx::GetDPIScale(),
- -ps_.rcPaint.top / gfx::GetDPIScale());
-}
-
-} // namespace gfx
diff --git a/ui/gfx/canvas_paint_win.h b/ui/gfx/canvas_paint_win.h
deleted file mode 100644
index 34f52aa1..0000000
--- a/ui/gfx/canvas_paint_win.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_GFX_CANVAS_PAINT_WIN_H_
-#define UI_GFX_CANVAS_PAINT_WIN_H_
-
-#include "skia/ext/platform_canvas.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/geometry/size.h"
-#include "ui/gfx/win/dpi.h"
-
-namespace gfx {
-
-// A class designed to help with WM_PAINT operations on Windows. It will create
-// the bitmap and canvas with the correct size and transform for the dirty rect.
-// The bitmap will be automatically painted to the screen on destruction.
-//
-// You MUST call isEmpty before painting to determine if anything needs
-// painting. Sometimes the dirty rect can actually be empty, and this makes
-// the bitmap functions we call unhappy. The caller should not paint in this
-// case.
-//
-// Therefore, all you need to do is:
-// case WM_PAINT: {
-// PAINTSTRUCT ps;
-// HDC hdc = BeginPaint(hwnd, &ps);
-// gfx::CanvasSkiaPaint canvas(hwnd, hdc, ps);
-// if (!canvas.isEmpty()) {
-// ... paint to the canvas ...
-// }
-// EndPaint(hwnd, &ps);
-// return 0;
-// }
-// Note: The created context is always inialized to (0, 0, 0, 0).
-class GFX_EXPORT CanvasSkiaPaint : public Canvas {
- public:
- // This constructor assumes the canvas is opaque.
- CanvasSkiaPaint(HWND hwnd, HDC dc, const PAINTSTRUCT& ps);
- ~CanvasSkiaPaint() override;
-
- // Creates a CanvasSkiaPaint for the specified region that paints to the
- // specified dc.
- CanvasSkiaPaint(HDC dc, bool opaque, int x, int y, int w, int h);
-
- // Returns the rectangle that is invalid.
- virtual gfx::Rect GetInvalidRect() const;
-
- // Returns true if the invalid region is empty. The caller should call this
- // function to determine if anything needs painting.
- bool is_empty() const {
- return ps_.rcPaint.right - ps_.rcPaint.left == 0 ||
- ps_.rcPaint.bottom - ps_.rcPaint.top == 0;
- };
-
- // Use to access the Windows painting parameters, especially useful for
- // getting the bounding rect for painting: paintstruct().rcPaint
- const PAINTSTRUCT& paint_struct() const { return ps_; }
-
- // Returns the DC that will be painted to
- HDC paint_dc() const { return paint_dc_; }
-
- private:
- void Init(bool opaque);
-
- HWND hwnd_;
- HDC paint_dc_;
- PAINTSTRUCT ps_;
-
- // Disallow copy and assign.
- DISALLOW_COPY_AND_ASSIGN(CanvasSkiaPaint);
-};
-
-} // namespace gfx
-
-#endif // UI_GFX_CANVAS_PAINT_WIN_H_
diff --git a/ui/gfx/canvas_skia_paint.h b/ui/gfx/canvas_skia_paint.h
index e9e22ff..01b366a 100644
--- a/ui/gfx/canvas_skia_paint.h
+++ b/ui/gfx/canvas_skia_paint.h
@@ -8,9 +8,7 @@
// This file provides an easy way to include the appropriate CanvasPaint
// header file on your platform.
-#if defined(WIN32)
-#include "ui/gfx/canvas_paint_win.h"
-#elif defined(__APPLE__)
+#if defined(__APPLE__)
#include "ui/gfx/canvas_paint_mac.h"
#else
#error "No canvas paint for this platform"
diff --git a/ui/gfx/gfx.gyp b/ui/gfx/gfx.gyp
index 7ecc19a..a045bd3 100644
--- a/ui/gfx/gfx.gyp
+++ b/ui/gfx/gfx.gyp
@@ -132,8 +132,6 @@
'canvas_notimplemented.cc',
'canvas_paint_mac.h',
'canvas_paint_mac.mm',
- 'canvas_paint_win.cc',
- 'canvas_paint_win.h',
'canvas_skia.cc',
'canvas_skia_paint.h',
'codec/jpeg_codec.cc',
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
index a5e41d9..1960cf1 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
@@ -898,15 +898,10 @@ void DesktopWindowTreeHostWin::HandleInputLanguageChange(
input_method()->OnInputLocaleChanged();
}
-bool DesktopWindowTreeHostWin::HandlePaintAccelerated(
+void DesktopWindowTreeHostWin::HandlePaintAccelerated(
const gfx::Rect& invalid_rect) {
- return native_widget_delegate_->OnNativeWidgetPaintAccelerated(invalid_rect);
-}
-
-void DesktopWindowTreeHostWin::HandlePaint(gfx::Canvas* canvas) {
- // It appears possible to get WM_PAINT after WM_DESTROY.
if (compositor())
- compositor()->ScheduleRedrawRect(gfx::Rect());
+ compositor()->ScheduleRedrawRect(invalid_rect);
}
bool DesktopWindowTreeHostWin::HandleTooltipNotify(int w_param,
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h
index 6e32fc7..29aeb02 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h
@@ -184,8 +184,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin
LRESULT* result) override;
void HandleInputLanguageChange(DWORD character_set,
HKL input_language_id) override;
- bool HandlePaintAccelerated(const gfx::Rect& invalid_rect) override;
- void HandlePaint(gfx::Canvas* canvas) override;
+ void HandlePaintAccelerated(const gfx::Rect& invalid_rect) override;
bool HandleTooltipNotify(int w_param,
NMHDR* l_param,
LRESULT* l_result) override;
diff --git a/ui/views/widget/native_widget_delegate.h b/ui/views/widget/native_widget_delegate.h
index 7c75e1b..4f5ed9e 100644
--- a/ui/views/widget/native_widget_delegate.h
+++ b/ui/views/widget/native_widget_delegate.h
@@ -106,11 +106,6 @@ class VIEWS_EXPORT NativeWidgetDelegate {
// Returns true if the delegate has a FocusManager.
virtual bool HasFocusManager() const = 0;
- // Paints the widget using acceleration. If the widget is not using
- // accelerated painting this returns false and does nothing.
- virtual bool OnNativeWidgetPaintAccelerated(
- const gfx::Rect& dirty_region) = 0;
-
// Paints the rootview in the context. This will also refresh the compositor
// tree if necessary.
virtual void OnNativeWidgetPaint(const ui::PaintContext& context) = 0;
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index 64e131e..b4d2a48 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -1172,15 +1172,6 @@ bool Widget::HasFocusManager() const {
return !!focus_manager_.get();
}
-bool Widget::OnNativeWidgetPaintAccelerated(const gfx::Rect& dirty_region) {
- ui::Compositor* compositor = GetCompositor();
- if (!compositor)
- return false;
-
- compositor->ScheduleRedrawRect(dirty_region);
- return true;
-}
-
void Widget::OnNativeWidgetPaint(const ui::PaintContext& context) {
// On Linux Aura, we can get here during Init() because of the
// SetInitialBounds call.
diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h
index 59e7b1d..16d6640 100644
--- a/ui/views/widget/widget.h
+++ b/ui/views/widget/widget.h
@@ -794,7 +794,6 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
void OnNativeWidgetBeginUserBoundsChange() override;
void OnNativeWidgetEndUserBoundsChange() override;
bool HasFocusManager() const override;
- bool OnNativeWidgetPaintAccelerated(const gfx::Rect& dirty_region) override;
void OnNativeWidgetPaint(const ui::PaintContext& context) override;
int GetNonClientComponent(const gfx::Point& point) override;
void OnKeyEvent(ui::KeyEvent* event) override;
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index 653fe3c..751278f 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -27,7 +27,6 @@
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/keyboard_code_conversion_win.h"
#include "ui/gfx/canvas.h"
-#include "ui/gfx/canvas_skia_paint.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/icon_util.h"
#include "ui/gfx/path.h"
@@ -207,34 +206,6 @@ BOOL CALLBACK SendDwmCompositionChanged(HWND window, LPARAM param) {
return TRUE;
}
-// See comments in OnNCPaint() for details of this struct.
-struct ClipState {
- // The window being painted.
- HWND parent;
-
- // DC painting to.
- HDC dc;
-
- // Origin of the window in terms of the screen.
- int x;
- int y;
-};
-
-// See comments in OnNCPaint() for details of this function.
-static BOOL CALLBACK ClipDCToChild(HWND window, LPARAM param) {
- ClipState* clip_state = reinterpret_cast<ClipState*>(param);
- if (GetParent(window) == clip_state->parent && IsWindowVisible(window)) {
- RECT bounds;
- GetWindowRect(window, &bounds);
- ExcludeClipRect(clip_state->dc,
- bounds.left - clip_state->x,
- bounds.top - clip_state->y,
- bounds.right - clip_state->x,
- bounds.bottom - clip_state->y);
- }
- return TRUE;
-}
-
// The thickness of an auto-hide taskbar in pixels.
const int kAutoHideTaskbarThicknessPx = 2;
@@ -2083,19 +2054,6 @@ void HWNDMessageHandler::OnNCPaint(HRGN rgn) {
OffsetRect(&dirty_region, -window_rect.left, -window_rect.top);
}
- // In theory GetDCEx should do what we want, but I couldn't get it to work.
- // In particular the docs mentiond DCX_CLIPCHILDREN, but as far as I can tell
- // it doesn't work at all. So, instead we get the DC for the window then
- // manually clip out the children.
- HDC dc = GetWindowDC(hwnd());
- ClipState clip_state;
- clip_state.x = window_rect.left;
- clip_state.y = window_rect.top;
- clip_state.parent = hwnd();
- clip_state.dc = dc;
- EnumChildWindows(hwnd(), &ClipDCToChild,
- reinterpret_cast<LPARAM>(&clip_state));
-
gfx::Rect old_paint_region = invalid_rect_;
if (!old_paint_region.IsEmpty()) {
// The root view has a region that needs to be painted. Include it in the
@@ -2107,21 +2065,8 @@ void HWNDMessageHandler::OnNCPaint(HRGN rgn) {
}
SchedulePaintInRect(gfx::Rect(dirty_region));
+ delegate_->HandlePaintAccelerated(gfx::Rect(dirty_region));
- // gfx::CanvasSkiaPaint's destructor does the actual painting. As such, wrap
- // the following in a block to force paint to occur so that we can release
- // the dc.
- if (!delegate_->HandlePaintAccelerated(gfx::Rect(dirty_region))) {
- gfx::CanvasSkiaPaint canvas(dc,
- true,
- dirty_region.left,
- dirty_region.top,
- dirty_region.right - dirty_region.left,
- dirty_region.bottom - dirty_region.top);
- delegate_->HandlePaint(&canvas);
- }
-
- ReleaseDC(hwnd(), dc);
// When using a custom frame, we want to avoid calling DefWindowProc() since
// that may render artifacts.
SetMsgHandled(delegate_->IsUsingCustomFrame());
@@ -2178,11 +2123,8 @@ void HWNDMessageHandler::OnPaint(HDC dc) {
HDC display_dc = BeginPaint(hwnd(), &ps);
CHECK(display_dc);
- // Try to paint accelerated first.
- if (!IsRectEmpty(&ps.rcPaint) &&
- !delegate_->HandlePaintAccelerated(gfx::Rect(ps.rcPaint))) {
- delegate_->HandlePaint(NULL);
- }
+ if (!IsRectEmpty(&ps.rcPaint))
+ delegate_->HandlePaintAccelerated(gfx::Rect(ps.rcPaint));
EndPaint(hwnd(), &ps);
}
diff --git a/ui/views/win/hwnd_message_handler_delegate.h b/ui/views/win/hwnd_message_handler_delegate.h
index 9a2e688..eda75f3 100644
--- a/ui/views/win/hwnd_message_handler_delegate.h
+++ b/ui/views/win/hwnd_message_handler_delegate.h
@@ -193,12 +193,8 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate {
virtual void HandleInputLanguageChange(DWORD character_set,
HKL input_language_id) = 0;
- // Called to compel the delegate to paint |invalid_rect| accelerated. Returns
- // true if accelerated painting was performed.
- virtual bool HandlePaintAccelerated(const gfx::Rect& invalid_rect) = 0;
-
- // Called to compel the delegate to paint using the software path.
- virtual void HandlePaint(gfx::Canvas* canvas) = 0;
+ // Called to compel the delegate to paint |invalid_rect| accelerated.
+ virtual void HandlePaintAccelerated(const gfx::Rect& invalid_rect) = 0;
// Called to forward a WM_NOTIFY message to the tooltip manager.
virtual bool HandleTooltipNotify(int w_param,