1 // Copyright (c) 2012 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 "content/renderer/sad_plugin.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "skia/ext/platform_canvas.h"
11 #include "ui/gfx/geometry/rect.h"
15 void PaintSadPlugin(blink::WebCanvas
* webcanvas
,
16 const gfx::Rect
& plugin_rect
,
17 const SkBitmap
& sad_plugin_bitmap
) {
18 const int width
= plugin_rect
.width();
19 const int height
= plugin_rect
.height();
21 SkCanvas
* canvas
= webcanvas
;
22 SkAutoCanvasRestore
auto_restore(canvas
, true);
23 // We draw the sad-plugin bitmap at the origin of canvas.
24 // Add a translation so that it appears at the origin of plugin rect.
25 canvas
->translate(plugin_rect
.x(), plugin_rect
.y());
28 paint
.setStyle(SkPaint::kFill_Style
);
29 paint
.setColor(SK_ColorBLACK
);
30 canvas
->drawRectCoords(0, 0, SkIntToScalar(width
), SkIntToScalar(height
),
34 SkIntToScalar(std::max(0, (width
- sad_plugin_bitmap
.width()) / 2)),
35 SkIntToScalar(std::max(0, (height
- sad_plugin_bitmap
.height()) / 2)));
38 } // namespace content