OLD | NEW |
1 // Copyright (c) 2008, Google Inc. All rights reserved. | 1 // Copyright (c) 2008, Google Inc. All rights reserved. |
2 // | 2 // |
3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
5 // met: | 5 // met: |
6 // | 6 // |
7 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
10 // copyright notice, this list of conditions and the following disclaimer | 10 // copyright notice, this list of conditions and the following disclaimer |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 #include "base/gfx/image_operations.h" | 37 #include "base/gfx/image_operations.h" |
38 #include "base/gfx/platform_canvas.h" | 38 #include "base/gfx/platform_canvas.h" |
39 #include "base/gfx/skia_utils.h" | 39 #include "base/gfx/skia_utils.h" |
40 | 40 |
41 #include "SkBitmap.h" | 41 #include "SkBitmap.h" |
42 #include "SkColorPriv.h" | 42 #include "SkColorPriv.h" |
43 #include "SkShader.h" | 43 #include "SkShader.h" |
44 #include "SkDashPathEffect.h" | 44 #include "SkDashPathEffect.h" |
45 | 45 |
| 46 #if defined(OS_LINUX) |
| 47 #include "GdkSkia.h" |
| 48 #endif |
| 49 |
46 // State ----------------------------------------------------------------------- | 50 // State ----------------------------------------------------------------------- |
47 | 51 |
48 // Encapsulates the additional painting state information we store for each | 52 // Encapsulates the additional painting state information we store for each |
49 // pushed graphics state. | 53 // pushed graphics state. |
50 struct PlatformContextSkia::State { | 54 struct PlatformContextSkia::State { |
51 State(); | 55 State(); |
52 State(const State&); | 56 State(const State&); |
53 ~State(); | 57 ~State(); |
54 | 58 |
55 // Common shader state. | 59 // Common shader state. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 142 |
139 // PlatformContextSkia --------------------------------------------------------- | 143 // PlatformContextSkia --------------------------------------------------------- |
140 | 144 |
141 // Danger: canvas can be NULL. | 145 // Danger: canvas can be NULL. |
142 PlatformContextSkia::PlatformContextSkia(gfx::PlatformCanvas* canvas) | 146 PlatformContextSkia::PlatformContextSkia(gfx::PlatformCanvas* canvas) |
143 : m_canvas(canvas) | 147 : m_canvas(canvas) |
144 , m_stateStack(sizeof(State)) | 148 , m_stateStack(sizeof(State)) |
145 { | 149 { |
146 m_stateStack.append(State()); | 150 m_stateStack.append(State()); |
147 m_state = &m_stateStack.last(); | 151 m_state = &m_stateStack.last(); |
| 152 #if defined(OS_LINUX) |
| 153 m_gdkskia = m_canvas ? gdk_skia_new(m_canvas) : NULL; |
| 154 #endif |
148 } | 155 } |
149 | 156 |
150 PlatformContextSkia::~PlatformContextSkia() | 157 PlatformContextSkia::~PlatformContextSkia() |
151 { | 158 { |
| 159 #if defined(OS_LINUX) |
| 160 if (m_gdkskia) { |
| 161 g_object_unref(m_gdkskia); |
| 162 m_gdkskia = NULL; |
| 163 } |
| 164 #endif |
152 } | 165 } |
153 | 166 |
154 void PlatformContextSkia::setCanvas(gfx::PlatformCanvas* canvas) | 167 void PlatformContextSkia::setCanvas(gfx::PlatformCanvas* canvas) |
155 { | 168 { |
156 m_canvas = canvas; | 169 m_canvas = canvas; |
157 } | 170 } |
158 | 171 |
159 void PlatformContextSkia::save() | 172 void PlatformContextSkia::save() |
160 { | 173 { |
161 m_stateStack.append(*m_state); | 174 m_stateStack.append(*m_state); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 | 415 |
403 const SkBitmap* PlatformContextSkia::bitmap() const | 416 const SkBitmap* PlatformContextSkia::bitmap() const |
404 { | 417 { |
405 return &m_canvas->getDevice()->accessBitmap(false); | 418 return &m_canvas->getDevice()->accessBitmap(false); |
406 } | 419 } |
407 | 420 |
408 bool PlatformContextSkia::IsPrinting() | 421 bool PlatformContextSkia::IsPrinting() |
409 { | 422 { |
410 return m_canvas->getTopPlatformDevice().IsVectorial(); | 423 return m_canvas->getTopPlatformDevice().IsVectorial(); |
411 } | 424 } |
OLD | NEW |