Don't crash when SimpleCache index is corrupt.
[chromium-blink-merge.git] / ui / gfx / canvas_paint_win.cc
blob27898fca3b80965cf3c7b6b3b7568fb151267028
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 "base/basictypes.h"
6 #include "base/compiler_specific.h"
7 #include "ui/gfx/canvas.h"
8 #include "ui/gfx/canvas_skia_paint.h"
9 #include "ui/gfx/rect.h"
11 namespace {
13 #if !defined(USE_AURA)
14 class CanvasPaintWin : public gfx::CanvasPaint, public gfx::CanvasSkiaPaint {
15 public:
16 explicit CanvasPaintWin(gfx::NativeView view);
17 virtual ~CanvasPaintWin();
19 // Overridden from CanvasPaint:
20 virtual bool IsValid() const OVERRIDE;
21 virtual gfx::Rect GetInvalidRect() const OVERRIDE;
22 virtual gfx::Canvas* AsCanvas() OVERRIDE;
24 private:
25 DISALLOW_COPY_AND_ASSIGN(CanvasPaintWin);
28 CanvasPaintWin::CanvasPaintWin(gfx::NativeView view)
29 : gfx::CanvasSkiaPaint(view) {}
31 CanvasPaintWin::~CanvasPaintWin() {}
33 bool CanvasPaintWin::IsValid() const {
34 return isEmpty();
37 gfx::Rect CanvasPaintWin::GetInvalidRect() const {
38 return gfx::Rect(paintStruct().rcPaint);
41 gfx::Canvas* CanvasPaintWin::AsCanvas() {
42 return this;
44 #endif
46 } // namespace
48 namespace gfx {
50 CanvasPaint* CanvasPaint::CreateCanvasPaint(gfx::NativeView view) {
51 #if !defined(USE_AURA)
52 return new CanvasPaintWin(view);
53 #else
54 return NULL;
55 #endif
58 } // namespace gfx