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

Side by Side Diff: skia/ext/platform_canvas_skia.cc

Issue 9722032: aura: Use platform independent skia::PlatformCanvas when possible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | skia/skia.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "skia/ext/platform_canvas.h"
6
7 #include "base/debug/trace_event.h"
8 #include "skia/ext/bitmap_platform_device.h"
9
10 // TODO(reveman): a lot of unnecessary duplication of code from
11 // platform_canvas_[win|linux|mac].cc in here. Need to refactor
12 // PlatformCanvas to avoid this:
13 // http://code.google.com/p/chromium/issues/detail?id=119555
14
15 namespace skia {
16
17 PlatformCanvas::PlatformCanvas(int width, int height, bool is_opaque) {
18 TRACE_EVENT2("skia", "PlatformCanvas::PlatformCanvas",
19 "width", width, "height", height);
20 if (!initialize(width, height, is_opaque))
21 SK_CRASH();
22 }
23
24 #if defined(WIN32)
25 PlatformCanvas::PlatformCanvas(int width,
26 int height,
27 bool is_opaque,
28 HANDLE shared_section) {
29 TRACE_EVENT2("skia", "PlatformCanvas::PlatformCanvas",
30 "width", width, "height", height);
31 if (!initialize(width, height, is_opaque, shared_section))
32 SK_CRASH();
33 }
34 #elif defined(__APPLE__)
35 PlatformCanvas::PlatformCanvas(int width, int height, bool is_opaque,
36 uint8_t* data) {
37 TRACE_EVENT2("skia", "PlatformCanvas::PlatformCanvas",
38 "width", width, "height", height);
39 if (!initialize(width, height, is_opaque, data))
40 SK_CRASH();
41 }
42 PlatformCanvas::PlatformCanvas(int width,
43 int height,
44 bool is_opaque,
45 CGContextRef context) {
46 TRACE_EVENT2("skia", "PlatformCanvas::PlatformCanvas",
47 "width", width, "height", height);
48 if (!initialize(context, width, height, is_opaque))
49 SK_CRASH();
50 }
51 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \
52 defined(__sun) || defined(ANDROID)
53 PlatformCanvas::PlatformCanvas(int width, int height, bool is_opaque,
54 uint8_t* data) {
55 TRACE_EVENT2("skia", "PlatformCanvas::PlatformCanvas",
56 "width", width, "height", height);
57 if (!initialize(width, height, is_opaque, data))
58 SK_CRASH();
59 }
60 #endif
61
62 PlatformCanvas::~PlatformCanvas() {
63 }
64
65 #if defined(WIN32)
66 bool PlatformCanvas::initialize(int width,
67 int height,
68 bool is_opaque,
69 HANDLE shared_section) {
70 // Use platform specific device for shared_section.
71 if (shared_section) {
72 if (initializeWithDevice(BitmapPlatformDevice::Create(width,
73 height,
74 is_opaque,
75 shared_section)))
76 return true;
77
78 // TODO(reveman): move the failure investigation from
79 // platform_canvas_win.cc to bitmap_platform_device_win.cc.
80 return false;
81 }
82
83 return initializeWithDevice(new SkDevice(
84 SkBitmap::kARGB_8888_Config, width, height, is_opaque));
85 }
86 #elif defined(__APPLE__)
87 bool PlatformCanvas::initialize(int width,
88 int height,
89 bool is_opaque,
90 uint8_t* data) {
91 // Use platform specific device for data.
92 if (data)
93 return initializeWithDevice(BitmapPlatformDevice::CreateWithData(
94 data, width, height, is_opaque));
95
96 return initializeWithDevice(new SkDevice(
97 SkBitmap::kARGB_8888_Config, width, height, is_opaque));
98 }
99
100 bool PlatformCanvas::initialize(CGContextRef context,
101 int width,
102 int height,
103 bool is_opaque) {
104 return initializeWithDevice(BitmapPlatformDevice::Create(
105 context, width, height, is_opaque));
106 }
107 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \
108 defined(__sun) || defined(ANDROID)
109 bool PlatformCanvas::initialize(int width, int height, bool is_opaque,
110 uint8_t* data) {
111 // Use platform specific device for data.
112 if (data)
113 return initializeWithDevice(BitmapPlatformDevice::Create(
114 width, height, is_opaque, data));
115
116 return initializeWithDevice(new SkDevice(
117 SkBitmap::kARGB_8888_Config, width, height, is_opaque));
118 }
119 #endif
120
121 } // namespace skia
OLDNEW
« no previous file with comments | « no previous file | skia/skia.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698