| Index: webkit/tools/pepper_test_plugin/plugin_object.cc
|
| ===================================================================
|
| --- webkit/tools/pepper_test_plugin/plugin_object.cc (revision 35652)
|
| +++ webkit/tools/pepper_test_plugin/plugin_object.cc (working copy)
|
| @@ -28,16 +28,12 @@
|
| #include <stdio.h>
|
| #include <string>
|
|
|
| -#if defined(INDEPENDENT_PLUGIN)
|
| -#define CHECK(x)
|
| -#else
|
| #include "base/logging.h"
|
| #include "gpu/command_buffer/client/gles2_lib.h"
|
| #include "gpu/command_buffer/client/gles2_demo_cc.h"
|
| #include "third_party/skia/include/core/SkBitmap.h"
|
| #include "third_party/skia/include/core/SkCanvas.h"
|
| #include "third_party/skia/include/effects/SkGradientShader.h"
|
| -#endif
|
| #include "webkit/tools/pepper_test_plugin/event_handler.h"
|
| #include "webkit/tools/pepper_test_plugin/test_object.h"
|
|
|
| @@ -214,26 +210,7 @@
|
|
|
| // Bitmap painting -------------------------------------------------------------
|
|
|
| -#if defined(INDEPENDENT_PLUGIN)
|
| -void DrawSampleBitmap(void *region, int width, int height) {
|
| - int32 *bitmap = reinterpret_cast<int32 *>(region);
|
| -
|
| - for (int h = 0; h < height; ++h) {
|
| - uint8 opacity = (h * 0xff) / height;
|
| - for (int w = 0; w < width; ++w) {
|
| - // kudos to apatrick for noticing we're using premultiplied alpha
|
| - uint8 greenness = (w * opacity) / width;
|
| - *bitmap++ = (opacity << 24) | (greenness << 8);
|
| - }
|
| - }
|
| -}
|
| -#else
|
| -void DrawSampleBitmap(void *region, int width, int height) {
|
| - SkBitmap bitmap;
|
| - bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
|
| - bitmap.setPixels(region);
|
| -
|
| - SkCanvas canvas(bitmap);
|
| +void DrawSampleBitmap(SkCanvas& canvas, int width, int height) {
|
| SkRect rect;
|
| rect.set(SkIntToScalar(0), SkIntToScalar(0),
|
| SkIntToScalar(width), SkIntToScalar(height));
|
| @@ -256,7 +233,7 @@
|
|
|
| canvas.drawPath(path, paint);
|
| }
|
| -#endif
|
| +
|
| void FlushCallback(NPP instance, NPDeviceContext* context,
|
| NPError err, void* user_data) {
|
| }
|
| @@ -313,22 +290,26 @@
|
|
|
| void PluginObject::SetWindow(const NPWindow& window) {
|
| if (dimensions_ == 2) {
|
| - width_ = window.width;
|
| - height_ = window.height;
|
| + size_.set_width(window.width);
|
| + size_.set_height(window.height);
|
|
|
| NPDeviceContext2DConfig config;
|
| NPDeviceContext2D context;
|
| device2d_->initializeContext(npp_, &config, &context);
|
|
|
| - DrawSampleBitmap(context.region, width_, height_);
|
| + SkBitmap bitmap;
|
| + bitmap.setConfig(SkBitmap::kARGB_8888_Config, window.width, window.height);
|
| + bitmap.setPixels(context.region);
|
|
|
| + SkCanvas canvas(bitmap);
|
| + DrawSampleBitmap(canvas, window.width, window.height);
|
| +
|
| // TODO(brettw) figure out why this cast is necessary, the functions seem to
|
| // match. Could be a calling convention mismatch?
|
| NPDeviceFlushContextCallbackPtr callback =
|
| reinterpret_cast<NPDeviceFlushContextCallbackPtr>(&FlushCallback);
|
| device2d_->flushContext(npp_, &context, callback, NULL);
|
| } else {
|
| -#if !defined(INDEPENDENT_PLUGIN)
|
| if (!command_buffer_.get()) {
|
| if (!InitializeCommandBuffer())
|
| return;
|
| @@ -338,12 +319,10 @@
|
|
|
| // Schedule the first call to Draw.
|
| browser->pluginthreadasynccall(npp_, Draw3DCallback, this);
|
| -#endif
|
| }
|
| }
|
|
|
| void PluginObject::Draw3D() {
|
| -#if !defined(INDEPENDENT_PLUGIN)
|
| // Render some stuff.
|
| gles2::g_gl_impl = gles2_implementation_.get();
|
| GLFromCPPTestFunction();
|
| @@ -353,11 +332,9 @@
|
|
|
| // Schedule another call to Draw.
|
| browser->pluginthreadasynccall(npp_, Draw3DCallback, this);
|
| -#endif
|
| }
|
|
|
| bool PluginObject::InitializeCommandBuffer() {
|
| -#if !defined(INDEPENDENT_PLUGIN)
|
| const static int32 kCommandBufferSize = 512 * 1024;
|
| command_buffer_.reset(new CommandBufferPepper(npp_, browser));
|
| if (command_buffer_->Initialize(kCommandBufferSize)) {
|
| @@ -383,7 +360,6 @@
|
| }
|
|
|
| command_buffer_.reset();
|
| -#endif
|
|
|
| return false;
|
| }
|
|
|