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

Side by Side Diff: platform_tools/android/examples/hello_skia_app/jni/helloskia.cpp

Issue 2223023002: Cleanup use of legacy SkSurface creation methods a bit (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rm public.bzl Created 4 years, 4 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
« no previous file with comments | « platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_GaneshPictureRenderer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
1 #include <math.h> 8 #include <math.h>
2 #include <jni.h> 9 #include <jni.h>
3 #include <android/bitmap.h> 10 #include <android/bitmap.h>
4 11
5 #include "SkCanvas.h" 12 #include "SkCanvas.h"
6 #include "SkGraphics.h" 13 #include "SkGraphics.h"
7 #include "SkSurface.h" 14 #include "SkSurface.h"
8 #include "SkString.h" 15 #include "SkString.h"
9 #include "SkTime.h" 16 #include "SkTime.h"
10 17
(...skipping 11 matching lines...) Expand all
22 { 29 {
23 // Grab the dst bitmap info and pixels 30 // Grab the dst bitmap info and pixels
24 AndroidBitmapInfo dstInfo; 31 AndroidBitmapInfo dstInfo;
25 void* dstPixels; 32 void* dstPixels;
26 AndroidBitmap_getInfo(env, dstBitmap, &dstInfo); 33 AndroidBitmap_getInfo(env, dstBitmap, &dstInfo);
27 AndroidBitmap_lockPixels(env, dstBitmap, &dstPixels); 34 AndroidBitmap_lockPixels(env, dstBitmap, &dstPixels);
28 35
29 SkImageInfo info = SkImageInfo::MakeN32Premul(dstInfo.width, dstInfo.height) ; 36 SkImageInfo info = SkImageInfo::MakeN32Premul(dstInfo.width, dstInfo.height) ;
30 37
31 // Create a surface from the given bitmap 38 // Create a surface from the given bitmap
32 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterDirect(info, dstPixels, dstInfo.stride)); 39 sk_sp<SkSurface> surface(SkSurface::MakeRasterDirect(info, dstPixels, dstInf o.stride));
33 SkCanvas* canvas = surface->getCanvas(); 40 SkCanvas* canvas = surface->getCanvas();
34 41
35 // Draw something "interesting" 42 // Draw something "interesting"
36 43
37 // Clear the canvas with a white color 44 // Clear the canvas with a white color
38 canvas->drawColor(SK_ColorWHITE); 45 canvas->drawColor(SK_ColorWHITE);
39 46
40 // Setup a SkPaint for drawing our text 47 // Setup a SkPaint for drawing our text
41 SkPaint paint; 48 SkPaint paint;
42 paint.setColor(SK_ColorBLACK); // This is a solid black color for our text 49 paint.setColor(SK_ColorBLACK); // This is a solid black color for our text
(...skipping 18 matching lines...) Expand all
61 float x = (float)i / 99.0f; 68 float x = (float)i / 99.0f;
62 float offset = elapsedTime / 1000.0f; 69 float offset = elapsedTime / 1000.0f;
63 canvas->drawLine(sin(x * M_PI + offset) * 800.0f, 0, // first endpoint 70 canvas->drawLine(sin(x * M_PI + offset) * 800.0f, 0, // first endpoint
64 cos(x * M_PI + offset) * 800.0f, 800, // second endpoin t 71 cos(x * M_PI + offset) * 800.0f, 800, // second endpoin t
65 paint); // SkPapint to te ll how to draw the line 72 paint); // SkPapint to te ll how to draw the line
66 } 73 }
67 74
68 // Unlock the dst's pixels 75 // Unlock the dst's pixels
69 AndroidBitmap_unlockPixels(env, dstBitmap); 76 AndroidBitmap_unlockPixels(env, dstBitmap);
70 } 77 }
OLDNEW
« no previous file with comments | « platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_GaneshPictureRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698