Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: webkit/port/platform/graphics/PlatformContextSkia.cpp

Issue 9757: Cache the GdkSkia object in PlatformContextSkia so that we aren't creating (Closed)
Patch Set: Moving files against Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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 }
OLDNEW
« no previous file with comments | « webkit/port/platform/graphics/PlatformContextSkia.h ('k') | webkit/port/platform/graphics/skia/GdkSkia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698