| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/sad_plugin.h" | 5 #include "content/renderer/sad_plugin.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "cc/paint/paint_canvas.h" | 10 #include "cc/paint/paint_canvas.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 cc::PaintCanvas* canvas = webcanvas; | 22 cc::PaintCanvas* canvas = webcanvas; |
| 23 cc::PaintCanvasAutoRestore auto_restore(canvas, true); | 23 cc::PaintCanvasAutoRestore auto_restore(canvas, true); |
| 24 // We draw the sad-plugin bitmap at the origin of canvas. | 24 // We draw the sad-plugin bitmap at the origin of canvas. |
| 25 // Add a translation so that it appears at the origin of plugin rect. | 25 // Add a translation so that it appears at the origin of plugin rect. |
| 26 canvas->translate(plugin_rect.x(), plugin_rect.y()); | 26 canvas->translate(plugin_rect.x(), plugin_rect.y()); |
| 27 | 27 |
| 28 cc::PaintFlags flags; | 28 cc::PaintFlags flags; |
| 29 flags.setStyle(cc::PaintFlags::kFill_Style); | 29 flags.setStyle(cc::PaintFlags::kFill_Style); |
| 30 flags.setColor(SK_ColorBLACK); | 30 flags.setColor(SK_ColorBLACK); |
| 31 canvas->drawRectCoords(0, 0, SkIntToScalar(width), SkIntToScalar(height), | 31 canvas->drawRect(SkRect::MakeIWH(width, height), flags); |
| 32 flags); | |
| 33 canvas->drawBitmap( | 32 canvas->drawBitmap( |
| 34 sad_plugin_bitmap, | 33 sad_plugin_bitmap, |
| 35 SkIntToScalar(std::max(0, (width - sad_plugin_bitmap.width()) / 2)), | 34 SkIntToScalar(std::max(0, (width - sad_plugin_bitmap.width()) / 2)), |
| 36 SkIntToScalar(std::max(0, (height - sad_plugin_bitmap.height()) / 2))); | 35 SkIntToScalar(std::max(0, (height - sad_plugin_bitmap.height()) / 2))); |
| 37 } | 36 } |
| 38 | 37 |
| 39 } // namespace content | 38 } // namespace content |
| OLD | NEW |