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

Side by Side Diff: experimental/SkV8Example/BaseContext.h

Issue 676423002: Start moving to the new canvas structure. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | experimental/SkV8Example/BaseContext.cpp » ('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 /*
2 * Copyright 2014 Google Inc.
3 *
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 *
8 */
9
10 #ifndef SkV8Example_BaseContext_DEFINED
11 #define SkV8Example_BaseContext_DEFINED
12
13 #include <v8.h>
14
15 #include "SkPaint.h"
16
17 class SkCanvas;
18 class Global;
19
20 // BaseContext contains common functionality for both JsContext
21 // and DisplayList.
22 class BaseContext {
23 public:
24 BaseContext(Global* global)
25 : fGlobal(global)
26 {
27 fFillStyle.setColor(SK_ColorBLACK);
28 fFillStyle.setAntiAlias(true);
29 fFillStyle.setStyle(SkPaint::kFill_Style);
30 fStrokeStyle.setColor(SK_ColorBLACK);
31 fStrokeStyle.setAntiAlias(true);
32 fStrokeStyle.setStyle(SkPaint::kStroke_Style);
33 }
34 virtual ~BaseContext() {}
35
36 // Retrieve the SkCanvas to draw on. May return NULL.
37 virtual SkCanvas* getCanvas() = 0;
38
39 // Add the Javascript attributes and methods that BaseContext implements to the ObjectTemplate.
40 void addAttributesAndMethods(v8::Handle<v8::ObjectTemplate> tmpl);
41
42 protected:
43 // Get the pointer out of obj.
44 static BaseContext* Unwrap(v8::Handle<v8::Object> obj);
45
46 Global* fGlobal;
47 SkPaint fFillStyle;
48 SkPaint fStrokeStyle;
49
50 private:
51 static void GetStyle(v8::Local<v8::String> name,
52 const v8::PropertyCallbackInfo<v8::Value>& info,
53 const SkPaint& style);
54 static void SetStyle(v8::Local<v8::String> name, v8::Local<v8::Value> value,
55 const v8::PropertyCallbackInfo<void>& info,
56 SkPaint& style);
57 // JS Attributes
58 static void GetFillStyle(v8::Local<v8::String> name,
59 const v8::PropertyCallbackInfo<v8::Value>& info);
60 static void SetFillStyle(v8::Local<v8::String> name, v8::Local<v8::Value> va lue,
61 const v8::PropertyCallbackInfo<void>& info);
62 static void GetStrokeStyle(v8::Local<v8::String> name,
63 const v8::PropertyCallbackInfo<v8::Value>& info);
64 static void SetStrokeStyle(v8::Local<v8::String> name, v8::Local<v8::Value> value,
65 const v8::PropertyCallbackInfo<void>& info);
66 static void GetWidth(v8::Local<v8::String> name,
67 const v8::PropertyCallbackInfo<v8::Value>& info);
68 static void GetHeight(v8::Local<v8::String> name,
69 const v8::PropertyCallbackInfo<v8::Value>& info);
70
71 // JS Methods
72 static void FillRect(const v8::FunctionCallbackInfo<v8::Value>& args);
73 static void Stroke(const v8::FunctionCallbackInfo<v8::Value>& args);
74 static void Fill(const v8::FunctionCallbackInfo<v8::Value>& args);
75 static void Rotate(const v8::FunctionCallbackInfo<v8::Value>& args);
76 static void Save(const v8::FunctionCallbackInfo<v8::Value>& args);
77 static void Restore(const v8::FunctionCallbackInfo<v8::Value>& args);
78 static void Translate(const v8::FunctionCallbackInfo<v8::Value>& args);
79 static void ResetTransform(const v8::FunctionCallbackInfo<v8::Value>& args);
80 };
81
82 #endif
OLDNEW
« no previous file with comments | « no previous file | experimental/SkV8Example/BaseContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698