Chromium drawing

original
2013/05/17 17:02
Reading number 1K

Chromium drawing should also start from WM_PAINT

HWNDMessageHandler is the medium of UI and system messages in Chromium. It's up to it.

OK, here comes a WM_PAINT message.

In void HWNDMessageHandler:: OnPaint (HDC dc), the key codes are as follows:

 scoped_ptr<gfx::CanvasPaint> canvas( gfx::CanvasPaint::CreateCanvasPaint(hwnd())); delegate_->HandlePaint(canvas->AsCanvas());

Here's Gfx:: CanvasPaint is a platform independent canvas. When a new canvas comes out, it will be scoped. When it leaves, it will be deconstructed.

Class CanvasPaintWin: public gfx:: CanvasPaint, public gfx:: CanvasSkiaPaint CanvasPaint is actually Avatar of CanvasPaintWin.

The destruction of CanvasSkiaPaint will be executed

 virtual ~CanvasSkiaPaint() { if (! isEmpty()) { 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); } if (for_paint_) EndPaint(hwnd_, &ps_); }

At last, it comes to platform related drawing. Currently, it is GDI BitBlt, GdiAlphaBlend, etc

It is not seen that some functions are called actively, but are executed in some objects, which is very common in Chromium.

Well, we have a clear picture of the canvas to be drawn. What is the drawing process. Look back at this sentence

 delegate_->HandlePaint(canvas->AsCanvas())

there Delegate_ is known as HWNDMessageHandlerDelegate * delegate_;

class VIEWS_EXPORT NativeWidgetWin : public internal::NativeWidgetPrivate,
                                     public HWNDMessageHandlerDelegate
In most cases NativeWidgetWin incarnate.

Then it will come to the following

 void NativeWidgetWin::HandlePaint(gfx::Canvas* canvas) { delegate_->OnNativeWidgetPaint(canvas); }

there Delegate_ is known as internal:: NativeWidgetDelegate * delegate_;

 class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, public FocusTraversable

As above, you will enter the Widget's OnNativeWidgetPaint

 void Widget::OnNativeWidgetPaint(gfx::Canvas* canvas) { // On Linux Aura, we can get here during Init() because of the // SetInitialBounds call. if (native_widget_initialized_) GetRootView()->Paint(canvas); }

Finally, I found my old nest. When I got root_view, I began to traverse Paint. Their paint results finally passed Canvas is drawn on the screen!

Expand to read the full text
Loading
Click to lead the topic 📣 Post and join the discussion 🔥
Reward
zero comment
one Collection
one fabulous
 Back to top
Top