| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef EMBEDDERS_OPENGLUI_COMMON_CANVAS_CONTEXT_H_ | 5 #ifndef EMBEDDERS_OPENGLUI_COMMON_CANVAS_CONTEXT_H_ |
| 6 #define EMBEDDERS_OPENGLUI_COMMON_CANVAS_CONTEXT_H_ | 6 #define EMBEDDERS_OPENGLUI_COMMON_CANVAS_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "embedders/openglui/common/canvas_state.h" | 8 #include "embedders/openglui/common/canvas_state.h" |
| 9 #include "embedders/openglui/common/graphics_handler.h" | 9 #include "embedders/openglui/common/graphics_handler.h" |
| 10 #include "embedders/openglui/common/log.h" | 10 #include "embedders/openglui/common/log.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 inline void setImageSmoothingEnabled(bool enabled) { | 97 inline void setImageSmoothingEnabled(bool enabled) { |
| 98 // TODO(gram): We're not actually doing anything with this yet. | 98 // TODO(gram): We're not actually doing anything with this yet. |
| 99 imageSmoothingEnabled_ = enabled; | 99 imageSmoothingEnabled_ = enabled; |
| 100 } | 100 } |
| 101 | 101 |
| 102 inline void setGlobalCompositeOperation(const char* op) { | 102 inline void setGlobalCompositeOperation(const char* op) { |
| 103 state_->setGlobalCompositeOperation(op); | 103 state_->setGlobalCompositeOperation(op); |
| 104 } | 104 } |
| 105 | 105 |
| 106 inline void Save() { | 106 void Save(); |
| 107 state_ = state_->Save(); | 107 void Restore(); |
| 108 } | |
| 109 | |
| 110 inline void Restore() { | |
| 111 CanvasState* popped_state = state_; | |
| 112 state_ = state_->Restore(); | |
| 113 if (state_ != popped_state) { | |
| 114 // Only delete if the pop was successful. | |
| 115 delete popped_state; | |
| 116 } | |
| 117 } | |
| 118 | 108 |
| 119 inline void Rotate(float angle) { | 109 inline void Rotate(float angle) { |
| 120 canvas_->rotate(Radians2Degrees(angle)); | 110 canvas_->rotate(Radians2Degrees(angle)); |
| 121 } | 111 } |
| 122 | 112 |
| 123 inline void Translate(float x, float y) { | 113 inline void Translate(float x, float y) { |
| 124 canvas_->translate(x, y); | 114 canvas_->translate(x, y); |
| 125 } | 115 } |
| 126 | 116 |
| 127 inline void Scale(float x, float y) { | 117 inline void Scale(float x, float y) { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 289 |
| 300 inline void ResetClip() { | 290 inline void ResetClip() { |
| 301 // TODO(gram): Check this. Is it affected by the transform? | 291 // TODO(gram): Check this. Is it affected by the transform? |
| 302 canvas_->clipRect(SkRect::MakeLTRB(0, 0, width_, height_), | 292 canvas_->clipRect(SkRect::MakeLTRB(0, 0, width_, height_), |
| 303 SkRegion::kReplace_Op); | 293 SkRegion::kReplace_Op); |
| 304 } | 294 } |
| 305 | 295 |
| 306 virtual void Flush() { | 296 virtual void Flush() { |
| 307 canvas_->flush(); | 297 canvas_->flush(); |
| 308 } | 298 } |
| 299 |
| 300 inline void SetFillGradient(bool is_radial, double x0, double y0, double r0, |
| 301 double x1, double y1, double r1, |
| 302 int stops, float* positions, char** colors) { |
| 303 state_->SetFillGradient(is_radial, x0, y0, r0, x1, y1, r1, |
| 304 stops, positions, colors); |
| 305 } |
| 306 |
| 307 inline void SetStrokeGradient(bool is_radial, double x0, double y0, double r0, |
| 308 double x1, double y1, double r1, |
| 309 int stops, float* positions, char** colors) { |
| 310 state_->SetStrokeGradient(is_radial, x0, y0, r0, x1, y1, r1, |
| 311 stops, positions, colors); |
| 312 } |
| 313 |
| 314 inline const SkBitmap* GetBitmap() { |
| 315 SkDevice* device = canvas_->getDevice(); |
| 316 return &device->accessBitmap(false); |
| 317 } |
| 309 }; | 318 }; |
| 310 | 319 |
| 311 CanvasContext* Context2D(int handle); | 320 CanvasContext* Context2D(int handle); |
| 312 void FreeContexts(); | 321 void FreeContexts(); |
| 313 | 322 |
| 314 #endif // EMBEDDERS_OPENGLUI_COMMON_CANVAS_CONTEXT_H_ | 323 #endif // EMBEDDERS_OPENGLUI_COMMON_CANVAS_CONTEXT_H_ |
| 315 | 324 |
| OLD | NEW |