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

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

Issue 787803004: Update from https://crrev.com/307664 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase. Created 6 years 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
« no previous file with comments | « skia/ext/platform_canvas.h ('k') | skia/ext/platform_device.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "skia/ext/platform_canvas.h" 5 #include "skia/ext/platform_canvas.h"
6 6
7 #include "skia/ext/bitmap_platform_device.h" 7 #include "skia/ext/bitmap_platform_device.h"
8 #include "third_party/skia/include/core/SkTypes.h" 8 #include "third_party/skia/include/core/SkTypes.h"
9 9
10 namespace skia { 10 namespace skia {
(...skipping 14 matching lines...) Expand all
25 25
26 return 0; 26 return 0;
27 } 27 }
28 28
29 void EndPlatformPaint(SkCanvas* canvas) { 29 void EndPlatformPaint(SkCanvas* canvas) {
30 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); 30 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas));
31 if (platform_device) 31 if (platform_device)
32 platform_device->EndPlatformPaint(); 32 platform_device->EndPlatformPaint();
33 } 33 }
34 34
35 void DrawToNativeContext(SkCanvas* canvas, PlatformSurface context, int x,
36 int y, const PlatformRect* src_rect) {
37 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas));
38 if (platform_device)
39 platform_device->DrawToNativeContext(context, x, y, src_rect);
40 }
41
42 void MakeOpaque(SkCanvas* canvas, int x, int y, int width, int height) { 35 void MakeOpaque(SkCanvas* canvas, int x, int y, int width, int height) {
43 if (width <= 0 || height <= 0) 36 if (width <= 0 || height <= 0)
44 return; 37 return;
45 38
46 SkRect rect; 39 SkRect rect;
47 rect.setXYWH(SkIntToScalar(x), SkIntToScalar(y), 40 rect.setXYWH(SkIntToScalar(x), SkIntToScalar(y),
48 SkIntToScalar(width), SkIntToScalar(height)); 41 SkIntToScalar(width), SkIntToScalar(height));
49 SkPaint paint; 42 SkPaint paint;
50 paint.setColor(SK_ColorBLACK); 43 paint.setColor(SK_ColorBLACK);
51 paint.setXfermodeMode(SkXfermode::kDstATop_Mode); 44 paint.setXfermodeMode(SkXfermode::kDstATop_Mode);
52 canvas->drawRect(rect, paint); 45 canvas->drawRect(rect, paint);
53 } 46 }
54 47
55 size_t PlatformCanvasStrideForWidth(unsigned width) { 48 size_t PlatformCanvasStrideForWidth(unsigned width) {
56 return 4 * width; 49 return 4 * width;
57 } 50 }
58 51
59 SkCanvas* CreateCanvas(const skia::RefPtr<SkBaseDevice>& device, OnFailureType f ailureType) { 52 SkCanvas* CreateCanvas(const skia::RefPtr<SkBaseDevice>& device, OnFailureType f ailureType) {
60 if (!device) { 53 if (!device) {
61 if (CRASH_ON_FAILURE == failureType) 54 if (CRASH_ON_FAILURE == failureType)
62 SK_CRASH(); 55 SK_CRASH();
63 return NULL; 56 return NULL;
64 } 57 }
65 return new SkCanvas(device.get()); 58 return new SkCanvas(device.get());
66 } 59 }
67 60
68 PlatformBitmap::PlatformBitmap() : surface_(0), platform_extra_(0) {} 61 PlatformBitmap::PlatformBitmap() : surface_(0), platform_extra_(0) {}
69 62
70 } // namespace skia 63 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/platform_canvas.h ('k') | skia/ext/platform_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698