Fixed service side implementation of glTexStorage2DEXT to only initialize the number of
[chromium-blink-merge.git] / chrome / renderer / webview_color_overlay.cc
blobd7ae529dcba809beaf181bfe80272119727d786f
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/renderer/webview_color_overlay.h"
7 #include "base/logging.h"
8 #include "content/public/renderer/render_view.h"
9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "third_party/skia/include/core/SkPaint.h"
11 #include "third_party/skia/include/core/SkRect.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
13 #include "ui/gfx/size.h"
14 #include "ui/gfx/skia_util.h"
16 #if WEBKIT_USING_CG
17 #include "skia/ext/skia_utils_mac.h"
18 #endif
20 WebViewColorOverlay::WebViewColorOverlay(content::RenderView* render_view,
21 SkColor color)
22 : render_view_(render_view),
23 color_(color) {
24 render_view_->GetWebView()->addPageOverlay(this, 0);
27 WebViewColorOverlay::~WebViewColorOverlay() {
28 if (render_view_->GetWebView())
29 render_view_->GetWebView()->removePageOverlay(this);
32 void WebViewColorOverlay::paintPageOverlay(WebKit::WebCanvas* canvas) {
33 SkRect rect = gfx::RectToSkRect(gfx::Rect(render_view_->GetSize()));
35 #if WEBKIT_USING_SKIA
36 SkPaint paint;
37 paint.setColor(color_);
38 paint.setStyle(SkPaint::kFill_Style);
39 canvas->drawRect(rect, paint);
40 #elif WEBKIT_USING_CG
41 CGContextSaveGState(canvas);
42 CGColorRef color = gfx::SkColorToCGColorRef(color_);
43 CGContextSetFillColorWithColor(canvas, color);
44 CGColorRelease(color);
45 CGContextFillRect(canvas, gfx::SkRectToCGRect(rect));
46 CGContextRestoreGState(canvas);
47 #else
48 NOTIMPLEMENTED();
49 #endif