-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrawing.cpp
More file actions
64 lines (45 loc) · 1.32 KB
/
Copy pathDrawing.cpp
File metadata and controls
64 lines (45 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "Drawing.h"
#include "utils/image_reader.h"
#include "bitmap_time/bitmap_time.h"
#include "GrContext.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
using namespace sk_app;
Application* Application::Create(int argc, char** argv, void* platformData) {
return new Drawing(argc, argv, platformData);
}
Drawing::Drawing(int argc, char** argv, void* platformData)
: fBackendType(Window::kNativeGL_BackendType) {
SkGraphics::Init();
fWindow = Window::CreateNativeWindow(platformData);
fWindow->setRequestedDisplayParams(DisplayParams());
// register callbacks
fWindow->pushLayer(this);
fWindow->attach(fBackendType);
}
Drawing::~Drawing() {
fWindow->detach();
delete fWindow;
}
void Drawing::onBackendCreated() {
fWindow->show();
fWindow->inval();
}
void Drawing::onPaint(SkCanvas* canvas) {
// Clear background
canvas->clear(SK_ColorWHITE);
BitmapTime bmtm("/home/jonhpark/Downloads/colorloop.gif");
canvas->drawBitmap(bmtm.makeXTSlice(325), 0,0);
canvas->drawBitmap(bmtm.makeYTSlice(325), 800,0);
}
void Drawing::onIdle() {
// Just re-paint continously
fWindow->inval();
}